mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
New ps1/exe version from Jens. Needs new asm5900-mfx5.
committer: mfx <mfx> 1034617199 +0000
This commit is contained in:
parent
accbc5d809
commit
fe531960ab
2
TODO
2
TODO
|
@ -6,7 +6,7 @@ UPX TODO list. Last updated 2002-07-16.
|
||||||
|
|
||||||
- resync stub with UPX 1.2 branch
|
- resync stub with UPX 1.2 branch
|
||||||
|
|
||||||
- p_psx.cpp (psx/exe) needs some work
|
- p_ps1.cpp (ps1/exe) needs some work
|
||||||
|
|
||||||
- src/stub/l_lx_elf86.lds does not work with current binutils
|
- src/stub/l_lx_elf86.lds does not work with current binutils
|
||||||
(generates a several MB file)
|
(generates a several MB file)
|
||||||
|
|
10
doc/upx.pod
10
doc/upx.pod
|
@ -13,7 +13,7 @@ B<upx> S<[ I<command> ]> S<[ I<options> ]> I<filename>...
|
||||||
=head1 ABSTRACT
|
=head1 ABSTRACT
|
||||||
|
|
||||||
The Ultimate Packer for eXecutables
|
The Ultimate Packer for eXecutables
|
||||||
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
|
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
|
||||||
Markus F.X.J. Oberhumer, Laszlo Molnar & John F. Reiser
|
Markus F.X.J. Oberhumer, Laszlo Molnar & John F. Reiser
|
||||||
http://wildsau.idv.uni-linz.ac.at/mfx/upx.html
|
http://wildsau.idv.uni-linz.ac.at/mfx/upx.html
|
||||||
http://upx.tsx.org
|
http://upx.tsx.org
|
||||||
|
@ -76,7 +76,7 @@ B<UPX> is a versatile executable packer with the following features:
|
||||||
* linux/386
|
* linux/386
|
||||||
* linux/elf386
|
* linux/elf386
|
||||||
* linux/sh386
|
* linux/sh386
|
||||||
* ps/exe
|
* ps1/exe
|
||||||
* rtm32/pe
|
* rtm32/pe
|
||||||
* tmt/adam
|
* tmt/adam
|
||||||
* vmlinuz/386 [bootable Linux kernel]
|
* vmlinuz/386 [bootable Linux kernel]
|
||||||
|
@ -676,7 +676,7 @@ Extra options available for this executable format:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=head2 NOTES FOR PS/EXE
|
=head2 NOTES FOR PS1/EXE
|
||||||
|
|
||||||
This is the executable format used by the Sony PlayStation (PSone),
|
This is the executable format used by the Sony PlayStation (PSone),
|
||||||
a Mips R3000 based gaming console which is popular since the late '90s.
|
a Mips R3000 based gaming console which is popular since the late '90s.
|
||||||
|
@ -891,6 +891,8 @@ Please report all bugs immediately to the authors.
|
||||||
|
|
||||||
John F. Reiser <jreiser@BitWagon.com>
|
John F. Reiser <jreiser@BitWagon.com>
|
||||||
|
|
||||||
|
Jens Medoch <jssg@users.sourceforge.net>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
=head1 COPYRIGHT
|
||||||
|
@ -901,6 +903,8 @@ Copyright (C) 1996-2001 Laszlo Molnar
|
||||||
|
|
||||||
Copyright (C) 2000-2001 John F. Reiser
|
Copyright (C) 2000-2001 John F. Reiser
|
||||||
|
|
||||||
|
Copyright (C) 2002 Jens Medoch
|
||||||
|
|
||||||
This program may be used freely, and you are welcome to
|
This program may be used freely, and you are welcome to
|
||||||
redistribute it under certain conditions.
|
redistribute it under certain conditions.
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ OBJECTS1 = \
|
||||||
packer$o packerf$o packhead$o packmast$o \
|
packer$o packerf$o packhead$o packmast$o \
|
||||||
p_com$o p_djgpp2$o p_elks$o p_exe$o \
|
p_com$o p_djgpp2$o p_elks$o p_exe$o \
|
||||||
p_lx_elf$o p_lx_exc$o p_lx_sep$o p_lx_sh$o \
|
p_lx_elf$o p_lx_exc$o p_lx_sep$o p_lx_sh$o \
|
||||||
p_psx$o p_sys$o p_tmt$o p_tos$o \
|
p_ps1$o p_sys$o p_tmt$o p_tos$o \
|
||||||
p_unix$o p_vmlinz$o p_w16ne$o p_w32pe$o p_wcle$o
|
p_unix$o p_vmlinz$o p_w16ne$o p_w32pe$o p_wcle$o
|
||||||
|
|
||||||
# no exceptions or RTTI
|
# no exceptions or RTTI
|
||||||
|
|
|
@ -517,7 +517,7 @@ inline void operator delete[](void *p)
|
||||||
#define UPX_F_VMLINUZ_i386 15
|
#define UPX_F_VMLINUZ_i386 15
|
||||||
#define UPX_F_BVMLINUZ_i386 16
|
#define UPX_F_BVMLINUZ_i386 16
|
||||||
#define UPX_F_ELKS_8086 17
|
#define UPX_F_ELKS_8086 17
|
||||||
#define UPX_F_PSX_EXE 18
|
#define UPX_F_PS1_EXE 18
|
||||||
#define UPX_F_ATARI_TOS 129
|
#define UPX_F_ATARI_TOS 129
|
||||||
#define UPX_F_SOLARIS_SPARC 130
|
#define UPX_F_SOLARIS_SPARC 130
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ void show_help(int x)
|
||||||
#endif
|
#endif
|
||||||
#if 1
|
#if 1
|
||||||
fg = con_fg(f,FG_YELLOW);
|
fg = con_fg(f,FG_YELLOW);
|
||||||
con_fprintf(f,"Options for psx/exe:\n");
|
con_fprintf(f,"Options for ps1/exe:\n");
|
||||||
fg = con_fg(f,fg);
|
fg = con_fg(f,fg);
|
||||||
con_fprintf(f,
|
con_fprintf(f,
|
||||||
" --all-methods try all available compression methods\n"
|
" --all-methods try all available compression methods\n"
|
||||||
|
@ -257,7 +257,7 @@ void show_help(int x)
|
||||||
"linux/386, "
|
"linux/386, "
|
||||||
"linux/elf386, "
|
"linux/elf386, "
|
||||||
"linux/sh386, "
|
"linux/sh386, "
|
||||||
"psx/exe, "
|
"ps1/exe, "
|
||||||
"rtm32/pe, "
|
"rtm32/pe, "
|
||||||
"tmt/adam,\n "
|
"tmt/adam,\n "
|
||||||
"vmlinuz/386, "
|
"vmlinuz/386, "
|
||||||
|
@ -346,6 +346,7 @@ void show_version(int x)
|
||||||
fprintf(f,"Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer\n");
|
fprintf(f,"Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer\n");
|
||||||
fprintf(f,"Copyright (C) 1996-2002 Laszlo Molnar\n");
|
fprintf(f,"Copyright (C) 1996-2002 Laszlo Molnar\n");
|
||||||
fprintf(f,"Copyright (C) 2000-2002 John F. Reiser\n");
|
fprintf(f,"Copyright (C) 2000-2002 John F. Reiser\n");
|
||||||
|
fprintf(f,"Copyright (C) 2002 Jens Medoch\n");
|
||||||
fprintf(f,"UPX comes with ABSOLUTELY NO WARRANTY; for details type `%s -L'.\n", progname);
|
fprintf(f,"UPX comes with ABSOLUTELY NO WARRANTY; for details type `%s -L'.\n", progname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -696,7 +696,7 @@ static int do_option(int optc, const char *arg)
|
||||||
opt->unix.ptinterp = true;
|
opt->unix.ptinterp = true;
|
||||||
break;
|
break;
|
||||||
case 670:
|
case 670:
|
||||||
opt->psx.no_align = true;
|
opt->ps1.no_align = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\0':
|
case '\0':
|
||||||
|
@ -813,7 +813,7 @@ static const struct mfx_option longopts[] =
|
||||||
{"compress-icons", 2, 0, 631},
|
{"compress-icons", 2, 0, 631},
|
||||||
{"compress-resources", 2, 0, 632},
|
{"compress-resources", 2, 0, 632},
|
||||||
{"strip-relocs", 2, 0, 633},
|
{"strip-relocs", 2, 0, 633},
|
||||||
// psx/exe
|
// ps1/exe
|
||||||
{"no-align", 0x10, 0, 670},
|
{"no-align", 0x10, 0, 670},
|
||||||
|
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
|
|
|
@ -107,7 +107,7 @@ struct options_t {
|
||||||
} djgpp2;
|
} djgpp2;
|
||||||
struct {
|
struct {
|
||||||
bool no_align;
|
bool no_align;
|
||||||
} psx;
|
} ps1;
|
||||||
struct {
|
struct {
|
||||||
bool split_segments;
|
bool split_segments;
|
||||||
} tos;
|
} tos;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
/* p_psx.cpp --
|
/* p_ps1.cpp --
|
||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2001 Laszlo Molnar
|
Copyright (C) 1996-2001 Laszlo Molnar
|
||||||
|
Copyright (C) 2002 Jens Medoch
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
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
|
and/or modify them under the terms of the GNU General Public License as
|
||||||
|
@ -20,8 +21,11 @@
|
||||||
If not, write to the Free Software Foundation, Inc.,
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
||||||
|
|
||||||
|
Jens Medoch
|
||||||
|
<jssg@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,10 +33,10 @@
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "packer.h"
|
#include "packer.h"
|
||||||
#include "p_psx.h"
|
#include "p_ps1.h"
|
||||||
|
|
||||||
static const
|
static const
|
||||||
#include "stub/l_psx.h"
|
#include "stub/l_ps1.h"
|
||||||
|
|
||||||
|
|
||||||
#define MIPS_HI(a) (((a) >> 16) /*+(((a)&0x8000)>>15)*/)
|
#define MIPS_HI(a) (((a) >> 16) /*+(((a)&0x8000)>>15)*/)
|
||||||
|
@ -44,35 +48,40 @@ static const
|
||||||
#define PS_MAX_SIZE 0x1e8000
|
#define PS_MAX_SIZE 0x1e8000
|
||||||
|
|
||||||
#define IH_BKUP (10*sizeof(LE32))
|
#define IH_BKUP (10*sizeof(LE32))
|
||||||
|
#define EIGHTBIT
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
PackPsx::PackPsx(InputFile *f) :
|
PackPs1::PackPs1(InputFile *f) :
|
||||||
super(f)
|
super(f)
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT(sizeof(psx_exe_t) == 188);
|
COMPILE_TIME_ASSERT(sizeof(ps1_exe_t) == 188);
|
||||||
COMPILE_TIME_ASSERT(IH_BKUP == 40);
|
COMPILE_TIME_ASSERT(IH_BKUP == 40);
|
||||||
|
|
||||||
cfile_size = 0;
|
fdata_size = cfile_size = 0;
|
||||||
scan_count = 0;
|
sa_cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int *PackPsx::getCompressionMethods(int method, int level) const
|
const int *PackPs1::getCompressionMethods(int method, int level) const
|
||||||
{
|
{
|
||||||
|
#ifdef EIGHTBIT
|
||||||
|
return Packer::getDefaultCompressionMethods_8(method, level);
|
||||||
|
#else
|
||||||
return Packer::getDefaultCompressionMethods_LE32(method, level);
|
return Packer::getDefaultCompressionMethods_LE32(method, level);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const int *PackPsx::getFilters() const
|
const int *PackPs1::getFilters() const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// functions for marker handling
|
// functions for marker handling
|
||||||
int PackPsx::patch_mips_le16(void *b, int blen, const void *old, unsigned new_)
|
int PackPs1::patch_mips_le16(void *b, int blen, const void *old, unsigned new_)
|
||||||
{
|
{
|
||||||
unsigned char w[2];
|
unsigned char w[2];
|
||||||
|
|
||||||
|
@ -80,7 +89,7 @@ int PackPsx::patch_mips_le16(void *b, int blen, const void *old, unsigned new_)
|
||||||
return patch_le16(b, blen, &w, new_);
|
return patch_le16(b, blen, &w, new_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PackPsx::patch_mips_le32(void *b, int blen, const void *old, unsigned new_)
|
int PackPs1::patch_mips_le32(void *b, int blen, const void *old, unsigned new_)
|
||||||
{
|
{
|
||||||
unsigned char w[4];
|
unsigned char w[4];
|
||||||
|
|
||||||
|
@ -88,7 +97,7 @@ int PackPsx::patch_mips_le32(void *b, int blen, const void *old, unsigned new_)
|
||||||
return patch_le32(b, blen, &w, new_);
|
return patch_le32(b, blen, &w, new_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PackPsx::patch_hi_lo(void *b, int blen, const void *old_hi, const void *old_lo, unsigned new_)
|
int PackPs1::patch_hi_lo(void *b, int blen, const void *old_hi, const void *old_lo, unsigned new_)
|
||||||
{
|
{
|
||||||
patch_mips_le16(b, blen, old_lo, MIPS_LO(new_));
|
patch_mips_le16(b, blen, old_lo, MIPS_LO(new_));
|
||||||
patch_mips_le16(b, blen, old_hi, MIPS_HI(new_));
|
patch_mips_le16(b, blen, old_hi, MIPS_HI(new_));
|
||||||
|
@ -100,7 +109,7 @@ int PackPsx::patch_hi_lo(void *b, int blen, const void *old_hi, const void *old_
|
||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
bool PackPsx::canPack()
|
bool PackPs1::canPack()
|
||||||
{
|
{
|
||||||
unsigned char buf[256];
|
unsigned char buf[256];
|
||||||
fdata_size = file_size-PS_HDR_SIZE;
|
fdata_size = file_size-PS_HDR_SIZE;
|
||||||
|
@ -130,27 +139,34 @@ bool PackPsx::canPack()
|
||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
int PackPsx::buildLoader(const Filter *)
|
int PackPs1::buildLoader(const Filter *)
|
||||||
{
|
{
|
||||||
initLoader(nrv_loader,sizeof(nrv_loader));
|
initLoader(nrv_loader,sizeof(nrv_loader));
|
||||||
addLoader("PSXMAIN0", "PSXDECO0", NULL);
|
addLoader("PSXPREP0","PSXSTSZ0","PSXMAIN0",
|
||||||
if (ph.method == M_NRV2B_LE32)
|
ih.tx_ptr&0xffff ? "PSXJSTA0" : "PSXJSTH0",
|
||||||
|
"PSXDECO0",
|
||||||
|
NULL);
|
||||||
|
#ifdef EIGHTBIT
|
||||||
|
if (ph.method == M_NRV2B_8)
|
||||||
|
addLoader("PSXN2BD0", NULL);
|
||||||
|
else if (ph.method == M_NRV2D_8)
|
||||||
|
addLoader("PSXN2DD0", NULL);
|
||||||
|
else if (ph.method == M_NRV2E_8)
|
||||||
|
addLoader("PSXN2ED0", NULL);
|
||||||
|
#else
|
||||||
|
if (ph.method == M_NRV2B_LE32)
|
||||||
addLoader("PSXN2BD0", NULL);
|
addLoader("PSXN2BD0", NULL);
|
||||||
else if (ph.method == M_NRV2D_LE32)
|
else if (ph.method == M_NRV2D_LE32)
|
||||||
addLoader("PSXN2DD0", NULL);
|
addLoader("PSXN2DD0", NULL);
|
||||||
|
else if (ph.method == M_NRV2E_LE32)
|
||||||
|
addLoader("PSXN2ED0", NULL);
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
throwInternalError("unknown compression method");
|
throwInternalError("unknown compression method");
|
||||||
if (scan_count)
|
if (sa_cnt)
|
||||||
{
|
addLoader((sa_cnt > 0xfffc) ? "MSETBIG0" : "MSETSML0", // set small/big memset
|
||||||
if (scan_count > 0xfffc)
|
(ih.tx_len & 3) ? "MSETUAL0" : "MSETALG0", // un/aligned memset
|
||||||
addLoader("MSETBIG0", NULL); // set big memset
|
NULL);
|
||||||
else
|
|
||||||
addLoader("MSETSML0", NULL); // set small memset
|
|
||||||
if ((ih.tx_len & 3))
|
|
||||||
addLoader("MSETUAL0", NULL); // unaligned memset
|
|
||||||
else
|
|
||||||
addLoader("MSETALG0", NULL); // aligned memset
|
|
||||||
}
|
|
||||||
addLoader("PSXEXIT0", "IDENTSTR", "PSXPHDR0", NULL);
|
addLoader("PSXEXIT0", "IDENTSTR", "PSXPHDR0", NULL);
|
||||||
return getLoaderSize();
|
return getLoaderSize();
|
||||||
}
|
}
|
||||||
|
@ -160,7 +176,7 @@ int PackPsx::buildLoader(const Filter *)
|
||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
void PackPsx::pack(OutputFile *fo)
|
void PackPs1::pack(OutputFile *fo)
|
||||||
{
|
{
|
||||||
|
|
||||||
ibuf.alloc(fdata_size);
|
ibuf.alloc(fdata_size);
|
||||||
|
@ -173,21 +189,21 @@ void PackPsx::pack(OutputFile *fo)
|
||||||
|
|
||||||
// this scans the end of file for 2048 bytes sector alignment
|
// this scans the end of file for 2048 bytes sector alignment
|
||||||
// this should be padded with zeros
|
// this should be padded with zeros
|
||||||
while (!(*p_scan--)) { if ((scan_count += 1) > (0xfffc<<3)) break; }
|
while (!(*p_scan--)) { if ((sa_cnt += 1) > (0xfffc<<3)) break; }
|
||||||
if (scan_count > 0xfffc)
|
if (sa_cnt > 0xfffc)
|
||||||
scan_count = ALIGN_DOWN(scan_count,8);
|
sa_cnt = ALIGN_DOWN(sa_cnt,8);
|
||||||
else
|
else
|
||||||
scan_count = ALIGN_DOWN(scan_count,4);
|
sa_cnt = ALIGN_DOWN(sa_cnt,4);
|
||||||
|
|
||||||
// prepare packheader
|
// prepare packheader
|
||||||
ph.u_len = (fdata_size - scan_count);
|
ph.u_len = (fdata_size - sa_cnt);
|
||||||
ph.filter = 0;
|
ph.filter = 0;
|
||||||
|
|
||||||
Filter ft(ph.level);
|
Filter ft(ph.level);
|
||||||
// compress (max_match = 65535)
|
// compress (max_match = 65535)
|
||||||
compressWithFilters(&ft, 512, 0, NULL, 0, 65535, 0, 0);
|
compressWithFilters(&ft, 512, 0, NULL, 0, 65535, 0, 0);
|
||||||
|
|
||||||
if (ph.overlap_overhead <= scan_count)
|
if (ph.overlap_overhead <= sa_cnt)
|
||||||
overlap = 0;
|
overlap = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -195,7 +211,7 @@ void PackPsx::pack(OutputFile *fo)
|
||||||
throwCantPack("packed data overlap (try --force)");
|
throwCantPack("packed data overlap (try --force)");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
overlap = ALIGN_UP((ph.overlap_overhead-scan_count),4);
|
overlap = ALIGN_UP((ph.overlap_overhead-sa_cnt),4);
|
||||||
opt->info_mode += !opt->info_mode ? 1 : 0;
|
opt->info_mode += !opt->info_mode ? 1 : 0;
|
||||||
infoWarning("%s will load to a %d bytes higher offset",fi->getName(),overlap);
|
infoWarning("%s will load to a %d bytes higher offset",fi->getName(),overlap);
|
||||||
}
|
}
|
||||||
|
@ -209,6 +225,8 @@ void PackPsx::pack(OutputFile *fo)
|
||||||
const int h_len = lsize-getLoaderSectionStart("IDENTSTR");
|
const int h_len = lsize-getLoaderSectionStart("IDENTSTR");
|
||||||
const int e_len = lsize-h_len;
|
const int e_len = lsize-h_len;
|
||||||
const int d_len = e_len-getLoaderSectionStart("PSXDECO0");
|
const int d_len = e_len-getLoaderSectionStart("PSXDECO0");
|
||||||
|
int s_len;
|
||||||
|
getLoaderSection("PSXSTSZ0",&s_len); // get size of pushed/poped regs
|
||||||
|
|
||||||
MemBuffer loader(lsize);
|
MemBuffer loader(lsize);
|
||||||
memcpy(loader,getLoader(),lsize);
|
memcpy(loader,getLoader(),lsize);
|
||||||
|
@ -224,21 +242,23 @@ void PackPsx::pack(OutputFile *fo)
|
||||||
unsigned comp_data_start = (decomp_data_start+pad)-ph.c_len+(overlap ? overlap : 0);
|
unsigned comp_data_start = (decomp_data_start+pad)-ph.c_len+(overlap ? overlap : 0);
|
||||||
|
|
||||||
pad = 0;
|
pad = 0;
|
||||||
if (!opt->psx.no_align)
|
if (!opt->ps1.no_align)
|
||||||
// align the packed file to mode 2 data sector size (2048)
|
// align the packed file to mode 2 data sector size (2048)
|
||||||
pad = CHK_ALIGNED(ph.c_len+pad_code+e_len, 2048);
|
pad = CHK_ALIGNED(ph.c_len+pad_code+e_len, 2048);
|
||||||
|
|
||||||
const int entry = comp_data_start - e_len - pad_code;
|
const int entry = comp_data_start - e_len - pad_code;
|
||||||
patchPackHeader(loader,lsize);
|
patchPackHeader(loader,lsize);
|
||||||
patch_mips_le32(loader,e_len,"JPEP",MIPS_JP(ih.epc));
|
patch_mips_le32(loader,e_len,"JPEP",MIPS_JP(ih.epc));
|
||||||
if (scan_count)
|
if (sa_cnt)
|
||||||
patch_mips_le16(loader,e_len,"SC",
|
patch_mips_le16(loader,e_len,"SC",
|
||||||
MIPS_LO(scan_count > 0xfffc ? scan_count >> 3 : scan_count));
|
MIPS_LO(sa_cnt > 0xfffc ? sa_cnt >> 3 : sa_cnt));
|
||||||
patch_hi_lo(loader,e_len,"OH","OL",decomp_data_start);
|
if (ih.tx_ptr & 0xffff)
|
||||||
// patch_hi_lo(loader,e_len,"LH","LL",ph.u_len+pad_code+pad);
|
patch_hi_lo(loader,e_len,"OH","OL",decomp_data_start);
|
||||||
|
else
|
||||||
|
patch_mips_le16(loader,e_len,"OH",decomp_data_start>>16);
|
||||||
patch_hi_lo(loader,e_len,"CH","CL",comp_data_start);
|
patch_hi_lo(loader,e_len,"CH","CL",comp_data_start);
|
||||||
patch_hi_lo(loader,e_len,"DH","DL",entry+(e_len-d_len));
|
patch_hi_lo(loader,e_len,"DH","DL",entry+(e_len-d_len));
|
||||||
patch_mips_le16(loader,e_len,"LS",d_len);
|
patch_mips_le16(loader,e_len,"LS",d_len+s_len);
|
||||||
|
|
||||||
// set the file load address
|
// set the file load address
|
||||||
oh.tx_ptr = entry-pad;
|
oh.tx_ptr = entry-pad;
|
||||||
|
@ -277,9 +297,12 @@ void PackPsx::pack(OutputFile *fo)
|
||||||
#if 0
|
#if 0
|
||||||
printf("%-13s: compressed : %8ld bytes\n", getName(), (long) ph.c_len);
|
printf("%-13s: compressed : %8ld bytes\n", getName(), (long) ph.c_len);
|
||||||
printf("%-13s: decompressor : %8ld bytes\n", getName(), (long) e_len);
|
printf("%-13s: decompressor : %8ld bytes\n", getName(), (long) e_len);
|
||||||
printf("%-13s: code entry : %8ld bytes\n", getName(), (long) oh.epc);
|
|
||||||
printf("%-13s: load address : %8ld bytes\n", getName(), (long) oh.tx_ptr);
|
printf("%-13s: code entry :%0X8 bytes\n", getName(), (unsigned int) oh.epc);
|
||||||
|
printf("%-13s: load address :%0X8 bytes\n", getName(), (unsigned int) oh.tx_ptr);
|
||||||
printf("%-13s: section size : %8ld bytes\n", getName(), (long) oh.tx_len);
|
printf("%-13s: section size : %8ld bytes\n", getName(), (long) oh.tx_len);
|
||||||
|
printf("%-13s: eof in mem IF:%0X8 bytes\n", getName(), (unsigned int) ih.tx_ptr+ih.tx_len);
|
||||||
|
printf("%-13s: eof in mem OF:%0X8 bytes\n", getName(), (unsigned int) oh.tx_ptr+oh.tx_len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +311,7 @@ void PackPsx::pack(OutputFile *fo)
|
||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
int PackPsx::canUnpack()
|
int PackPs1::canUnpack()
|
||||||
{
|
{
|
||||||
if (!readPackHeader(0x400))
|
if (!readPackHeader(0x400))
|
||||||
return false;
|
return false;
|
||||||
|
@ -302,7 +325,7 @@ int PackPsx::canUnpack()
|
||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
void PackPsx::unpack(OutputFile *fo)
|
void PackPs1::unpack(OutputFile *fo)
|
||||||
{
|
{
|
||||||
fdata_size = file_size-PS_HDR_SIZE;
|
fdata_size = file_size-PS_HDR_SIZE;
|
||||||
ibuf.alloc(file_size);
|
ibuf.alloc(file_size);
|
|
@ -1,9 +1,10 @@
|
||||||
/* p_psx.cpp --
|
/* p_ps1.h --
|
||||||
|
|
||||||
This file is part of the UPX executable compressor.
|
This file is part of the UPX executable compressor.
|
||||||
|
|
||||||
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
|
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
|
||||||
Copyright (C) 1996-2001 Laszlo Molnar
|
Copyright (C) 1996-2001 Laszlo Molnar
|
||||||
|
Copyright (C) 2002 Jens Medoch
|
||||||
|
|
||||||
UPX and the UCL library are free software; you can redistribute them
|
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
|
and/or modify them under the terms of the GNU General Public License as
|
||||||
|
@ -20,27 +21,30 @@
|
||||||
If not, write to the Free Software Foundation, Inc.,
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
||||||
|
|
||||||
|
Jens Medoch
|
||||||
|
<jssg@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __UPX_P_PSX_H
|
#ifndef __UPX_P_PS1_H
|
||||||
#define __UPX_P_PSX_H
|
#define __UPX_P_PS1_H
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// psx/exe
|
// ps1/exe
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
class PackPsx : public Packer
|
class PackPs1 : public Packer
|
||||||
{
|
{
|
||||||
typedef Packer super;
|
typedef Packer super;
|
||||||
public:
|
public:
|
||||||
PackPsx(InputFile *f);
|
PackPs1(InputFile *f);
|
||||||
virtual int getVersion() const { return 13; }
|
virtual int getVersion() const { return 13; }
|
||||||
virtual int getFormat() const { return UPX_F_PSX_EXE; }
|
virtual int getFormat() const { return UPX_F_PS_EXE; }
|
||||||
virtual const char *getName() const { return "ps/exe"; }
|
virtual const char *getName() const { return "ps1/exe"; }
|
||||||
virtual const int *getCompressionMethods(int method, int level) const;
|
virtual const int *getCompressionMethods(int method, int level) const;
|
||||||
virtual const int *getFilters() const;
|
virtual const int *getFilters() const;
|
||||||
|
|
||||||
|
@ -56,7 +60,7 @@ protected:
|
||||||
virtual int patch_mips_le32(void *b, int blen, const void *old, unsigned new_);
|
virtual int patch_mips_le32(void *b, int blen, const void *old, unsigned new_);
|
||||||
virtual int patch_hi_lo(void *b, int blen, const void *old_hi, const void *old_lo, unsigned new_);
|
virtual int patch_hi_lo(void *b, int blen, const void *old_hi, const void *old_lo, unsigned new_);
|
||||||
|
|
||||||
struct psx_exe_t
|
struct ps1_exe_t
|
||||||
{
|
{
|
||||||
char id[8];
|
char id[8];
|
||||||
LE32 text;
|
LE32 text;
|
||||||
|
@ -86,10 +90,10 @@ protected:
|
||||||
}
|
}
|
||||||
__attribute_packed;
|
__attribute_packed;
|
||||||
|
|
||||||
psx_exe_t ih, oh;
|
ps1_exe_t ih, oh;
|
||||||
|
|
||||||
upx_uint overlap;
|
upx_uint overlap;
|
||||||
upx_uint scan_count;
|
upx_uint sa_cnt;
|
||||||
|
|
||||||
// filesize-PS_HDR_SIZE
|
// filesize-PS_HDR_SIZE
|
||||||
upx_uint fdata_size;
|
upx_uint fdata_size;
|
|
@ -49,7 +49,7 @@
|
||||||
#include "p_w16ne.h"
|
#include "p_w16ne.h"
|
||||||
#include "p_w32pe.h"
|
#include "p_w32pe.h"
|
||||||
#include "p_vmlinz.h"
|
#include "p_vmlinz.h"
|
||||||
#include "p_psx.h"
|
#include "p_ps1.h"
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -214,7 +214,7 @@ static Packer* try_packers(InputFile *f, try_function func)
|
||||||
//
|
//
|
||||||
// psone
|
// psone
|
||||||
//
|
//
|
||||||
if ((p = func(new PackPsx(f),f)) != NULL)
|
if ((p = func(new PackPs1(f),f)) != NULL)
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -15,7 +15,7 @@ l_exe.h
|
||||||
l_lx_elf86.h
|
l_lx_elf86.h
|
||||||
l_lx_exec86.h
|
l_lx_exec86.h
|
||||||
l_lx_sh86.h
|
l_lx_sh86.h
|
||||||
l_psx.h
|
l_ps1.h
|
||||||
l_sys.h
|
l_sys.h
|
||||||
l_t_n2b.h
|
l_t_n2b.h
|
||||||
l_t_n2bs.h
|
l_t_n2bs.h
|
||||||
|
|
|
@ -26,7 +26,7 @@ STUBS = \
|
||||||
l_com.h \
|
l_com.h \
|
||||||
l_djgpp2.h stubify.h \
|
l_djgpp2.h stubify.h \
|
||||||
l_exe.h \
|
l_exe.h \
|
||||||
l_psx.h \
|
l_ps1.h \
|
||||||
l_sys.h \
|
l_sys.h \
|
||||||
l_t_n2b.h l_t_n2bs.h l_t_n2d.h l_t_n2ds.h l_t_n2e.h l_t_n2es.h \
|
l_t_n2b.h l_t_n2bs.h l_t_n2d.h l_t_n2ds.h l_t_n2e.h l_t_n2es.h \
|
||||||
l_tmt.h \
|
l_tmt.h \
|
||||||
|
@ -108,8 +108,11 @@ ASM_M68K = sh $(srcdir)/scripts/asl_m68k.sh
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# MIPS R3000
|
# MIPS R3000
|
||||||
|
CPP_MR3K = gcc -I$(UCL_UPX) -I$(srcdir) -E -x assembler-with-cpp -Wall -Wp,-P,-C,-traditional
|
||||||
APP_MR3K = perl -w $(srcdir)/scripts/app_mr3k.pl
|
APP_MR3K = perl -w $(srcdir)/scripts/app_mr3k.pl
|
||||||
ASM_MR3K = asm5900 --nologo -q -I$(UCL_UPX) -I$(srcdir)
|
ASM_MR3K = asm5900 --nologo -q
|
||||||
|
#APP_MR3K = perl -w $(srcdir)/scripts/app_mr3k.pl
|
||||||
|
#ASM_MR3K = asm5900 --nologo -q -I$(UCL_UPX) -I$(srcdir)
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
|
@ -271,6 +274,17 @@ l_t_x2ds.h: l_tos2.s
|
||||||
$(BIN2H) $T.bin nrv2d_loader_small $@
|
$(BIN2H) $T.bin nrv2d_loader_small $@
|
||||||
|
|
||||||
|
|
||||||
|
# /***********************************************************************
|
||||||
|
# // ps1/exe
|
||||||
|
# ************************************************************************/
|
||||||
|
|
||||||
|
l_ps1.h: l_ps1.asm
|
||||||
|
$(CPP_MR3K) -o $T.asx $<
|
||||||
|
$(APP_MR3K) $T.asx $T.asy
|
||||||
|
$(ASM_MR3K) $T.asy -o$T.bin -l$T.lst
|
||||||
|
$(BIN2H) $T.bin nrv_loader $@
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
# // linux rules (exec, elf, sh, sep)
|
# // linux rules (exec, elf, sh, sep)
|
||||||
# ************************************************************************/
|
# ************************************************************************/
|
||||||
|
@ -344,16 +358,6 @@ upxd: l_lx_sep.o l_lx_sep86.asm
|
||||||
$(BRANDELF) $@
|
$(BRANDELF) $@
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
|
||||||
# // psx/exe
|
|
||||||
# ************************************************************************/
|
|
||||||
|
|
||||||
l_psx.h: l_psx.asm
|
|
||||||
$(APP_MR3K) $< $T.asx
|
|
||||||
$(ASM_MR3K) $T.asx -o$T.bin -l$T.lst
|
|
||||||
$(BIN2H) $T.bin nrv_loader $@
|
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
# // dependencies
|
# // dependencies
|
||||||
# ************************************************************************/
|
# ************************************************************************/
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
; l_psx.asm -- psx/exe program entry & decompressor
|
; l_ps1.asm -- ps1/exe program entry & decompressor
|
||||||
;
|
;
|
||||||
; This file is part of the UPX executable compressor.
|
; This file is part of the UPX executable compressor.
|
||||||
;
|
;
|
||||||
; Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
|
; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
|
||||||
; Copyright (C) 1996-2002 Laszlo Molnar
|
; Copyright (C) 1996-2001 Laszlo Molnar
|
||||||
|
; Copyright (C) 2002 Jens Medoch
|
||||||
|
; All Rights Reserved.
|
||||||
;
|
;
|
||||||
; UPX and the UCL library are free software; you can redistribute them
|
; 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
|
; and/or modify them under the terms of the GNU General Public License as
|
||||||
|
@ -23,9 +25,25 @@
|
||||||
; Markus F.X.J. Oberhumer Laszlo Molnar
|
; Markus F.X.J. Oberhumer Laszlo Molnar
|
||||||
; <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
; <mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
||||||
;
|
;
|
||||||
; psOne r3k v1.2 by ssg
|
; Jens Medoch
|
||||||
|
; <jssg@users.sourceforge.net>
|
||||||
|
;
|
||||||
|
|
||||||
INCLUDE "mr3k/macros.asm"
|
|
||||||
|
#include "mr3k/macros.ash"
|
||||||
|
|
||||||
|
do_regs MACRO _w
|
||||||
|
_w at,0(sp)
|
||||||
|
_w a0,4(sp)
|
||||||
|
_w a1,8(sp)
|
||||||
|
_w a2,12(sp)
|
||||||
|
_w a3,16(sp)
|
||||||
|
_w v0,20(sp)
|
||||||
|
_w v1,24(sp)
|
||||||
|
_w ra,28(sp)
|
||||||
|
do_regs ENDM
|
||||||
|
|
||||||
|
DEFINE REG_SZ = (8*4)
|
||||||
|
|
||||||
ORG 0
|
ORG 0
|
||||||
|
|
||||||
|
@ -33,56 +51,67 @@ INCLUDE "mr3k/macros.asm"
|
||||||
; ============= ENTRY POINT
|
; ============= ENTRY POINT
|
||||||
; =============
|
; =============
|
||||||
|
|
||||||
; __PSXMAIN0__
|
|
||||||
entry:
|
entry:
|
||||||
|
; __PSXPREP0__ ; needed by packer to calc the LS value
|
||||||
addiu at,zero,'LS' ; size of decomp. routine
|
addiu at,zero,'LS' ; size of decomp. routine
|
||||||
sub sp,at ; adjust the stack with this size
|
sub sp,at ; adjust the stack with this size
|
||||||
addi sp,-(8*4)
|
; __PSXPREPZ__ ; needed by packer to calc the LS value
|
||||||
sw at,0(sp)
|
; __PSXSTSZ0__ ; needed by packer to calc the LS value
|
||||||
sw a0,4(sp)
|
do_regs sw ; push used regs
|
||||||
sw a1,8(sp)
|
; __PSXSTSZZ__
|
||||||
sw a2,12(sp)
|
; __PSXMAIN0__
|
||||||
sw a3,16(sp)
|
subiu a0,at,REG_SZ ; a0 = counter copyloop
|
||||||
sw v0,20(sp)
|
addiu a3,sp,REG_SZ ; get offset for decomp. routine
|
||||||
sw v1,24(sp)
|
|
||||||
sw ra,28(sp)
|
|
||||||
move a0,at
|
|
||||||
lui a2,'DH' ; load DECOMPRESSION HI offset
|
|
||||||
ori a2,'DL' ; and the LO part
|
|
||||||
addiu a3,sp,(8*4)
|
|
||||||
move a1,a3
|
move a1,a3
|
||||||
|
lui a2,'DH' ; load decomp routine HI offset
|
||||||
|
ori a2,'DL' ; and the LO offset
|
||||||
copyloop:
|
copyloop:
|
||||||
|
addi a0,-4
|
||||||
lw at,0(a2) ; memcpy *a2 -> at -> *a1
|
lw at,0(a2) ; memcpy *a2 -> at -> *a1
|
||||||
addiu a2,4
|
addiu a2,4
|
||||||
addi a0,-4
|
|
||||||
sw at,0(a1)
|
sw at,0(a1)
|
||||||
bnez a0,copyloop
|
bnez a0,copyloop
|
||||||
addiu a1,4
|
addiu a1,4
|
||||||
|
|
||||||
lui a0,'CH' ; load COMPDATA HI offset
|
lui a0,'CH' ; load COMPDATA HI offset
|
||||||
ori a0,'CL' ; and the LO part
|
ori a0,'CL' ; and the LO part
|
||||||
; lui a1,'LH' ; length of compressed data
|
; lui a1,'LH' ; compressed data length
|
||||||
; ori a1,'LL' ; HI and LO, but disabled
|
; ori a1,'LL' ; HI and LO !disabled
|
||||||
|
; __PSXMAINZ__
|
||||||
|
; __PSXJSTA0__
|
||||||
lui a2,'OH' ; load DECOMPDATA HI offset
|
lui a2,'OH' ; load DECOMPDATA HI offset
|
||||||
jr a3
|
jr a3
|
||||||
ori a2,'OL' ; load DECOMPDATA LO offset
|
ori a2,'OL' ; load DECOMPDATA LO offset
|
||||||
; __PSXMAINZ__
|
; __PSXJSTAZ__
|
||||||
|
; __PSXJSTH0__
|
||||||
|
jr a3 ;
|
||||||
|
lui a2,'OH' ; same for HI only !(offset&0xffff)
|
||||||
|
; __PSXJSTHZ__
|
||||||
|
|
||||||
; =============
|
; =============
|
||||||
; ============= DECOMPRESSION
|
; ============= DECOMPRESSION
|
||||||
; =============
|
; =============
|
||||||
|
#if 1
|
||||||
|
# define NRV_BB 8
|
||||||
|
#else
|
||||||
|
# define NRV_BB 32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
# define SMALL
|
||||||
|
#endif
|
||||||
|
|
||||||
; __PSXDECO0__
|
; __PSXDECO0__
|
||||||
; __PSXDECOZ__
|
; __PSXDECOZ__
|
||||||
; __PSXN2BD0__
|
; __PSXN2BD0__
|
||||||
INCLUDE "mr3k/n2b_d32.asm"
|
#include "mr3k/n2b_d.ash"
|
||||||
; __PSXN2BDZ__
|
; __PSXN2BDZ__
|
||||||
; __PSXN2DD0__
|
; __PSXN2DD0__
|
||||||
INCLUDE "mr3k/n2d_d32.asm"
|
#include "mr3k/n2d_d.ash"
|
||||||
; __PSXN2DDZ__
|
; __PSXN2DDZ__
|
||||||
; ;_PSXN2ED0__
|
; __PSXN2ED0__
|
||||||
; ;;;;;INCLUDE "mr3k/n2e_d32.asm"
|
#include "mr3k/n2e_d.ash"
|
||||||
; ;_PSXN2EDZ__
|
; __PSXN2EDZ__
|
||||||
|
|
||||||
|
|
||||||
; __MSETBIG0__
|
; __MSETBIG0__
|
||||||
|
@ -108,15 +137,7 @@ memset_unaligned:
|
||||||
addiu a2,4
|
addiu a2,4
|
||||||
; __MSETUALZ__
|
; __MSETUALZ__
|
||||||
; __PSXEXIT0__
|
; __PSXEXIT0__
|
||||||
lw a0,4(sp)
|
do_regs lw ; pop used regs
|
||||||
lw a1,8(sp)
|
|
||||||
lw a2,12(sp)
|
|
||||||
lw a3,16(sp)
|
|
||||||
lw v0,20(sp)
|
|
||||||
lw v1,24(sp)
|
|
||||||
lw ra,28(sp)
|
|
||||||
lw at,0(sp)
|
|
||||||
addiu sp,(8*4)
|
|
||||||
DW 'JPEP' ; marker for the entry jump
|
DW 'JPEP' ; marker for the entry jump
|
||||||
addu sp,at
|
addu sp,at
|
||||||
; __PSXEXITZ__
|
; __PSXEXITZ__
|
|
@ -1,4 +1,4 @@
|
||||||
#define UPX_VERSION_HEX 0x019001 /* 01.90.01 */
|
#define UPX_VERSION_HEX 0x019001 /* 01.90.01 */
|
||||||
#define UPX_VERSION_STRING "1.90.1"
|
#define UPX_VERSION_STRING "1.90.1"
|
||||||
#define UPX_VERSION_STRING4 "1.90"
|
#define UPX_VERSION_STRING4 "1.90"
|
||||||
#define UPX_VERSION_DATE "Sep 12th 2002"
|
#define UPX_VERSION_DATE "Oct 14th 2002"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user