mirror of
https://github.com/upx/upx
synced 2025-10-05 19:20:23 +08:00
--force-pie inhibits treating as shared library (for 'rust', etc.)
https://github.com/upx/upx/issues/200 modified: main.cpp modified: options.h modified: p_lx_elf.cpp
This commit is contained in:
parent
9f651ee40f
commit
614c86fb7d
|
@ -869,6 +869,9 @@ static int do_option(int optc, const char *arg)
|
||||||
case 676:
|
case 676:
|
||||||
opt->o_unix.android_shlib = true;
|
opt->o_unix.android_shlib = true;
|
||||||
break;
|
break;
|
||||||
|
case 677:
|
||||||
|
opt->o_unix.force_pie = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case '\0':
|
case '\0':
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1020,6 +1023,7 @@ static const struct mfx_option longopts[] =
|
||||||
{"unmap-all-pages", 0x10, 0, 674}, // linux /proc/self/exe vanishes
|
{"unmap-all-pages", 0x10, 0, 674}, // linux /proc/self/exe vanishes
|
||||||
{"preserve-build-id", 0, 0, 675},
|
{"preserve-build-id", 0, 0, 675},
|
||||||
{"android-shlib", 0, 0, 676},
|
{"android-shlib", 0, 0, 676},
|
||||||
|
{"force-pie", 0, 0, 677},
|
||||||
// watcom/le
|
// watcom/le
|
||||||
{"le", 0x10, 0, 620}, // produce LE output
|
{"le", 0x10, 0, 620}, // produce LE output
|
||||||
// win32/pe
|
// win32/pe
|
||||||
|
|
|
@ -147,6 +147,7 @@ struct options_t {
|
||||||
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
|
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
|
||||||
bool preserve_build_id; // copy the build-id to the compressed binary
|
bool preserve_build_id; // copy the build-id to the compressed binary
|
||||||
bool android_shlib; // keep some ElfXX_Shdr for dlopen()
|
bool android_shlib; // keep some ElfXX_Shdr for dlopen()
|
||||||
|
bool force_pie; // choose DF_1_PIE instead of is_shlib
|
||||||
} o_unix;
|
} o_unix;
|
||||||
struct {
|
struct {
|
||||||
bool le;
|
bool le;
|
||||||
|
|
|
@ -1840,7 +1840,8 @@ bool PackLinuxElf32::canPack()
|
||||||
dynstr= (char const *)elf_find_dynamic(Elf32_Dyn::DT_STRTAB);
|
dynstr= (char const *)elf_find_dynamic(Elf32_Dyn::DT_STRTAB);
|
||||||
dynsym= (Elf32_Sym const *)elf_find_dynamic(Elf32_Dyn::DT_SYMTAB);
|
dynsym= (Elf32_Sym const *)elf_find_dynamic(Elf32_Dyn::DT_SYMTAB);
|
||||||
|
|
||||||
if (Elf32_Dyn::DF_1_PIE & elf_unsigned_dynamic(Elf32_Dyn::DT_FLAGS_1)
|
if (opt->o_unix.force_pie
|
||||||
|
|| Elf32_Dyn::DF_1_PIE & elf_unsigned_dynamic(Elf32_Dyn::DT_FLAGS_1)
|
||||||
|| calls_crt1((Elf32_Rel const *)elf_find_dynamic(Elf32_Dyn::DT_REL),
|
|| calls_crt1((Elf32_Rel const *)elf_find_dynamic(Elf32_Dyn::DT_REL),
|
||||||
(int)elf_unsigned_dynamic(Elf32_Dyn::DT_RELSZ))
|
(int)elf_unsigned_dynamic(Elf32_Dyn::DT_RELSZ))
|
||||||
|| calls_crt1((Elf32_Rel const *)elf_find_dynamic(Elf32_Dyn::DT_JMPREL),
|
|| calls_crt1((Elf32_Rel const *)elf_find_dynamic(Elf32_Dyn::DT_JMPREL),
|
||||||
|
@ -2076,7 +2077,8 @@ PackLinuxElf64::canPack()
|
||||||
dynstr= (char const *)elf_find_dynamic(Elf64_Dyn::DT_STRTAB);
|
dynstr= (char const *)elf_find_dynamic(Elf64_Dyn::DT_STRTAB);
|
||||||
dynsym= (Elf64_Sym const *)elf_find_dynamic(Elf64_Dyn::DT_SYMTAB);
|
dynsym= (Elf64_Sym const *)elf_find_dynamic(Elf64_Dyn::DT_SYMTAB);
|
||||||
|
|
||||||
if (Elf64_Dyn::DF_1_PIE & elf_unsigned_dynamic(Elf64_Dyn::DT_FLAGS_1)
|
if (opt->o_unix.force_pie
|
||||||
|
|| Elf64_Dyn::DF_1_PIE & elf_unsigned_dynamic(Elf64_Dyn::DT_FLAGS_1)
|
||||||
|| calls_crt1((Elf64_Rela const *)elf_find_dynamic(Elf64_Dyn::DT_RELA),
|
|| calls_crt1((Elf64_Rela const *)elf_find_dynamic(Elf64_Dyn::DT_RELA),
|
||||||
(int)elf_unsigned_dynamic(Elf64_Dyn::DT_RELASZ))
|
(int)elf_unsigned_dynamic(Elf64_Dyn::DT_RELASZ))
|
||||||
|| calls_crt1((Elf64_Rela const *)elf_find_dynamic(Elf64_Dyn::DT_JMPREL),
|
|| calls_crt1((Elf64_Rela const *)elf_find_dynamic(Elf64_Dyn::DT_JMPREL),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user