fix binaries without .gnu.hash section
This commit is contained in:
parent
5d6f086b3d
commit
57fe1d3835
|
@ -1106,9 +1106,12 @@ 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) {
|
||||
else if (d_tag == DT_GNU_HASH) {
|
||||
auto shdr = findSection2(".gnu.hash");
|
||||
// some binaries might this section stripped
|
||||
// in which case we just ignore the value.
|
||||
if (shdr) dyn->d_un.d_ptr = shdr->sh_addr;
|
||||
} else if (d_tag == DT_JMPREL) {
|
||||
auto shdr = findSection2(".rel.plt");
|
||||
if (!shdr) shdr = findSection2(".rela.plt"); /* 64-bit Linux, x86-64 */
|
||||
if (!shdr) shdr = findSection2(".rela.IA_64.pltoff"); /* 64-bit Linux, IA-64 */
|
||||
|
|
|
@ -30,7 +30,8 @@ src_TESTS = \
|
|||
build-id.sh \
|
||||
invalid-elf.sh \
|
||||
endianness.sh \
|
||||
contiguous_note_sections.sh
|
||||
contiguous_note_sections.sh \
|
||||
no-gnu-hash.sh
|
||||
|
||||
build_TESTS = \
|
||||
$(no_rpath_arch_TESTS)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#! /bin/sh -e
|
||||
SCRATCH=scratch/$(basename $0 .sh)
|
||||
|
||||
rm -rf ${SCRATCH}
|
||||
mkdir -p ${SCRATCH}
|
||||
|
||||
cp simple ${SCRATCH}/
|
||||
|
||||
strip --remove-section=.gnu.hash ${SCRATCH}/simple
|
||||
|
||||
# Check if patchelf handles binaries with GNU_HASH in dynamic section but
|
||||
# without .gnu.hash section
|
||||
../src/patchelf --set-interpreter /oops ${SCRATCH}/simple
|
Loading…
Reference in New Issue