Skip to content

Commit 5a2bee0

Browse files
authored
[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: #125679 (comment) Signed-off-by: Ruoyu Qiu <[email protected]>
1 parent 3dc1594 commit 5a2bee0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Diff for: llvm/test/tools/llvm-objdump/ELF/private-headers.test

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Sections:
3030
- Name: .dynamic
3131
Type: SHT_DYNAMIC
3232
Flags: [ SHF_ALLOC ]
33+
Link: 1
3334
Entries:
3435
- Tag: DT_NEEDED
3536
Value: 0x1

Diff for: llvm/tools/llvm-objdump/ELFDump.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ static Expected<StringRef> getDynamicStrTab(const ELFFile<ELFT> &Elf) {
7878
return SectionsOrError.takeError();
7979

8080
for (const typename ELFT::Shdr &Sec : *SectionsOrError) {
81-
if (Sec.sh_type == ELF::SHT_DYNSYM)
82-
return Elf.getStringTableForSymtab(Sec);
81+
if (Sec.sh_type == ELF::SHT_DYNAMIC)
82+
return Elf.getLinkAsStrtab(Sec);
8383
}
8484

8585
return createError("dynamic string table not found");

0 commit comments

Comments
 (0)