summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-03-06 06:01:14 (GMT)
committerGitHub <noreply@github.com>2019-03-06 06:01:14 (GMT)
commit60662393ba843d68e17f4d87a13bccda58b4b2c0 (patch)
tree3824799fda9cc300cc0b9c9664a181bdef6838e0
parent27ffe8ae871e7a186018d66020ef3f6162c12c69 (diff)
parent52ab908394958a2a5d0476e306e2cad4da4fdeae (diff)
downloadpatchelf-60662393ba843d68e17f4d87a13bccda58b4b2c0.zip
patchelf-60662393ba843d68e17f4d87a13bccda58b4b2c0.tar.gz
patchelf-60662393ba843d68e17f4d87a13bccda58b4b2c0.tar.bz2
Merge pull request #149 from ezquat/fix-66
Fix issue #66: ignore 0th section header when sorting, don't overwrite NOBITS
-rw-r--r--src/patchelf.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc
index 3ca38d9..0b4965a 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -475,7 +475,7 @@ void ElfFile<ElfFileParamNames>::sortShdrs()
/* Sort the sections by offset. */
CompShdr comp;
comp.elfFile = this;
- sort(shdrs.begin(), shdrs.end(), comp);
+ sort(shdrs.begin() + 1, shdrs.end(), comp);
/* Restore the sh_link mappings. */
for (unsigned int i = 1; i < rdi(hdr->e_shnum); ++i)
@@ -642,7 +642,8 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
for (auto & i : replacedSections) {
std::string sectionName = i.first;
Elf_Shdr & shdr = findSection(sectionName);
- memset(contents + rdi(shdr.sh_offset), 'X', rdi(shdr.sh_size));
+ if (shdr.sh_type != SHT_NOBITS)
+ memset(contents + rdi(shdr.sh_offset), 'X', rdi(shdr.sh_size));
}
for (auto & i : replacedSections) {