diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-05-29 10:12:47 (GMT) |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-05-29 10:12:47 (GMT) |
commit | 55a701beb7bc50c5438d64ab869321f808ad7bd3 (patch) | |
tree | 29fdf72751bfc3594c8d9118561710b542c71cfe /src | |
parent | 7da11cac0b892d85f19f4132c1912105e3686c7f (diff) | |
download | patchelf-55a701beb7bc50c5438d64ab869321f808ad7bd3.zip patchelf-55a701beb7bc50c5438d64ab869321f808ad7bd3.tar.gz patchelf-55a701beb7bc50c5438d64ab869321f808ad7bd3.tar.bz2 |
* Overwriting replaced sections with 'X's revealed a bug: we weren't
updating the DT_GNU_HASH field in the .dynamic section, which is a
problem when we move the .gnu.hash section.
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 d481e56..76b43b4 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -201,6 +201,10 @@ I ElfFile<ElfFileParamNames>::rdi(I i) #define DT_RUNPATH 29 #endif +#ifndef DT_GNU_HASH +#define DT_GNU_HASH 0x6ffffef5 +#endif + static void debug(const char * format, ...) { @@ -485,7 +489,7 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff, Elf_Shdr & shdr = findSection(sectionName); debug("rewriting section `%s' from offset %d to offset %d\n", sectionName.c_str(), rdi(shdr.sh_offset), curOff); - + memset(contents + rdi(shdr.sh_offset), 'X', rdi(shdr.sh_size)); memcpy(contents + curOff, (unsigned char *) i->second.c_str(), i->second.size()); @@ -755,6 +759,8 @@ void ElfFile<ElfFileParamNames>::rewriteHeaders(Elf_Addr phdrAddress) dyn->d_un.d_ptr = findSection(".dynsym").sh_addr; else if (d_tag == DT_HASH) dyn->d_un.d_ptr = findSection(".hash").sh_addr; + else if (d_tag == DT_GNU_HASH) + dyn->d_un.d_ptr = findSection(".gnu.hash").sh_addr; else if (d_tag == DT_JMPREL) { Elf_Shdr * shdr = findSection2(".rel.plt"); if (!shdr) shdr = findSection2(".rela.plt"); /* 64-bit Linux, x86-64 */ |