static uClibc on amd64 passes entry.%rdx to 'atexit'
https://github.com/upx/upx/issues/166 modified: ../.github/travis_testsuite_1.sh modified: stub/src/amd64-linux.elf-entry.S modified: stub/src/amd64-linux.elf-fold.S modified: stub/src/amd64-linux.elf-main.c
This commit is contained in:
+597
-597
File diff suppressed because it is too large
Load Diff
@@ -32,8 +32,8 @@
|
||||
|
||||
|
||||
#define STUB_AMD64_LINUX_ELF_FOLD_SIZE 2148
|
||||
#define STUB_AMD64_LINUX_ELF_FOLD_ADLER32 0x00ad254f
|
||||
#define STUB_AMD64_LINUX_ELF_FOLD_CRC32 0x43dc8ba8
|
||||
#define STUB_AMD64_LINUX_ELF_FOLD_ADLER32 0xd5552522
|
||||
#define STUB_AMD64_LINUX_ELF_FOLD_CRC32 0xfa491d41
|
||||
|
||||
unsigned char stub_amd64_linux_elf_fold[2148] = {
|
||||
/* 0x0000 */ 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -53,7 +53,7 @@ unsigned char stub_amd64_linux_elf_fold[2148] = {
|
||||
/* 0x00e0 */ 119, 6,128,126,254, 15,116, 6, 44,232, 60, 1,119,228, 72, 57,
|
||||
/* 0x00f0 */ 206,115, 22, 86,173, 40,208,117,223, 95, 15,200, 41,248, 1,216,
|
||||
/* 0x0100 */ 171, 72, 57,206,115, 3,172,235,223, 91,195, 88, 65, 86, 65, 87,
|
||||
/* 0x0110 */ 80, 72,137,230, 72,129,236, 0, 16, 0, 0, 84, 95,106, 9, 89,
|
||||
/* 0x0110 */ 80, 72,137,230, 72,129,236, 0, 16, 0, 0, 84, 95,106, 10, 89,
|
||||
/* 0x0120 */ 243, 72,165, 72,131, 62, 0, 72,165,117,248, 73,137,254, 72,171,
|
||||
/* 0x0130 */ 72,131, 62, 0, 72,165,117,248, 73,137,252, 72,131, 62, 0, 72,
|
||||
/* 0x0140 */ 165, 72,165,117,246, 73,137,255, 73,137,245, 77, 41,252,186,255,
|
||||
@@ -65,7 +65,7 @@ unsigned char stub_amd64_linux_elf_fold[2148] = {
|
||||
/* 0x01a0 */ 141,119,248, 72,193,233, 3,243, 72,165, 72,141,103, 8,252, 75,
|
||||
/* 0x01b0 */ 141, 12, 38,139, 67,252,131,224, 1, 72, 1,193, 65, 89, 94, 95,
|
||||
/* 0x01c0 */ 88, 72,129,236, 0, 8, 0, 0, 72,137,226, 80, 73,137,232,232,
|
||||
/* 0x01d0 */ 72, 5, 0, 0, 72,129,196, 8, 8, 0, 0, 72,137, 68, 36, 24,
|
||||
/* 0x01d0 */ 72, 5, 0, 0, 72,129,196, 8, 8, 0, 0, 72,137, 68, 36, 32,
|
||||
/* 0x01e0 */ 91, 69, 41,201, 65,137,216,106, 2, 65, 90,106, 1, 90,190, 0,
|
||||
/* 0x01f0 */ 16, 0, 0,106, 0, 95,106, 9, 88, 15, 5,137,223,106, 3, 88,
|
||||
/* 0x0200 */ 15, 5, 95, 94,106, 11, 88, 65,255,102,248,176, 9, 73,137,202,
|
||||
@@ -139,7 +139,7 @@ unsigned char stub_amd64_linux_elf_fold[2148] = {
|
||||
/* 0x0640 */ 208,117, 82, 73,139, 84, 36, 40, 73,139,116, 36, 16, 73, 59, 84,
|
||||
/* 0x0650 */ 36, 32, 72,141, 4, 50, 74,141, 12, 40,117, 14,137,200,247,216,
|
||||
/* 0x0660 */ 37,255, 15, 0, 0,131,248, 3,119, 13, 73,131,124, 36, 8, 0,
|
||||
/* 0x0670 */ 74,141, 76, 46, 12,117, 30, 72,133,201,199, 1, 15, 5,195,144,
|
||||
/* 0x0670 */ 74,141, 76, 46, 12,117, 30, 72,133,201,199, 1, 15, 5, 90,195,
|
||||
/* 0x0680 */ 116, 19, 72,139,124, 36, 32, 72,137,202, 49,246, 72,131,231,254,
|
||||
/* 0x0690 */ 232,248,252,255,255,139, 84, 36, 8, 76,137,254, 72,137,239,232,
|
||||
/* 0x06a0 */ 146,251,255,255,133,192,116, 10,191,127, 0, 0, 0,232,112,251,
|
||||
|
||||
@@ -65,11 +65,13 @@ M_NRV2D_LE32=5
|
||||
M_NRV2E_LE32=8
|
||||
|
||||
|
||||
// https://www.uclibc.org/docs/psABI-x86_64.pdf
|
||||
section ELFMAINX
|
||||
sz_pack2= .-4
|
||||
_start: .globl _start
|
||||
//// nop; int3 # uncomment for debugging
|
||||
push %rax // space for entry address
|
||||
push %rdx // register this function pointer with 'atexit'
|
||||
call main // push &decompress
|
||||
|
||||
/* Returns 0 on success; non-zero on failure. */
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
* <jreiser@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
NBPW= 8
|
||||
#include "arch/amd64/macros.S"
|
||||
#include "arch/amd64/regs.h"
|
||||
|
||||
@@ -68,7 +69,7 @@ __NR_readlink= 89
|
||||
|
||||
// IN:
|
||||
// %rbx= &O_BINFO; %rbp= f_exp; %r14= ADRX; %r15= LENX;
|
||||
// rsp/ elfaddr,fd,ADRU,LENU,%entry, argc,argv,0,envp,0,auxv,0,strings
|
||||
// rsp/ elfaddr,fd,ADRU,LENU,rdx,%entry, argc,argv,0,envp,0,auxv,0,strings
|
||||
|
||||
fold_begin:
|
||||
//// int3 // DEBUG only
|
||||
@@ -82,7 +83,7 @@ L90:
|
||||
mov %rsp,%rsi
|
||||
sub $PATH_MAX,%rsp
|
||||
push %rsp; pop %rdi
|
||||
push $9; pop %rcx; rep movsq # f_unf,LENX,ADRX,elfaddr,fd,ADRU,LENU,%entry,argc
|
||||
push $10; pop %rcx; rep movsq # f_unf,LENX,ADRX,elfaddr,fd,ADRU,LENU,rdx,%entry,argc
|
||||
0:
|
||||
cmpq $0,(%rsi); movsq; jne 0b # move past argv
|
||||
movq %rdi,%r14 # remember &new_env[0]
|
||||
@@ -145,8 +146,8 @@ L90:
|
||||
Elf32_Auxv_t *arg4, f_decompr arg5, f_unf arg6,
|
||||
Elf64_Addr elfaddr )
|
||||
*/
|
||||
addq $1*8+OVERHEAD,%rsp # toss elfaddr, too
|
||||
movq %rax,3*8(%rsp) # entry
|
||||
addq $1*NBPW+OVERHEAD,%rsp # toss elfaddr, too
|
||||
movq %rax,4*NBPW(%rsp) # entry
|
||||
pop %rbx # fd
|
||||
|
||||
// Map 1 page of /proc/self/exe so that it does not disappear.
|
||||
@@ -164,7 +165,7 @@ L90:
|
||||
pop %arg1 # ADRU
|
||||
pop %arg2 # LENU
|
||||
push $ __NR_munmap; pop %rax
|
||||
jmp *-8(%r14) # goto: syscall; ret
|
||||
jmp *-8(%r14) # goto: syscall; pop %rdx; ret
|
||||
|
||||
mmap: .globl mmap
|
||||
movb $ __NR_mmap,%al
|
||||
|
||||
@@ -238,7 +238,7 @@ make_hatch_x86_64(
|
||||
(phdr->p_offset==0) )
|
||||
)
|
||||
{
|
||||
hatch[0] = 0x90c3050f; // syscall; ret; nop
|
||||
hatch[0] = 0xc35a050f; // syscall; pop %rdx; ret
|
||||
}
|
||||
else {
|
||||
hatch = 0;
|
||||
|
||||
@@ -2,18 +2,18 @@ file format elf64-x86-64
|
||||
|
||||
Sections:
|
||||
Idx Name Size VMA LMA File off Algn Flags
|
||||
0 ELFMAINX 0000000e 0000000000000000 0000000000000000 00000040 2**0 CONTENTS, RELOC, READONLY
|
||||
1 NRV_HEAD 00000066 0000000000000000 0000000000000000 0000004e 2**0 CONTENTS, READONLY
|
||||
2 NRV2E 000000b7 0000000000000000 0000000000000000 000000b4 2**0 CONTENTS, RELOC, READONLY
|
||||
3 NRV2D 0000009e 0000000000000000 0000000000000000 0000016b 2**0 CONTENTS, RELOC, READONLY
|
||||
4 NRV2B 00000090 0000000000000000 0000000000000000 00000209 2**0 CONTENTS, RELOC, READONLY
|
||||
5 LZMA_ELF00 00000064 0000000000000000 0000000000000000 00000299 2**0 CONTENTS, RELOC, READONLY
|
||||
6 LZMA_DEC10 000009f7 0000000000000000 0000000000000000 000002fd 2**0 CONTENTS, READONLY
|
||||
7 LZMA_DEC20 000009f7 0000000000000000 0000000000000000 00000cf4 2**0 CONTENTS, READONLY
|
||||
8 LZMA_DEC30 00000014 0000000000000000 0000000000000000 000016eb 2**0 CONTENTS, READONLY
|
||||
9 NRV_TAIL 00000000 0000000000000000 0000000000000000 000016ff 2**0 CONTENTS, READONLY
|
||||
10 ELFMAINY 0000003a 0000000000000000 0000000000000000 000016ff 2**0 CONTENTS, RELOC, READONLY
|
||||
11 ELFMAINZ 000000e4 0000000000000000 0000000000000000 00001739 2**0 CONTENTS, RELOC, READONLY
|
||||
0 ELFMAINX 0000000f 0000000000000000 0000000000000000 00000040 2**0 CONTENTS, RELOC, READONLY
|
||||
1 NRV_HEAD 00000066 0000000000000000 0000000000000000 0000004f 2**0 CONTENTS, READONLY
|
||||
2 NRV2E 000000b7 0000000000000000 0000000000000000 000000b5 2**0 CONTENTS, RELOC, READONLY
|
||||
3 NRV2D 0000009e 0000000000000000 0000000000000000 0000016c 2**0 CONTENTS, RELOC, READONLY
|
||||
4 NRV2B 00000090 0000000000000000 0000000000000000 0000020a 2**0 CONTENTS, RELOC, READONLY
|
||||
5 LZMA_ELF00 00000064 0000000000000000 0000000000000000 0000029a 2**0 CONTENTS, RELOC, READONLY
|
||||
6 LZMA_DEC10 000009f7 0000000000000000 0000000000000000 000002fe 2**0 CONTENTS, READONLY
|
||||
7 LZMA_DEC20 000009f7 0000000000000000 0000000000000000 00000cf5 2**0 CONTENTS, READONLY
|
||||
8 LZMA_DEC30 00000014 0000000000000000 0000000000000000 000016ec 2**0 CONTENTS, READONLY
|
||||
9 NRV_TAIL 00000000 0000000000000000 0000000000000000 00001700 2**0 CONTENTS, READONLY
|
||||
10 ELFMAINY 0000003a 0000000000000000 0000000000000000 00001700 2**0 CONTENTS, RELOC, READONLY
|
||||
11 ELFMAINZ 000000e4 0000000000000000 0000000000000000 0000173a 2**0 CONTENTS, RELOC, READONLY
|
||||
SYMBOL TABLE:
|
||||
0000000000000000 l d NRV_HEAD 0000000000000000 NRV_HEAD
|
||||
0000000000000000 l d LZMA_DEC30 0000000000000000 LZMA_DEC30
|
||||
@@ -32,7 +32,7 @@ SYMBOL TABLE:
|
||||
|
||||
RELOCATION RECORDS FOR [ELFMAINX]:
|
||||
OFFSET TYPE VALUE
|
||||
0000000000000002 R_X86_64_PC32 ELFMAINZ+0x00000000000000c7
|
||||
0000000000000003 R_X86_64_PC32 ELFMAINZ+0x00000000000000c7
|
||||
|
||||
RELOCATION RECORDS FOR [NRV2E]:
|
||||
OFFSET TYPE VALUE
|
||||
|
||||
Reference in New Issue
Block a user