diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-05-28 11:53:16 (GMT) |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-05-28 11:53:16 (GMT) |
commit | 36f96d03dba4a3bf19a3a228786aac5e69ea85d2 (patch) | |
tree | c4c20a8be03d7b0a8b52c9b7c4ba1b9a14df3b55 /src | |
parent | 1f713dd5684829f1714e161aae6c64e295e68e5a (diff) | |
download | patchelf-36f96d03dba4a3bf19a3a228786aac5e69ea85d2.zip patchelf-36f96d03dba4a3bf19a3a228786aac5e69ea85d2.tar.gz patchelf-36f96d03dba4a3bf19a3a228786aac5e69ea85d2.tar.bz2 |
* When reordering the section headers, the e_shstrndx field in the ELF
header should be updated as well.
Diffstat (limited to 'src')
-rw-r--r-- | src/patchelf.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc index f47c814..29d51ac 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -307,6 +307,9 @@ void ElfFile<ElfFileParamNames>::sortShdrs() (rdi(shdrs[i].sh_type) == SHT_REL || rdi(shdrs[i].sh_type) == SHT_RELA)) info[getSectionName(shdrs[i])] = getSectionName(shdrs[rdi(shdrs[i].sh_info)]); + /* Idem for the index of the .shstrtab section in the ELF header. */ + SectionName shstrtabName = getSectionName(shdrs[rdi(hdr->e_shstrndx)]); + /* Sort the sections by offset. */ CompShdr comp; comp.elfFile = this; @@ -324,6 +327,9 @@ void ElfFile<ElfFileParamNames>::sortShdrs() (rdi(shdrs[i].sh_type) == SHT_REL || rdi(shdrs[i].sh_type) == SHT_RELA)) wri(shdrs[i].sh_info, findSection3(info[getSectionName(shdrs[i])])); + + /* And the .shstrtab index. */ + wri(hdr->e_shstrndx, findSection3(shstrtabName)); } @@ -579,7 +585,7 @@ void ElfFile<ElfFileParamNames>::rewriteSections() /* Rewrite the section header table. For neatness, keep the sections sorted. */ assert(rdi(hdr->e_shnum) == shdrs.size()); - //sortShdrs(); !!! breaks the library + sortShdrs(); for (unsigned int i = 1; i < rdi(hdr->e_shnum); ++i) * ((Elf_Shdr *) (contents + rdi(hdr->e_shoff)) + i) = shdrs[i]; |