merge. arm/pe lzma updates
This commit is contained in:
+2
-1
@@ -214,7 +214,8 @@ tmp/amd64-linux.elf-main.o : $(srcdir)/src/$$T.c
|
||||
arm-linux.elf% : tc_list = arm-linux.elf default
|
||||
arm-linux.elf% : tc_bfdname = elf32-littlearm
|
||||
|
||||
tc.arm-linux.elf.gcc = arm-9tdmi-linux-gnu-gcc-3.4.5 -march=armv4 -nostdinc -MMD
|
||||
#tc.arm-linux.elf.gcc = arm-9tdmi-linux-gnu-gcc-3.4.5 -march=armv4 -nostdinc -MMD
|
||||
tc.arm-linux.elf.gcc = arm-unknown-linux-gnu-gcc-4.1.0 -march=armv4 -nostdinc -MMD
|
||||
tc.arm-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
|
||||
tc.arm-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror
|
||||
tc.arm-linux.elf.ld = $(call tc,m-ld)
|
||||
|
||||
+1889
-1017
File diff suppressed because it is too large
Load Diff
+1498
-1416
File diff suppressed because it is too large
Load Diff
+827
-870
File diff suppressed because it is too large
Load Diff
@@ -27,14 +27,19 @@ lzma_d_c%.S : tc_list = arm-lzma arm-linux.elf default
|
||||
lzma_d_c%.S : tc_bfdname = elf32-littlearm
|
||||
|
||||
tc.arm-lzma.gcc = $(tc.arm-linux.elf.gcc)
|
||||
tc.arm-lzma.gcc += -march=armv4
|
||||
tc.arm-lzma.gcc += -march=armv4 -fPIC
|
||||
tc.arm-lzma.gcc += -Os
|
||||
tc.arm-lzma.gcc += -ffunction-sections
|
||||
tc.arm-lzma.gcc += -I$(UPX_LZMADIR)
|
||||
tc.arm-lzma.gcc += -I$(top_srcdir)/src
|
||||
|
||||
lzma_d_c%.S : lzma_d_c.c
|
||||
$(call tc,gcc) $(PP_FLAGS) -S $< -o $@
|
||||
lzma_d_cf.S : lzma_d_c.c
|
||||
$(call tc,gcc) $(PP_FLAGS) -S $< -o tmp/$T.s
|
||||
sed -e '1,/LzmaDecode:/d' -e '/\.size/d' -e '/\.ident/d' -e 's/\.L/f.L/g' <tmp/$T.s >$@
|
||||
|
||||
lzma_d_cs.S : lzma_d_c.c
|
||||
$(call tc,gcc) $(PP_FLAGS) -S $< -o tmp/$T.s
|
||||
sed -e '1,/LzmaDecode:/d' -e '/\.size/d' -e '/\.ident/d' -e 's/\.L/s.L/g' <tmp/$T.s >$@
|
||||
|
||||
lzma_d_cf.% : PP_FLAGS = -DFAST
|
||||
lzma_d_cs.% : PP_FLAGS = -DSMALL
|
||||
|
||||
@@ -45,8 +45,11 @@
|
||||
#define M_LZMA 14
|
||||
ldrb ip,meth; cmp ip,#M_LZMA; bne not_lzma
|
||||
|
||||
PUSH {fp,lr}
|
||||
mov fp,sp
|
||||
#if defined(LINUX_ARM_CACHEFLUSH) /*{*/
|
||||
PUSH {dst,ldst, fp,lr} // dst,ldst for cache flush
|
||||
#else /*}{*/
|
||||
PUSH { fp,lr}
|
||||
#endif /*}*/
|
||||
|
||||
#define a0 r0
|
||||
#define a1 r1
|
||||
@@ -71,8 +74,8 @@
|
||||
mov fp,fp,LSR #3 // lit_context_bits + lit_pos_bits
|
||||
mov ip,ip,LSL fp // 2*LZMA_LIT_SIZE << (lit_context_bits + lit_pos_bits)
|
||||
mov fp,sp
|
||||
add ip,ip,# ((4*4 + 2*LZMA_BASE_SIZE)>>8)<<8
|
||||
add ip,ip,#0xff & (4*4 + 2*LZMA_BASE_SIZE)
|
||||
#define W 4 /* even #bits to round up so that 8 bits span all the 1's */
|
||||
add ip,ip,#((~(~0<<W) + State + 2*LZMA_BASE_SIZE)>>W)<<W
|
||||
sub sp,sp,ip
|
||||
|
||||
ldr ip,[ldst]
|
||||
@@ -101,6 +104,25 @@
|
||||
strb ip,[sp,#0 + State]
|
||||
|
||||
add a0,sp,#State
|
||||
bl 1f // the call
|
||||
mov sp,fp
|
||||
|
||||
#if defined(LINUX_ARM_CACHEFLUSH) /*{*/
|
||||
/* linux/include/asm-arm/unistd.h */
|
||||
#define __NR_SYSCALL_BASE 0x900000
|
||||
#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
|
||||
#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
|
||||
mov r3,r0 // save result value
|
||||
POP {r0,r1} // dst, ldst
|
||||
ldr r1,[r1] // ldst by reference
|
||||
add r1,r1,r0 // just beyond what was written
|
||||
mov r2,#0
|
||||
swi __ARM_NR_cacheflush // decompressed region
|
||||
mov r0,r3 // result value
|
||||
#endif /*}*/
|
||||
|
||||
POP {fp,pc}
|
||||
1:
|
||||
|
||||
section LZMA_DEC10
|
||||
#include "lzma_d_cs.S"
|
||||
@@ -109,8 +131,6 @@
|
||||
#include "lzma_d_cf.S"
|
||||
|
||||
section LZMA_DEC30
|
||||
mov sp,fp
|
||||
POP {fp,pc}
|
||||
|
||||
not_lzma:
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,138 @@
|
||||
/* nrv2b_d8.S -- ARM decompressor for NRV2B
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2006 Laszlo Molnar
|
||||
Copyright (C) 2000-2006 John F. Reiser
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
and/or modify them under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
||||
|
||||
John F. Reiser
|
||||
<jreiser@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#define src r0
|
||||
#define len r1
|
||||
#define dst r2
|
||||
#define tmp r3
|
||||
#define bits r4
|
||||
#define off r5
|
||||
|
||||
/* macros reduce "noise" when comparing this ARM code to corresponding THUMB code */
|
||||
#define PUSH stmdb sp!,
|
||||
#define POP ldmia sp!,
|
||||
#define ADD2( dst,src) add dst,dst,src
|
||||
#define ADD2S(dst,src) adds dst,dst,src
|
||||
#define ADC2( dst,src) adc dst,dst,src
|
||||
#define ADC2S(dst,src) adcs dst,dst,src
|
||||
#define SUB2( dst,src) sub dst,dst,src
|
||||
#define SUB2S(dst,src) subs dst,dst,src
|
||||
#define LDRB3(reg,psrc,incr) ldrb reg,psrc,incr
|
||||
#define STRB3(reg,pdst,incr) strb reg,pdst,incr
|
||||
|
||||
#undef GETBIT
|
||||
#define GETBIT ADD2S(bits,bits); bleq get8_n2b
|
||||
|
||||
#define getnextb(reg) GETBIT; ADC2S(reg,reg) /* Set Condition Codes on result */
|
||||
#define jnextb0 GETBIT; bcc
|
||||
#define jnextb1 GETBIT; bcs
|
||||
|
||||
ucl_nrv2b_decompress_8: .globl ucl_nrv2b_decompress_8 // ARM mode
|
||||
.type ucl_nrv2b_decompress_8, %function
|
||||
/* error = (*)(char const *src, int len_src, char *dst, int *plen_dst) */
|
||||
add r1,len,src // r1= eof_src;
|
||||
PUSH {r1,r2,r3, r4,r5, lr}
|
||||
mvn off,#~-1 // off= -1 initial condition
|
||||
mov bits,#1<<31 // refill next time
|
||||
b top_n2b
|
||||
|
||||
eof_n2b:
|
||||
POP {r1,r3,r4} // r1= eof_src; r3= orig_dst; r4= plen_dst
|
||||
SUB2(src,r1) // 0 if actual src length equals expected length
|
||||
SUB2(dst,r3) // actual dst length
|
||||
str dst,[r4]
|
||||
|
||||
#if defined(LINUX_ARM_CACHEFLUSH) /*{*/
|
||||
/* linux/include/asm-arm/unistd.h */
|
||||
#define __NR_SYSCALL_BASE 0x900000
|
||||
#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
|
||||
#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
|
||||
mov r4,r0 // save result value
|
||||
mov r0,r3 // orig_dst
|
||||
add r1,r3,dst // orig_dst + dst_len
|
||||
mov r2,#0
|
||||
swi __ARM_NR_cacheflush // decompressed region
|
||||
mov r0,r4 // result value
|
||||
#endif /*}*/
|
||||
|
||||
POP {r4,r5, pc} // return
|
||||
|
||||
get8_n2b: // In: Carry set [from adding 0x80000000 (1<<31) to itself]
|
||||
LDRB3(bits,[src],#1) // zero-extend next byte
|
||||
adc bits,bits,bits // double and insert CarryIn as low bit
|
||||
movs bits,bits,lsl #24 // move to top byte, and set CarryOut from old bit 8
|
||||
mov pc,lr
|
||||
|
||||
lit_n2b:
|
||||
LDRB3(tmp,[src],#1)
|
||||
STRB3(tmp,[dst],#1)
|
||||
top_n2b:
|
||||
jnextb1 lit_n2b
|
||||
|
||||
mov len,#1 // the msb
|
||||
getoff_n2b: // ss11 len= [2..)
|
||||
getnextb(len)
|
||||
jnextb0 getoff_n2b
|
||||
|
||||
subs tmp,len,#3 // set Carry
|
||||
mov len,#0 // Carry unaffected
|
||||
blo offprev_n2b // ss11 returned 2
|
||||
LDRB3(off,[src],#1) // low 8 bits
|
||||
orr off,off,tmp,lsl #8
|
||||
mvns off,off; beq eof_n2b // off= ~off
|
||||
offprev_n2b: // In: 0==len
|
||||
getnextb(len); getnextb(len); bne plus1_n2b // two bits; 1,2,3 ==> 2,3,4
|
||||
|
||||
mov len,#1 // the msb
|
||||
getlen_n2b: // ss11 len= [2..)
|
||||
getnextb(len)
|
||||
jnextb0 getlen_n2b
|
||||
ADD2(len,#2) // [2..) ==> [4..);
|
||||
plus1_n2b:
|
||||
ADD2(len,#1) // 1,2,3 ==> 2,3,4; [4..) ==> [5..)
|
||||
/* 'cmn': add the inputs, set condition codes, discard the sum */
|
||||
cmn off,#0xd<<8 // within M2_MAX_OFFSET
|
||||
addcc len,len,#1 // too far away, so minimum match length is 3
|
||||
|
||||
add tmp,dst,len
|
||||
ldrb tmp,[tmp,#-1] // force cacheline allocate
|
||||
|
||||
copy_n2b:
|
||||
ldrb tmp,[dst,off]
|
||||
STRB3(tmp,[dst],#1)
|
||||
SUB2S(len,#1); bne copy_n2b
|
||||
b top_n2b
|
||||
|
||||
.size ucl_nrv2b_decompress_8, .-ucl_nrv2b_decompress_8
|
||||
/*
|
||||
vi:ts=8:et:nowrap
|
||||
*/
|
||||
|
||||
@@ -179,7 +179,8 @@ near_n2e:
|
||||
add tmp,dst,cnt
|
||||
cmp tmp,dstlim; bhi bad_dst_n2e // too much output
|
||||
#endif /*}*/
|
||||
ldrb tmp,[dst] // force cacheline allocate
|
||||
add tmp,dst,len
|
||||
ldrb tmp,[tmp,#-1] // force cacheline allocate
|
||||
copy_n2e:
|
||||
ldrb tmp,[dst,off]
|
||||
CHECK_BYTE
|
||||
|
||||
@@ -33,8 +33,13 @@ tc.arm-lzma.gcc += -ffunction-sections
|
||||
tc.arm-lzma.gcc += -I$(UPX_LZMADIR)
|
||||
tc.arm-lzma.gcc += -I$(top_srcdir)/src
|
||||
|
||||
lzma_d_c%.S : lzma_d_c.c
|
||||
$(call tc,gcc) $(PP_FLAGS) -S $< -o $@
|
||||
lzma_d_cf.S : lzma_d_c.c
|
||||
$(call tc,gcc) $(PP_FLAGS) -S $< -o tmp/$T.s
|
||||
sed -e '1,/LzmaDecode:/d' -e '/\.size/d' -e '/\.ident/d' -e 's/\.L/.Lf/g' <tmp/$T.s >$@
|
||||
|
||||
lzma_d_cs.S : lzma_d_c.c
|
||||
$(call tc,gcc) $(PP_FLAGS) -S $< -o tmp/$T.s
|
||||
sed -e '1,/LzmaDecode:/d' -e '/\.size/d' -e '/\.ident/d' -e 's/\.L/.Ls/g' <tmp/$T.s >$@
|
||||
|
||||
lzma_d_cf.% : PP_FLAGS = -DFAST
|
||||
lzma_d_cs.% : PP_FLAGS = -DSMALL
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,7 @@
|
||||
*/
|
||||
#define section .section
|
||||
|
||||
#define bkpt .long 0xe1200070
|
||||
sz_Elf32_Ehdr = 13*4
|
||||
sz_Elf32_Phdr = 8*4
|
||||
|
||||
@@ -37,6 +38,8 @@ sz_b_info= 12
|
||||
sz_unc= 0
|
||||
sz_cpr= 4
|
||||
b_method= 8
|
||||
sz_l_info= 12
|
||||
sz_p_info= 12
|
||||
|
||||
PROT_READ= 1
|
||||
PROT_WRITE= 2
|
||||
@@ -49,31 +52,40 @@ MAP_ANONYMOUS= 0x20
|
||||
PAGE_SHIFT= 12
|
||||
PAGE_SIZE = -(~0<<PAGE_SHIFT)
|
||||
|
||||
//.long sz_pack2 // placed there by ::pack3()
|
||||
section ELFMAINX
|
||||
start_params:
|
||||
.long ADRM // dst for map
|
||||
.long LENF // end_decompress - (start_params -4)
|
||||
.long CPR0 // cpr0 - (start_params -4)
|
||||
_start: .globl _start
|
||||
/* Get some pages: enough
|
||||
to duplicate the entire compressed PT_LOAD, plus 1 page, located just after
|
||||
the brk() of the _un_compressed program. The address and length are pre-
|
||||
calculated by PackLinuxElf32arm::pack3(), and patched in at compress time.
|
||||
the brk() of the _un_compressed program. The address is pre-calculated
|
||||
calculated by PackLinuxElf32arm::addLinkerSymbols().
|
||||
*/
|
||||
adr r12,start_params
|
||||
ldmia r12!,{r0,r1, r8,r10} // ADRM,LENM, ADRC,CNTC
|
||||
stmdb sp!,{r0,r1,r2} // ADRU,LENU,space for sz_unc
|
||||
adr r12,start_params -4 // &sz_pack2
|
||||
ldmia r12,{r1,r2, r10,r11} // r1= sz_pack2; r2= ADRM; r10= LENF; r11= CPR0;
|
||||
add r10,r10,r12 // end_decompress
|
||||
add r11,r11,r12 // cpr0
|
||||
mov r0,r2 // ADRM
|
||||
sub r9,r12,r1 // &our_Elf32_Ehdr
|
||||
add r1,r1,# PAGE_SIZE
|
||||
stmdb sp!,{r0,r1,r2} // ADRU,LENU,space for sz_unc
|
||||
mov r2,#PROT_READ | PROT_WRITE | PROT_EXEC
|
||||
mov r3,#MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS
|
||||
mvn r4,#0 // -1; cater to *BSD for fd when MAP_ANON
|
||||
swi 0x009000c0 // mmap64
|
||||
cmn r0,#4096
|
||||
bcs msg_SELinux
|
||||
mov r9,r0 // destination for copy
|
||||
copy:
|
||||
ldmia r8!,{r0,r1,r2,r3,r4,r5,r6,r7}; subs r10,r10,#1
|
||||
stmia r9!,{r0,r1,r2,r3,r4,r5,r6,r7}; bne copy
|
||||
ldmia r9!,{r1,r2,r3,r4,r5,r6,r7,r8}; cmp r9,r10 // upto end-decompress
|
||||
stmia r0!,{r1,r2,r3,r4,r5,r6,r7,r8}; blo copy
|
||||
|
||||
mov lr,r9 // dst for unfolded code
|
||||
sub r11,r9,r8 // relocation amount
|
||||
ldmia r12!,{r1,r4,r9,r10} // len_f,cpr0,LENX,ADRX
|
||||
add r5,r12,r11 // relocated f_decompress
|
||||
sub r4,r0,r9 // relocation amount
|
||||
adr r5,f_decompress
|
||||
mov lr,r0 // dst for unfolded code
|
||||
add r5,r5,r4 // relocated f_decompress
|
||||
|
||||
/* linux/include/asm-arm/unistd.h */
|
||||
#define __NR_SYSCALL_BASE 0x900000
|
||||
@@ -81,38 +93,43 @@ copy:
|
||||
#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
|
||||
|
||||
mov r0,r5
|
||||
add r1,r1,r0 // relocated end_decompress
|
||||
add r1,r9,r4 // relocated end_decompress
|
||||
mov r2,#0
|
||||
swi __ARM_NR_cacheflush // relocated decompressor
|
||||
|
||||
add r0, r4,# sz_b_info
|
||||
ldr r1,[r4,# sz_cpr ]
|
||||
ldr r9,[r12] // sz_pack2
|
||||
sub r9,r9,#sz_Elf32_Ehdr + 2*sz_Elf32_Phdr + sz_l_info + sz_p_info
|
||||
sub r10,r12,r9 // &b_info
|
||||
add r10,r10,r4 // relocated &b_info
|
||||
|
||||
ldrb r0,[r11,# b_method ] // 5th param
|
||||
stmdb sp!,{r0,lr}
|
||||
ldr r3,[r11,# sz_unc]
|
||||
add r0, r11,# sz_b_info
|
||||
ldr r1,[r11,# sz_cpr ]
|
||||
mov r2,lr // dst
|
||||
add r3,sp,#2*4 // &sz_unc
|
||||
ldrb r4,[r4,# b_method ]
|
||||
mov pc,r5 // decompress folded code; go there (lr)
|
||||
str r3,[sp,#2*4] // sz_unc; lzma needs for EOF
|
||||
add r3, sp,#2*4 // &sz_unc
|
||||
mov lr,pc; mov pc,r5 // decompress folded code [opcode 'bx' not in v4a]
|
||||
ldmia sp!,{r1, pc} // discard 5th param; return
|
||||
|
||||
start_params:
|
||||
.long ADRM // dst for map
|
||||
.long LENM // len for map
|
||||
|
||||
.long ADRC // src for copy
|
||||
.long CNTC // cnt for copy: number of 32-byte blocks
|
||||
|
||||
.long len_f // length of decompressor code
|
||||
.long cpr0
|
||||
|
||||
.long LENX // total size of compressed data
|
||||
.long ADRX // &b_info of 1st compressed block (after moving)
|
||||
f_decompress:
|
||||
#define LINUX_ARM_CACHEFLUSH 1
|
||||
|
||||
section NRV_HEAD
|
||||
// empty
|
||||
section NRV_TAIL
|
||||
// empty
|
||||
|
||||
section NRV2E
|
||||
#include "arch/arm/v4a/nrv2e_d8.S"
|
||||
|
||||
section NRV2D
|
||||
#include "arch/arm/v4a/nrv2d_d8.S"
|
||||
|
||||
section NRV2B
|
||||
#include "arch/arm/v4a/nrv2b_d8.S"
|
||||
|
||||
#include "arch/arm/v4a/lzma_d.S"
|
||||
|
||||
section ELFMAINY
|
||||
@@ -135,8 +152,6 @@ L71:
|
||||
cpr0:
|
||||
/* { b_info={sz_unc, sz_cpr, {4 char}}, folded_loader...} */
|
||||
|
||||
eof:
|
||||
|
||||
/*
|
||||
vi:ts=8:et:nowrap
|
||||
*/
|
||||
|
||||
@@ -388,7 +388,7 @@ section CallLZMA
|
||||
|
||||
section LZMA_DECODE
|
||||
|
||||
#undef section
|
||||
section LZMA_DEC10
|
||||
#include "arch/arm/v4a/lzma_d_cs.S"
|
||||
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
@@ -340,6 +340,6 @@ section CallLZMA
|
||||
section LZMA_DECODE
|
||||
.real_start_ofLZMA_DECODE: // suppress silly warnings
|
||||
|
||||
#undef section
|
||||
section LZMA_DEC10
|
||||
#include "arch/arm/v4t/lzma_d_cs.S"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user