elf32arm escape hatch: avoid Elf32_Ehdr if possible

This commit is contained in:
John Reiser
2006-06-02 08:51:02 -07:00
parent 537b78d564
commit 1f18050930
6 changed files with 220 additions and 196 deletions
+1 -11
View File
@@ -1208,11 +1208,9 @@ void PackLinuxElf32arm::pack3(OutputFile *fo, Filter &ft)
unsigned lo_va_stub = elfout.phdr[0].p_vaddr;
unsigned adrc;
unsigned adrm;
unsigned adru;
unsigned adrx;
unsigned cntc;
unsigned lenm;
unsigned lenu;
len += lsize;
bool const is_big = true;
@@ -1223,19 +1221,15 @@ void PackLinuxElf32arm::pack3(OutputFile *fo, Filter &ft)
lo_va_stub = lo_va_user;
adrc = lo_va_stub;
adrm = getbrk(phdri, ehdri.e_phnum);
adru = PAGE_MASK & (~PAGE_MASK + adrm); // round up to page boundary
adrx = adru + hlen;
adrx = hlen + (PAGE_MASK & (~PAGE_MASK + adrm)); // round up to page boundary
lenm = PAGE_SIZE + len;
lenu = PAGE_SIZE + len;
cntc = len >> 5;
}
else {
adrm = lo_va_stub + len;
adrc = adrm;
adru = lo_va_stub;
adrx = lo_va_stub + hlen;
lenm = PAGE_SIZE;
lenu = PAGE_SIZE + len;
cntc = 0;
}
adrm = PAGE_MASK & (~PAGE_MASK + adrm); // round up to page boundary
@@ -1245,10 +1239,6 @@ void PackLinuxElf32arm::pack3(OutputFile *fo, Filter &ft)
patch_le32(p,lsize,"ADRX", adrx); // compressed input for eXpansion
patch_le32(p,lsize,"LENX", len0 - hlen);
patch_le32(p,lsize,"JMPU", 8 + lo_va_user); // trampoline for unmap
patch_le32(p,lsize,"LENU", lenu); // len for unmap
patch_le32(p,lsize,"ADRU", adru); // addr for unmap
patch_le32(p,lsize,"CNTC", cntc); // count for copy
patch_le32(p,lsize,"ADRC", adrc); // addr for copy
+12 -10
View File
@@ -46,23 +46,24 @@ fold_begin:
/* In:
r10= &b_info of first compressed block (after move)
r9= total size of compressed data
r8= JMPU
r7= LENU
r6= ADRU
r5= f_decompress
sp/ sz_unc_fold,argc,argv...
sp/ ADRU,LENU,sz_unc,argc,argv...
*/
ldr r3,[sp,#4] @ argc; sz_unc was pushed
add sp,sp,#4 @ discard sz_unc
ldr r3,[sp,#3*4] @ argc
add r3,sp,r3,lsl #2 @ skip argv
add r3,r3,#4+4 @ skip argc, env_end
add r3,r3,#3*4 +4 +4 @ skip ADRU,LENU,sz_unc, argc, env_end
.Lenv:
ldr r0,[r3],#4 @ skip env
cmp r0,#0
bne .Lenv
/* r3= &Elf32_auxv_t */
mov r2,r3
.Laux:
ldr r0,[r2],#2*4 @ .a_type
cmp r0,#0
bne .Laux
str r2,[sp,#2*4] @ clobber sz_unc with 1+ &Elf32_auxv_t[AT_NULL@.a_type]
stmdb sp!,{r6,r7,r8} @ ADRU,LENU,JMPU
sub sp,sp,#MAX_ELF_HDR + OVERHEAD @ alloca
mov r4,r9 @ total size of compressed data
ldr r9,[r10,#sz_cpr] @ xi.size of ELF headers
@@ -74,10 +75,11 @@ fold_begin:
stmdb sp!,{r3,r4,r5,r6,r7,r8,r9,r10,r11}
ldmia sp!,{r0,r1,r2,r3}
bl upx_main
mov lr,r0 @ entry address
add sp,sp,#(9-4)*4
add sp,sp,#MAX_ELF_HDR + OVERHEAD @ un-alloca
mov r2,r0 @ entry address
ldmia sp!,{r0,r1,pc} @ goto [sys $__NR_munmap; mov pc,r2]
ldmia sp!,{r0,r1,r2} @ ADRU,LENU,1+ &Elf32_auxv_t[AT_NULL@.a_type]
ldr pc,[r2,#4 -2*4] @ Elf32_auxv_t[AT_NULL@.a_type].a_val
f_unfilter: @ (char *ptr, uint len, uint cto, uint fid)
ptr .req r0
+130 -122
View File
@@ -1,4 +1,4 @@
/* fold_elf32arm.h -- created from fold_elf32arm.bin, 1952 (0x7a0) bytes
/* fold_elf32arm.h -- created from fold_elf32arm.bin, 2076 (0x81c) bytes
This file is part of the UPX executable compressor.
@@ -27,131 +27,139 @@
*/
#define LINUX_ELF32ARM_FOLD_SIZE 1952
#define LINUX_ELF32ARM_FOLD_ADLER32 0x11fa2723
#define LINUX_ELF32ARM_FOLD_CRC32 0x7a128d81
#define LINUX_ELF32ARM_FOLD_SIZE 2076
#define LINUX_ELF32ARM_FOLD_ADLER32 0x40fd5272
#define LINUX_ELF32ARM_FOLD_CRC32 0x0e817a00
unsigned char linux_elf32arm_fold[1952] = {
unsigned char linux_elf32arm_fold[2076] = {
127, 69, 76, 70, 1, 1, 1, 97, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 0 */
2, 0, 40, 0, 1, 0, 0, 0,128,128, 0, 0, 52, 0, 0, 0, /* 0x 10 */
0, 0, 0, 0, 2, 0, 0, 0, 52, 0, 32, 0, 2, 0, 0, 0, /* 0x 20 */
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, /* 0x 30 */
0,128, 0, 0,160, 7, 0, 0,160, 7, 0, 0, 5, 0, 0, 0, /* 0x 40 */
0,128, 0, 0, 1, 0, 0, 0,160, 7, 0, 0,160,135, 0, 0, /* 0x 50 */
160,135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, /* 0x 60 */
0,128, 0, 0, 28, 8, 0, 0, 28, 8, 0, 0, 5, 0, 0, 0, /* 0x 40 */
0,128, 0, 0, 1, 0, 0, 0, 28, 8, 0, 0, 28,136, 0, 0, /* 0x 50 */
28,136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, /* 0x 60 */
0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 70 */
4, 48,157,229, 4,208,141,226, 3, 49,141,224, 8, 48,131,226, /* 0x 80 */
4, 0,147,228, 0, 0, 80,227,252,255,255, 26,192, 1, 45,233, /* 0x 90 */
10,220, 77,226, 9, 64,160,225, 4,144,154,229, 13,128,160,225, /* 0x a0 */
0,112,154,229, 32, 96,143,226, 12,144,137,226, 0,176,160,227, /* 0x b0 */
248, 15, 45,233, 15, 0,189,232, 94, 1, 0,235, 20,208,141,226, /* 0x c0 */
10,220,141,226, 0, 32,160,225, 3,128,189,232,255, 48, 3,226, /* 0x d0 */
80, 0, 83,227, 14,240,160, 17, 33, 17,176,225, 0, 0, 80, 19, /* 0x e0 */
14,240,160, 1, 1, 16, 81,226, 1, 49,144,231, 15, 52, 3,226, /* 0x f0 */
11, 4, 83,227, 4, 0, 0, 26,255, 52, 3,226, 1, 48, 67,224, /* 0x 100 */
255, 52,195,227, 3, 48,131,225, 1, 49,128,231,244,255,255, 26, /* 0x 110 */
14,240,160,225, 1, 0,144,239, 3, 0,144,239, 14,240,160,225, /* 0x 120 */
5, 0,144,239, 14,240,160,225, 6, 0,144,239, 14,240,160,225, /* 0x 130 */
45, 0,144,239, 14,240,160,225, 91, 0,144,239, 14,240,160,225, /* 0x 140 */
125, 0,144,239, 14,240,160,225, 4, 80, 45,229, 8, 80,157,229, /* 0x 150 */
4, 64, 45,229, 8, 64,157,229, 37, 86,160,225,192, 0,144,239, /* 0x 160 */
4, 64,157,228, 4, 80,157,228, 14,240,160,225, 4,224, 45,229, /* 0x 170 */
0, 48,144,229, 2, 0, 83,225, 2,192,160,225, 4,224,144,229, /* 0x 180 */
127, 0,160, 51,226,255,255, 59, 1, 32, 66,226, 1, 0,114,227, /* 0x 190 */
4, 0, 0, 10, 1, 48,222,228, 1, 32, 66,226, 1, 48,193,228, /* 0x 1a0 */
1, 0,114,227,249,255,255,234, 4, 32,144,229, 0, 48,144,229, /* 0x 1b0 */
12, 32,130,224, 3, 48,108,224, 0, 48,128,229, 4, 32,128,229, /* 0x 1c0 */
4,240,157,228,240, 64, 45,233, 1, 64,160,225, 0, 16,145,229, /* 0x 1d0 */
20,208, 77,226, 0, 0, 81,227, 0, 80,160,225, 2,112,160,225, /* 0x 1e0 */
3, 96,160,225, 70, 0, 0, 10, 8, 16,141,226, 12, 32,160,227, /* 0x 1f0 */
5, 0,160,225,220,255,255,235, 8, 16,157,229, 0, 0, 81,227, /* 0x 200 */
12, 32,157,229, 6, 0, 0, 26,252, 48,159,229, 3, 0, 82,225, /* 0x 210 */
5, 0, 0, 26, 0, 48,149,229, 0, 0, 83,227, 56, 0, 0, 10, /* 0x 220 */
1, 0, 0,234, 0, 0, 82,227, 1, 0, 0, 26,127, 0,160,227, /* 0x 230 */
183,255,255,235, 1, 0, 82,225,251,255,255,138, 0, 48,148,229, /* 0x 240 */
3, 0, 81,225,248,255,255,138, 1, 0, 82,225, 4, 48,148,229, /* 0x 250 */
33, 0, 0, 42, 16,192,221,229, 4, 0,149,229, 2, 16,160,225, /* 0x 260 */
0,192,141,229, 3, 32,160,225, 4, 48,141,226, 15,224,160,225, /* 0x 270 */
7,240,160,225, 0, 0, 80,227,235,255,255, 26, 10, 0,157,233, /* 0x 280 */
3, 0, 81,225,232,255,255, 26, 17, 32,221,229, 0, 0, 82,227, /* 0x 290 */
0, 0, 86, 19, 9, 0, 0, 10, 2, 12, 81,227, 2, 0, 0,138, /* 0x 2a0 */
0, 48,148,229, 1, 0, 83,225, 4, 0, 0, 26, 2, 48,160,225, /* 0x 2b0 */
4, 0,148,229, 18, 32,221,229, 15,224,160,225, 6,240,160,225, /* 0x 2c0 */
4, 48,149,229, 12, 16,157,229, 0, 32,149,229, 1, 48,131,224, /* 0x 2d0 */
2, 32, 97,224, 12, 0,133,232, 2, 0, 0,234, 3, 16,160,225, /* 0x 2e0 */
5, 0,160,225,160,255,255,235, 8, 16,157,229, 12, 0,148,232, /* 0x 2f0 */
2, 32, 97,224, 1, 48,131,224, 0, 0, 82,227, 12, 0,132,232, /* 0x 300 */
183,255,255,234, 20,208,141,226,240,128,189,232, 85, 80, 88, 33, /* 0x 310 */
0, 0, 80,227, 14,240,160, 1, 1, 0, 16,227, 14,240,160, 17, /* 0x 320 */
0, 48,144,229, 1, 0, 83,225, 6, 0, 0, 10, 1, 0, 83,227, /* 0x 330 */
0, 48,160, 19, 1, 48,160, 3, 0, 0, 81,227, 0, 48,160, 3, /* 0x 340 */
0, 0, 83,227, 1, 0, 0, 10, 6, 0,128,232, 14,240,160,225, /* 0x 350 */
8, 0,128,226,241,255,255,234,240, 79, 45,233, 40,208, 77,226, /* 0x 360 */
1,160,160,225, 28,192,145,229, 2,176,160,225,176, 17,209,225, /* 0x 370 */
80, 32,157,229,188,226,218,225, 2, 0, 81,227, 12,112,138,224, /* 0x 380 */
24, 0,141,229, 20, 48,141,229, 16, 32,141,229, 50,128,160, 3, /* 0x 390 */
34,128,160, 19, 7, 16,160,225, 1,224, 94,226, 0, 96,224,227, /* 0x 3a0 */
0, 80,160,227, 12, 0, 0, 74, 0, 48,145,229, 1, 0, 83,227, /* 0x 3b0 */
6, 0, 0, 26, 8, 32,145,229, 20, 48,145,229, 2, 48,131,224, /* 0x 3c0 */
3, 0, 85,225, 3, 80,160, 49, 2, 0, 86,225, 2, 96,160, 33, /* 0x 3d0 */
1,224, 94,226, 32, 16,129,226,241,255,255,234,255,110,198,227, /* 0x 3e0 */
15, 96,198,227, 5, 48,102,224,255, 62,131,226, 15, 48,131,226, /* 0x 3f0 */
255, 94,195,227, 0, 64,160,227, 15, 80,197,227, 8, 48,160,225, /* 0x 400 */
0,192,224,227, 6, 0,160,225, 5, 16,160,225, 4, 32,160,225, /* 0x 410 */
0,192,141,229, 4, 64,141,229, 74,255,255,235,188, 50,218,225, /* 0x 420 */
3, 0, 84,225, 5, 48,128,224, 12, 64,141,229, 36, 48,141,229, /* 0x 430 */
0,144,102,224,106, 0, 0,170, 0, 48,151,229, 6, 0, 83,227, /* 0x 440 */
5, 0, 0, 26, 8, 32,151,229, 20, 0,157,229, 9, 32,130,224, /* 0x 450 */
3, 16,160,227,173,255,255,235, 90, 0, 0,234, 1, 0, 83,227, /* 0x 460 */
88, 0, 0, 26, 24, 48,151,229, 8, 16,151,229, 7, 48, 3,226, /* 0x 470 */
180, 33,159,229, 9, 16,129,224, 3, 49,160,225, 16, 0,151,229, /* 0x 480 */
50, 35,160,225, 1, 90,160,225, 20, 48,151,229, 0, 0, 91,227, /* 0x 490 */
4,192,151,229, 37, 90,160,225, 3, 48,129,224, 1, 64,101,224, /* 0x 4a0 */
24,224,157, 5, 7,128, 2,226, 5, 96,128,224, 2, 32,160, 19, /* 0x 4b0 */
0, 32,160, 3, 8, 48,141,229, 0,224,224, 19, 28, 0,141,229, /* 0x 4c0 */
32, 16,141,229, 18, 48,160, 3, 50, 48,160, 19, 12,192,101,224, /* 0x 4d0 */
8, 32,130,225, 4, 0,160,225, 6, 16,160,225, 0,224,141,229, /* 0x 4e0 */
4,192,141,229, 23,255,255,235, 0, 0, 84,225, 35, 0, 0, 26, /* 0x 4f0 */
0, 0, 91,227, 6, 0, 0, 10, 16, 32,157,229, 40, 49,176,225, /* 0x 500 */
2, 48,160, 17, 28, 16,141,226, 11, 0,160,225, 24, 32,157,229, /* 0x 510 */
43,255,255,235, 0, 48,102,226, 3, 90,160,225, 2, 0, 24,227, /* 0x 520 */
37, 90,160,225, 7, 0, 0, 10, 0, 0, 85,227, 6, 16,132,224, /* 0x 530 */
5, 32,160,225, 3, 0, 0, 10, 0, 48,160,227, 1, 32, 82,226, /* 0x 540 */
1, 48,193,228,251,255,255, 26, 0, 0, 91,227, 13, 0, 0, 10, /* 0x 550 */
4, 48,151,229, 0, 0, 83,227,208, 48,159, 5, 8, 48,132, 5, /* 0x 560 */
204, 48,159, 5, 4, 0,160,225, 12, 48,132, 5, 6, 16,160,225, /* 0x 570 */
8, 32,160,225,241,254,255,235, 0, 0, 80,227, 1, 0, 0, 10, /* 0x 580 */
127, 0,160,227,226,254,255,235, 5, 48,134,224, 3, 64,132,224, /* 0x 590 */
8, 48,157,229, 3, 0, 84,225, 10, 0, 0, 42, 0,192,224,227, /* 0x 5a0 */
3, 16,100,224, 0,192,141,229, 8, 32,160,225, 1,192,140,226, /* 0x 5b0 */
4, 0,160,225, 50, 48,160,227, 4,192,141,229,225,254,255,235, /* 0x 5c0 */
0, 0, 84,225,237,255,255, 26, 12, 32,157,229,188, 50,218,225, /* 0x 5d0 */
1, 32,130,226, 3, 0, 82,225, 32,112,135,226, 12, 32,141,229, /* 0x 5e0 */
147,255,255,234, 0, 0, 91,227, 4, 0, 0, 26, 24, 0,157,229, /* 0x 5f0 */
204,254,255,235, 0, 0, 80,227, 4, 0, 0, 10,223,255,255,234, /* 0x 600 */
176, 49,218,225, 3, 0, 83,227, 36, 0,157, 21,199,254,255, 27, /* 0x 610 */
76, 48,157,229, 0, 0, 83,227, 0,144,131, 21, 24, 0,154,229, /* 0x 620 */
9, 0,128,224, 40,208,141,226,240,143,189,232, 64, 98, 81,115, /* 0x 630 */
91, 0,144,239, 2,240,160,225,240, 71, 45,233, 12,208, 77,226, /* 0x 640 */
44,192,141,226, 52,112,141,226, 0, 80,160,225, 1, 96,160,225, /* 0x 650 */
3,160,160,225, 12, 16,160,225, 0, 48,160,227, 7, 0,160,225, /* 0x 660 */
4,144,156,229, 2,128,160,225, 52, 64,157,229,212,254,255,235, /* 0x 670 */
56, 48,157,229, 5, 0,160,225, 3, 48,100,224, 5, 16,160,227, /* 0x 680 */
188, 34,217,225, 56, 48,141,229, 52, 96,141,229, 31,255,255,235, /* 0x 690 */
52, 96,137,226, 5, 0,160,225, 4, 16,160,227,186, 34,217,225, /* 0x 6a0 */
26,255,255,235, 8, 48,150,229, 60, 32,157,229, 3, 32,130,224, /* 0x 6b0 */
52, 32,130,226, 5, 0,160,225, 3, 16,160,227, 19,255,255,235, /* 0x 6c0 */
8,192,141,226, 7, 32,160,225, 9, 16,160,225, 5, 48,160,225, /* 0x 6d0 */
8, 0,160,225, 0,192,141,229, 4,160,141,229, 29,255,255,235, /* 0x 6e0 */
0, 64,160,225, 9, 16,160,227, 4, 32,160,225, 5, 0,160,225, /* 0x 6f0 */
6,255,255,235,188, 18,217,225, 0, 32,160,227, 1, 0, 82,225, /* 0x 700 */
31, 0, 0,170, 0, 48,150,229, 3, 0, 83,227, 1, 32,130,226, /* 0x 710 */
24, 0, 0, 26, 8, 48,150,229, 8, 0,157,229, 0, 16,160,227, /* 0x 720 */
0, 0,131,224, 1, 32,160,225,124,254,255,235, 0, 64, 80,226, /* 0x 730 */
4, 0, 0,186, 9, 16,160,225, 2, 44,160,227,117,254,255,235, /* 0x 740 */
2, 12, 80,227, 1, 0, 0, 10,127, 0,160,227,112,254,255,235, /* 0x 750 */
0,192,160,227, 4, 0,160,225, 12, 32,160,225, 9, 16,160,225, /* 0x 760 */
12, 48,160,225, 0,192,141,229, 4,192,141,229,249,254,255,235, /* 0x 770 */
0, 64,160,225, 2, 0, 0,234, 1, 0, 82,225, 32, 96,134,226, /* 0x 780 */
222,255,255,234, 4, 0,160,225, 12,208,141,226,240,135,189,232 /* 0x 790 */
12, 48,157,229, 3, 49,141,224, 20, 48,131,226, 4, 0,147,228, /* 0x 80 */
0, 0, 80,227,252,255,255, 26, 3, 32,160,225, 8, 0,146,228, /* 0x 90 */
0, 0, 80,227,252,255,255, 26, 8, 32,141,229, 10,220, 77,226, /* 0x a0 */
9, 64,160,225, 4,144,154,229, 13,128,160,225, 0,112,154,229, /* 0x b0 */
36, 96,143,226, 12,144,137,226, 0,176,160,227,248, 15, 45,233, /* 0x c0 */
15, 0,189,232,122, 1, 0,235, 0,224,160,225, 20,208,141,226, /* 0x d0 */
10,220,141,226, 7, 0,189,232, 4,240, 18,229,255, 48, 3,226, /* 0x e0 */
80, 0, 83,227, 14,240,160, 17, 33, 17,176,225, 0, 0, 80, 19, /* 0x f0 */
14,240,160, 1, 1, 16, 81,226, 1, 49,144,231, 15, 52, 3,226, /* 0x 100 */
11, 4, 83,227, 4, 0, 0, 26,255, 52, 3,226, 1, 48, 67,224, /* 0x 110 */
255, 52,195,227, 3, 48,131,225, 1, 49,128,231,244,255,255, 26, /* 0x 120 */
14,240,160,225, 1, 0,144,239, 3, 0,144,239, 14,240,160,225, /* 0x 130 */
5, 0,144,239, 14,240,160,225, 6, 0,144,239, 14,240,160,225, /* 0x 140 */
45, 0,144,239, 14,240,160,225, 91, 0,144,239, 14,240,160,225, /* 0x 150 */
125, 0,144,239, 14,240,160,225, 4, 80, 45,229, 8, 80,157,229, /* 0x 160 */
4, 64, 45,229, 8, 64,157,229, 37, 86,160,225,192, 0,144,239, /* 0x 170 */
4, 64,157,228, 4, 80,157,228, 14,240,160,225, 4,224, 45,229, /* 0x 180 */
0, 48,144,229, 2, 0, 83,225, 2,192,160,225, 4,224,144,229, /* 0x 190 */
127, 0,160, 51,226,255,255, 59, 1, 32, 66,226, 1, 0,114,227, /* 0x 1a0 */
4, 0, 0, 10, 1, 48,222,228, 1, 32, 66,226, 1, 48,193,228, /* 0x 1b0 */
1, 0,114,227,249,255,255,234, 4, 32,144,229, 0, 48,144,229, /* 0x 1c0 */
12, 32,130,224, 3, 48,108,224, 0, 48,128,229, 4, 32,128,229, /* 0x 1d0 */
4,240,157,228,240, 64, 45,233, 1, 64,160,225, 0, 16,145,229, /* 0x 1e0 */
20,208, 77,226, 0, 0, 81,227, 0, 80,160,225, 2,112,160,225, /* 0x 1f0 */
3, 96,160,225, 70, 0, 0, 10, 8, 16,141,226, 12, 32,160,227, /* 0x 200 */
5, 0,160,225,220,255,255,235, 8, 16,157,229, 0, 0, 81,227, /* 0x 210 */
12, 32,157,229, 6, 0, 0, 26,252, 48,159,229, 3, 0, 82,225, /* 0x 220 */
5, 0, 0, 26, 0, 48,149,229, 0, 0, 83,227, 56, 0, 0, 10, /* 0x 230 */
1, 0, 0,234, 0, 0, 82,227, 1, 0, 0, 26,127, 0,160,227, /* 0x 240 */
183,255,255,235, 1, 0, 82,225,251,255,255,138, 0, 48,148,229, /* 0x 250 */
3, 0, 81,225,248,255,255,138, 1, 0, 82,225, 4, 48,148,229, /* 0x 260 */
33, 0, 0, 42, 16,192,221,229, 4, 0,149,229, 2, 16,160,225, /* 0x 270 */
0,192,141,229, 3, 32,160,225, 4, 48,141,226, 15,224,160,225, /* 0x 280 */
7,240,160,225, 0, 0, 80,227,235,255,255, 26, 10, 0,157,233, /* 0x 290 */
3, 0, 81,225,232,255,255, 26, 17, 32,221,229, 0, 0, 82,227, /* 0x 2a0 */
0, 0, 86, 19, 9, 0, 0, 10, 2, 12, 81,227, 2, 0, 0,138, /* 0x 2b0 */
0, 48,148,229, 1, 0, 83,225, 4, 0, 0, 26, 2, 48,160,225, /* 0x 2c0 */
4, 0,148,229, 18, 32,221,229, 15,224,160,225, 6,240,160,225, /* 0x 2d0 */
4, 48,149,229, 12, 16,157,229, 0, 32,149,229, 1, 48,131,224, /* 0x 2e0 */
2, 32, 97,224, 12, 0,133,232, 2, 0, 0,234, 3, 16,160,225, /* 0x 2f0 */
5, 0,160,225,160,255,255,235, 8, 16,157,229, 12, 0,148,232, /* 0x 300 */
2, 32, 97,224, 1, 48,131,224, 0, 0, 82,227, 12, 0,132,232, /* 0x 310 */
183,255,255,234, 20,208,141,226,240,128,189,232, 85, 80, 88, 33, /* 0x 320 */
0, 0, 80,227, 14,240,160, 1, 1, 0, 16,227, 14,240,160, 17, /* 0x 330 */
0, 48,144,229, 1, 0, 83,225, 6, 0, 0, 10, 1, 0, 83,227, /* 0x 340 */
0, 48,160, 19, 1, 48,160, 3, 0, 0, 81,227, 0, 48,160, 3, /* 0x 350 */
0, 0, 83,227, 1, 0, 0, 10, 6, 0,128,232, 14,240,160,225, /* 0x 360 */
8, 0,128,226,241,255,255,234,240, 79, 45,233, 40,208, 77,226, /* 0x 370 */
1,144,160,225, 28,192,145,229, 2,176,160,225,176, 17,209,225, /* 0x 380 */
80, 32,157,229,188,226,217,225, 2, 0, 81,227, 12,112,137,224, /* 0x 390 */
24, 0,141,229, 20, 48,141,229, 16, 32,141,229, 50,128,160, 3, /* 0x 3a0 */
34,128,160, 19, 7, 16,160,225, 1,224, 94,226, 0, 96,224,227, /* 0x 3b0 */
0, 80,160,227, 12, 0, 0, 74, 0, 48,145,229, 1, 0, 83,227, /* 0x 3c0 */
6, 0, 0, 26, 8, 32,145,229, 20, 48,145,229, 2, 48,131,224, /* 0x 3d0 */
3, 0, 85,225, 3, 80,160, 49, 2, 0, 86,225, 2, 96,160, 33, /* 0x 3e0 */
1,224, 94,226, 32, 16,129,226,241,255,255,234,255,110,198,227, /* 0x 3f0 */
15, 96,198,227, 5, 48,102,224,255, 62,131,226, 15, 48,131,226, /* 0x 400 */
255, 94,195,227, 0, 64,160,227, 15, 80,197,227, 8, 48,160,225, /* 0x 410 */
6, 0,160,225, 0,192,224,227, 5, 16,160,225, 4, 32,160,225, /* 0x 420 */
0,192,141,229, 4, 64,141,229, 74,255,255,235,188, 50,217,225, /* 0x 430 */
3, 0, 84,225, 5, 48,128,224, 12, 64,141,229, 36, 48,141,229, /* 0x 440 */
0, 96,102,224,133, 0, 0,170, 0, 48,151,229, 6, 0, 83,227, /* 0x 450 */
5, 0, 0, 26, 8, 32,151,229, 20, 0,157,229, 6, 32,130,224, /* 0x 460 */
3, 16,160,227,173,255,255,235,117, 0, 0,234, 1, 0, 83,227, /* 0x 470 */
115, 0, 0, 26, 24, 48,151,229, 8, 16,151,229, 7, 48, 3,226, /* 0x 480 */
32, 34,159,229, 6, 16,129,224, 3, 49,160,225, 16, 0,151,229, /* 0x 490 */
50, 35,160,225, 1, 74,160,225, 20, 48,151,229, 0, 0, 91,227, /* 0x 4a0 */
4,192,151,229, 36, 74,160,225, 3, 48,129,224, 1, 80,100,224, /* 0x 4b0 */
24,224,157, 5, 7,128, 2,226, 4,160,128,224, 2, 32,160, 19, /* 0x 4c0 */
0, 32,160, 3, 8, 48,141,229, 0,224,224, 19, 28, 0,141,229, /* 0x 4d0 */
32, 16,141,229, 18, 48,160, 3, 50, 48,160, 19, 12,192,100,224, /* 0x 4e0 */
8, 32,130,225, 5, 0,160,225, 10, 16,160,225, 0,224,141,229, /* 0x 4f0 */
4,192,141,229, 23,255,255,235, 0, 0, 85,225, 62, 0, 0, 26, /* 0x 500 */
0, 0, 91,227, 6, 0, 0, 10, 16, 32,157,229, 40, 49,176,225, /* 0x 510 */
2, 48,160, 17, 28, 16,141,226, 11, 0,160,225, 24, 32,157,229, /* 0x 520 */
43,255,255,235, 0, 48,106,226, 3, 74,160,225, 2, 0, 24,227, /* 0x 530 */
36, 74,160,225, 7, 0, 0, 10, 0, 0, 84,227, 10, 16,133,224, /* 0x 540 */
4, 32,160,225, 3, 0, 0, 10, 0, 48,160,227, 1, 32, 82,226, /* 0x 550 */
1, 48,193,228,251,255,255, 26, 0, 0, 91,227, 40, 0, 0, 10, /* 0x 560 */
0, 48,151,229, 1, 0, 83,227, 29, 0, 0, 26, 24, 48,151,229, /* 0x 570 */
1, 0, 19,227, 26, 0, 0, 10, 16, 32,135,226, 12, 0,146,232, /* 0x 580 */
8, 16,151,229, 2, 0, 83,225, 1, 48,131,224, 6, 32,131,224, /* 0x 590 */
4, 0, 0, 26, 0, 48, 98,226, 3, 58,160,225, 35, 58,160,225, /* 0x 5a0 */
7, 0, 83,227, 6, 0, 0,138, 4, 32,151,229,134, 48,134,224, /* 0x 5b0 */
3, 49,134,224, 3, 49,129,224, 0, 0, 82,227, 8, 32,131,226, /* 0x 5c0 */
3, 0, 0, 26,224, 48,159,229, 0, 48,130,229,220, 48,159,229, /* 0x 5d0 */
4, 48,130,229, 0, 0, 82,227, 20, 0,157, 21, 0, 16,160, 19, /* 0x 5e0 */
78,255,255, 27, 5, 0,160,225, 10, 16,160,225, 8, 32,160,225, /* 0x 5f0 */
214,254,255,235, 0, 0, 80,227, 1, 0, 0, 10,127, 0,160,227, /* 0x 600 */
199,254,255,235, 4, 48,138,224, 3, 80,133,224, 8, 48,157,229, /* 0x 610 */
3, 0, 85,225, 10, 0, 0, 42, 0,192,224,227, 3, 16,101,224, /* 0x 620 */
0,192,141,229, 8, 32,160,225, 1,192,140,226, 5, 0,160,225, /* 0x 630 */
50, 48,160,227, 4,192,141,229,198,254,255,235, 0, 0, 85,225, /* 0x 640 */
237,255,255, 26, 12, 32,157,229,188, 50,217,225, 1, 32,130,226, /* 0x 650 */
3, 0, 82,225, 32,112,135,226, 12, 32,141,229,120,255,255,234, /* 0x 660 */
0, 0, 91,227, 4, 0, 0, 26, 24, 0,157,229,177,254,255,235, /* 0x 670 */
0, 0, 80,227, 4, 0, 0, 10,223,255,255,234,176, 49,217,225, /* 0x 680 */
3, 0, 83,227, 36, 0,157, 21,172,254,255, 27, 76, 48,157,229, /* 0x 690 */
0, 0, 83,227, 0, 96,131, 21, 24, 0,153,229, 6, 0,128,224, /* 0x 6a0 */
40,208,141,226,240,143,189,232, 64, 98, 81,115, 91, 0,144,239, /* 0x 6b0 */
14,240,160,225,240, 71, 45,233, 12,208, 77,226, 44,192,141,226, /* 0x 6c0 */
52,112,141,226, 0, 80,160,225, 1, 96,160,225, 3,160,160,225, /* 0x 6d0 */
12, 16,160,225, 0, 48,160,227, 7, 0,160,225, 4,144,156,229, /* 0x 6e0 */
2,128,160,225, 52, 64,157,229,185,254,255,235, 56, 48,157,229, /* 0x 6f0 */
5, 0,160,225, 3, 48,100,224, 5, 16,160,227,188, 34,217,225, /* 0x 700 */
56, 48,141,229, 52, 96,141,229, 4,255,255,235, 52, 96,137,226, /* 0x 710 */
5, 0,160,225, 4, 16,160,227,186, 34,217,225,255,254,255,235, /* 0x 720 */
8, 48,150,229, 60, 32,157,229, 3, 32,130,224, 52, 32,130,226, /* 0x 730 */
5, 0,160,225, 3, 16,160,227,248,254,255,235, 8,192,141,226, /* 0x 740 */
7, 32,160,225, 9, 16,160,225, 5, 48,160,225, 8, 0,160,225, /* 0x 750 */
0,192,141,229, 4,160,141,229, 2,255,255,235, 0, 64,160,225, /* 0x 760 */
9, 16,160,227, 4, 32,160,225, 5, 0,160,225,235,254,255,235, /* 0x 770 */
188, 18,217,225, 0, 32,160,227, 1, 0, 82,225, 31, 0, 0,170, /* 0x 780 */
0, 48,150,229, 3, 0, 83,227, 1, 32,130,226, 24, 0, 0, 26, /* 0x 790 */
8, 48,150,229, 8, 0,157,229, 0, 16,160,227, 0, 0,131,224, /* 0x 7a0 */
1, 32,160,225, 97,254,255,235, 0, 64, 80,226, 4, 0, 0,186, /* 0x 7b0 */
9, 16,160,225, 2, 44,160,227, 90,254,255,235, 2, 12, 80,227, /* 0x 7c0 */
1, 0, 0, 10,127, 0,160,227, 85,254,255,235, 0,192,160,227, /* 0x 7d0 */
4, 0,160,225, 12, 32,160,225, 9, 16,160,225, 12, 48,160,225, /* 0x 7e0 */
0,192,141,229, 4,192,141,229,222,254,255,235, 0, 64,160,225, /* 0x 7f0 */
2, 0, 0,234, 1, 0, 82,225, 32, 96,134,226,222,255,255,234, /* 0x 800 */
4, 0,160,225, 12,208,141,226,240,135,189,232 /* 0x 810 */
};
+34 -6
View File
@@ -176,7 +176,7 @@ ERR_LAB
// Create (or find) an escape hatch to use when munmapping ourselves the stub.
// Called by do_xmap to create it; remembered in AT_NULL.d_val
static void *
make_hatch(Elf32_Phdr const *const phdr, unsigned const reloc)
make_hatch_x86(Elf32_Phdr const *const phdr, unsigned const reloc)
{
unsigned *hatch = 0;
if (phdr->p_type==PT_LOAD && phdr->p_flags & PF_X) {
@@ -205,6 +205,35 @@ make_hatch(Elf32_Phdr const *const phdr, unsigned const reloc)
}
return hatch;
}
#elif defined(__arm__) /*}{*/
static void *
make_hatch_arm(Elf32_Phdr const *const phdr, unsigned const reloc)
{
unsigned *hatch = 0;
if (phdr->p_type==PT_LOAD && phdr->p_flags & PF_X) {
// The format of the 'if' is
// if ( ( (hatch = loc1), test_loc1 )
// || ( (hatch = loc2), test_loc2 ) ) {
// action
// }
// which uses the comma to save bytes when test_locj involves locj
// and the action is the same when either test succeeds.
// Try page fragmentation just beyond .text .
if ( ( (hatch = (void *)(phdr->p_memsz + phdr->p_vaddr + reloc)),
( phdr->p_memsz==phdr->p_filesz // don't pollute potential .bss
&& 8<=(~PAGE_MASK & -(int)hatch) ) ) // space left on page
// Try Elf32_Ehdr.e_ident[8..15] . warning: 'const' cast away
|| ( (hatch = (void *)(&((Elf32_Ehdr *)phdr->p_vaddr + reloc)->e_ident[8])),
(phdr->p_offset==0) ) )
{
hatch[0]= 0xef90005b; // syscall __NR_unmap
hatch[1]= 0xe1a0f00e; // mov pc,lr
}
}
return hatch;
}
#endif /*}*/
static void
@@ -330,16 +359,15 @@ do_xmap(int const fdi, Elf32_Ehdr const *const ehdr, struct Extent *const xi,
}
if (xi) {
#if defined(__i386__) /*{*/
void *const hatch = make_hatch(phdr, reloc);
void *const hatch = make_hatch_x86(phdr, reloc);
if (0!=hatch) {
/* always update AT_NULL, especially for compressed PT_INTERP */
auxv_up((Elf32_auxv_t *)(~1 & (int)av), AT_NULL, (unsigned)hatch);
}
#elif defined(__arm__) /*}{*/
if (0==phdr->p_offset) {
Elf32_Ehdr *const ehdr = (Elf32_Ehdr *)(void *)addr;
*(int *)(void *)&ehdr->e_ident[ 8] = 0xef90005b; // syscall __NR_unmap
*(int *)(void *)&ehdr->e_ident[12] = 0xe1a0f002; // mov pc,r2
void *const hatch = make_hatch_arm(phdr, reloc);
if (0!=hatch) {
auxv_up((Elf32_auxv_t *)(void *)av, AT_NULL, (unsigned)hatch);
}
#endif /*}*/
if (0!=mprotect(addr, mlen, prot)) {
+4 -8
View File
@@ -64,6 +64,7 @@ _start: .globl _start
*/
adr r12,start_params
ldmia r12!,{r0,r1, r8,r10} @ ADRM,LENM, ADRC,CNTC
stmdb sp!,{r0,r1,r2} @ ADRU,LENU,space for sz_unc
mov r2,#PROT_READ | PROT_WRITE | PROT_EXEC
mov r3,#MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS
mvn r4,#0 @ -1; cater to *BSD for fd when MAP_ANON
@@ -77,11 +78,10 @@ copy:
mov lr,r9 @ dst for unfolded code
sub r11,r9,r8 @ relocation amount
ldmia r12!,{r6,r7,r8, r9,r10} @ ADRU,LENU,JMPU, LENX,ADRX
ldmia r12!,{r9,r10} @ LENX,ADRX
sub sp,sp,#4 @ space for sz_unc
/*ldrb r4,b_method+cpr0*/
mov r3,sp @ &sz_unc
ldrb r4,b_method+cpr0
add r3,sp,#2*4 @ &sz_unc
mov r2,lr @ dst
ldr r1,sz_cpr +cpr0
adr r0,sz_b_info +cpr0
@@ -95,10 +95,6 @@ start_params:
.ascii "ADRC" @ src for copy
.ascii "CNTC" @ cnt for copy: number of 32-byte blocks
.ascii "ADRU" @ addr for unmap; same as ADRM
.ascii "LENU" @ len for unmap; same as LENM
.ascii "JMPU" @ trampoline for unmap
.ascii "LENX" @ total size of compressed data
.ascii "ADRX" @ &b_info of 1st compressed block (after moving)
f_decompress:
+39 -39
View File
@@ -1,4 +1,4 @@
/* l_lx_elf32arm.h -- created from l_lx_elf32arm.bin, 544 (0x220) bytes
/* l_lx_elf32arm.h -- created from l_lx_elf32arm.bin, 536 (0x218) bytes
This file is part of the UPX executable compressor.
@@ -27,43 +27,43 @@
*/
#define LINUX_ELF32ARM_LOADER_SIZE 544
#define LINUX_ELF32ARM_LOADER_ADLER32 0xfef0e8e2
#define LINUX_ELF32ARM_LOADER_CRC32 0xa0cc8839
#define LINUX_ELF32ARM_LOADER_SIZE 536
#define LINUX_ELF32ARM_LOADER_ADLER32 0xbfbae653
#define LINUX_ELF32ARM_LOADER_CRC32 0x2728e7c0
unsigned char linux_elf32arm_loader[544] = {
84,192,143,226, 3, 5,188,232, 7, 32,160,227, 50, 48,160,227, /* 0x 0 */
0, 64,224,227,192, 0,144,239, 1, 10,112,227, 92, 0, 0, 42, /* 0x 10 */
0,144,160,225,255, 0,184,232, 1,160, 90,226,255, 0,169,232, /* 0x 20 */
251,255,255, 26, 9,224,160,225, 8,176, 73,224,192, 7,188,232, /* 0x 30 */
4,208, 77,226, 13, 48,160,225, 14, 32,160,225,208, 17,159,229, /* 0x 40 */
117, 15,143,226, 11, 80,140,224, 11,240,140,224, 65, 68, 82, 77, /* 0x 50 */
76, 69, 78, 77, 65, 68, 82, 67, 67, 78, 84, 67, 65, 68, 82, 85, /* 0x 60 */
76, 69, 78, 85, 74, 77, 80, 85, 76, 69, 78, 88, 65, 68, 82, 88, /* 0x 70 */
252, 64, 45,233, 0,112,129,224, 0, 80,224,227, 2, 65,160,227, /* 0x 80 */
10, 0, 0,234, 24, 0,189,232, 7, 0, 64,224, 3, 32, 66,224, /* 0x 90 */
0, 32,132,229,240,128,189,232, 1, 64,208,228, 4, 64,164,224, /* 0x a0 */
4, 76,176,225, 14,240,160,225, 1, 48,208,228, 1, 48,194,228, /* 0x b0 */
4, 64,148,224,247,255,255, 11,250,255,255, 42, 1, 16,160,227, /* 0x c0 */
3, 0, 0,234, 1, 16, 65,226, 4, 64,148,224,241,255,255, 11, /* 0x d0 */
1, 16,161,224, 4, 64,148,224,238,255,255, 11, 1, 16,161,224, /* 0x e0 */
4, 64,148,224,235,255,255, 11,245,255,255, 58, 3, 48, 81,226, /* 0x f0 */
0, 16,160,227, 6, 0, 0, 58, 1, 80,208,228, 3, 84,133,225, /* 0x 100 */
5, 80,240,225,222,255,255, 10,197, 80,176,225, 15, 0, 0, 42, /* 0x 110 */
2, 0, 0,234, 4, 64,148,224,222,255,255, 11, 11, 0, 0, 42, /* 0x 120 */
1, 16,160,227, 4, 64,148,224,218,255,255, 11, 7, 0, 0, 42, /* 0x 130 */
4, 64,148,224,215,255,255, 11, 1, 16,161,224, 4, 64,148,224, /* 0x 140 */
212,255,255, 11,249,255,255, 58, 4, 16,129,226, 3, 0, 0,234, /* 0x 150 */
4, 64,148,224,207,255,255, 11, 1, 16,161,224, 2, 16,129,226, /* 0x 160 */
5, 12,117,227, 0, 0, 0, 42, 1, 16,129,226, 0, 48,210,229, /* 0x 170 */
5, 48,210,231, 1, 48,194,228, 1, 16, 81,226,251,255,255, 26, /* 0x 180 */
202,255,255,234, 30, 32,160,227, 96, 16,143,226, 2, 0,160,227, /* 0x 190 */
4, 0,144,239,127, 0,160,227, 1, 0,144,239,252,255,255,234, /* 0x 1a0 */
10, 36, 73,100, 58, 32, 85, 80, 88, 32, 40, 67, 41, 32, 49, 57, /* 0x 1b0 */
57, 54, 45, 50, 48, 48, 54, 32,116,104,101, 32, 85, 80, 88, 32, /* 0x 1c0 */
84,101, 97,109, 46, 32, 65,108,108, 32, 82,105,103,104,116,115, /* 0x 1d0 */
32, 82,101,115,101,114,118,101,100, 46, 32,104,116,116,112, 58, /* 0x 1e0 */
47, 47,117,112,120, 46,115,102, 46,110,101,116, 32, 36, 10, 0, /* 0x 1f0 */
80, 82, 79, 84, 95, 69, 88, 69, 67,124, 80, 82, 79, 84, 95, 87, /* 0x 200 */
82, 73, 84, 69, 32,102, 97,105,108,101,100, 46, 10, 0, 0, 0 /* 0x 210 */
unsigned char linux_elf32arm_loader[536] = {
88,192,143,226, 3, 5,188,232, 7, 0, 45,233, 7, 32,160,227, /* 0x 0 */
50, 48,160,227, 0, 64,224,227,192, 0,144,239, 1, 10,112,227, /* 0x 10 */
89, 0, 0, 42, 0,144,160,225,255, 0,184,232, 1,160, 90,226, /* 0x 20 */
255, 0,169,232,251,255,255, 26, 9,224,160,225, 8,176, 73,224, /* 0x 30 */
0, 6,188,232,212, 65,223,229, 8, 48,141,226, 14, 32,160,225, /* 0x 40 */
196, 17,159,229,114, 15,143,226, 11, 80,140,224, 11,240,140,224, /* 0x 50 */
65, 68, 82, 77, 76, 69, 78, 77, 65, 68, 82, 67, 67, 78, 84, 67, /* 0x 60 */
76, 69, 78, 88, 65, 68, 82, 88,252, 64, 45,233, 0,112,129,224, /* 0x 70 */
0, 80,224,227, 2, 65,160,227, 10, 0, 0,234, 24, 0,189,232, /* 0x 80 */
7, 0, 64,224, 3, 32, 66,224, 0, 32,132,229,240,128,189,232, /* 0x 90 */
1, 64,208,228, 4, 64,164,224, 4, 76,176,225, 14,240,160,225, /* 0x a0 */
1, 48,208,228, 1, 48,194,228, 4, 64,148,224,247,255,255, 11, /* 0x b0 */
250,255,255, 42, 1, 16,160,227, 3, 0, 0,234, 1, 16, 65,226, /* 0x c0 */
4, 64,148,224,241,255,255, 11, 1, 16,161,224, 4, 64,148,224, /* 0x d0 */
238,255,255, 11, 1, 16,161,224, 4, 64,148,224,235,255,255, 11, /* 0x e0 */
245,255,255, 58, 3, 48, 81,226, 0, 16,160,227, 6, 0, 0, 58, /* 0x f0 */
1, 80,208,228, 3, 84,133,225, 5, 80,240,225,222,255,255, 10, /* 0x 100 */
197, 80,176,225, 15, 0, 0, 42, 2, 0, 0,234, 4, 64,148,224, /* 0x 110 */
222,255,255, 11, 11, 0, 0, 42, 1, 16,160,227, 4, 64,148,224, /* 0x 120 */
218,255,255, 11, 7, 0, 0, 42, 4, 64,148,224,215,255,255, 11, /* 0x 130 */
1, 16,161,224, 4, 64,148,224,212,255,255, 11,249,255,255, 58, /* 0x 140 */
4, 16,129,226, 3, 0, 0,234, 4, 64,148,224,207,255,255, 11, /* 0x 150 */
1, 16,161,224, 2, 16,129,226, 5, 12,117,227, 0, 0, 0, 42, /* 0x 160 */
1, 16,129,226, 0, 48,210,229, 5, 48,210,231, 1, 48,194,228, /* 0x 170 */
1, 16, 81,226,251,255,255, 26,202,255,255,234, 30, 32,160,227, /* 0x 180 */
96, 16,143,226, 2, 0,160,227, 4, 0,144,239,127, 0,160,227, /* 0x 190 */
1, 0,144,239,252,255,255,234, 10, 36, 73,100, 58, 32, 85, 80, /* 0x 1a0 */
88, 32, 40, 67, 41, 32, 49, 57, 57, 54, 45, 50, 48, 48, 54, 32, /* 0x 1b0 */
116,104,101, 32, 85, 80, 88, 32, 84,101, 97,109, 46, 32, 65,108, /* 0x 1c0 */
108, 32, 82,105,103,104,116,115, 32, 82,101,115,101,114,118,101, /* 0x 1d0 */
100, 46, 32,104,116,116,112, 58, 47, 47,117,112,120, 46,115,102, /* 0x 1e0 */
46,110,101,116, 32, 36, 10, 0, 80, 82, 79, 84, 95, 69, 88, 69, /* 0x 1f0 */
67,124, 80, 82, 79, 84, 95, 87, 82, 73, 84, 69, 32,102, 97,105, /* 0x 200 */
108,101,100, 46, 10, 0, 0, 0 /* 0x 210 */
};