[ifs] Added missing DT_STRSZ to the .dynamic section

This patch adds DT_STRSZ into the dynamic section, which was absent
previously. This was a bug and caused failures in other tools.

Differential Revision: https://reviews.llvm.org/D117058
This commit is contained in:
Haowei Wu 2022-01-11 14:45:57 -08:00
parent 7f51a9e273
commit a59bb21bf8
2 changed files with 3 additions and 1 deletions

View File

@ -226,6 +226,7 @@ public:
// Poplulate dynamic table.
size_t DynSymIndex = DynTab.Content.addAddr(DT_SYMTAB, 0);
size_t DynStrIndex = DynTab.Content.addAddr(DT_STRTAB, 0);
DynTab.Content.addValue(DT_STRSZ, DynSym.Size);
for (const std::string &Lib : Stub.NeededLibs)
DynTab.Content.addValue(DT_NEEDED, DynStr.Content.getOffset(Lib));
if (Stub.SoName)

View File

@ -142,10 +142,11 @@ Symbols:
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK: DynamicSection [ (4 entries)
# CHECK: DynamicSection [ (5 entries)
# CHECK-NEXT: Tag Type Name/Value
# CHECK-NEXT: 0x[[DYNTABZ]]0000006 SYMTAB
# CHECK-NEXT: 0x[[DYNTABZ]]0000005 STRTAB
# CHECK-NEXT: 0x[[DYNTABZ]]000000A STRSZ
# CHECK-NEXT: 0x[[DYNTABZ]]0000001 NEEDED Shared library: [libc.so.6]
# CHECK-NEXT: 0x[[DYNTABZ]]0000000 NULL
# CHECK-NEXT: ]