From c8dd2a3eb8463c67ec38c1c248cdc3adc674998e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Moln=C3=A1r?= Date: Mon, 27 Mar 2006 12:21:07 +0000 Subject: [PATCH] arm/pe: use -march=armv4t instead of v5 committer: ml1050 1143462067 +0000 --- src/stub/Makefile | 2 +- src/stub/l_armpe.h | 80 ++++++++++++++++++++++---------------------- src/stub/l_armpe_c.c | 12 +++++-- src/stub/l_armpe_s.S | 16 +++++++-- 4 files changed, 64 insertions(+), 46 deletions(-) diff --git a/src/stub/Makefile b/src/stub/Makefile index 0beb791b..f3eb1530 100644 --- a/src/stub/Makefile +++ b/src/stub/Makefile @@ -222,7 +222,7 @@ endif ### ARM-PE-WINCE ### -GCC_ARM := arm-9tdmi-linux-gnu-gcc -Os -march=armv5t +GCC_ARM := arm-9tdmi-linux-gnu-gcc -Os -march=armv4t LD_ARM := arm-9tdmi-linux-gnu-ld OBJCOPY_ARM := arm-9tdmi-linux-gnu-objcopy BIN2H_WINCE := perl -ne 'print "db\t", join(",", map { sprintf "%\#02x", $$_ } unpack("C*", $$_)), "\n"' diff --git a/src/stub/l_armpe.h b/src/stub/l_armpe.h index 1974dd56..92545aea 100644 --- a/src/stub/l_armpe.h +++ b/src/stub/l_armpe.h @@ -1,4 +1,4 @@ -/* l_armpe.h -- created from l_armpe.bin, 569 (0x239) bytes +/* l_armpe.h -- created from l_armpe.bin, 565 (0x235) bytes This file is part of the UPX executable compressor. @@ -27,45 +27,45 @@ */ -#define NRV_LOADER_SIZE 569 -#define NRV_LOADER_ADLER32 0xf95bc91d -#define NRV_LOADER_CRC32 0x9d6cf681 +#define NRV_LOADER_SIZE 565 +#define NRV_LOADER_ADLER32 0x52a7cd50 +#define NRV_LOADER_CRC32 0x6bf6849d -unsigned char nrv_loader[569] = { - 15, 64, 45,233, 48, 0,143,226, 14, 0,144,232, 2, 16,129,224, /* 0x 0 */ +unsigned char nrv_loader[565] = { + 15, 64, 45,233, 56, 0,143,226, 14, 0,144,232, 2, 16,129,224, /* 0x 0 */ 0, 32,147,229, 1, 58,131,226, 1, 0, 83,225,251,255,255,154, /* 0x 10 */ - 20, 0, 0,250, 15, 64,189,232, 44,240,159,229, 9, 75, 27,104, /* 0x 20 */ - 24, 71, 9, 75,251,231, 0, 0, 88,120,120, 88, 83, 82, 67, 48, /* 0x 30 */ - 83, 82, 67, 76, 68, 83, 84, 48, 68, 83, 84, 76, 66, 73, 77, 80, /* 0x 40 */ - 79, 78, 65, 77, 71, 69, 84, 80, 76, 79, 65, 68, 69, 78, 84, 82, /* 0x 50 */ - 2, 28,192,120,147,120, 0, 2,192, 24, 83,120, 0, 2,192, 24, /* 0x 60 */ - 19,120, 0, 2,192, 24,112, 71,240,181,163,176, 0, 35, 2,147, /* 0x 70 */ - 8,200, 2,200, 4,200, 4, 48, 16,200, 0,104, 0,144, 24, 28, /* 0x 80 */ - 2,171, 1,146, 0,240, 80,248, 37, 28, 40, 28,255,247,224,255, /* 0x 90 */ - 4, 30, 65,208, 0,155, 40, 29,228, 24,255,247,217,255, 1,154, /* 0x a0 */ -134, 24, 3,168, 2, 28, 35,120, 27, 6, 0, 43, 4,208, 27, 14, /* 0x b0 */ - 19,128, 1, 52, 2, 50,246,231, 0, 35, 19,128,255,247,177,255, /* 0x c0 */ - 8, 53, 7, 28, 43,120, 27, 6, 0, 43, 35,208, 27, 14, 1, 53, /* 0x d0 */ - 1, 43, 2,208,255, 43, 13,208, 24,224, 56, 28, 41, 28,255,247, /* 0x e0 */ -157,255, 52, 28, 32, 96, 4, 54, 43,120, 27, 6, 1, 53, 0, 43, /* 0x f0 */ -250,209,231,231,105,120, 43,120, 9, 2, 56, 28, 89, 24,255,247, /* 0x 100 */ -141,255, 52, 28, 2, 53, 4, 54, 32, 96,219,231, 0, 34, 1, 35, /* 0x 110 */ - 26, 96,215,231, 1, 53,184,231, 35,176,240,188, 1,188, 0, 71, /* 0x 120 */ - 1,192,143,226, 28,255, 47,225,252,181, 15, 24, 1, 36,101, 66, /* 0x 130 */ -228, 7, 5, 38, 54, 2, 15,224, 24,188,192, 27,210, 26, 34, 96, /* 0x 140 */ -240,188, 2,188, 8, 71, 4,120,100, 65, 1, 48, 36, 6,247, 70, /* 0x 150 */ - 3,120, 1, 48, 19,112, 1, 50, 36, 25,254, 70,243,208,247,210, /* 0x 160 */ - 1, 33, 4,224, 1, 57, 36, 25,254, 70,236,208, 73, 65, 36, 25, /* 0x 170 */ -254, 70,232,208, 73, 65, 36, 25,254, 70,228,208,242,211,203, 30, /* 0x 180 */ - 0, 33, 8,211, 27, 2, 5,120, 1, 48, 29, 67,237, 67,211,208, /* 0x 190 */ -109, 16, 19,210, 3,224, 36, 25,254, 70,212,208, 14,210, 1, 33, /* 0x 1a0 */ - 36, 25,254, 70,207,208, 9,210, 36, 25,254, 70,203,208, 73, 65, /* 0x 1b0 */ - 36, 25,254, 70,199,208,247,211, 4, 49, 4,224, 36, 25,254, 70, /* 0x 1c0 */ -193,208, 73, 65, 2, 49,238, 66, 0,210, 1, 49, 19,120, 83, 93, /* 0x 1d0 */ - 19,112, 1, 50, 1, 57,250,209,190,231, 0, 0, 85, 80, 88, 33, /* 0x 1e0 */ -161,216,208,213, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 1f0 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 65, 82, 77, 87, /* 0x 200 */ - 80, 69, 48, 48, 0, 0, 0, 0, 0, 85, 80, 88, 49, 72, 69, 65, /* 0x 210 */ - 68, 0,236, 1, 0, 0, 65, 82, 77, 87, 80, 69, 57, 57, 0, 12, /* 0x 220 */ - 2, 0, 0,255,255,255,255, 12, 2 /* 0x 230 */ + 4,224,143,226, 23,192,143,226, 28,255, 47,225, 15, 64,189,232, /* 0x 20 */ + 44,192,159,229, 28,255, 47,225, 8, 75, 27,104, 24, 71, 8, 75, /* 0x 30 */ +251,231, 27,224, 83, 82, 67, 48, 83, 82, 67, 76, 68, 83, 84, 48, /* 0x 40 */ + 68, 83, 84, 76, 66, 73, 77, 80, 79, 78, 65, 77, 71, 69, 84, 80, /* 0x 50 */ + 76, 79, 65, 68, 69, 78, 84, 82, 0,181, 3, 33, 67, 92, 18, 2, /* 0x 60 */ +210, 24, 1, 57,250,213, 16, 28, 2,188, 8, 71,240,181,163,176, /* 0x 70 */ + 0, 35, 2,147, 8,200, 2,200, 4,200, 4, 48, 16,200, 0,104, /* 0x 80 */ + 0,144, 24, 28, 2,171, 1,146, 0,240, 76,248, 37, 28, 40, 28, /* 0x 90 */ +255,247,226,255, 4, 30, 61,208, 0,155, 40, 29,228, 24,255,247, /* 0x a0 */ +219,255, 1,154,134, 24, 3,168, 2, 28, 35,120, 27, 6, 0, 43, /* 0x b0 */ + 4,208, 27, 14, 19,128, 1, 52, 2, 50,246,231, 0, 35, 19,128, /* 0x c0 */ +255,247,181,255, 8, 53, 7, 28, 43,120, 27, 6, 0, 43, 31,208, /* 0x d0 */ + 27, 14, 1, 53, 1, 43, 2,208,255, 43, 13,208,244,231, 56, 28, /* 0x e0 */ + 41, 28,255,247,161,255, 52, 28, 32, 96, 4, 54, 43,120, 27, 6, /* 0x f0 */ + 1, 53, 0, 43,250,209,231,231,105,120, 43,120, 9, 2, 56, 28, /* 0x 100 */ + 89, 24,255,247,145,255, 52, 28, 2, 53, 4, 54, 32, 96,219,231, /* 0x 110 */ + 1, 53,188,231, 35,176,240,188, 1,188, 0, 71, 1,192,143,226, /* 0x 120 */ + 28,255, 47,225,252,181, 15, 24, 1, 36,101, 66,228, 7, 5, 38, /* 0x 130 */ + 54, 2, 15,224, 24,188,192, 27,210, 26, 34, 96,240,188, 2,188, /* 0x 140 */ + 8, 71, 4,120,100, 65, 1, 48, 36, 6,247, 70, 3,120, 1, 48, /* 0x 150 */ + 19,112, 1, 50, 36, 25,254, 70,243,208,247,210, 1, 33, 4,224, /* 0x 160 */ + 1, 57, 36, 25,254, 70,236,208, 73, 65, 36, 25,254, 70,232,208, /* 0x 170 */ + 73, 65, 36, 25,254, 70,228,208,242,211,203, 30, 0, 33, 8,211, /* 0x 180 */ + 27, 2, 5,120, 1, 48, 29, 67,237, 67,211,208,109, 16, 19,210, /* 0x 190 */ + 3,224, 36, 25,254, 70,212,208, 14,210, 1, 33, 36, 25,254, 70, /* 0x 1a0 */ +207,208, 9,210, 36, 25,254, 70,203,208, 73, 65, 36, 25,254, 70, /* 0x 1b0 */ +199,208,247,211, 4, 49, 4,224, 36, 25,254, 70,193,208, 73, 65, /* 0x 1c0 */ + 2, 49,238, 66, 0,210, 1, 49, 19,120, 83, 93, 19,112, 1, 50, /* 0x 1d0 */ + 1, 57,250,209,190,231, 0, 0, 85, 80, 88, 33,161,216,208,213, /* 0x 1e0 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 1f0 */ + 0, 0, 0, 0, 0, 0, 0, 45, 65, 82, 77, 87, 80, 69, 48, 48, /* 0x 200 */ + 0, 0, 0, 0, 0, 85, 80, 88, 49, 72, 69, 65, 68, 0,232, 1, /* 0x 210 */ + 0, 0, 65, 82, 77, 87, 80, 69, 57, 57, 0, 8, 2, 0, 0,255, /* 0x 220 */ +255,255,255, 8, 2 /* 0x 230 */ }; diff --git a/src/stub/l_armpe_c.c b/src/stub/l_armpe_c.c index 96457f40..1ee22315 100644 --- a/src/stub/l_armpe_c.c +++ b/src/stub/l_armpe_c.c @@ -38,7 +38,14 @@ void *GetProcAddressA(const void *, const void *); static void *get_le32(const unsigned char *p) { - return (void *) (p[0] + p[1] * 0x100 + p[2] * 0x10000 + p[3] * 0x1000000); + //return (void *) (p[0] + p[1] * 0x100 + p[2] * 0x10000 + p[3] * 0x1000000); + + // the code below is 4 bytes shorter than the above when compiled + unsigned ret; + int ic; + for (ic = 3; ic >= 0; ic--) + ret = ret * 0x100 + p[ic]; + return (void *) ret; } static void handle_imports(const unsigned char *imp, unsigned name_offset, @@ -80,7 +87,7 @@ static void handle_imports(const unsigned char *imp, unsigned name_offset, *iat++ = (unsigned) GetProcAddressA(dll, (void *) ord); break; default: - *(int*) 1 = 0; + // *(int*) 1 = 0; break; } } @@ -99,7 +106,6 @@ void CHWrap(int); CHwrap(h); \ } while (0) - void upx_main(const unsigned *info) { int dlen = 0; diff --git a/src/stub/l_armpe_s.S b/src/stub/l_armpe_s.S index 50c90958..541b1fdc 100644 --- a/src/stub/l_armpe_s.S +++ b/src/stub/l_armpe_s.S @@ -49,9 +49,19 @@ L01: cmp r3, r1 bls L01 - blx upx_main @ call thumb +#ifdef __ARM_ARCH_4T__ + adr lr, armret + adr ip, call_upxmain + 1 + bx ip +armret: + ldmfd sp!, {r0 - r3, lr} + ldr ip, ENTR + bx ip +#else + blx upx_main @ call thumb armv5t style ldmfd sp!, {r0 - r3, lr} ldr pc, ENTR @ original entry +#endif @@@@@@@@@@@@@@@@ @@ -74,6 +84,9 @@ LoadLibraryW: ldr r3, LLIB b t_callr3 +call_upxmain: + b upx_main + @@@@@@@@@@@@@@@@ #if 0 @@ -137,7 +150,6 @@ filename: .code 32 .align 2 - .ascii "XxxX" SRC0: .ascii "SRC0" SRCL: .ascii "SRCL" DST0: .ascii "DST0"