mirror of
https://github.com/upx/upx.git
synced 2025-03-03 05:16:15 +00:00
more arm-linux.kernel work
This commit is contained in:
parent
bccaafda6d
commit
c5cfb7eb40
@ -774,6 +774,10 @@ void PackVmlinuxARM::pack(OutputFile *fo)
|
||||
|
||||
const unsigned lsize = getLoaderSize();
|
||||
|
||||
linker->defineSymbol( "COMPRESSED_LENGTH", txt_c_len);
|
||||
linker->defineSymbol("UNCOMPRESSED_LENGTH", txt_u_len);
|
||||
linker->defineSymbol("METHOD", ph.method);
|
||||
|
||||
defineFilterSymbols(linker, &ft);
|
||||
if (0x40==(0xf0 & ft.id)) {
|
||||
linker->defineSymbol("filter_length", ph.u_len); // redefine
|
||||
@ -796,17 +800,14 @@ void PackVmlinuxARM::pack(OutputFile *fo)
|
||||
shdro[1].sh_size = sizeof(stub_arm_linux_kernel_vmlinux_head) + txt_c_len + lsize;
|
||||
shdro[1].sh_addralign = 1;
|
||||
|
||||
// This ought to be a linker section (to handle the relocation of 'bl'),
|
||||
// but buildLoader gets called from the middle of compressWithFilters
|
||||
// so there is a circularity problem.
|
||||
fo->write(&stub_arm_linux_kernel_vmlinux_head[0], sizeof(stub_arm_linux_kernel_vmlinux_head)-9*4);
|
||||
tmp_le32 = get_le32(&stub_arm_linux_kernel_vmlinux_head[sizeof(stub_arm_linux_kernel_vmlinux_head)-9*4]);
|
||||
tmp_le32 = (0xff000000 & tmp_le32) | (0x00ffffff & (7+ ((3+ txt_c_len)>>2)));
|
||||
// First word from vmlinux-head.S
|
||||
fo->write(&stub_arm_linux_kernel_vmlinux_head[0], 4);
|
||||
|
||||
// Second word
|
||||
tmp_le32 = (0xff000000 & get_le32(&stub_arm_linux_kernel_vmlinux_head[4]))
|
||||
| (0x00ffffff & (-1+ ((3+ txt_c_len)>>2)));
|
||||
fo->write(&tmp_le32, 4);
|
||||
fo->write(&stub_arm_linux_kernel_vmlinux_head[sizeof(stub_arm_linux_kernel_vmlinux_head)-8*4], 5*4);
|
||||
tmp_le32 = txt_c_len; fo->write(&tmp_le32, 4);
|
||||
tmp_le32 = txt_u_len; fo->write(&tmp_le32, 4);
|
||||
tmp_le32 = ph.method; fo->write(&tmp_le32, 4);
|
||||
|
||||
fo_off += sizeof(stub_arm_linux_kernel_vmlinux_head);
|
||||
|
||||
fo->write(obuf, ~3& (3+ txt_c_len)); fo_off += ~3& (3+ txt_c_len);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* arm-linux.kernel.vmlinux-head.h
|
||||
created from arm-linux.kernel.vmlinux-head.bin, 68 (0x44) bytes
|
||||
created from arm-linux.kernel.vmlinux-head.bin, 8 (0x8) bytes
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
@ -28,14 +28,10 @@
|
||||
*/
|
||||
|
||||
|
||||
#define STUB_ARM_LINUX_KERNEL_VMLINUX_HEAD_SIZE 68
|
||||
#define STUB_ARM_LINUX_KERNEL_VMLINUX_HEAD_ADLER32 0xd30518ac
|
||||
#define STUB_ARM_LINUX_KERNEL_VMLINUX_HEAD_CRC32 0xa10e8134
|
||||
#define STUB_ARM_LINUX_KERNEL_VMLINUX_HEAD_SIZE 8
|
||||
#define STUB_ARM_LINUX_KERNEL_VMLINUX_HEAD_ADLER32 0x17bb0637
|
||||
#define STUB_ARM_LINUX_KERNEL_VMLINUX_HEAD_CRC32 0xccc03eaa
|
||||
|
||||
unsigned char stub_arm_linux_kernel_vmlinux_head[68] = {
|
||||
9, 96, 34,233, 2,208,160,225, 0, 32,160,225, 36, 0,143,226, /* 0x 0 */
|
||||
10, 16,176,232, 4, 48, 45,229, 13, 48,160,225, 4,192, 45,229, /* 0x 10 */
|
||||
254,255,255,235, 0, 0, 80,227, 7, 0, 0, 26, 14,112,157,232, /* 0x 20 */
|
||||
3, 0,130,224, 14,240,160,225, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 30 */
|
||||
0, 0, 0, 0 /* 0x 40 */
|
||||
unsigned char stub_arm_linux_kernel_vmlinux_head[8] = {
|
||||
14,192,160,225,254,255,255,235 /* 0x 0 */
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,31 +25,8 @@
|
||||
; <jreiser@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
/* Calling sequence of equivalent code in arch/arm/boot/compressed/misc.c:
|
||||
decompress_kernel: # (char *out, char *tmp, char *end_tmp, int arch_id)
|
||||
*/
|
||||
stmdb r2!,{r0,r3,sp,lr} // &outdata, arch_id, sp_in, retaddr
|
||||
mov sp,r2 // switch stacks to end_tmp area (64KB)
|
||||
mov r2,r0 // &outdata
|
||||
adr r0,.L10
|
||||
ldmia r0!,{r1,r3,ip} // r0=&indata; r1=insize; r3=outsize; ip=method
|
||||
str r3,[sp,#-4]! // outsize
|
||||
mov r3,sp // &outsize
|
||||
str ip,[sp,#-4]! // method
|
||||
// PackVmlinuxARM::pack knows the layout of the following words.
|
||||
bl LINUX000 // (&indata, insize, &outdata, &outsize, method)
|
||||
spin:
|
||||
cmp r0,#0 // check for success
|
||||
bne spin
|
||||
|
||||
ldmia sp,{r1,r2,r3,ip,sp,lr} // method, outsize, &outdata, arch_id, sp_in, retaddr
|
||||
add r0,r2,r3 // rv= &outdata[outsize]
|
||||
mov pc,lr // return
|
||||
.L10:
|
||||
.long COMPRESSED_LENGTH
|
||||
.long UNCOMPRESSED_LENGTH
|
||||
.long METHOD
|
||||
|
||||
mov ip,lr // ip= retaddr
|
||||
bl LINUX000 // lr= PIC location of compressed data
|
||||
// Compressed data appears >here<, then decompressor.
|
||||
|
||||
// vi:ts=8:et:nowrap
|
||||
|
@ -43,6 +43,37 @@
|
||||
*/
|
||||
section LINUX000
|
||||
// bkpt // qemu DEBUG only
|
||||
/* Calling sequence of equivalent code in arch/arm/boot/compressed/misc.c:
|
||||
decompress_kernel: # (char *out, char *tmp, char *tmp_end, int arch_id)
|
||||
lr= &indata; ip= retaddr # from arm-linux.kernel.vmlinux-head.S
|
||||
*/
|
||||
mov r1,r2 // tmp_end
|
||||
mov r2,r0 // &outdata
|
||||
mov r0,lr // &indata
|
||||
str ip,[r1,#-4]! // push retaddr on new stack
|
||||
|
||||
// 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
|
||||
ldr r3,2*4+.L10 // method
|
||||
mov sp,r1 // switch stacks to tmp_end area (64KB)
|
||||
ldr r1,0*4+.L10 // insize
|
||||
str r3,[sp,#-4]! // method
|
||||
ldr r3,1*4+.L10 // outsize
|
||||
str r3,[sp,#2*4] // outsize
|
||||
add r3,sp, #2*4 // &outsize
|
||||
bl .L20 // (&indata, insize, &outdata, &outsize, method)
|
||||
spin:
|
||||
cmp r0,#0 // check for success
|
||||
bne spin
|
||||
|
||||
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]
|
||||
mov pc,lr // return
|
||||
.L10:
|
||||
.long COMPRESSED_LENGTH
|
||||
.long UNCOMPRESSED_LENGTH
|
||||
.long METHOD
|
||||
.L20:
|
||||
/*
|
||||
r0= inptr
|
||||
r1= insize
|
||||
@ -81,6 +112,32 @@ section NRV2E
|
||||
// ============= UNFILTER
|
||||
// =============
|
||||
|
||||
#if 0 /*{ remind me about parameters for unfilter? */
|
||||
section LXCKLLT9
|
||||
pop ecx // MATCH05 len
|
||||
pop edx // MATCH04 cto
|
||||
pop edi // MATCH03 src
|
||||
|
||||
ckt32 edi, dl // dl has cto8
|
||||
/*
|
||||
;edi: adjust for the difference between 0 origin of buffer at filter,
|
||||
;and actual origin of destination at unfilter.
|
||||
;Filter.addvalue is 0: destination origin is unknown at filter time.
|
||||
;The input data is still relocatable, and address is assigned later
|
||||
;[as of 2004-12-15 it is 'always' 0x100000].
|
||||
*/
|
||||
|
||||
section LXCALLT9
|
||||
pop ecx // MATCH05 len
|
||||
pop edi // MATCH03 src
|
||||
cjt32 0
|
||||
section LINUX990
|
||||
pop esi // MATCH02 restore
|
||||
pop edi // MATCH01 restore
|
||||
xor ebx, ebx // booting the 1st cpu
|
||||
lret // MATCH00 set cs
|
||||
#endif /*}*/
|
||||
|
||||
section LXCKLLT9
|
||||
mvn ip,#4
|
||||
bkpt
|
||||
|
Loading…
x
Reference in New Issue
Block a user