1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

arm.shlib-init: escape hatch is 8 bytes; speedup movsl

This commit is contained in:
John Reiser 2009-10-25 20:40:26 -07:00
parent 6ab04d7bbc
commit 8a5b8c87fb
5 changed files with 2047 additions and 2000 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -85,7 +85,7 @@ __ARM_NR_cacheflush = 2 + __ARM_NR_BASE
// .long offset({p_info; b_info; compressed data})
_start: .globl _start
nop //; bkpt // for debugging
stmdb sp!,{arg1,arg2,arg3, eax,ecx,r6,r7, fp,lr,pc}
mov fp,sp
o_uinit= (3+4+2)*4 // pc
@ -146,9 +146,15 @@ L71:
.macro lsl dst,src,cnt
mov \dst,\src,lsl \cnt
.endm
.macro lsls dst,src,cnt
movs \dst,\src,lsl \cnt
.endm
.macro lsr dst,src,cnt
mov \dst,\src,lsr \cnt
.endm
.macro lsrs dst,src,cnt
movs \dst,\src,lsr \cnt
.endm
#define lodsl ldr eax,[esi],#4
#define lodslu bl get4u
@ -291,26 +297,31 @@ supervise:
bl L620
//hatch:
do_sys7t __NR_munmap
#if defined(ARMEL_EABI4) //{
swi 0 // last part of do_sys7t __NR_munmap
#elif defined(ARM_OLDABI) //}{
do_sys __NR_munmap
#else //}{
error ARMEL_EABI4, ARM_OLDABI
#endif //}
ldmia sp!,{arg1,arg2,arg3, eax,ecx,r6,r7, fp,lr,pc}
L620: // Implant escape hatch at end of .text
ldr eax,[fp,#o_hatch]
ldmia lr,{arg1,arg2,arg3}
stmia eax,{arg1,arg2,arg3}
ldmia lr,{arg1,arg2}
stmia eax,{arg1,arg2}
//p_unflt
ldmia sp!,{arg1,arg2,arg3,arg4, eax}
ldmia sp!,{arg1,arg2,arg3,arg4, eax, r12} // r12= w_fragment [toss]
tst arg4,arg4; beq 0f // 0==ftid ==> no filter
blx eax // unfilter
0:
add sp,sp,#4 // toss w_fragment
//p_mprot
ldr arg1,[sp,#0*4] // lo(dst)
ldr arg2,[sp,#1*4] // len
mov arg3,#0
add arg2,arg2,arg1 // hi(dst)
add arg2,arg2,#3*4 // len(hatch)
add arg2,arg2,#2*4 // len(hatch)
do_sys7t2 __ARM_NR_cacheflush
ldmia sp!,{arg1,arg2}
@ -318,17 +329,36 @@ L620: // Implant escape hatch at end of .text
do_sys7t __NR_mprotect
//p_unmap
ldmia sp!,{arg1,arg2, r3} // r3= &hatch
bx r3
#if defined(ARMEL_EABI4) //{
// first part of do_sys7t __NR_munmap
.if __NR_munmap <= 0xff
mov r7,#__NR_munmap
.else
mov r7,#__NR_munmap>>16
lsl r7,r7,#16
add r7,r7,#__NR_munmap - ((__NR_munmap>>16)<<16)
.endif
#endif //}
ldmia sp!,{arg1,arg2, pc} // goto hatch
movsl_subr:
ldr ecx,[esi,#-4] // 'bl <over>' instruction word
bic ecx,ecx,#0xff<<24 // displacment field
add ecx,ecx,#1 // displ omits one word
//b movsl
movsl: // FIXME: bug when 0==ecx
ldr tmp,[esi],#4; subs ecx,ecx,#1
str tmp,[edi],#4; bne movsl
// FALL THROUGH to the part of 'movsl' that trims to a multiple of 8 words.
// 7/8 of the time this is faster; 1/8 of the time it's slower.
9:
ldr tmp,[esi],#4; sub ecx,ecx,#1
str tmp,[edi],#4
movsl: // edi= 4-byte aligned dst; esi= 4-byte aligned src; ecx= word count
tst ecx,#7; bne 9b // work ecx down to multiple of 8
lsrs ecx,ecx,#3; beq 9f
stmdb sp!, {r2, r4,r6, r7,r8,r9} // tmp===r3, ecx===r5
7:
ldmia esi!,{r2,r3,r4,r6, r7,r8,r9,r12}; subs ecx,ecx,#1
stmia edi!,{r2,r3,r4,r6, r7,r8,r9,r12}; bne 7b
ldmia sp!, {r2, r4,r6, r7,r8,r9}
9:
ret
L220:

View File

@ -2,18 +2,18 @@ file format elf32-littlearm
Sections:
Idx Name Size VMA LMA File off Algn Flags
0 ELFMAINX 0000000c 00000000 00000000 00000034 2**0 CONTENTS, RELOC, READONLY
1 NRV_HEAD 00000000 00000000 00000000 00000040 2**0 CONTENTS, READONLY
2 NRV_TAIL 00000000 00000000 00000000 00000040 2**0 CONTENTS, READONLY
3 NRV2E 0000012c 00000000 00000000 00000040 2**0 CONTENTS, RELOC, READONLY
4 NRV2D 00000118 00000000 00000000 0000016c 2**0 CONTENTS, RELOC, READONLY
5 NRV2B 000000dc 00000000 00000000 00000284 2**0 CONTENTS, RELOC, READONLY
6 LZMA_ELF00 000000a8 00000000 00000000 00000360 2**0 CONTENTS, RELOC, READONLY
7 LZMA_DEC20 00000938 00000000 00000000 00000408 2**0 CONTENTS, RELOC, READONLY
8 LZMA_DEC10 00000478 00000000 00000000 00000d40 2**0 CONTENTS, RELOC, READONLY
9 LZMA_DEC30 00000000 00000000 00000000 000011b8 2**0 CONTENTS, READONLY
10 ELFMAINY 00000036 00000000 00000000 000011b8 2**0 CONTENTS, READONLY
11 ELFMAINZ 000002c0 00000000 00000000 000011ee 2**0 CONTENTS, RELOC, READONLY
0 ELFMAINX 00000010 00000000 00000000 00000034 2**0 CONTENTS, RELOC, READONLY
1 NRV_HEAD 00000000 00000000 00000000 00000044 2**0 CONTENTS, READONLY
2 NRV_TAIL 00000000 00000000 00000000 00000044 2**0 CONTENTS, READONLY
3 NRV2E 0000012c 00000000 00000000 00000044 2**0 CONTENTS, RELOC, READONLY
4 NRV2D 00000118 00000000 00000000 00000170 2**0 CONTENTS, RELOC, READONLY
5 NRV2B 000000dc 00000000 00000000 00000288 2**0 CONTENTS, RELOC, READONLY
6 LZMA_ELF00 000000a8 00000000 00000000 00000364 2**0 CONTENTS, RELOC, READONLY
7 LZMA_DEC20 00000938 00000000 00000000 0000040c 2**0 CONTENTS, RELOC, READONLY
8 LZMA_DEC10 00000478 00000000 00000000 00000d44 2**0 CONTENTS, RELOC, READONLY
9 LZMA_DEC30 00000000 00000000 00000000 000011bc 2**0 CONTENTS, READONLY
10 ELFMAINY 00000036 00000000 00000000 000011bc 2**0 CONTENTS, READONLY
11 ELFMAINZ 000002dc 00000000 00000000 000011f2 2**0 CONTENTS, RELOC, READONLY
SYMBOL TABLE:
00000000 l d NRV2E 00000000 NRV2E
00000000 l d NRV2D 00000000 NRV2D
@ -36,7 +36,7 @@ SYMBOL TABLE:
RELOCATION RECORDS FOR [ELFMAINX]:
OFFSET TYPE VALUE
00000008 R_ARM_PC24 ELFMAINZ
0000000c R_ARM_PC24 ELFMAINZ
RELOCATION RECORDS FOR [NRV2E]:
OFFSET TYPE VALUE
@ -258,11 +258,13 @@ OFFSET TYPE VALUE
0000015c R_ARM_PC24 ELFMAINZ
0000016c R_ARM_PC24 ELFMAINZ
0000018c R_ARM_PC24 ELFMAINZ
000001dc R_ARM_PC24 ELFMAINZ
000001ec R_ARM_PC24 ELFMAINZ
00000210 R_ARM_PC24 ELFMAINZ
00000224 R_ARM_PC24 ELFMAINZ
0000024c R_ARM_PC24 ELFMAINZ
0000025c R_ARM_PC24 ELFMAINZ
000001d8 R_ARM_PC24 ELFMAINZ
000001e0 R_ARM_PC24 ELFMAINZ
000001f4 R_ARM_PC24 ELFMAINZ
00000208 R_ARM_PC24 ELFMAINZ
0000022c R_ARM_PC24 ELFMAINZ
00000240 R_ARM_PC24 ELFMAINZ
00000268 R_ARM_PC24 ELFMAINZ
00000274 R_ARM_PC24 ELFMAINZ
00000278 R_ARM_PC24 ELFMAINZ
00000284 R_ARM_PC24 ELFMAINZ
00000290 R_ARM_PC24 ELFMAINZ

View File

@ -2,18 +2,18 @@ file format elf32-littlearm
Sections:
Idx Name Size VMA LMA File off Algn Flags
0 ELFMAINX 0000000c 00000000 00000000 00000034 2**0 CONTENTS, RELOC, READONLY
1 NRV_HEAD 00000000 00000000 00000000 00000040 2**0 CONTENTS, READONLY
2 NRV_TAIL 00000000 00000000 00000000 00000040 2**0 CONTENTS, READONLY
3 NRV2E 0000013c 00000000 00000000 00000040 2**0 CONTENTS, RELOC, READONLY
4 NRV2D 00000128 00000000 00000000 0000017c 2**0 CONTENTS, RELOC, READONLY
5 NRV2B 000000ec 00000000 00000000 000002a4 2**0 CONTENTS, RELOC, READONLY
6 LZMA_ELF00 000000b8 00000000 00000000 00000390 2**0 CONTENTS, RELOC, READONLY
7 LZMA_DEC20 00000938 00000000 00000000 00000448 2**0 CONTENTS, RELOC, READONLY
8 LZMA_DEC10 00000478 00000000 00000000 00000d80 2**0 CONTENTS, RELOC, READONLY
9 LZMA_DEC30 00000000 00000000 00000000 000011f8 2**0 CONTENTS, READONLY
10 ELFMAINY 0000003e 00000000 00000000 000011f8 2**0 CONTENTS, READONLY
11 ELFMAINZ 000002e0 00000000 00000000 00001236 2**0 CONTENTS, RELOC, READONLY
0 ELFMAINX 00000010 00000000 00000000 00000034 2**0 CONTENTS, RELOC, READONLY
1 NRV_HEAD 00000000 00000000 00000000 00000044 2**0 CONTENTS, READONLY
2 NRV_TAIL 00000000 00000000 00000000 00000044 2**0 CONTENTS, READONLY
3 NRV2E 0000013c 00000000 00000000 00000044 2**0 CONTENTS, RELOC, READONLY
4 NRV2D 00000128 00000000 00000000 00000180 2**0 CONTENTS, RELOC, READONLY
5 NRV2B 000000ec 00000000 00000000 000002a8 2**0 CONTENTS, RELOC, READONLY
6 LZMA_ELF00 000000b8 00000000 00000000 00000394 2**0 CONTENTS, RELOC, READONLY
7 LZMA_DEC20 00000938 00000000 00000000 0000044c 2**0 CONTENTS, RELOC, READONLY
8 LZMA_DEC10 00000478 00000000 00000000 00000d84 2**0 CONTENTS, RELOC, READONLY
9 LZMA_DEC30 00000000 00000000 00000000 000011fc 2**0 CONTENTS, READONLY
10 ELFMAINY 0000003e 00000000 00000000 000011fc 2**0 CONTENTS, READONLY
11 ELFMAINZ 000002fc 00000000 00000000 0000123a 2**0 CONTENTS, RELOC, READONLY
SYMBOL TABLE:
00000000 l d NRV2E 00000000 NRV2E
00000000 l d NRV2D 00000000 NRV2D
@ -36,7 +36,7 @@ SYMBOL TABLE:
RELOCATION RECORDS FOR [ELFMAINX]:
OFFSET TYPE VALUE
00000008 R_ARM_PC24 ELFMAINZ
0000000c R_ARM_PC24 ELFMAINZ
RELOCATION RECORDS FOR [NRV2E]:
OFFSET TYPE VALUE
@ -257,12 +257,14 @@ OFFSET TYPE VALUE
00000150 R_ARM_PC24 ELFMAINZ
00000160 R_ARM_PC24 ELFMAINZ
00000170 R_ARM_PC24 ELFMAINZ
00000194 R_ARM_PC24 ELFMAINZ
000001f0 R_ARM_PC24 ELFMAINZ
00000200 R_ARM_PC24 ELFMAINZ
00000228 R_ARM_PC24 ELFMAINZ
0000023c R_ARM_PC24 ELFMAINZ
00000264 R_ARM_PC24 ELFMAINZ
00000274 R_ARM_PC24 ELFMAINZ
00000190 R_ARM_PC24 ELFMAINZ
000001ec R_ARM_PC24 ELFMAINZ
000001f4 R_ARM_PC24 ELFMAINZ
00000208 R_ARM_PC24 ELFMAINZ
0000021c R_ARM_PC24 ELFMAINZ
00000244 R_ARM_PC24 ELFMAINZ
00000258 R_ARM_PC24 ELFMAINZ
00000280 R_ARM_PC24 ELFMAINZ
0000028c R_ARM_PC24 ELFMAINZ
00000290 R_ARM_PC24 ELFMAINZ
0000029c R_ARM_PC24 ELFMAINZ
000002a8 R_ARM_PC24 ELFMAINZ