[llvm-objdump]Correct .dynstr finding of getDynamicStrTab() (#127975)

The dynamic string table used by the dynamic section is referenced by
the sh_link field of that section, so we should use that directly,
rather than going via the dynamic symbol table.
More info:
https://github.com/llvm/llvm-project/pull/125679#discussion_r1961333454

Signed-off-by: Ruoyu Qiu <cabbaken@outlook.com>
This commit is contained in:
Ruoyu Qiu 2025-02-24 18:39:40 +08:00 committed by GitHub
parent 3dc159431b
commit 5a2bee04d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -30,6 +30,7 @@ Sections:
- Name: .dynamic
Type: SHT_DYNAMIC
Flags: [ SHF_ALLOC ]
Link: 1
Entries:
- Tag: DT_NEEDED
Value: 0x1

View File

@ -78,8 +78,8 @@ static Expected<StringRef> getDynamicStrTab(const ELFFile<ELFT> &Elf) {
return SectionsOrError.takeError();
for (const typename ELFT::Shdr &Sec : *SectionsOrError) {
if (Sec.sh_type == ELF::SHT_DYNSYM)
return Elf.getStringTableForSymtab(Sec);
if (Sec.sh_type == ELF::SHT_DYNAMIC)
return Elf.getLinkAsStrtab(Sec);
}
return createError("dynamic string table not found");