From c1f89c077e44a495c62ed0dcfaeca21510df93ef Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 17 Feb 2017 13:38:12 +0100 Subject: Don't check whether DT_STRTAB matches .dynstr We don't really care whether DT_STRTAB is correct, since we overwrite it anyway. https://github.com/NixOS/nixpkgs/issues/22333 --- src/patchelf.cc | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/patchelf.cc b/src/patchelf.cc index 619d403..5077cd5 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -1016,20 +1016,8 @@ void ElfFile::modifySoname(sonameMode op, const std::string & Elf_Shdr & shdrDynStr = findSection(".dynstr"); char * strTab = (char *) contents + rdi(shdrDynStr.sh_offset); - /* Find the DT_STRTAB entry in the dynamic section. */ - Elf_Dyn * dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset)); - Elf_Addr strTabAddr = 0; - for ( ; rdi(dyn->d_tag) != DT_NULL; dyn++) - if (rdi(dyn->d_tag) == DT_STRTAB) - strTabAddr = rdi(dyn->d_un.d_ptr); - if (!strTabAddr) error("strange: no string table"); - - /* We assume that the virtual address in the DT_STRTAB entry - of the dynamic section corresponds to the .dynstr section. */ - assert(strTabAddr == rdi(shdrDynStr.sh_addr)); - /* Walk through the dynamic section, look for the DT_SONAME entry. */ - dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset)); + Elf_Dyn * dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset)); Elf_Dyn * dynSoname = 0; char * soname = 0; for ( ; rdi(dyn->d_tag) != DT_NULL; dyn++) { @@ -1123,15 +1111,6 @@ void ElfFile::modifyRPath(RPathOp op, Elf_Shdr & shdrDynStr = findSection(".dynstr"); char * strTab = (char *) contents + rdi(shdrDynStr.sh_offset); - /* Find the DT_STRTAB entry in the dynamic section. */ - Elf_Dyn * dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset)); - Elf_Addr strTabAddr = 0; - for ( ; rdi(dyn->d_tag) != DT_NULL; dyn++) - if (rdi(dyn->d_tag) == DT_STRTAB) strTabAddr = rdi(dyn->d_un.d_ptr); - if (!strTabAddr) error("strange: no string table"); - - assert(strTabAddr == rdi(shdrDynStr.sh_addr)); - /* Walk through the dynamic section, look for the RPATH/RUNPATH entry. @@ -1146,7 +1125,7 @@ void ElfFile::modifyRPath(RPathOp op, generates a DT_RPATH and DT_RUNPATH pointing at the same string. */ std::vector neededLibs; - dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset)); + Elf_Dyn * dyn = (Elf_Dyn *) (contents + rdi(shdrDynamic.sh_offset)); Elf_Dyn * dynRPath = 0, * dynRunPath = 0; char * rpath = 0; for ( ; rdi(dyn->d_tag) != DT_NULL; dyn++) { -- cgit v0.12