From 1d462ee424b18cb704660ed4332c848eb1413800 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Thu, 14 Dec 2017 11:17:01 -0800 Subject: [PATCH] MIPS shlib --lzma stub coding error: wrong register https://github.com/upx/upx/issues/139 (part2) modified: stub/src/mipsel.r3000-linux.shlib-init.S --- src/stub/mips.r3000-linux.shlib-init.h | 30 +++++------ src/stub/mipsel.r3000-linux.shlib-init.h | 30 +++++------ src/stub/src/mipsel.r3000-linux.shlib-init.S | 52 ++++++++++---------- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/stub/mips.r3000-linux.shlib-init.h b/src/stub/mips.r3000-linux.shlib-init.h index f46d460c..1333e649 100644 --- a/src/stub/mips.r3000-linux.shlib-init.h +++ b/src/stub/mips.r3000-linux.shlib-init.h @@ -32,8 +32,8 @@ #define STUB_MIPS_R3000_LINUX_SHLIB_INIT_SIZE 9963 -#define STUB_MIPS_R3000_LINUX_SHLIB_INIT_ADLER32 0x8f666f05 -#define STUB_MIPS_R3000_LINUX_SHLIB_INIT_CRC32 0x301b3ae0 +#define STUB_MIPS_R3000_LINUX_SHLIB_INIT_ADLER32 0xcaf96c4d +#define STUB_MIPS_R3000_LINUX_SHLIB_INIT_CRC32 0xe1fd739d unsigned char stub_mips_r3000_linux_shlib_init[9963] = { /* 0x0000 */ 127, 69, 76, 70, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -105,15 +105,15 @@ unsigned char stub_mips_r3000_linux_shlib_init[9963] = { /* 0x0420 */ 0, 9, 76, 0, 1, 46, 72, 37, 36,132, 0, 4, 0, 9,119,194, /* 0x0430 */ 0, 9, 72, 64, 3,224, 0, 8, 37, 41, 0, 1, 17,169,255,238, /* 0x0440 */ 0, 9,119,194, 3,224, 0, 8, 0, 9, 72, 64,144,153, 0, 0, -/* 0x0450 */ 36, 7,250, 0,144,152, 0, 1, 51, 34, 0, 7, 0, 25,200,194, -/* 0x0460 */ 3, 39, 56, 4, 36,231,241, 96, 3,167,232, 33,175,167, 0, 40, +/* 0x0450 */ 36, 3,250, 0,144,152, 0, 1, 51, 34, 0, 7, 0, 25,200,194, +/* 0x0460 */ 3, 35, 24, 4, 36, 99,241, 96, 3,163,232, 33,175,163, 0, 40, /* 0x0470 */ 39,170, 0, 32,175,191, 0, 44,140,233, 0, 0,175,166, 0, 36, /* 0x0480 */ 0,192, 64, 33, 39,167, 0, 28, 36,166,255,254, 36,133, 0, 2, -/* 0x0490 */ 39,164, 0, 48,160,130, 0, 2, 51, 7, 0, 15,160,135, 0, 0, +/* 0x0490 */ 39,164, 0, 48,160,130, 0, 2, 51, 3, 0, 15,160,131, 0, 0, /* 0x04a0 */ 0, 24,193, 2, 4, 17, 0, 16,160,152, 0, 1,175,162, 0, 28, /* 0x04b0 */ 143,164, 0, 36,143,165, 0, 32, 36, 6, 0, 3, 36, 2, 16, 51, -/* 0x04c0 */ 0, 0, 0, 12,143,162, 0, 28,143,167, 0, 40,143,191, 0, 44, -/* 0x04d0 */ 3,167, 56, 35, 39,189, 0, 4, 23,167,255,254,175,160,255,252, +/* 0x04c0 */ 0, 0, 0, 12,143,162, 0, 28,143,163, 0, 40,143,191, 0, 44, +/* 0x04d0 */ 3,163, 24, 35, 39,189, 0, 4, 23,163,255,254,175,160,255,252, /* 0x04e0 */ 3,224, 0, 8, 0, 0, 0, 0, 39,189,255,200,175,183, 0, 52, /* 0x04f0 */ 175,182, 0, 48,175,181, 0, 44,175,180, 0, 40,175,179, 0, 36, /* 0x0500 */ 175,178, 0, 32,175,177, 0, 28,175,176, 0, 24, 0,160,168, 33, @@ -475,10 +475,10 @@ unsigned char stub_mips_r3000_linux_shlib_init[9963] = { /* 0x1b40 */ 0,137, 32, 35,175,164, 0, 52, 1, 9, 64, 35, 0,137, 32, 33, /* 0x1b50 */ 0, 9, 72,130,167,169, 0, 48,167,185, 0, 50,175,168, 0, 44, /* 0x1b60 */ 136,168, 0, 0,152,168, 0, 3, 36,165, 0, 4, 1, 0, 72, 33, -/* 0x1b70 */ 36,165, 0, 4,175,191, 0, 40, 39,167, 0, 44,175,165, 0, 24, -/* 0x1b80 */ 175,169, 0, 28,175,164, 0, 32,175,167, 0, 36, 48,167, 0, 3, -/* 0x1b90 */ 33, 41, 0, 3, 1, 39, 72, 32, 0, 9, 72,130,135,167, 0, 48, -/* 0x1ba0 */ 0,233, 48, 32,135,167, 0, 50, 0,230, 48, 32, 4, 17, 0, 91, +/* 0x1b70 */ 36,165, 0, 4,175,191, 0, 40, 39,163, 0, 44,175,165, 0, 24, +/* 0x1b80 */ 175,169, 0, 28,175,164, 0, 32,175,163, 0, 36, 48,163, 0, 3, +/* 0x1b90 */ 33, 41, 0, 3, 1, 35, 72, 32, 0, 9, 72,130,135,163, 0, 48, +/* 0x1ba0 */ 0,105, 48, 32,135,163, 0, 50, 0,102, 48, 32, 4, 17, 0, 91, /* 0x1bb0 */ 175,191, 0, 20, 36, 7, 8, 18,143,165, 0, 56, 4, 17, 0, 75, /* 0x1bc0 */ 143,164, 0, 52,135,169, 0, 48, 0, 64, 32, 33, 4, 17, 0, 55, /* 0x1bd0 */ 143,165, 0, 60,143,185, 0, 40,143,167, 0, 36,143,166, 0, 32, @@ -494,8 +494,8 @@ unsigned char stub_mips_r3000_linux_shlib_init[9963] = { /* 0x1c70 */ 143,169, 0, 76,143,168, 0, 72, 39,189, 0, 96, 3, 0, 0, 8, /* 0x1c80 */ 36, 2, 15,251,140,169,255,248, 0, 9, 76, 0, 0, 9, 76, 2, /* 0x1c90 */ 16, 0, 0, 6, 37, 41,255,255,140,162, 0, 0, 36,165, 0, 4, -/* 0x1ca0 */ 172,130, 0, 0, 36,132, 0, 4, 37, 41,255,255, 49, 39, 0, 3, -/* 0x1cb0 */ 20,224,255,250,140,162, 0, 0,140,163, 0, 4,140,184, 0, 8, +/* 0x1ca0 */ 172,130, 0, 0, 36,132, 0, 4, 37, 41,255,255, 49, 35, 0, 3, +/* 0x1cb0 */ 20, 96,255,250,140,162, 0, 0,140,163, 0, 4,140,184, 0, 8, /* 0x1cc0 */ 140,185, 0, 12,172,130, 0, 0,172,131, 0, 4,172,152, 0, 8, /* 0x1cd0 */ 172,153, 0, 12, 37, 41,255,252, 36,165, 0, 16, 21, 32,255,245, /* 0x1ce0 */ 36,132, 0, 16, 3,224, 0, 8, 0, 0, 0, 0, 36, 2,255,255, @@ -505,8 +505,8 @@ unsigned char stub_mips_r3000_linux_shlib_init[9963] = { /* 0x1d20 */ 4, 17, 0, 37, 0, 0, 0, 0, 0, 6, 40,128, 36, 7, 8, 2, /* 0x1d30 */ 175,165, 0, 64, 4, 17,255,237, 36, 4, 0, 0,175,162, 0, 60, /* 0x1d40 */ 143,165, 0, 52, 0, 64, 32, 33, 4, 17,255,216,135,169, 0, 48, -/* 0x1d50 */ 143,165, 0, 24,143,169, 0, 28, 48,167, 0, 3, 0,167, 40, 35, -/* 0x1d60 */ 1, 39, 72, 33, 0,135, 56, 33,175,167, 0, 24, 33, 41, 0, 3, +/* 0x1d50 */ 143,165, 0, 24,143,169, 0, 28, 48,163, 0, 3, 0,163, 40, 35, +/* 0x1d60 */ 1, 35, 72, 33, 0,131, 24, 33,175,163, 0, 24, 33, 41, 0, 3, /* 0x1d70 */ 4, 17,255,206, 0, 9, 72,130, 0,128, 48, 33,135,169, 0, 50, /* 0x1d80 */ 143,165, 0, 40, 4, 17,255,201,175,164, 0, 40,143,165, 0, 20, /* 0x1d90 */ 4, 17,255,188,175,164, 0, 20, 0,128, 40, 33, 0,192, 32, 33, diff --git a/src/stub/mipsel.r3000-linux.shlib-init.h b/src/stub/mipsel.r3000-linux.shlib-init.h index 55baeb81..ecccd484 100644 --- a/src/stub/mipsel.r3000-linux.shlib-init.h +++ b/src/stub/mipsel.r3000-linux.shlib-init.h @@ -32,8 +32,8 @@ #define STUB_MIPSEL_R3000_LINUX_SHLIB_INIT_SIZE 9846 -#define STUB_MIPSEL_R3000_LINUX_SHLIB_INIT_ADLER32 0xd05358ff -#define STUB_MIPSEL_R3000_LINUX_SHLIB_INIT_CRC32 0x3ec3da01 +#define STUB_MIPSEL_R3000_LINUX_SHLIB_INIT_ADLER32 0x05c55647 +#define STUB_MIPSEL_R3000_LINUX_SHLIB_INIT_CRC32 0x14e66e45 unsigned char stub_mipsel_r3000_linux_shlib_init[9846] = { /* 0x0000 */ 127, 69, 76, 70, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -97,16 +97,16 @@ unsigned char stub_mipsel_r3000_linux_shlib_init[9846] = { /* 0x03a0 */ 207,255, 0, 16, 0, 0, 0, 0, 0, 0,137,152, 3, 0,137,136, /* 0x03b0 */ 4, 0,132, 36,194,119, 9, 0, 64, 72, 9, 0, 8, 0,224, 3, /* 0x03c0 */ 1, 0, 41, 37,248,255,169, 17,194,119, 9, 0, 8, 0,224, 3, -/* 0x03d0 */ 64, 72, 9, 0, 0, 0,153,144, 0,250, 7, 36, 1, 0,152,144, -/* 0x03e0 */ 7, 0, 34, 51,194,200, 25, 0, 4, 56, 39, 3, 96,241,231, 36, -/* 0x03f0 */ 33,232,167, 3, 40, 0,167,175, 32, 0,170, 39, 44, 0,191,175, +/* 0x03d0 */ 64, 72, 9, 0, 0, 0,153,144, 0,250, 3, 36, 1, 0,152,144, +/* 0x03e0 */ 7, 0, 34, 51,194,200, 25, 0, 4, 24, 35, 3, 96,241, 99, 36, +/* 0x03f0 */ 33,232,163, 3, 40, 0,163,175, 32, 0,170, 39, 44, 0,191,175, /* 0x0400 */ 0, 0,233,140, 36, 0,166,175, 33, 64,192, 0, 28, 0,167, 39, /* 0x0410 */ 254,255,166, 36, 2, 0,133, 36, 48, 0,164, 39, 2, 0,130,160, -/* 0x0420 */ 15, 0, 7, 51, 0, 0,135,160, 2,193, 24, 0, 16, 0, 17, 4, +/* 0x0420 */ 15, 0, 3, 51, 0, 0,131,160, 2,193, 24, 0, 16, 0, 17, 4, /* 0x0430 */ 1, 0,152,160, 28, 0,162,175, 36, 0,164,143, 32, 0,165,143, /* 0x0440 */ 3, 0, 6, 36, 51, 16, 2, 36, 12, 0, 0, 0, 28, 0,162,143, -/* 0x0450 */ 40, 0,167,143, 44, 0,191,143, 35, 56,167, 3, 4, 0,189, 39, -/* 0x0460 */ 254,255,167, 23,252,255,160,175, 8, 0,224, 3, 0, 0, 0, 0, +/* 0x0450 */ 40, 0,163,143, 44, 0,191,143, 35, 24,163, 3, 4, 0,189, 39, +/* 0x0460 */ 254,255,163, 23,252,255,160,175, 8, 0,224, 3, 0, 0, 0, 0, /* 0x0470 */ 200,255,189, 39, 52, 0,183,175, 48, 0,182,175, 44, 0,181,175, /* 0x0480 */ 40, 0,180,175, 36, 0,179,175, 32, 0,178,175, 28, 0,177,175, /* 0x0490 */ 24, 0,176,175, 33,168,160, 0, 12, 0,167,175, 33,152, 0, 1, @@ -468,10 +468,10 @@ unsigned char stub_mipsel_r3000_linux_shlib_init[9846] = { /* 0x1ad0 */ 35, 64, 9, 1, 33, 32,137, 0,130, 72, 9, 0, 48, 0,169,167, /* 0x1ae0 */ 50, 0,185,167, 44, 0,168,175, 0, 0,168,152, 3, 0,168,136, /* 0x1af0 */ 4, 0,165, 36, 33, 72, 0, 1, 4, 0,165, 36, 40, 0,191,175, -/* 0x1b00 */ 44, 0,167, 39, 24, 0,165,175, 28, 0,169,175, 32, 0,164,175, -/* 0x1b10 */ 36, 0,167,175, 3, 0,167, 48, 3, 0, 41, 33, 32, 72, 39, 1, -/* 0x1b20 */ 130, 72, 9, 0, 48, 0,167,135, 32, 48,233, 0, 50, 0,167,135, -/* 0x1b30 */ 32, 48,230, 0, 91, 0, 17, 4, 20, 0,191,175, 18, 8, 7, 36, +/* 0x1b00 */ 44, 0,163, 39, 24, 0,165,175, 28, 0,169,175, 32, 0,164,175, +/* 0x1b10 */ 36, 0,163,175, 3, 0,163, 48, 3, 0, 41, 33, 32, 72, 35, 1, +/* 0x1b20 */ 130, 72, 9, 0, 48, 0,163,135, 32, 48,105, 0, 50, 0,163,135, +/* 0x1b30 */ 32, 48,102, 0, 91, 0, 17, 4, 20, 0,191,175, 18, 8, 7, 36, /* 0x1b40 */ 56, 0,165,143, 75, 0, 17, 4, 52, 0,164,143, 48, 0,169,135, /* 0x1b50 */ 33, 32, 64, 0, 55, 0, 17, 4, 60, 0,165,143, 40, 0,185,143, /* 0x1b60 */ 36, 0,167,143, 32, 0,166,143, 28, 0,165,143, 9,248, 32, 3, @@ -487,7 +487,7 @@ unsigned char stub_mipsel_r3000_linux_shlib_init[9846] = { /* 0x1c00 */ 96, 0,189, 39, 8, 0, 0, 3,251, 15, 2, 36,248,255,169,140, /* 0x1c10 */ 0, 76, 9, 0, 2, 76, 9, 0, 6, 0, 0, 16,255,255, 41, 37, /* 0x1c20 */ 0, 0,162,140, 4, 0,165, 36, 0, 0,130,172, 4, 0,132, 36, -/* 0x1c30 */ 255,255, 41, 37, 3, 0, 39, 49,250,255,224, 20, 0, 0,162,140, +/* 0x1c30 */ 255,255, 41, 37, 3, 0, 35, 49,250,255, 96, 20, 0, 0,162,140, /* 0x1c40 */ 4, 0,163,140, 8, 0,184,140, 12, 0,185,140, 0, 0,130,172, /* 0x1c50 */ 4, 0,131,172, 8, 0,152,172, 12, 0,153,172,252,255, 41, 37, /* 0x1c60 */ 16, 0,165, 36,245,255, 32, 21, 16, 0,132, 36, 8, 0,224, 3, @@ -498,8 +498,8 @@ unsigned char stub_mipsel_r3000_linux_shlib_init[9846] = { /* 0x1cb0 */ 128, 40, 6, 0, 2, 8, 7, 36, 64, 0,165,175,237,255, 17, 4, /* 0x1cc0 */ 0, 0, 4, 36, 60, 0,162,175, 52, 0,165,143, 33, 32, 64, 0, /* 0x1cd0 */ 216,255, 17, 4, 48, 0,169,135, 24, 0,165,143, 28, 0,169,143, -/* 0x1ce0 */ 3, 0,167, 48, 35, 40,167, 0, 33, 72, 39, 1, 33, 56,135, 0, -/* 0x1cf0 */ 24, 0,167,175, 3, 0, 41, 33,206,255, 17, 4,130, 72, 9, 0, +/* 0x1ce0 */ 3, 0,163, 48, 35, 40,163, 0, 33, 72, 35, 1, 33, 24,131, 0, +/* 0x1cf0 */ 24, 0,163,175, 3, 0, 41, 33,206,255, 17, 4,130, 72, 9, 0, /* 0x1d00 */ 33, 48,128, 0, 50, 0,169,135, 40, 0,165,143,201,255, 17, 4, /* 0x1d10 */ 40, 0,164,175, 20, 0,165,143,188,255, 17, 4, 20, 0,164,175, /* 0x1d20 */ 33, 40,128, 0, 33, 32,192, 0, 0, 0, 6, 36, 51, 16, 2, 36, diff --git a/src/stub/src/mipsel.r3000-linux.shlib-init.S b/src/stub/src/mipsel.r3000-linux.shlib-init.S index e30b59a4..7027c0f3 100644 --- a/src/stub/src/mipsel.r3000-linux.shlib-init.S +++ b/src/stub/src/mipsel.r3000-linux.shlib-init.S @@ -218,14 +218,14 @@ lxlzma_retval = lxlzma_srcdone #define a6 t2 lbu t9,0(lxsrc) # ((lit_context_bits + lit_pos_bits)<<3) | pos_bits - li ta3,-2*LZMA_LIT_NUM + li v1,-2*LZMA_LIT_NUM lbu t8,1(lxsrc) # (lit_pos_bits<<4) | lit_context_bits andi v0,t9,7 # pos_bits srl t9,t9,3 # (lit_context_bits + lit_pos_bits) - sllv ta3,ta3,t9 - addiu ta3,ta3,-4 - 2*LZMA_BASE_NUM - lxlzma_szframe - addu sp,sp,ta3 # alloca - sw ta3,lxlzma_sv_sp(sp) # dynamic frame size + sllv v1,v1,t9 + addiu v1,v1,-4 - 2*LZMA_BASE_NUM - lxlzma_szframe + addu sp,sp,v1 # alloca + sw v1,lxlzma_sv_sp(sp) # dynamic frame size addiu a6,sp,lxlzma_dstdone sw ra, lxlzma_sv_pc(sp) lw a5,0(lxdstlen) @@ -236,8 +236,8 @@ lxlzma_retval = lxlzma_srcdone addiu a1,lxsrc,2 # 2 header bytes addiu a0,sp,lxlzma_szframe # &CLzamDecoderState sb v0,2(a0) # pos_bits - andi ta3,t8,0xf - sb ta3, 0(a0) # lit_context_bits + andi v1,t8,0xf + sb v1, 0(a0) # lit_context_bits srl t8,t8,4 bal lzma_decode sb t8,1(a0) # lit_pos_bits @@ -260,15 +260,15 @@ lxlzma_retval = lxlzma_srcdone lw v0,lxlzma_retval(sp) # return value from decompression - lw ta3,lxlzma_sv_sp(sp) + lw v1,lxlzma_sv_sp(sp) lw ra,lxlzma_sv_pc(sp) /* Workaround suspected glibc bug: elf/rtld.c assumes uninit local is zero. 2007-11-24 openembedded.org mipsel-linux 2.6.12.6/glibc 2.3.2 */ - subu ta3,sp,ta3 # previous sp (un_alloca) + subu v1,sp,v1 # previous sp (un_alloca) 0: addiu sp,4 - bne sp,ta3,0b + bne sp,v1,0b sw $0,-4(sp) jr ra @@ -380,10 +380,10 @@ f_wexpf= 2+ f_wfrag slot p_unflt,5 sw edi,0*NBPW + p_unflt(sp) // dst param for unfilter step 7 sw eax,1*NBPW + p_unflt(sp) // dstlen also for unfilter step 7 - lb ta3,b_method-4+1(esi) - sw ta3,2*NBPW + p_unflt(sp) // ftid - lb ta3,b_method-4+2(esi) - sw ta3,3*NBPW + p_unflt(sp) // cto8 + lb v1,b_method-4+1(esi) + sw v1,2*NBPW + p_unflt(sp) // ftid + lb v1,b_method-4+2(esi) + sw v1,3*NBPW + p_unflt(sp) // cto8 #endif //} UNFILTER lodslu; move ecx,eax // ecx= srclen #if UNFILTER //{ @@ -395,19 +395,19 @@ f_wexpf= 2+ f_wfrag slot f_expf sw ra,f_expf(sp) - la ta3,o_dstlen(sp) // &dstlen + la v1,o_dstlen(sp) // &dstlen slot p_uncpr,4 sw esi,0*NBPW + p_uncpr(sp) // src; arglist ready for decompress step 6 sw ecx,1*NBPW + p_uncpr(sp) // srclen sw edi,2*NBPW + p_uncpr(sp) // dst - sw ta3,3*NBPW + p_uncpr(sp) // &dstlen + sw v1,3*NBPW + p_uncpr(sp) // &dstlen - andi ta3,esi,3 // length of prefix alignment + andi v1,esi,3 // length of prefix alignment addi ecx,ecx,3 // allow suffix alignment - add ecx,ecx,ta3 // prefix increases byte length + add ecx,ecx,v1 // prefix increases byte length srl ecx,ecx,2 - lh ta3,f_wfrag(sp); add edx,ta3,ecx // w_srclen + w_frag - lh ta3,f_wexpf(sp); add edx,ta3,edx // + n_words(f_exp) + lh v1,f_wfrag(sp); add edx,v1,ecx // w_srclen + w_frag + lh v1,f_wexpf(sp); add edx,v1,edx // + n_words(f_exp) #if UNFILTER //{ bal wlen_subr // edx += n_words (f_unf) @@ -506,7 +506,7 @@ movsl_subr: sw v0,0*NBPW(edi); addiu edi,edi,1*NBPW addiu ecx,ecx,-1 movsl: // edi= 4-byte aligned dst; esi= 4-byte aligned src; ecx= *WORD* count - andi ta3,ecx,3; bnez ta3,4+ 9b //; nop # same instr at 9b: and 9f: + andi v1,ecx,3; bnez v1,4+ 9b //; nop # same instr at 9b: and 9f: 9: lw v0,0*NBPW(esi); lw v1,1*NBPW(esi); lw t8,2*NBPW(esi); lw t9,3*NBPW(esi) sw v0,0*NBPW(edi); sw v1,1*NBPW(edi); sw t8,2*NBPW(edi); sw t9,3*NBPW(edi) @@ -544,11 +544,11 @@ L220: lw esi,0*NBPW + p_uncpr(sp) // src lw ecx,1*NBPW + p_uncpr(sp) // len - andi ta3,esi,3 // length of prefix alignment - subu esi,esi,ta3 // down to word aligned - addu ecx,ecx,ta3 // prefix increases byte length - addu ta3,edi,ta3 // skip prefix at destination - sw ta3,0*NBPW + p_uncpr(sp) // dst + andi v1,esi,3 // length of prefix alignment + subu esi,esi,v1 // down to word aligned + addu ecx,ecx,v1 // prefix increases byte length + addu v1,edi,v1 // skip prefix at destination + sw v1,0*NBPW + p_uncpr(sp) // dst addi ecx,ecx,3 // round up to full words bal movsl // copy all aligned words that contain compressed data srl ecx,ecx,2