Android 64-bit ARM shared library stub: use 4Ki page size until more is known
https://github.com/upx/upx/issues/124 modified: p_lx_elf.cpp modified: stub/arm64-linux.shlib-init.h modified: stub/src/arm64-linux.shlib-init.S modified: stub/tmp/arm64-linux.shlib-init.bin.dump
This commit is contained in:
@@ -586,6 +586,15 @@ PackLinuxElf::addStubEntrySections(Filter const *)
|
|||||||
addLoader("ELFMAINZe", NULL);
|
addLoader("ELFMAINZe", NULL);
|
||||||
}
|
}
|
||||||
addLoader("+40,ELFMAINZ", NULL);
|
addLoader("+40,ELFMAINZ", NULL);
|
||||||
|
if (hasLoaderSection("ANDMAJNZ")) { // Android trouble with args to DT_INIT
|
||||||
|
if (opt->o_unix.android_shlib) {
|
||||||
|
addLoader("ANDMAJNZ", NULL); // constant PAGE_SIZE
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addLoader("ELFMAJNZ", NULL); // PAGE_SIZE from AT_PAGESZ
|
||||||
|
}
|
||||||
|
addLoader("ELFMAKNZ", NULL);
|
||||||
|
}
|
||||||
if (hasLoaderSection("ELFMAINZu")) {
|
if (hasLoaderSection("ELFMAINZu")) {
|
||||||
addLoader("ELFMAINZu", NULL);
|
addLoader("ELFMAINZu", NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
+543
-513
File diff suppressed because it is too large
Load Diff
@@ -136,22 +136,11 @@ _start: .globl _start
|
|||||||
// brk #0 // debugging
|
// brk #0 // debugging
|
||||||
stp arg1,arg2,[sp,#f_argc - sp_frame]! // f_argv
|
stp arg1,arg2,[sp,#f_argc - sp_frame]! // f_argv
|
||||||
stp arg3,x0, [sp,#f_envp] // %f_uinit
|
stp arg3,x0, [sp,#f_envp] // %f_uinit
|
||||||
|
str lr, [sp,#f_my_ra]
|
||||||
// Calculate PAGE_MASK
|
|
||||||
0: // Advance envp to auxp
|
|
||||||
ldr x3,[arg3],#NBPW; cbnz x3,0b
|
|
||||||
|
|
||||||
mov x3,#1<<PAGE_SHIFT // default
|
|
||||||
0: // Find AT_PAGESZ
|
|
||||||
ldp x0,x1,[arg3],#2*NBPW; cbz x0,5f // AT_NULL==.a_type; use default
|
|
||||||
cmp x0,#AT_PAGESZ; bne 0b
|
|
||||||
5: // auxp cannot be empty (must have AT_UID), so 'cmp' above sets nzvc
|
|
||||||
csel x1,x1,x3,eq // x1 if found, else x3
|
|
||||||
neg x1,x1
|
|
||||||
stp x1,lr,[sp,#f_PMASK] // f_my_ra
|
|
||||||
|
|
||||||
bl main // ra= &f_decompress
|
bl main // ra= &f_decompress
|
||||||
f_decompress:
|
f_decompress:
|
||||||
|
|
||||||
#define LINUX_ARM_CACHEFLUSH 1
|
#define LINUX_ARM_CACHEFLUSH 1
|
||||||
|
|
||||||
section NRV_HEAD
|
section NRV_HEAD
|
||||||
@@ -187,10 +176,27 @@ L71:
|
|||||||
/* IDENTSTR goes here */
|
/* IDENTSTR goes here */
|
||||||
|
|
||||||
section ELFMAINZ
|
section ELFMAINZ
|
||||||
#define lodsl ldr eax,[rsi],#4
|
|
||||||
#define lodslu lodsl
|
|
||||||
|
|
||||||
main:
|
main:
|
||||||
|
|
||||||
|
section ELFMAJNZ
|
||||||
|
// Calculate PAGE_MASK
|
||||||
|
0: // Advance envp to auxp
|
||||||
|
ldr x3,[arg3],#NBPW; cbnz x3,0b
|
||||||
|
|
||||||
|
mov x3,#1<<PAGE_SHIFT // default
|
||||||
|
0: // Find AT_PAGESZ
|
||||||
|
ldp x0,x1,[arg3],#2*NBPW; cbz x0,5f // AT_NULL==.a_type; use default
|
||||||
|
cmp x0,#AT_PAGESZ; bne 0b
|
||||||
|
5: // auxp cannot be empty (must have AT_UID), so 'cmp' above sets nzvc
|
||||||
|
csel x1,x1,x3,eq // x1 if found, else x3
|
||||||
|
neg x1,x1
|
||||||
|
|
||||||
|
section ANDMAJNZ // Android passes junk args to DT_INIT?
|
||||||
|
mov x1,#~0<<12 // -4096
|
||||||
|
|
||||||
|
section ELFMAKNZ
|
||||||
|
str x1,[sp,#f_PMASK]
|
||||||
|
|
||||||
// 1. allocate temporary pages
|
// 1. allocate temporary pages
|
||||||
// 2. copy to temporary pages:
|
// 2. copy to temporary pages:
|
||||||
// fragment of page below dst; compressed src;
|
// fragment of page below dst; compressed src;
|
||||||
@@ -207,8 +213,11 @@ main:
|
|||||||
// 12. goto user DT_INIT
|
// 12. goto user DT_INIT
|
||||||
|
|
||||||
mov rdx,lr // &f_decompress
|
mov rdx,lr // &f_decompress
|
||||||
|
|
||||||
add rsi,rdx,# _start - f_decompress - 4*4
|
add rsi,rdx,# _start - f_decompress - 4*4
|
||||||
|
|
||||||
|
#define lodsl ldr eax,[rsi],#4
|
||||||
|
#define lodslu lodsl
|
||||||
|
|
||||||
mov rcx,rsi
|
mov rcx,rsi
|
||||||
lodsl; sub rcx,rcx,rax; //str ecx,[sp,#o_reloc]
|
lodsl; sub rcx,rcx,rax; //str ecx,[sp,#o_reloc]
|
||||||
lodsl; add rax,rcx,rax; str rax,[sp,#f_uinit] // reloc DT_INIT for step 12
|
lodsl; add rax,rcx,rax; str rax,[sp,#f_uinit] // reloc DT_INIT for step 12
|
||||||
|
|||||||
@@ -2,18 +2,21 @@ file format elf64-littleaarch64
|
|||||||
|
|
||||||
Sections:
|
Sections:
|
||||||
Idx Name Size VMA LMA File off Algn Flags
|
Idx Name Size VMA LMA File off Algn Flags
|
||||||
0 ELFMAINX 00000034 0000000000000000 0000000000000000 00000040 2**0 CONTENTS, RELOC, READONLY
|
0 ELFMAINX 00000010 0000000000000000 0000000000000000 00000040 2**0 CONTENTS, RELOC, READONLY
|
||||||
1 NRV_HEAD 00000000 0000000000000000 0000000000000000 00000074 2**0 CONTENTS, READONLY
|
1 NRV_HEAD 00000000 0000000000000000 0000000000000000 00000050 2**0 CONTENTS, READONLY
|
||||||
2 NRV_TAIL 00000000 0000000000000000 0000000000000000 00000074 2**0 CONTENTS, READONLY
|
2 NRV_TAIL 00000000 0000000000000000 0000000000000000 00000050 2**0 CONTENTS, READONLY
|
||||||
3 NRV2E 00000128 0000000000000000 0000000000000000 00000074 2**0 CONTENTS, READONLY
|
3 NRV2E 00000128 0000000000000000 0000000000000000 00000050 2**0 CONTENTS, READONLY
|
||||||
4 NRV2D 0000011c 0000000000000000 0000000000000000 0000019c 2**0 CONTENTS, READONLY
|
4 NRV2D 0000011c 0000000000000000 0000000000000000 00000178 2**0 CONTENTS, READONLY
|
||||||
5 NRV2B 000000f0 0000000000000000 0000000000000000 000002b8 2**0 CONTENTS, READONLY
|
5 NRV2B 000000f0 0000000000000000 0000000000000000 00000294 2**0 CONTENTS, READONLY
|
||||||
6 LZMA_ELF00 000000d0 0000000000000000 0000000000000000 000003a8 2**0 CONTENTS, RELOC, READONLY
|
6 LZMA_ELF00 000000d0 0000000000000000 0000000000000000 00000384 2**0 CONTENTS, RELOC, READONLY
|
||||||
7 LZMA_DEC20 00000968 0000000000000000 0000000000000000 00000478 2**0 CONTENTS, READONLY
|
7 LZMA_DEC20 00000968 0000000000000000 0000000000000000 00000454 2**0 CONTENTS, READONLY
|
||||||
8 LZMA_DEC10 0000049c 0000000000000000 0000000000000000 00000de0 2**0 CONTENTS, READONLY
|
8 LZMA_DEC10 0000049c 0000000000000000 0000000000000000 00000dbc 2**0 CONTENTS, READONLY
|
||||||
9 LZMA_DEC30 00000000 0000000000000000 0000000000000000 0000127c 2**0 CONTENTS, READONLY
|
9 LZMA_DEC30 00000000 0000000000000000 0000000000000000 00001258 2**0 CONTENTS, READONLY
|
||||||
10 ELFMAINY 0000003e 0000000000000000 0000000000000000 0000127c 2**0 CONTENTS, READONLY
|
10 ELFMAINY 0000003e 0000000000000000 0000000000000000 00001258 2**0 CONTENTS, READONLY
|
||||||
11 ELFMAINZ 0000028c 0000000000000000 0000000000000000 000012ba 2**0 CONTENTS, READONLY
|
11 ELFMAINZ 00000000 0000000000000000 0000000000000000 00001296 2**0 CONTENTS, READONLY
|
||||||
|
12 ELFMAJNZ 00000024 0000000000000000 0000000000000000 00001296 2**0 CONTENTS, READONLY
|
||||||
|
13 ANDMAJNZ 00000004 0000000000000000 0000000000000000 000012ba 2**0 CONTENTS, READONLY
|
||||||
|
14 ELFMAKNZ 00000290 0000000000000000 0000000000000000 000012be 2**0 CONTENTS, READONLY
|
||||||
SYMBOL TABLE:
|
SYMBOL TABLE:
|
||||||
0000000000000000 l d LZMA_DEC30 0000000000000000 LZMA_DEC30
|
0000000000000000 l d LZMA_DEC30 0000000000000000 LZMA_DEC30
|
||||||
0000000000000000 l d ELFMAINZ 0000000000000000 ELFMAINZ
|
0000000000000000 l d ELFMAINZ 0000000000000000 ELFMAINZ
|
||||||
@@ -27,6 +30,9 @@ SYMBOL TABLE:
|
|||||||
0000000000000000 l d LZMA_DEC20 0000000000000000 LZMA_DEC20
|
0000000000000000 l d LZMA_DEC20 0000000000000000 LZMA_DEC20
|
||||||
0000000000000000 l d LZMA_DEC10 0000000000000000 LZMA_DEC10
|
0000000000000000 l d LZMA_DEC10 0000000000000000 LZMA_DEC10
|
||||||
0000000000000000 l d ELFMAINY 0000000000000000 ELFMAINY
|
0000000000000000 l d ELFMAINY 0000000000000000 ELFMAINY
|
||||||
|
0000000000000000 l d ELFMAJNZ 0000000000000000 ELFMAJNZ
|
||||||
|
0000000000000000 l d ANDMAJNZ 0000000000000000 ANDMAJNZ
|
||||||
|
0000000000000000 l d ELFMAKNZ 0000000000000000 ELFMAKNZ
|
||||||
0000000000000000 g ELFMAINX 0000000000000000 _start
|
0000000000000000 g ELFMAINX 0000000000000000 _start
|
||||||
0000000000000000 g F NRV2E 0000000000000128 ucl_nrv2e_decompress_32
|
0000000000000000 g F NRV2E 0000000000000128 ucl_nrv2e_decompress_32
|
||||||
0000000000000000 g F NRV2D 000000000000011c ucl_nrv2d_decompress_32
|
0000000000000000 g F NRV2D 000000000000011c ucl_nrv2d_decompress_32
|
||||||
@@ -36,7 +42,7 @@ SYMBOL TABLE:
|
|||||||
|
|
||||||
RELOCATION RECORDS FOR [ELFMAINX]:
|
RELOCATION RECORDS FOR [ELFMAINX]:
|
||||||
OFFSET TYPE VALUE
|
OFFSET TYPE VALUE
|
||||||
0000000000000030 R_AARCH64_CALL26 ELFMAINZ
|
000000000000000c R_AARCH64_CALL26 ELFMAINZ
|
||||||
|
|
||||||
RELOCATION RECORDS FOR [LZMA_ELF00]:
|
RELOCATION RECORDS FOR [LZMA_ELF00]:
|
||||||
OFFSET TYPE VALUE
|
OFFSET TYPE VALUE
|
||||||
|
|||||||
Reference in New Issue
Block a user