mirror of
https://github.com/upx/upx.git
synced 2025-02-19 23:51:29 +00:00
Fix amd64 shared libraries
Some checks failed
CI / Rebuild stubs (push) Has been cancelled
CI / ubuntu-20.04 (push) Has been cancelled
CI / ubuntu-22.04 (push) Has been cancelled
CI / ubuntu-24.04 (push) Has been cancelled
CI / macos-13 (push) Has been cancelled
CI / macos-14 (push) Has been cancelled
CI / macos-15 (push) Has been cancelled
CI / windows-2019-amd64 (push) Has been cancelled
CI / windows-2022-amd64 (push) Has been cancelled
CI / windows arm64ec-win64-vs2022 (push) Has been cancelled
CI / windows amd64-win64-vs2019 (push) Has been cancelled
CI / windows amd64-win64-vs2022 (push) Has been cancelled
CI / windows arm64-win64-vs2019 (push) Has been cancelled
CI / windows arm64-win64-vs2022 (push) Has been cancelled
CI / windows i386-win32-vs2019 (push) Has been cancelled
CI / windows i386-win32-vs2022 (push) Has been cancelled
CI / zigcc i386-linux-gnu.2.3.4 (push) Has been cancelled
CI / zigcc aarch64-macos.11.0-none (push) Has been cancelled
CI / zigcc aarch64-windows-gnu (push) Has been cancelled
CI / zigcc i386-windows-gnu (push) Has been cancelled
CI / zigcc aarch64-linux-musl (push) Has been cancelled
CI / zigcc arm-linux-musleabihf (push) Has been cancelled
CI / zigcc armeb-linux-musleabihf (push) Has been cancelled
CI / zigcc i386-linux-musl (push) Has been cancelled
CI / zigcc mips-linux-musleabi (push) Has been cancelled
CI / zigcc mips-linux-musleabihf (push) Has been cancelled
CI / zigcc mipsel-linux-musleabi (push) Has been cancelled
CI / zigcc mipsel-linux-musleabihf (push) Has been cancelled
CI / zigcc powerpc-linux-musleabihf (push) Has been cancelled
CI / zigcc powerpc64-linux-musl (push) Has been cancelled
CI / zigcc powerpc64le-linux-musl (push) Has been cancelled
CI / zigcc x86_64-linux-gnu.2.3.4 (push) Has been cancelled
CI / zigcc x86_64-linux-musl (push) Has been cancelled
CI / zigcc x86_64-macos.11.0-none (push) Has been cancelled
CI / zigcc x86_64-windows-gnu (push) Has been cancelled
Some checks failed
CI / Rebuild stubs (push) Has been cancelled
CI / ubuntu-20.04 (push) Has been cancelled
CI / ubuntu-22.04 (push) Has been cancelled
CI / ubuntu-24.04 (push) Has been cancelled
CI / macos-13 (push) Has been cancelled
CI / macos-14 (push) Has been cancelled
CI / macos-15 (push) Has been cancelled
CI / windows-2019-amd64 (push) Has been cancelled
CI / windows-2022-amd64 (push) Has been cancelled
CI / windows arm64ec-win64-vs2022 (push) Has been cancelled
CI / windows amd64-win64-vs2019 (push) Has been cancelled
CI / windows amd64-win64-vs2022 (push) Has been cancelled
CI / windows arm64-win64-vs2019 (push) Has been cancelled
CI / windows arm64-win64-vs2022 (push) Has been cancelled
CI / windows i386-win32-vs2019 (push) Has been cancelled
CI / windows i386-win32-vs2022 (push) Has been cancelled
CI / zigcc i386-linux-gnu.2.3.4 (push) Has been cancelled
CI / zigcc aarch64-macos.11.0-none (push) Has been cancelled
CI / zigcc aarch64-windows-gnu (push) Has been cancelled
CI / zigcc i386-windows-gnu (push) Has been cancelled
CI / zigcc aarch64-linux-musl (push) Has been cancelled
CI / zigcc arm-linux-musleabihf (push) Has been cancelled
CI / zigcc armeb-linux-musleabihf (push) Has been cancelled
CI / zigcc i386-linux-musl (push) Has been cancelled
CI / zigcc mips-linux-musleabi (push) Has been cancelled
CI / zigcc mips-linux-musleabihf (push) Has been cancelled
CI / zigcc mipsel-linux-musleabi (push) Has been cancelled
CI / zigcc mipsel-linux-musleabihf (push) Has been cancelled
CI / zigcc powerpc-linux-musleabihf (push) Has been cancelled
CI / zigcc powerpc64-linux-musl (push) Has been cancelled
CI / zigcc powerpc64le-linux-musl (push) Has been cancelled
CI / zigcc x86_64-linux-gnu.2.3.4 (push) Has been cancelled
CI / zigcc x86_64-linux-musl (push) Has been cancelled
CI / zigcc x86_64-macos.11.0-none (push) Has been cancelled
CI / zigcc x86_64-windows-gnu (push) Has been cancelled
Inspired by https://github.com/upx/upx/issues/880 (https://github.com/microsoft/mimalloc.git on Linux) but still need test case. modified: p_lx_elf.cpp modified: stub/amd64-linux.elf-so_entry.h modified: stub/src/amd64-linux.elf-so_entry.S
This commit is contained in:
parent
f5ff0ef348
commit
90632e9317
@ -2794,9 +2794,9 @@ upx_uint64_t PackLinuxElf32::canPack_Shdr(Elf32_Phdr const *pload_x0)
|
||||
Elf32_Shdr const *shdr = shdri;
|
||||
for (int j= e_shnum; --j>=0; ++shdr) {
|
||||
unsigned const sh_type = get_te32(&shdr->sh_type);
|
||||
if (Elf32_Shdr::SHF_EXECINSTR & get_te32(&shdr->sh_flags)) {
|
||||
if (!shdr_xva && Elf32_Shdr::SHF_EXECINSTR & get_te32(&shdr->sh_flags)) {
|
||||
shdr_xva = shdr;
|
||||
xct_va = umin((unsigned) xct_va, get_te32(&shdr->sh_addr));
|
||||
xct_va = get_te32(&shdr_xva->sh_addr);
|
||||
}
|
||||
// Hook the first slot of DT_PREINIT_ARRAY or DT_INIT_ARRAY.
|
||||
if (!user_init_rp && (
|
||||
@ -2922,20 +2922,6 @@ bad:
|
||||
}
|
||||
}
|
||||
}
|
||||
// If shdr_xva->sh_size is too small, then probably it won't compress.
|
||||
// So look for a Shdr that has PROGBITS and not SHF_WRITE, which is
|
||||
// much larger, and use that for the compressibility decision.
|
||||
if (shdr_xva->sh_size < 0x1000) {
|
||||
shdr = shdr_xva;
|
||||
while (SHT_PROGBITS == get_te32(&shdr[-1].sh_type)) --shdr; // backup
|
||||
for (; SHT_PROGBITS == get_te32(&shdr->sh_type)
|
||||
&& !(SHF_WRITE & get_te32(&shdr->sh_flags)); ++shdr) {
|
||||
if (0x4000 <= get_te32(&shdr->sh_size)) {
|
||||
xct_va = get_te32(&shdr->sh_addr); // hopefully more compressible
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return xct_va;
|
||||
}
|
||||
|
||||
@ -2945,9 +2931,9 @@ upx_uint64_t PackLinuxElf64::canPack_Shdr(Elf64_Phdr const *pload_x0)
|
||||
Elf64_Shdr const *shdr = shdri;
|
||||
for (int j= e_shnum; --j>=0; ++shdr) {
|
||||
unsigned const sh_type = get_te32(&shdr->sh_type);
|
||||
if (Elf64_Shdr::SHF_EXECINSTR & get_te64(&shdr->sh_flags)) {
|
||||
if (!shdr_xva && Elf64_Shdr::SHF_EXECINSTR & get_te64(&shdr->sh_flags)) {
|
||||
shdr_xva = shdr;
|
||||
xct_va = umin(xct_va, get_te64(&shdr->sh_addr));
|
||||
xct_va = get_te64_32(&shdr_xva->sh_addr);
|
||||
}
|
||||
// Hook the first slot of DT_PREINIT_ARRAY or DT_INIT_ARRAY.
|
||||
if (!user_init_rp && (
|
||||
@ -3067,20 +3053,6 @@ upx_uint64_t PackLinuxElf64::canPack_Shdr(Elf64_Phdr const *pload_x0)
|
||||
}
|
||||
}
|
||||
}
|
||||
// If shdr_xva->sh_size is too small, then probably it won't compress.
|
||||
// So look for a Shdr that has PROGBITS and not SHF_WRITE, which is
|
||||
// much larger, and use that for the compressibility decision.
|
||||
if (shdr_xva->sh_size < 0x1000) {
|
||||
shdr = shdr_xva;
|
||||
while (SHT_PROGBITS == get_te32(&shdr[-1].sh_type)) --shdr; // backup
|
||||
for (; SHT_PROGBITS == get_te32(&shdr->sh_type)
|
||||
&& !(SHF_WRITE & get_te64(&shdr->sh_flags)); ++shdr) {
|
||||
if (0x4000 <= get_te64(&shdr->sh_size)) {
|
||||
xct_va = get_te64(&shdr->sh_addr); // hopefully more compressible
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return xct_va;
|
||||
}
|
||||
|
||||
@ -5793,6 +5765,7 @@ int PackLinuxElf64::pack2_shlib(OutputFile *fo, Filter &ft, unsigned pre_xct_top
|
||||
// Copy up to xct_off
|
||||
// FIXME: fo->write(&file_image[x.offset], x.size);
|
||||
if (len) {
|
||||
fi->seek(p_offset, SEEK_SET);
|
||||
fi->read(ibuf, len); total_in += len;
|
||||
fo->write(ibuf, len); total_out += len;
|
||||
|
||||
|
50
src/stub/amd64-linux.elf-so_entry.h
generated
50
src/stub/amd64-linux.elf-so_entry.h
generated
@ -33,8 +33,8 @@
|
||||
/* clang-format off */
|
||||
|
||||
#define STUB_AMD64_LINUX_ELF_SO_ENTRY_SIZE 6372
|
||||
#define STUB_AMD64_LINUX_ELF_SO_ENTRY_ADLER32 0x1eeb7b9f
|
||||
#define STUB_AMD64_LINUX_ELF_SO_ENTRY_CRC32 0x08003832
|
||||
#define STUB_AMD64_LINUX_ELF_SO_ENTRY_ADLER32 0xf9607bd7
|
||||
#define STUB_AMD64_LINUX_ELF_SO_ENTRY_CRC32 0x7ca0bbfb
|
||||
|
||||
unsigned char stub_amd64_linux_elf_so_entry[6372] = {
|
||||
/* 0x0000 */ 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@ -76,29 +76,29 @@ unsigned char stub_amd64_linux_elf_so_entry[6372] = {
|
||||
/* 0x0240 */ 139, 92, 36, 8, 72,139,108, 36, 16, 76,139,100, 36, 24, 76,139,
|
||||
/* 0x0250 */ 108, 36, 32, 72,131,196, 40,195,144, 82, 86, 87, 83, 85, 72,137,
|
||||
/* 0x0260 */ 229, 72,141, 29, 0, 0, 0, 0, 72,141, 5,217,255,255,255, 80,
|
||||
/* 0x0270 */ 139, 3, 80, 72, 41,196, 72,131,228,240, 41,210, 72,141, 53, 76,
|
||||
/* 0x0280 */ 1, 0, 0, 41,255,104, 1, 1, 0, 0,232, 45, 1, 0, 0,133,
|
||||
/* 0x0290 */ 192,120, 54, 80,186, 0, 2, 0, 0, 72,141,116, 36, 8, 95, 87,
|
||||
/* 0x02a0 */ 106, 0,232, 21, 1, 0, 0, 76,141, 4, 48, 95,106, 3,232, 9,
|
||||
/* 0x02b0 */ 1, 0, 0, 72,141,116, 36, 8, 72,173, 72,145, 72,173, 72,131,
|
||||
/* 0x02c0 */ 249, 6,116, 10, 76, 57,198,124,239,184, 0, 16, 0, 0, 72,247,
|
||||
/* 0x02d0 */ 216, 80, 72,141, 21, 27, 0, 0, 0, 72,141,124, 36, 8, 85,139,
|
||||
/* 0x02e0 */ 75, 4, 72,141,115, 12, 72, 1,241, 81, 49,219, 49,201,106,255,
|
||||
/* 0x02f0 */ 93,252,235, 20,243, 15, 30,250, 1,219,116, 2,243,195,139, 30,
|
||||
/* 0x0300 */ 72,131,238,252, 17,219,195,164,255,210,114,251,141, 65, 1,255,
|
||||
/* 0x0310 */ 210, 17,192,255,210,115,248,131,232, 3,114, 12,193,224, 8,172,
|
||||
/* 0x0320 */ 131,240,255,116, 47, 72, 99,232,141, 65, 1,255,210, 17,201,255,
|
||||
/* 0x0330 */ 210, 17,201,117, 13,137,193,131,192, 2,255,210, 17,201,255,210,
|
||||
/* 0x0340 */ 115,248,129,253, 0,243,255,255, 17,193, 86, 72,141, 52, 47,243,
|
||||
/* 0x0350 */ 164, 94,235,180, 89, 72, 57,206,116, 1,244, 93,104,117,112, 88,
|
||||
/* 0x0360 */ 0, 84, 95,106, 16, 94,184, 63, 1, 0, 0, 15, 5,133,192,121,
|
||||
/* 0x0370 */ 9,133,246,116, 4, 49,246,235,237,244, 89,143, 4, 36, 80, 95,
|
||||
/* 0x0380 */ 84, 94, 80, 72,139, 85,240,106, 1,232, 46, 0, 0, 0, 65, 88,
|
||||
/* 0x0390 */ 72,141,101,240, 94, 86, 69, 41,201,106, 2, 65, 90,106, 5, 90,
|
||||
/* 0x03a0 */ 41,255,106, 9,232, 19, 0, 0, 0, 80, 65, 80, 95,106, 3,232,
|
||||
/* 0x03b0 */ 8, 0, 0, 0, 88, 80, 72,131,192, 16,255,224, 72,139, 68, 36,
|
||||
/* 0x03c0 */ 8, 15, 5, 72, 61, 0,240,255,255,114, 1,204,194, 8, 0, 47,
|
||||
/* 0x03d0 */ 112,114,111, 99, 47,115,101,108,102, 47, 97,117,120,118, 0, 0,
|
||||
/* 0x0270 */ 139, 3, 80, 72, 41,196, 72,131,228,240, 41,210, 72,141, 53, 74,
|
||||
/* 0x0280 */ 1, 0, 0, 41,255,104, 1, 1, 0, 0,232, 43, 1, 0, 0,133,
|
||||
/* 0x0290 */ 192,120, 52, 80,186, 0, 2, 0, 0, 72,141,116, 36, 8, 95, 87,
|
||||
/* 0x02a0 */ 106, 0,232, 19, 1, 0, 0, 76,141, 4, 48, 95,106, 3,232, 7,
|
||||
/* 0x02b0 */ 1, 0, 0, 72,137,230, 72,173, 72,145, 72,173, 72,131,249, 6,
|
||||
/* 0x02c0 */ 116, 10, 76, 57,198,124,239,184, 0, 16, 0, 0, 72,247,216, 80,
|
||||
/* 0x02d0 */ 72,141, 21, 27, 0, 0, 0, 72,141,124, 36, 8, 85,139, 75, 4,
|
||||
/* 0x02e0 */ 72,141,115, 12, 72, 1,241, 81, 49,219, 49,201,106,255, 93,252,
|
||||
/* 0x02f0 */ 235, 20,243, 15, 30,250, 1,219,116, 2,243,195,139, 30, 72,131,
|
||||
/* 0x0300 */ 238,252, 17,219,195,164,255,210,114,251,141, 65, 1,255,210, 17,
|
||||
/* 0x0310 */ 192,255,210,115,248,131,232, 3,114, 12,193,224, 8,172,131,240,
|
||||
/* 0x0320 */ 255,116, 47, 72, 99,232,141, 65, 1,255,210, 17,201,255,210, 17,
|
||||
/* 0x0330 */ 201,117, 13,137,193,131,192, 2,255,210, 17,201,255,210,115,248,
|
||||
/* 0x0340 */ 129,253, 0,243,255,255, 17,193, 86, 72,141, 52, 47,243,164, 94,
|
||||
/* 0x0350 */ 235,180, 89, 72, 57,206,116, 1,244, 93,104,117,112, 88, 0, 84,
|
||||
/* 0x0360 */ 95,106, 16, 94,184, 63, 1, 0, 0, 15, 5,133,192,121, 9,133,
|
||||
/* 0x0370 */ 246,116, 4, 49,246,235,237,244, 89,143, 4, 36, 80, 95, 84, 94,
|
||||
/* 0x0380 */ 80, 72,139, 85,240,106, 1,232, 46, 0, 0, 0, 65, 88, 72,141,
|
||||
/* 0x0390 */ 101,240, 94, 86, 69, 41,201,106, 2, 65, 90,106, 5, 90, 41,255,
|
||||
/* 0x03a0 */ 106, 9,232, 19, 0, 0, 0, 80, 65, 80, 95,106, 3,232, 8, 0,
|
||||
/* 0x03b0 */ 0, 0, 88, 80, 72,131,192, 16,255,224, 72,139, 68, 36, 8, 15,
|
||||
/* 0x03c0 */ 5, 72, 61, 0,240,255,255,114, 1,204,194, 8, 0, 47,112,114,
|
||||
/* 0x03d0 */ 111, 99, 47,115,101,108,102, 47, 97,117,120,118, 0, 0, 0, 0,
|
||||
/* 0x03e0 */ 117,112,120, 0, 47,100,101,118, 47,115,104,109, 0,109,101,109,
|
||||
/* 0x03f0 */ 102,100, 95, 99,114,101, 97,116,101, 0,117,112,120, 0, 47,100,
|
||||
/* 0x0400 */ 101,118, 47,115,104,109, 0, 0, 46,115,121,109,116, 97, 98, 0,
|
||||
|
@ -119,7 +119,7 @@ O_RDONLY= 0
|
||||
push $__NR_read; call do_sys; lea (%rax,%arg2),%end_aux
|
||||
pop %arg1 // fd_psa
|
||||
push $__NR_close; call do_sys
|
||||
lea 1*NBPW(%rsp),%rsi // buffer
|
||||
mov %rsp,%rsi // buffer
|
||||
0:
|
||||
lodsq; xchg %rax,%rcx // tag
|
||||
lodsq // value
|
||||
|
Loading…
x
Reference in New Issue
Block a user