1
0
mirror of https://github.com/upx/upx.git synced 2025-08-11 22:52:30 +08:00

PowerPC syscall trace for debugging the run-time de-compressor

Enabled for now.
https://github.com/upx/upx/issues/907
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/powerpc-linux.elf-fold.S
           plus generated .h .map
This commit is contained in:
John Reiser
2025-04-14 09:52:08 -07:00
parent ea168d0cc3
commit 7a37986240
4 changed files with 1009 additions and 880 deletions

View File

@ -64,8 +64,8 @@ a7bd9f616231d883f6700b09e3c9a0af2880c6b5e5b0ce1cd8f06de43c48856c *m68k-atari.tos
d790e823be29f042f0abb71205b226c88b63e228a8f0099cd176d779e708685e *mips-linux.elf/upx-3.95
1edb6d6a7826afcc4c09420fa922967693f4ec010527221233870dc949ace694 *mipsel-linux.elf/upx-3.91
e188225afe6ed6446027df13fcc78f273062462fd4b780202a69df432a1f9944 *mipsel-linux.elf/upx-3.95
73647d5f2e41585d433d4f86d44705916edca21e8f84d698e724e5d6fffe9dce *powerpc-linux.elf/upx-3.91
3ca30ab9c09159265fee0c3aadb4e874415224cdbd9def7d1d676a75ccd77bee *powerpc-linux.elf/upx-3.95
c0320e9633812b132c27398c4036ebfafc49b3b913ba29e058f7a72b9d245bb8 *powerpc-linux.elf/upx-3.91
1e13e42fb56b2899ec3084fd9fbbdac3b32e59779d7d43621c85a9341b060e97 *powerpc-linux.elf/upx-3.95
9707d56b97a878716715a4ea5d2725874314f95d419df9dcf36c6920b822a63f *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t120_compress_ucl_nrv2d_3_no_filter="\
@ -87,8 +87,8 @@ eba33a75c261eaa8d558c05d88910331e0dfe20945eae296ed17b21525dd0e95 *armeb-linux.el
32cc63a6c95e021081df317674f44109a0dffea20fb19f8f07f7feaefbb1806a *mips-linux.elf/upx-3.95
01827714994db6432346eaa133c0a8183332b0fe5b9d9c2ccd405c7b34ea9169 *mipsel-linux.elf/upx-3.91
eab36dc7153eaac876a81a62a7e3a75a7fd24d5def5188236fe41ac7cc9724e9 *mipsel-linux.elf/upx-3.95
74b68a48450c18f8108e58d7c1b9e60f295a941daf0cf24a701c9ae861353885 *powerpc-linux.elf/upx-3.91
e912c2a1a47fe1fd6cd85f95327960bc749a3b603487c42a01cc1c9d6b786af8 *powerpc-linux.elf/upx-3.95
dc56430b15f9ce8f0e1f42200373f8e83f8810da4fc8ade5e57a299985064312 *powerpc-linux.elf/upx-3.91
4be58427abf39d38b4b63949e6423c5de778882712cb82bc90a3fcaec163ebf6 *powerpc-linux.elf/upx-3.95
4e7d18a7a31244e05addfc122b58b66fac6919f959468ff3a31f54d2e62029b0 *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\
@ -110,8 +110,8 @@ c78db15a8113b806e56812fd842fb467d2a9c9557fcdc0467dae3f4c33316630 *i386-win32.pe/
20b1e81d34595b7ca4f24b2bcd1007f73deb5dd51c97dd47bc820605d39f6bf0 *mips-linux.elf/upx-3.95
5080fcf8e4116157f617fadbd26c1fee4277babd7849bb29507c95b7688bdc46 *mipsel-linux.elf/upx-3.91
d33531ff51ca68e9f413471810f5334e9af8557b96acdbc9582e5df7d9287532 *mipsel-linux.elf/upx-3.95
5150b0c0879b9f2535b14cb55ce4a2907bcb8137b39e356cbd4c3e9a201c30a5 *powerpc-linux.elf/upx-3.91
28993fcf38565f6c7aeb0485e0267b0c73b89c6d4663921eda24124a427de5e7 *powerpc-linux.elf/upx-3.95
b275f3956c8e3f4d6e719c18047550fe6ae830f65c03fcf22a3df4ca6c363353 *powerpc-linux.elf/upx-3.91
6aa1cdc0c5e0f716fdc85b02357647cfe49c5edf621703e402d700edcc44926a *powerpc-linux.elf/upx-3.95
94d84a94a2b3c88d834250aba9199fdee5f17912749ce38fd5b32c5c77901492 *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t140_compress_lzma_2_no_filter="\
@ -133,8 +133,8 @@ e268c98fdacfd04268d76644f2bb4746ae04b57801407aaa1867798840eeeea0 *m68k-atari.tos
4ba29feb578cdb79a741dbf22c87ee8a35d7e5d65420f06abea4b8a1ef8ece21 *mips-linux.elf/upx-3.95
cbd713f5e414ae2e8bc119728f4fedd7d93efeb66739596adca2325bdcea41f9 *mipsel-linux.elf/upx-3.91
1e759075596f8d2f627f55b7e252061c67f36244417ada14e41e150cfcad2ccf *mipsel-linux.elf/upx-3.95
badea86cfe633a6ac5c1807822efb60f791d8b8512e9249bfc0b08c0ecff1507 *powerpc-linux.elf/upx-3.91
9f833198a5471862bdf0cae56794ca3850fb0f8e54ec72aeb78e33f8b6524087 *powerpc-linux.elf/upx-3.95
234a2ae752a1b2f89a1bfcedfe774d89ae06908f452ce1ba5afc9628bae38ad6 *powerpc-linux.elf/upx-3.91
f1a08f44ccb8160c14e1bffe50931afec3b4e6ae3aed257182a9fdec60f0309f *powerpc-linux.elf/upx-3.95
2358a33f1f5112c87eb7e7777b383976781cfb362a0e6b0620554838c3c26c47 *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t150_compress_ucl_2_all_filters="\
@ -156,8 +156,8 @@ e414ad0aba43790d0498b26c23055fb051129b6cbe3e070a1406c91ac5b8032b *m68k-atari.tos
e5fbb95e8ad8d5eafc0ea1894b21e6c17fbeffe493544da396884df5388ca847 *mips-linux.elf/upx-3.95
2d9ca9eea93bc10983af299b6340f0447c3b1538dff0ce333d9dfec88f0f9cab *mipsel-linux.elf/upx-3.91
e8d67346ad4ada869335bfb73998f6ce786225aad7053224efdaddd29614b58c *mipsel-linux.elf/upx-3.95
31281eaa2bdd392ebc67b66edec2c83f61971284b4e4faff88c4b4c43ecbaa21 *powerpc-linux.elf/upx-3.91
5e83c714a8a36a51b079d541a272728310c7186917dd031ef96a5ed8a2333308 *powerpc-linux.elf/upx-3.95
158acfd45619abefa19649dec6254592f5d8ddf95b906edf2d00ebd767e0b604 *powerpc-linux.elf/upx-3.91
be50e2fb1665ab9a9a7e23d36a5b931d190607e0a4a8fdea10f09ddeb103c2ee *powerpc-linux.elf/upx-3.95
40ef133ef445e0162054556d5fcc85d8d7738887f43e0aab592093369f5f2e9f *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t160_compress_all_methods_1_no_filter="\
@ -179,8 +179,8 @@ f3d33c5c9809943a902133490bcf0cfbe39a5ef1635a0c29b3bdc4f35dfffa50 *i386-win32.pe/
8564e1cfb394eb336e1872cf641e6fd2c6eafa27969ad4b69390057fb6fea7ec *mips-linux.elf/upx-3.95
17fcf22713c6b702106c2e3911c181971f3cd6e613edfb99004d22ef1b79c9a3 *mipsel-linux.elf/upx-3.91
99a335f2eb49a724415ca5ff2518659fec6810110e95fc2aa5647a0d677720e6 *mipsel-linux.elf/upx-3.95
cc829dbc4d91282887f73add2fa013e8c3e577b360f8d5a90f12f4b1d0a58f6a *powerpc-linux.elf/upx-3.91
ba2f2ca2837d81cfc6069e8d89687958b361fef868ab63b2dac10e2160c9e1ad *powerpc-linux.elf/upx-3.95
82d06f2964675f9927f9d2aa8962e8512bb005aba21f85c24c580e6c8502bae9 *powerpc-linux.elf/upx-3.91
f58a98142522b4446bba0800b0f8e272037e8794aa60b404a2b580544c5517f5 *powerpc-linux.elf/upx-3.95
fc9feb22dcbe188d87e27ec724ac3b56a19087ec734f2d80d99a49893481a8d6 *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t170_compress_all_methods_no_lzma_5_no_filter="\
@ -202,8 +202,8 @@ ad47c7522167f6f7e47d495e1fa119431386ca5ea9bc16b6a4b9cb38cf9cd29f *i386-win32.pe/
7cf400b26e03fdfcbf2649735cc1d4539214ea2f545fd6be7e6025aedf515c61 *mips-linux.elf/upx-3.95
a08aff8b3d32a6e9f271593c300a9efd36397ead93540e55c671ba3aa64f7f39 *mipsel-linux.elf/upx-3.91
090eff7b1e473dd3543949a176520a07d71fa9fb3ce685c4a65f0cca879f9786 *mipsel-linux.elf/upx-3.95
eede0d52fe701b6a56763d935486099e597c01109170c8c44f5d091cf3f2857a *powerpc-linux.elf/upx-3.91
458b55a73288e2195d33a47d0e9aa575277f0cdfe72a337c3a71a5f1feb254b7 *powerpc-linux.elf/upx-3.95
b5e00639b315bd783f099218f6635940a4017bf1fd7e7fcfe47a497cf8863f91 *powerpc-linux.elf/upx-3.91
1ed7c95f2a6e84bb67f22dd0362f89af7b638e13e398de9c2a254e88253c18a3 *powerpc-linux.elf/upx-3.95
4d8ea1a2a10c9ef18ef429e8950ba75adeeb12da60c6169dc1c6449240cd44c6 *powerpc64le-linux.elf/upx-3.95
"
########## end .sha256sums.recreate

File diff suppressed because it is too large Load Diff

View File

@ -322,33 +322,138 @@ munmap: .globl munmap
mmap: .globl mmap
li r0,SYS_mmap
sysgo:
#define TRACE 1
#if TRACE //{
FD_STDERR= 2
Tr1= 0*NBPW
Tr0= 1*NBPW
Tr3= 2*NBPW // a0
Tr4= 3*NBPW // a1
Tr5= 4*NBPW // a2
Tr6= 5*NBPW // a3
Tr7= 6*NBPW // a4
Tr8= 7*NBPW // a5
Tlr= 8*NBPW
Tctr= 9*NBPW
Tbuf= 10*NBPW
T_FRAME= 10*NBPW + 96
stwu sp,-T_FRAME(sp)
stw r0,Tr0(sp) // SYS_n
stw r3,Tr3(sp) // a0
stw r4,Tr4(sp) // a1
stw r5,Tr5(sp) // a2
stw r6,Tr6(sp) // a3
stw r7,Tr7(sp) // a4
stw r8,Tr8(sp) // a5
mflr r0; stw r0,Tlr(sp)
mfctr r0; stw r0,Tctr(sp)
outp= r3
p_word= r4
Tw= r5
Thex= r6
nib= r7
call get_Thex
la outp,-1+Tbuf(sp) // output ptr (for update)
la p_word,-NBPW+Tr1(sp)
Lword:
lwzu Tw,NBPW(p_word) // next word
call Tword
la r0,NBPW+Tr8(sp)
cmpw r0,p_word; bgt Lword
li r0,' '; call Tflush
lwz r0,Tlr(sp); mtlr r0
lwz r0,Tctr(sp); mtctr r0
lwz r0,Tr0(sp)
lwz a0,Tr3(sp)
lwz a1,Tr4(sp)
lwz a2,Tr5(sp)
lwz a3,Tr6(sp)
lwz a4,Tr7(sp)
lwz a5,Tr8(sp)
#endif //}
sc
bns+ no_fail // 'bns': branch if No Summary[Overflow]
neg a0,a0 // failure: return -errno (always >[unsigned] PAGE_MASK)
no_fail:
#if TRACE //{
stw r0,Tr0(sp) // SYS_n
stw r3,Tr3(sp) // a0
stw r4,Tr4(sp) // a1
stw r5,Tr5(sp) // a2
stw r6,Tr6(sp) // a3
stw r7,Tr7(sp) // a4
stw r8,Tr8(sp) // a5
mflr r0; stw r0,Tlr(sp)
mfctr r0; stw r0,Tctr(sp)
mr Tw,a0 // value from sc
call get_Thex
la outp,-1+Tbuf(sp) // output ptr (for update)
la p_word,NBPW+Tr8(sp); call Tword // one word only
li r0,'\n'; call Tflush
lwz r0, Tlr(sp); mtlr r0
lwz r0,Tctr(sp); mtctr r0
lwz r0,Tr0(sp)
lwz a0,Tr3(sp)
lwz a1,Tr4(sp)
lwz a2,Tr5(sp)
lwz a3,Tr6(sp)
lwz a4,Tr7(sp)
lwz a5,Tr8(sp)
addi sp,sp,T_FRAME
#endif //}
ret
#if TRACE //{
Tword:
li r0,8; mtctr r0 // 8 nibbles per word
li r0,' '; stbu r0,1(outp) // leading punctuation for word
Tnib:
rotlwi Tw,Tw,4; andi. nib,Tw,0xF; add nib,nib,Thex
lbz r0,0(nib)
stbu r0,1(outp)
bdnz Tnib
ret
Tflush:
stbu r0,1(outp) // terminating punctuation
la outp,1(outp) // update adjust
la a1,Tbuf(sp) // in Tflush
subf a2,a1,outp
li a0,FD_STDERR; li r0,SYS_write; sc // write(FD_STDERR, ptr, size)
ret
get_Thex:
mflr r0
call 0f; .asciI "0123456789abcdef"; 0:
mflr Thex
mtlr r0; ret
#endif //}
__NR_memfd_create= 360
MFD_EXEC= 0x10
EINVAL= 22
memfd_create: .globl memfd_create
mflr a3
mflr r0; stwu r0,-2*NBPW(sp)
li a1,MFD_EXEC // modern clue
mfd_try:
call 0f; .asciz "upx"; 0:
mflr a0
SYS_memfd_create= __NR_memfd_create
li r0,SYS_memfd_create; sc; bns+ 0f // success
cmpi cr7,a1,0; bne cr7,1f // not 2nd time
li r0,SYS_memfd_create; call sysgo
cmpi cr7,a0,0; bge cr7,0f // success
cmpi cr6,a1,0; bne cr6,1f // not 2nd time
8:
teq r0,r0 // 2nd error, or unexpected 1st error
teq r3,r3 // 2nd error, or unexpected 1st error
1:
cmpi cr7,a0,EINVAL; bne cr7,8b // unexpected 1st error
cmpi cr7,a0,-EINVAL; bne cr7,8b // unexpected 1st error
li a1,0; b mfd_try // 2nd attempt
0:
mtlr a3
ret
lwz r0,0(sp); la sp,2*NBPW(sp)
mtlr r0; ret
memcpy: .globl memcpy // (dst, src, n)
cmpwi a2,0; beq- 9f

View File

@ -50,19 +50,19 @@ LOAD tmp/powerpc-expand.o
LOAD tmp/powerpc-linux.elf-main2.o
OUTPUT(tmp/powerpc-linux.elf-fold.bin elf32-powerpc)
SYSCALLS 0x0000000000000000 0x100
SYSCALLS 0x0000000000000000 0x100 tmp/powerpc-linux.elf-fold.o
SYSCALLS 0x0000000000000000 0x27c
SYSCALLS 0x0000000000000000 0x27c tmp/powerpc-linux.elf-fold.o
0x0000000000000058 munmap
0x00000000000000b8 memcpy
0x0000000000000234 memcpy
0x0000000000000010 readlink
0x0000000000000018 ftruncate
0x0000000000000060 mmap
0x0000000000000028 write
0x0000000000000074 memfd_create
0x00000000000001e0 memfd_create
0x0000000000000030 read
0x00000000000000dc memset
0x0000000000000258 memset
0x0000000000000050 msync
0x00000000000000f8 my_bkpt
0x0000000000000274 my_bkpt
0x0000000000000000 exit
0x0000000000000008 brk
0x0000000000000040 openat