1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

New version from Jens.

committer: mfx <mfx> 1036855572 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2002-11-09 15:26:12 +00:00
parent 46ae6e1c2a
commit f91849ec4b
3 changed files with 58 additions and 40 deletions

View File

@ -39,15 +39,16 @@ static const
#include "stub/l_ps1.h"
#define MIPS_HI(a) (((a) >> 16) /*+(((a)&0x8000)>>15)*/)
#define MIPS_HI(a) (((a) >> 16) /* + (((a)&0x8000)>>15) */ )
#define MIPS_LO(a) ((a) & 0xffff)
#define MIPS_JP(a) ((0x08 <<24) | (((a) & 0x0fffffff) >> 2))
#define MIPS_JP(a) ((0x08 << 24) | (((a) & 0x0fffffff) >> 2))
#define CHK_ALIGNED(a,b) ((b) - ((a) % (b)))
#define NOCACHE(a) ((a) & 0x1FFFFFFF)
#define PS_HDR_SIZE 2048 // one CD sector in bytes
#define PS_MAX_SIZE 0x1e8000
#define IH_BKUP (10*sizeof(LE32))
#define IH_BKUP (10 * sizeof(LE32))
#define EIGHTBIT
@ -236,10 +237,10 @@ void PackPs1::pack(OutputFile *fo)
pad = ALIGN_UP((cfile_size ? cfile_size : ih.tx_len), 4);
pad_code = CHK_ALIGNED(ph.c_len, 4);
const unsigned decomp_data_start = ih.tx_ptr;
const unsigned decomp_data_start = NOCACHE(ih.tx_ptr);
// set the offset for compressed stuff at the very end of file
const unsigned comp_data_start = (decomp_data_start+pad+overlap)-ph.c_len;
const unsigned comp_data_start = NOCACHE(((decomp_data_start+pad+overlap)-ph.c_len));
if (!opt->ps1.no_align)
// align the packed file to mode 2 data sector size (2048)
@ -248,7 +249,7 @@ void PackPs1::pack(OutputFile *fo)
// no align
pad = 0;
const unsigned entry = comp_data_start - e_len - pad_code;
const unsigned entry = NOCACHE(comp_data_start - e_len - pad_code);
patchPackHeader(loader,lsize);
patch_mips_le32(loader,e_len,"JPEP",MIPS_JP(ih.epc));
if (sa_cnt)
@ -265,9 +266,9 @@ void PackPs1::pack(OutputFile *fo)
patch_mips_le16(loader,e_len,"LS",d_len+s_len);
// set the file load address
oh.tx_ptr = entry-pad;
oh.tx_ptr = entry - pad;
// set the correct file len in header
oh.tx_len = (ph.c_len+e_len+pad+pad_code);
oh.tx_len = ph.c_len + e_len + pad + pad_code;
// set the code entry
oh.epc = entry;

View File

@ -78,6 +78,9 @@ copyloop:
; lui a1,'LH' ; compressed data length
; ori a1,'LL' ; HI and LO !disabled
; __PSXMAINZ__
; =============
; __PSXJSTA0__
lui a2,'OH' ; load DECOMPDATA HI offset
jr a3
@ -113,6 +116,7 @@ copyloop:
#include <mr3k/n2e_d.ash>
; __PSXN2EDZ__
; =============
; __MSETBIG0__
ori a0,zero,'SC' ; amount of removed zero's at eof
@ -121,6 +125,9 @@ copyloop:
; __MSETSML0__
ori a0,zero,'SC' ; amount of removed zero's at eof
; __MSETSMLZ__
; =============
; __MSETALG0__
memset_aligned:
addi a0,-4
@ -136,11 +143,20 @@ memset_unaligned:
bnez a0,memset_unaligned
addiu a2,4
; __MSETUALZ__
; =============
; __PSXEXIT0__
li t2,160 ; flushes
jalr ra,t2 ; instruction
li t1,68 ; cache
do_regs lw ; pop used regs
DW 'JPEP' ; marker for the entry jump
addu sp,at
; __PSXEXITZ__
; =============
; __PSXPHDR0__
DB 85,80,88,33 ; 0 UPX_MAGIC_LE32
; another magic for PackHeader::putPackHeader

View File

@ -1,4 +1,4 @@
/* l_ps1.h -- created from l_ps1.bin, 1578 (0x62a) bytes
/* l_ps1.h -- created from l_ps1.bin, 1590 (0x636) bytes
This file is part of the UPX executable compressor.
@ -26,10 +26,10 @@
*/
#define NRV_LOADER_ADLER32 0x3513513d
#define NRV_LOADER_CRC32 0x768dc7a3
#define NRV_LOADER_ADLER32 0x6ad553ee
#define NRV_LOADER_CRC32 0x7be8c655
unsigned char nrv_loader[1578] = {
unsigned char nrv_loader[1590] = {
83, 76, 1, 36, 34,232,161, 3, 0, 0,161,175, 4, 0,164,175, /* 0x 0 */
8, 0,165,175, 12, 0,166,175, 16, 0,167,175, 20, 0,162,175, /* 0x 10 */
24, 0,163,175, 28, 0,191,175,224,255, 36, 36, 32, 0,167, 39, /* 0x 20 */
@ -101,32 +101,33 @@ unsigned char nrv_loader[1578] = {
1, 0, 66, 48, 67, 83, 4, 52,192, 32, 4, 0, 67, 83, 4, 52, /* 0x 440 */
252,255,132, 32, 0, 0,192,172,253,255,128, 20, 4, 0,198, 36, /* 0x 450 */
252,255,132, 32, 3, 0,192,168, 0, 0,192,184,252,255,128, 20, /* 0x 460 */
4, 0,198, 36, 0, 0,161,143, 4, 0,164,143, 8, 0,165,143, /* 0x 470 */
12, 0,166,143, 16, 0,167,143, 20, 0,162,143, 24, 0,163,143, /* 0x 480 */
28, 0,191,143, 80, 69, 80, 74, 33,232,161, 3, 85, 80, 88, 33, /* 0x 490 */
161,216,208,213, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 4a0 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 80, 83, 88, 80, /* 0x 4b0 */
82, 69, 80, 48, 0, 0, 0, 0, 80, 83, 88, 80, 82, 69, 80, 90, /* 0x 4c0 */
8, 0, 0, 0, 80, 83, 88, 83, 84, 83, 90, 48, 8, 0, 0, 0, /* 0x 4d0 */
80, 83, 88, 83, 84, 83, 90, 90, 40, 0, 0, 0, 80, 83, 88, 77, /* 0x 4e0 */
65, 73, 78, 48, 40, 0, 0, 0, 80, 83, 88, 77, 65, 73, 78, 90, /* 0x 4f0 */
92, 0, 0, 0, 80, 83, 88, 74, 83, 84, 65, 48, 92, 0, 0, 0, /* 0x 500 */
80, 83, 88, 74, 83, 84, 65, 90,104, 0, 0, 0, 80, 83, 88, 74, /* 0x 510 */
83, 84, 72, 48,104, 0, 0, 0, 80, 83, 88, 74, 83, 84, 72, 90, /* 0x 520 */
112, 0, 0, 0, 80, 83, 88, 68, 69, 67, 79, 48,112, 0, 0, 0, /* 0x 530 */
80, 83, 88, 68, 69, 67, 79, 90,112, 0, 0, 0, 80, 83, 88, 78, /* 0x 540 */
50, 66, 68, 48,112, 0, 0, 0, 80, 83, 88, 78, 50, 66, 68, 90, /* 0x 550 */
148, 1, 0, 0, 80, 83, 88, 78, 50, 68, 68, 48,148, 1, 0, 0, /* 0x 560 */
80, 83, 88, 78, 50, 68, 68, 90,220, 2, 0, 0, 80, 83, 88, 78, /* 0x 570 */
50, 69, 68, 48,220, 2, 0, 0, 80, 83, 88, 78, 50, 69, 68, 90, /* 0x 580 */
68, 4, 0, 0, 77, 83, 69, 84, 66, 73, 71, 48, 68, 4, 0, 0, /* 0x 590 */
77, 83, 69, 84, 66, 73, 71, 90, 76, 4, 0, 0, 77, 83, 69, 84, /* 0x 5a0 */
83, 77, 76, 48, 76, 4, 0, 0, 77, 83, 69, 84, 83, 77, 76, 90, /* 0x 5b0 */
80, 4, 0, 0, 77, 83, 69, 84, 65, 76, 71, 48, 80, 4, 0, 0, /* 0x 5c0 */
77, 83, 69, 84, 65, 76, 71, 90, 96, 4, 0, 0, 77, 83, 69, 84, /* 0x 5d0 */
85, 65, 76, 48, 96, 4, 0, 0, 77, 83, 69, 84, 85, 65, 76, 90, /* 0x 5e0 */
116, 4, 0, 0, 80, 83, 88, 69, 88, 73, 84, 48,116, 4, 0, 0, /* 0x 5f0 */
80, 83, 88, 69, 88, 73, 84, 90,156, 4, 0, 0, 80, 83, 88, 80, /* 0x 600 */
72, 68, 82, 48,156, 4, 0, 0, 80, 83, 88, 80, 72, 68, 82, 90, /* 0x 610 */
188, 4, 0, 0,255,255,255,255,188, 4 /* 0x 620 */
4, 0,198, 36,160, 0, 10, 36, 9,248, 64, 1, 68, 0, 9, 36, /* 0x 470 */
0, 0,161,143, 4, 0,164,143, 8, 0,165,143, 12, 0,166,143, /* 0x 480 */
16, 0,167,143, 20, 0,162,143, 24, 0,163,143, 28, 0,191,143, /* 0x 490 */
80, 69, 80, 74, 33,232,161, 3, 85, 80, 88, 33,161,216,208,213, /* 0x 4a0 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 4b0 */
0, 0, 0, 0, 0, 0, 0, 45, 80, 83, 88, 80, 82, 69, 80, 48, /* 0x 4c0 */
0, 0, 0, 0, 80, 83, 88, 80, 82, 69, 80, 90, 8, 0, 0, 0, /* 0x 4d0 */
80, 83, 88, 83, 84, 83, 90, 48, 8, 0, 0, 0, 80, 83, 88, 83, /* 0x 4e0 */
84, 83, 90, 90, 40, 0, 0, 0, 80, 83, 88, 77, 65, 73, 78, 48, /* 0x 4f0 */
40, 0, 0, 0, 80, 83, 88, 77, 65, 73, 78, 90, 92, 0, 0, 0, /* 0x 500 */
80, 83, 88, 74, 83, 84, 65, 48, 92, 0, 0, 0, 80, 83, 88, 74, /* 0x 510 */
83, 84, 65, 90,104, 0, 0, 0, 80, 83, 88, 74, 83, 84, 72, 48, /* 0x 520 */
104, 0, 0, 0, 80, 83, 88, 74, 83, 84, 72, 90,112, 0, 0, 0, /* 0x 530 */
80, 83, 88, 68, 69, 67, 79, 48,112, 0, 0, 0, 80, 83, 88, 68, /* 0x 540 */
69, 67, 79, 90,112, 0, 0, 0, 80, 83, 88, 78, 50, 66, 68, 48, /* 0x 550 */
112, 0, 0, 0, 80, 83, 88, 78, 50, 66, 68, 90,148, 1, 0, 0, /* 0x 560 */
80, 83, 88, 78, 50, 68, 68, 48,148, 1, 0, 0, 80, 83, 88, 78, /* 0x 570 */
50, 68, 68, 90,220, 2, 0, 0, 80, 83, 88, 78, 50, 69, 68, 48, /* 0x 580 */
220, 2, 0, 0, 80, 83, 88, 78, 50, 69, 68, 90, 68, 4, 0, 0, /* 0x 590 */
77, 83, 69, 84, 66, 73, 71, 48, 68, 4, 0, 0, 77, 83, 69, 84, /* 0x 5a0 */
66, 73, 71, 90, 76, 4, 0, 0, 77, 83, 69, 84, 83, 77, 76, 48, /* 0x 5b0 */
76, 4, 0, 0, 77, 83, 69, 84, 83, 77, 76, 90, 80, 4, 0, 0, /* 0x 5c0 */
77, 83, 69, 84, 65, 76, 71, 48, 80, 4, 0, 0, 77, 83, 69, 84, /* 0x 5d0 */
65, 76, 71, 90, 96, 4, 0, 0, 77, 83, 69, 84, 85, 65, 76, 48, /* 0x 5e0 */
96, 4, 0, 0, 77, 83, 69, 84, 85, 65, 76, 90,116, 4, 0, 0, /* 0x 5f0 */
80, 83, 88, 69, 88, 73, 84, 48,116, 4, 0, 0, 80, 83, 88, 69, /* 0x 600 */
88, 73, 84, 90,168, 4, 0, 0, 80, 83, 88, 80, 72, 68, 82, 48, /* 0x 610 */
168, 4, 0, 0, 80, 83, 88, 80, 72, 68, 82, 90,200, 4, 0, 0, /* 0x 620 */
255,255,255,255,200, 4 /* 0x 630 */
};