mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
eabi-linux.shlib unfilter in thumb mode
This commit is contained in:
parent
eeae73296e
commit
ee1a8e6a32
|
@ -158,13 +158,11 @@ p_mprot=_ // 15
|
|||
lsr tmp,tmp,#2; push_ tmp // w_fragment
|
||||
o_wfrag=_ // 16
|
||||
|
||||
.balign 4
|
||||
call4 L610
|
||||
.arm
|
||||
f_unfilter: // (char *ptr, uint len, uint cto, uint fid)
|
||||
#define ptr r0
|
||||
#define len r1
|
||||
#define cto r2
|
||||
#define cto r2 /* FIXME: unused */
|
||||
#define fid r3
|
||||
|
||||
#define t1 r2
|
||||
|
@ -173,27 +171,26 @@ f_unfilter: // (char *ptr, uint len, uint cto, uint fid)
|
|||
#ifndef FILTER_ID /*{*/
|
||||
#define FILTER_ID 0x50 /* little-endian */
|
||||
#endif /*}*/
|
||||
and fid,fid,#0xff
|
||||
cmp fid,#FILTER_ID // last use of fid
|
||||
bxne lr // no-op if not filter 0x50
|
||||
|
||||
movs len,len,lsr #2 // word count
|
||||
cmpne ptr,#0
|
||||
bxeq lr // no-op if either len or ptr is 0
|
||||
|
||||
lsl fid,fid,#24; tst len,len; beq unf_done
|
||||
lsr fid,fid,#24; tst ptr,ptr; beq unf_done
|
||||
cmp fid,#FILTER_ID; bne unf_done // last use of fid
|
||||
b tst_unf
|
||||
top_unf:
|
||||
sub len,len,#1
|
||||
ldr t1,[ptr,len,lsl #2]
|
||||
and t2,t1,#0x0f<<24
|
||||
cmp t2, #0x0b<<24; bne tst_unf // not 'bl' subroutine call
|
||||
and t2,t1,#0xff<<24 // all the non-displacement bits
|
||||
sub t1,t1,len // convert to word-relative displacement
|
||||
bic t1,t1,#0xff<<24 // restrict to displacement field
|
||||
sub len,len,#4
|
||||
ldr t1,[ptr,len]
|
||||
lsl t2,t1,#4
|
||||
lsr t2,t2,#4+24 // bits 27..24
|
||||
cmp t2,#0x0b; bne tst_unf // not 'bl' subroutine call
|
||||
lsr len,len,#2; sub t2,t1,len // convert to word-relative displacement
|
||||
lsl len,len,#2
|
||||
lsr t1,t1,#24; lsl t2,t2,#8
|
||||
lsl t1,t1,#24; lsr t2,t2,#8
|
||||
orr t1,t1,t2 // re-combine
|
||||
str t1,[ptr,len,lsl #2]
|
||||
str t1,[ptr,len]
|
||||
tst_unf:
|
||||
cmp len,#0
|
||||
bne top_unf
|
||||
unf_done:
|
||||
ret
|
||||
|
||||
#undef ptr
|
||||
|
@ -204,10 +201,9 @@ tst_unf:
|
|||
#undef t1
|
||||
#undef t2
|
||||
|
||||
.thumb
|
||||
.thumb_func
|
||||
L610:
|
||||
mov tmp,lr; sub tmp,#1; push_ tmp // &f_unfilter (ARM mode)
|
||||
push_ lr // &f_unfilter (thumb mode)
|
||||
o_unflt=_ // 17
|
||||
ldrb tmp,[esi,#b_method-4+1]; push_ tmp // ftid
|
||||
ldrb tmp,[esi,#b_method-4+2]; push_ tmp // cto8
|
||||
|
@ -330,13 +326,11 @@ _=-5+_ // 22
|
|||
pop_ tmp // toss arg5
|
||||
|
||||
//p_unflt // 21
|
||||
pop {arg1,arg2,arg3,arg4, eax}
|
||||
_=-5+_ // 16
|
||||
pop {arg1,arg2,arg3,arg4, eax, r5} // r5= w_fragment [discard]
|
||||
_=-6+_ // 15
|
||||
tst arg4,arg4; beq 0f // 0==ftid ==> no filter
|
||||
blx eax // unfilter
|
||||
blx eax // f_unfilter
|
||||
0:
|
||||
add sp,#4 // toss w_fragment
|
||||
_=-1+_ // 15
|
||||
ldr arg1,[sp,#0*4] // lo(dst)
|
||||
ldr arg2,[sp,#1*4] // len
|
||||
add arg2,arg1 // hi(dst)
|
||||
|
@ -365,6 +359,8 @@ _=-3+_ // 9
|
|||
.thumb_func
|
||||
movsl_subr:
|
||||
.real_start_ofmovsl_subr:
|
||||
lsr esi,esi,#2
|
||||
lsl esi,esi,#2 // word align [corrects for thumb-mode]
|
||||
push {lr}; mov tmp,esi; bl wlen_subr
|
||||
pop {tmp}; mov lr,tmp
|
||||
// FALL THROUGH to the part of 'movsl' that trims to a multiple of 8 words.
|
||||
|
@ -374,17 +370,17 @@ movsl_subr:
|
|||
str tmp,[edi,#0]; add edi,#4
|
||||
sub ecx,#1
|
||||
.thumb_func
|
||||
movsl:
|
||||
movsl: // In: edi= 4-byte aligned dst; esi= 4-byte aligned src; ecx= word count
|
||||
.real_start_ofmovsl:
|
||||
mov tmp,#7; tst ecx,tmp; bne 9b
|
||||
lsr ecx,#3; beq 9f
|
||||
.balign 4; bx pc; nop // enter ARM mode
|
||||
.arm
|
||||
stmdb sp!,{r2,r4,r6, r7,r8,r9} // tmp===r3, ecx===r5
|
||||
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}
|
||||
ldmia sp!,{r2, r4,r6, r7,r8,r9}
|
||||
9:
|
||||
ret
|
||||
|
||||
|
@ -452,11 +448,12 @@ o_super=_ // 28
|
|||
|
||||
ldr esi,[SP(o_uncpr)]
|
||||
str edi,[SP(o_uncpr)]
|
||||
bl movsl_subr // copy decompressor (FIXME: must be ARM mode)
|
||||
bl movsl_subr // copy decompressor
|
||||
|
||||
add tmp,edi,#1 // dst f_unfilter thumb mode
|
||||
ldr esi,[SP(o_unflt)]
|
||||
str edi,[SP(o_unflt)]
|
||||
bl movsl_subr // copy unfilter (FIXME: must be ARM mode)
|
||||
str tmp,[SP(o_unflt)]
|
||||
bl movsl_subr // copy f_unfilter
|
||||
|
||||
pop_ esi // &supervise
|
||||
add r7,edi,#1 // &copied (thumb mode)
|
||||
|
@ -476,6 +473,8 @@ get4u:
|
|||
ret
|
||||
|
||||
wlen_subr: // Out: ecx= nwords of inline subr at *tmp
|
||||
lsr tmp,tmp,#2
|
||||
lsl tmp,tmp,#2 // word align (correct for thumb mode)
|
||||
sub tmp,#4
|
||||
ldrh ecx,[tmp,#0]; lsl ecx,#32-11; lsr ecx,#32-11-11 // hi(disp)
|
||||
ldrh tmp,[tmp,#2]; lsl tmp,#32-11; lsr tmp,#32-11- 0 // lo(disp)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,20 +2,19 @@ file format elf32-littlearm
|
|||
|
||||
Sections:
|
||||
Idx Name Size VMA LMA File off Algn Flags
|
||||
0 ELFMAINX 000000bc 00000000 00000000 00000034 2**2 CONTENTS, RELOC, READONLY
|
||||
1 NRV_HEAD 00000000 00000000 00000000 000000f0 2**0 CONTENTS, READONLY
|
||||
2 NRV_TAIL 00000000 00000000 00000000 000000f0 2**0 CONTENTS, READONLY
|
||||
3 NRV2E 0000013c 00000000 00000000 000000f0 2**0 CONTENTS, RELOC, READONLY
|
||||
4 NRV2D 00000128 00000000 00000000 0000022c 2**0 CONTENTS, RELOC, READONLY
|
||||
5 NRV2B 000000ec 00000000 00000000 00000354 2**0 CONTENTS, RELOC, READONLY
|
||||
6 LZMA_ELF00 000000b8 00000000 00000000 00000440 2**0 CONTENTS, RELOC, READONLY
|
||||
7 LZMA_DEC20 00000938 00000000 00000000 000004f8 2**0 CONTENTS, RELOC, READONLY
|
||||
8 LZMA_DEC10 00000478 00000000 00000000 00000e30 2**0 CONTENTS, RELOC, READONLY
|
||||
9 LZMA_DEC30 00000000 00000000 00000000 000012a8 2**0 CONTENTS, READONLY
|
||||
10 ELFMAINY 0000003e 00000000 00000000 000012a8 2**0 CONTENTS, READONLY
|
||||
11 ELFMAINZ 00000160 00000000 00000000 000012e8 2**2 CONTENTS, RELOC, READONLY
|
||||
0 ELFMAINX 000000a0 00000000 00000000 00000034 2**2 CONTENTS, RELOC, READONLY
|
||||
1 NRV_HEAD 00000000 00000000 00000000 000000d4 2**0 CONTENTS, READONLY
|
||||
2 NRV_TAIL 00000000 00000000 00000000 000000d4 2**0 CONTENTS, READONLY
|
||||
3 NRV2E 0000013c 00000000 00000000 000000d4 2**0 CONTENTS, RELOC, READONLY
|
||||
4 NRV2D 00000128 00000000 00000000 00000210 2**0 CONTENTS, RELOC, READONLY
|
||||
5 NRV2B 000000ec 00000000 00000000 00000338 2**0 CONTENTS, RELOC, READONLY
|
||||
6 LZMA_ELF00 000000b8 00000000 00000000 00000424 2**0 CONTENTS, RELOC, READONLY
|
||||
7 LZMA_DEC20 00000938 00000000 00000000 000004dc 2**0 CONTENTS, RELOC, READONLY
|
||||
8 LZMA_DEC10 00000478 00000000 00000000 00000e14 2**0 CONTENTS, RELOC, READONLY
|
||||
9 LZMA_DEC30 00000000 00000000 00000000 0000128c 2**0 CONTENTS, READONLY
|
||||
10 ELFMAINY 0000003e 00000000 00000000 0000128c 2**0 CONTENTS, READONLY
|
||||
11 ELFMAINZ 0000016c 00000000 00000000 000012cc 2**2 CONTENTS, RELOC, READONLY
|
||||
SYMBOL TABLE:
|
||||
00000000 l d ELFMAINX 00000000 ELFMAINX
|
||||
00000000 l ELFMAINX 00000000 .real_start_ofELFMAINX
|
||||
00000000 l d NRV2E 00000000 NRV2E
|
||||
00000000 l d NRV2D 00000000 NRV2D
|
||||
|
@ -26,6 +25,7 @@ SYMBOL TABLE:
|
|||
00000000 l d LZMA_DEC30 00000000 LZMA_DEC30
|
||||
00000000 l d ELFMAINZ 00000000 ELFMAINZ
|
||||
00000000 l ELFMAINZ 00000000 .real_start_ofELFMAINZ
|
||||
00000000 l d ELFMAINX 00000000 ELFMAINX
|
||||
00000000 l d NRV_HEAD 00000000 NRV_HEAD
|
||||
00000000 l d NRV_TAIL 00000000 NRV_TAIL
|
||||
00000000 l d ELFMAINY 00000000 ELFMAINY
|
||||
|
@ -40,11 +40,9 @@ RELOCATION RECORDS FOR [ELFMAINX]:
|
|||
OFFSET TYPE VALUE
|
||||
00000030 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000048 R_ARM_THM_CALL .real_start_ofELFMAINX
|
||||
00000074 R_ARM_PC24 ELFMAINX
|
||||
00000090 R_ARM_PC24 ELFMAINX
|
||||
000000aa R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
000000b0 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
000000b8 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000090 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000096 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
0000009c R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
|
||||
RELOCATION RECORDS FOR [NRV2E]:
|
||||
OFFSET TYPE VALUE
|
||||
|
@ -257,12 +255,12 @@ OFFSET TYPE VALUE
|
|||
00000028 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000030 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000050 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
0000006a R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000080 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
000000b0 R_ARM_PC24 ELFMAINZ
|
||||
000000ce R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
000000f4 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
0000010c R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000116 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
0000011e R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000126 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000068 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000082 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
000000b4 R_ARM_PC24 ELFMAINZ
|
||||
000000d2 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
000000f8 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000110 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
0000011a R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
00000124 R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
0000012c R_ARM_THM_CALL .real_start_ofELFMAINZ
|
||||
|
|
Loading…
Reference in New Issue
Block a user