mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
unfilter for arm-linux.kernel
This commit is contained in:
parent
cd70b48831
commit
bd5cef1411
|
@ -397,25 +397,17 @@ void PackVmlinuxARM::buildLoader(const Filter *ft)
|
||||||
{
|
{
|
||||||
// prepare loader
|
// prepare loader
|
||||||
initLoader(stub_arm_linux_kernel_vmlinux, sizeof(stub_arm_linux_kernel_vmlinux));
|
initLoader(stub_arm_linux_kernel_vmlinux, sizeof(stub_arm_linux_kernel_vmlinux));
|
||||||
addLoader("LINUX000",
|
addLoader("LINUX000", NULL);
|
||||||
(0x40==(0xf0 & ft->id)) ? "LXCKLLT1" : (ft->id ? "LXCALLT1" : ""),
|
|
||||||
"LXMOVEUP",
|
|
||||||
getDecompressorSections(),
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
if (ft->id) {
|
if (ft->id) {
|
||||||
assert(ft->calls > 0);
|
assert(ft->calls > 0);
|
||||||
if (0x40==(0xf0 & ft->id)) {
|
addLoader("LINUX010", NULL);
|
||||||
addLoader("LXCKLLT9", NULL);
|
}
|
||||||
}
|
addLoader("LINUX020", NULL);
|
||||||
else {
|
if (ft->id) {
|
||||||
addLoader("LXCALLT9", NULL);
|
|
||||||
}
|
|
||||||
addFilter32(ft->id);
|
addFilter32(ft->id);
|
||||||
}
|
}
|
||||||
addLoader("LINUX990",
|
addLoader("LINUX030", getDecompressorSections(),
|
||||||
ph.first_offset_found == 1 ? "LINUX991" : "",
|
"IDENTSTR,UPX1HEAD", NULL);
|
||||||
"LINUX992,IDENTSTR,UPX1HEAD", NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,10 +419,16 @@ static bool defineFilterSymbols(Linker *linker, const Filter *ft)
|
||||||
}
|
}
|
||||||
assert(ft->calls > 0);
|
assert(ft->calls > 0);
|
||||||
|
|
||||||
linker->defineSymbol("filter_cto", ft->cto);
|
if (0x50==(0xF0 & ft->id)) {
|
||||||
linker->defineSymbol("filter_length",
|
linker->defineSymbol("FID", ft->id);
|
||||||
(ft->id & 0xf) % 3 == 0 ? ft->calls :
|
linker->defineSymbol("CTO", ft->cto);
|
||||||
ft->lastcall - ft->calls * 4);
|
}
|
||||||
|
else {
|
||||||
|
linker->defineSymbol("filter_cto", ft->cto);
|
||||||
|
linker->defineSymbol("filter_length",
|
||||||
|
(ft->id & 0xf) % 3 == 0 ? ft->calls :
|
||||||
|
ft->lastcall - ft->calls * 4);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,13 @@ void Packer::addFilter32(int filter_id)
|
||||||
assert(isValidFilter(filter_id));
|
assert(isValidFilter(filter_id));
|
||||||
|
|
||||||
if (filter_id < 0x80) {
|
if (filter_id < 0x80) {
|
||||||
if ((filter_id & 0xf) % 3 == 0) {
|
if (0x50==(0xF0 & filter_id)) {
|
||||||
|
addLoader("CKLLTR00",
|
||||||
|
((0x50==filter_id) ? "CKLLTR50" :
|
||||||
|
(0x51==filter_id) ? "CKLLTR51" : ""),
|
||||||
|
"CKLLTR10", NULL);
|
||||||
|
}
|
||||||
|
else if ((filter_id & 0xf) % 3 == 0) {
|
||||||
if (filter_id < 0x40) {
|
if (filter_id < 0x40) {
|
||||||
addLoader("CALLTR00",
|
addLoader("CALLTR00",
|
||||||
(filter_id > 0x20) ? "CTCLEVE1" : "",
|
(filter_id > 0x20) ? "CTCLEVE1" : "",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -54,26 +54,84 @@ decompress_kernel: # (char *out, char *tmp, char *tmp_end, int arch_id)
|
||||||
|
|
||||||
// Value stored from r1 to memory will be overwritten by outsize.
|
// Value stored from r1 to memory will be overwritten by outsize.
|
||||||
stmdb r1!,{r0,r1,r2,r3,sp} // &indata, space, &outdata, arch_id, sp_in
|
stmdb r1!,{r0,r1,r2,r3,sp} // &indata, space, &outdata, arch_id, sp_in
|
||||||
ldr r3,2*4+.L10 // method
|
loadcon8 3,METHOD // mov r3,#METHOD
|
||||||
mov sp,r1 // switch stacks to tmp_end area (64KB)
|
mov sp,r1 // switch stacks to tmp_end area (64KB)
|
||||||
ldr r1,0*4+.L10 // insize
|
ldr r1,1f // insize
|
||||||
str r3,[sp,#-4]! // method
|
str r3,[sp,#-4]! // method
|
||||||
ldr r3,1*4+.L10 // outsize
|
ldr r3,2f // outsize
|
||||||
str r3,[sp,#2*4] // outsize
|
str r3,[sp,#2*4] // outsize
|
||||||
add r3,sp, #2*4 // &outsize
|
add r3,sp, #2*4 // &outsize
|
||||||
bl .L20 // (&indata, insize, &outdata, &outsize, method)
|
bl decompressor // (&indata, insize, &outdata, &outsize, method)
|
||||||
|
b 3f
|
||||||
|
1:
|
||||||
|
.long COMPRESSED_LENGTH
|
||||||
|
2:
|
||||||
|
.long UNCOMPRESSED_LENGTH
|
||||||
|
3:
|
||||||
spin:
|
spin:
|
||||||
cmp r0,#0 // check for success
|
cmp r0,#0 // check for success
|
||||||
bne spin
|
bne spin
|
||||||
|
|
||||||
|
section LINUX010
|
||||||
|
ldr r0,[sp,#3*4] // &outdata
|
||||||
|
ldr r1,[sp,#2*4] // outsize
|
||||||
|
loadcon8 2,CTO // mov r2,#CTO
|
||||||
|
loadcon8 3,FID // mov r3,#FID
|
||||||
|
bl unfilter // unfilter(&outdata, outsize, cto, fid)
|
||||||
|
|
||||||
|
section LINUX020
|
||||||
ldmia sp,{r0,r1,r2,r3,ip,sp,lr} // method, &indata, outsize, &outdata, arch_id, sp_in, retaddr
|
ldmia sp,{r0,r1,r2,r3,ip,sp,lr} // method, &indata, outsize, &outdata, arch_id, sp_in, retaddr
|
||||||
add r0,r2,r3 // rv= &outdata[outsize]
|
add r0,r2,r3 // rv= &outdata[outsize]
|
||||||
mov pc,lr // return
|
mov pc,lr // return
|
||||||
.L10:
|
|
||||||
.long COMPRESSED_LENGTH
|
// =============
|
||||||
.long UNCOMPRESSED_LENGTH
|
// ============= UNFILTER
|
||||||
.long METHOD
|
// =============
|
||||||
.L20:
|
section CKLLTR00
|
||||||
|
//f_unfilter: @ (char *ptr, uint len, uint cto, uint fid)
|
||||||
|
ptr .req r0
|
||||||
|
len .req r1
|
||||||
|
cto .req r2 @ unused
|
||||||
|
fid .req r3
|
||||||
|
|
||||||
|
t1 .req r2
|
||||||
|
t2 .req r3
|
||||||
|
unfilter:
|
||||||
|
and fid,fid,#0xff
|
||||||
|
section CKLLTR50
|
||||||
|
cmp fid,#0x50 @ last use of fid
|
||||||
|
section CKLLTR51
|
||||||
|
cmp fid,#0x51 @ last use of fid
|
||||||
|
|
||||||
|
section CKLLTR10
|
||||||
|
movne pc,lr @ no-op if not filter 0x50
|
||||||
|
|
||||||
|
movs len,len,lsr #2 @ word count
|
||||||
|
cmpne ptr,#0
|
||||||
|
moveq pc,lr @ no-op if either len or ptr is 0
|
||||||
|
|
||||||
|
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
|
||||||
|
orr t1,t1,t2 @ re-combine
|
||||||
|
str t1,[ptr,len,lsl #2]
|
||||||
|
tst_unf:
|
||||||
|
cmp len,#0
|
||||||
|
bne top_unf
|
||||||
|
mov pc,lr
|
||||||
|
|
||||||
|
.unreq ptr
|
||||||
|
.unreq len
|
||||||
|
.unreq cto
|
||||||
|
.unreq fid
|
||||||
|
|
||||||
|
section LINUX030
|
||||||
|
decompressor:
|
||||||
/*
|
/*
|
||||||
r0= inptr
|
r0= inptr
|
||||||
r1= insize
|
r1= insize
|
||||||
|
@ -82,17 +140,6 @@ spin:
|
||||||
sp/ method
|
sp/ method
|
||||||
*/
|
*/
|
||||||
|
|
||||||
section LXCALLT1
|
|
||||||
mvn ip,#1
|
|
||||||
bkpt
|
|
||||||
section LXCKLLT1
|
|
||||||
mvn ip,#2
|
|
||||||
bkpt
|
|
||||||
.long filter_cto,filter_length
|
|
||||||
section LXMOVEUP
|
|
||||||
mvn ip,#3
|
|
||||||
bkpt
|
|
||||||
|
|
||||||
// =============
|
// =============
|
||||||
// ============= DECOMPRESSION
|
// ============= DECOMPRESSION
|
||||||
// =============
|
// =============
|
||||||
|
@ -108,10 +155,6 @@ section NRV2E
|
||||||
|
|
||||||
#include "arch/arm/v5a/lzma_d.S"
|
#include "arch/arm/v5a/lzma_d.S"
|
||||||
|
|
||||||
// =============
|
|
||||||
// ============= UNFILTER
|
|
||||||
// =============
|
|
||||||
|
|
||||||
#if 0 /*{ remind me about parameters for unfilter? */
|
#if 0 /*{ remind me about parameters for unfilter? */
|
||||||
section LXCKLLT9
|
section LXCKLLT9
|
||||||
pop ecx // MATCH05 len
|
pop ecx // MATCH05 len
|
||||||
|
|
Loading…
Reference in New Issue
Block a user