Skip to content

Commit c1f89c0

Browse files
committed
Don't check whether DT_STRTAB matches .dynstr
We don't really care whether DT_STRTAB is correct, since we overwrite it anyway. NixOS/nixpkgs#22333
1 parent 49ce42d commit c1f89c0

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

src/patchelf.cc

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,20 +1016,8 @@ void ElfFile<ElfFileParamNames>::modifySoname(sonameMode op, const std::string &
10161016
Elf_Shdr & shdrDynStr = findSection(".dynstr");
10171017
char * strTab = (char *) contents + rdi(shdrDynStr.sh_offset);
10181018

1019-
/* Find the DT_STRTAB entry in the dynamic section. */
1020-
Elf_Dyn * dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset));
1021-
Elf_Addr strTabAddr = 0;
1022-
for ( ; rdi(dyn->d_tag) != DT_NULL; dyn++)
1023-
if (rdi(dyn->d_tag) == DT_STRTAB)
1024-
strTabAddr = rdi(dyn->d_un.d_ptr);
1025-
if (!strTabAddr) error("strange: no string table");
1026-
1027-
/* We assume that the virtual address in the DT_STRTAB entry
1028-
of the dynamic section corresponds to the .dynstr section. */
1029-
assert(strTabAddr == rdi(shdrDynStr.sh_addr));
1030-
10311019
/* Walk through the dynamic section, look for the DT_SONAME entry. */
1032-
dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset));
1020+
Elf_Dyn * dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset));
10331021
Elf_Dyn * dynSoname = 0;
10341022
char * soname = 0;
10351023
for ( ; rdi(dyn->d_tag) != DT_NULL; dyn++) {
@@ -1123,15 +1111,6 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op,
11231111
Elf_Shdr & shdrDynStr = findSection(".dynstr");
11241112
char * strTab = (char *) contents + rdi(shdrDynStr.sh_offset);
11251113

1126-
/* Find the DT_STRTAB entry in the dynamic section. */
1127-
Elf_Dyn * dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset));
1128-
Elf_Addr strTabAddr = 0;
1129-
for ( ; rdi(dyn->d_tag) != DT_NULL; dyn++)
1130-
if (rdi(dyn->d_tag) == DT_STRTAB) strTabAddr = rdi(dyn->d_un.d_ptr);
1131-
if (!strTabAddr) error("strange: no string table");
1132-
1133-
assert(strTabAddr == rdi(shdrDynStr.sh_addr));
1134-
11351114

11361115
/* Walk through the dynamic section, look for the RPATH/RUNPATH
11371116
entry.
@@ -1146,7 +1125,7 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op,
11461125
generates a DT_RPATH and DT_RUNPATH pointing at the same
11471126
string. */
11481127
std::vector<std::string> neededLibs;
1149-
dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset));
1128+
Elf_Dyn * dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset));
11501129
Elf_Dyn * dynRPath = 0, * dynRunPath = 0;
11511130
char * rpath = 0;
11521131
for ( ; rdi(dyn->d_tag) != DT_NULL; dyn++) {

0 commit comments

Comments
 (0)