mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
DT_JMPREL vanished (binutils-2.26.1); check all DT_RELA.
modified: p_elf_enum.h modified: p_lx_elf.cpp
This commit is contained in:
parent
97e975b4f6
commit
d688a05ac7
|
@ -146,6 +146,7 @@
|
|||
DT_STRTAB = 5, /* String table */
|
||||
DT_SYMTAB = 6, /* Symbol table */
|
||||
DT_RELA = 7, /* Relocations which do contain an addend */
|
||||
DT_RELASZ = 8, /* Total size of Rela relocs */
|
||||
DT_RELAENT = 9, /* Size of one RELA relocation */
|
||||
DT_INIT = 12, /* Address of init function */
|
||||
DT_REL = 17, /* Relocations which contain no addend */
|
||||
|
|
|
@ -1702,6 +1702,8 @@ PackLinuxElf64ppcle::canPack()
|
|||
// which references the symbol, because DT_GNU_HASH contains only
|
||||
// defined symbols, and there might be no DT_HASH.
|
||||
|
||||
Elf64_Rela const *
|
||||
rela= (Elf64_Rela const *)elf_find_dynamic(Elf64_Dyn::DT_RELA);
|
||||
Elf64_Rela const *
|
||||
jmprela= (Elf64_Rela const *)elf_find_dynamic(Elf64_Dyn::DT_JMPREL);
|
||||
for ( int sz = elf_unsigned_dynamic(Elf64_Dyn::DT_PLTRELSZ);
|
||||
|
@ -1716,6 +1718,19 @@ PackLinuxElf64ppcle::canPack()
|
|||
goto proceed;
|
||||
}
|
||||
|
||||
// 2016-10-09 DT_JMPREL is no more (binutils-2.26.1)?
|
||||
// Check the general case, too.
|
||||
for ( int sz = elf_unsigned_dynamic(Elf64_Dyn::DT_RELASZ);
|
||||
0 < sz;
|
||||
(sz -= sizeof(Elf64_Rela)), ++rela
|
||||
) {
|
||||
unsigned const symnum = get_te64(&rela->r_info) >> 32;
|
||||
char const *const symnam = get_te32(&dynsym[symnum].st_name) + dynstr;
|
||||
if (0==strcmp(symnam, "__libc_start_main")
|
||||
|| 0==strcmp(symnam, "__uClibc_main")
|
||||
|| 0==strcmp(symnam, "__uClibc_start_main"))
|
||||
goto proceed;
|
||||
}
|
||||
// Heuristic HACK for shared libraries (compare Darwin (MacOS) Dylib.)
|
||||
// If there is an existing DT_INIT, and if everything that the dynamic
|
||||
// linker ld-linux needs to perform relocations before calling DT_INIT
|
||||
|
@ -1878,6 +1893,8 @@ PackLinuxElf64amd::canPack()
|
|||
// which references the symbol, because DT_GNU_HASH contains only
|
||||
// defined symbols, and there might be no DT_HASH.
|
||||
|
||||
Elf64_Rela const *
|
||||
rela= (Elf64_Rela const *)elf_find_dynamic(Elf64_Dyn::DT_RELA);
|
||||
Elf64_Rela const *
|
||||
jmprela= (Elf64_Rela const *)elf_find_dynamic(Elf64_Dyn::DT_JMPREL);
|
||||
for ( int sz = elf_unsigned_dynamic(Elf64_Dyn::DT_PLTRELSZ);
|
||||
|
@ -1892,6 +1909,20 @@ PackLinuxElf64amd::canPack()
|
|||
goto proceed;
|
||||
}
|
||||
|
||||
// 2016-10-09 DT_JMPREL is no more (binutils-2.26.1)?
|
||||
// Check the general case, too.
|
||||
for ( int sz = elf_unsigned_dynamic(Elf64_Dyn::DT_RELASZ);
|
||||
0 < sz;
|
||||
(sz -= sizeof(Elf64_Rela)), ++rela
|
||||
) {
|
||||
unsigned const symnum = get_te64(&rela->r_info) >> 32;
|
||||
char const *const symnam = get_te32(&dynsym[symnum].st_name) + dynstr;
|
||||
if (0==strcmp(symnam, "__libc_start_main")
|
||||
|| 0==strcmp(symnam, "__uClibc_main")
|
||||
|| 0==strcmp(symnam, "__uClibc_start_main"))
|
||||
goto proceed;
|
||||
}
|
||||
|
||||
// Heuristic HACK for shared libraries (compare Darwin (MacOS) Dylib.)
|
||||
// If there is an existing DT_INIT, and if everything that the dynamic
|
||||
// linker ld-linux needs to perform relocations before calling DT_INIT
|
||||
|
|
Loading…
Reference in New Issue
Block a user