1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +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:
John Reiser 2018-04-26 13:44:17 -07:00
parent 9f651ee40f
commit 614c86fb7d
3 changed files with 9 additions and 2 deletions

View File

@ -869,6 +869,9 @@ static int do_option(int optc, const char *arg)
case 676:
opt->o_unix.android_shlib = true;
break;
case 677:
opt->o_unix.force_pie = true;
break;
case '\0':
return -1;
@ -1020,6 +1023,7 @@ static const struct mfx_option longopts[] =
{"unmap-all-pages", 0x10, 0, 674}, // linux /proc/self/exe vanishes
{"preserve-build-id", 0, 0, 675},
{"android-shlib", 0, 0, 676},
{"force-pie", 0, 0, 677},
// watcom/le
{"le", 0x10, 0, 620}, // produce LE output
// win32/pe

View File

@ -147,6 +147,7 @@ struct options_t {
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
bool preserve_build_id; // copy the build-id to the compressed binary
bool android_shlib; // keep some ElfXX_Shdr for dlopen()
bool force_pie; // choose DF_1_PIE instead of is_shlib
} o_unix;
struct {
bool le;

View File

@ -1840,7 +1840,8 @@ bool PackLinuxElf32::canPack()
dynstr= (char const *)elf_find_dynamic(Elf32_Dyn::DT_STRTAB);
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),
(int)elf_unsigned_dynamic(Elf32_Dyn::DT_RELSZ))
|| 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);
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),
(int)elf_unsigned_dynamic(Elf64_Dyn::DT_RELASZ))
|| calls_crt1((Elf64_Rela const *)elf_find_dynamic(Elf64_Dyn::DT_JMPREL),