Checked in psx/exe patches from Jens.

committer: mfx <mfx> 1026820270 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2002-07-16 11:51:10 +00:00
parent ead8daf26c
commit 789cfea682
16 changed files with 739 additions and 11 deletions

View File

@ -3,7 +3,7 @@ SHELL = /bin/sh
top_srcdir = ..
PACKAGE = upx
VERSION_DATE = 04 Jan 2001
VERSION_DATE = 16 Jul 2002
VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h)
TRIMSPACE = cat

View File

@ -63,6 +63,7 @@ OBJECTS1 = \
packer$o packerf$o packhead$o packmast$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_psx$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

View File

@ -511,6 +511,9 @@ struct options_t {
struct {
bool coff;
} djgpp2;
struct {
unsigned no_align;
} psx;
struct {
bool split_segments;
} tos;

View File

@ -191,6 +191,15 @@ void show_help(int x)
" --script=/path/upxX use path/upxX as decompressor\n"
"\n");
#endif
#if 1
fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"Options for psx/exe:\n");
fg = con_fg(f,fg);
con_fprintf(f,
" --all-methods try all available compression methods\n"
" --no-align don't align to mode2 sector format\n"
"\n");
#endif
#if 1
fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"Options for tmt/adam:\n");
@ -249,13 +258,14 @@ void show_help(int x)
"linux/386, "
"linux/elf386, "
"linux/sh386, "
"psx/exe, "
"rtm32/pe, "
"tmt/adam, "
"vmlinuz/386,\n "
"tmt/adam,\n "
"vmlinuz/386, "
"watcom/le, "
//"win16/ne, "
"win32/pe"
"\n\nUPX comes with ABSOLUTELY NO WARRANTY; for details visit http://upx.tsx.org\n"
"\n\nUPX comes with ABSOLUTELY NO WARRANTY; for details visit http://upx.sf.net\n"
//"\n\nUPX comes with ABSOLUTELY NO WARRANTY; for details type `upx -L'.\n"
"");

View File

@ -674,6 +674,9 @@ static int do_option(int optc, const char *arg)
if (mfx_optarg && mfx_optarg[0])
set_script_name(mfx_optarg,1);
break;
case 670:
opt->psx.no_align = true;
break;
case '\0':
return -1;
@ -788,6 +791,8 @@ static const struct mfx_option longopts[] =
{"compress-icons", 2, 0, 631},
{"compress-resources", 2, 0, 632},
{"strip-relocs", 2, 0, 633},
// psx/exe
{"no-align", 0x10, 0, 670},
{ 0, 0, 0, 0 }
};

318
src/p_psx.cpp Normal file
View File

@ -0,0 +1,318 @@
/* p_psx.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2001 Laszlo Molnar
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
markus.oberhumer@jk.uni-linz.ac.at ml1050@cdata.tvnet.hu
*/
#include "conf.h"
#include "file.h"
#include "filter.h"
#include "packer.h"
#include "p_psx.h"
#include "version.h"
static const
#include "stub/l_psx.h"
//#define TESTING
/*************************************************************************
//
**************************************************************************/
const int *PackPsx::getCompressionMethods(int method, int level) const
{
static const int m_nrv2b[] = { M_NRV2B_LE32, M_NRV2D_LE32, -1 };
static const int m_nrv2d[] = { M_NRV2D_LE32, M_NRV2B_LE32, -1 };
if (M_IS_NRV2B(method))
return m_nrv2b;
if (M_IS_NRV2D(method))
return m_nrv2d;
if (level == 1 || file_size-PS_HDR_SIZE < 512*1024)
return m_nrv2b;
return m_nrv2d;
}
const int *PackPsx::getFilters() const
{
return NULL;
}
/*************************************************************************
//
**************************************************************************/
bool PackPsx::canPack()
{
right_file_size = 0;
file_data_size = file_size-PS_HDR_SIZE;
fi->seek(0, SEEK_SET);
fi->readx(&ih, sizeof(ih));
if ((memcmp(&ih.id,"PS-X EXE",8) != 0) && (memcmp(&ih.id,"EXE X-SP",8) != 0))
return false;
checkAlreadyPacked(&ih, sizeof(ih));
if (file_data_size != ih.tx_len || (ih.tx_len & 3))
if (!opt->force)
throwCantPack("check header for file size (try --force)");
else
right_file_size = file_data_size;
if (file_size <= (PS_HDR_SIZE*3) && !opt->force)
throwCantPack("file is too small");
if (file_size > PS_MAX_SIZE && !opt->force)
throwCantPack("file is too big (try --force)");
// i_hdrp = 0;
return true;
}
/*************************************************************************
//
**************************************************************************/
int PackPsx::buildLoader(const Filter *)
{
initLoader(nrv_loader,sizeof(nrv_loader));
addLoader("PSXMAIN0", "PSXDECO0", NULL);
if (M_IS_NRV2B(ph.method))
addLoader("PSXN2BD0", NULL);
else if (M_IS_NRV2D(ph.method))
addLoader("PSXN2DD0", NULL);
else
throwBadLoader();
if (scan_count)
addLoader("PSXMSET0", NULL);
addLoader("PSXEXIT0""PSXPHDR0", NULL);
return getLoaderSize();
}
/*************************************************************************
//
**************************************************************************/
void PackPsx::pack(OutputFile *fo)
{
ibuf.alloc(file_size);
obuf.allocForCompression(file_data_size);
upx_byte *p_scan = ibuf+(file_size-1);
// read file
fi->seek(0,SEEK_SET);
fi->readx(ibuf, file_size);
// this scans the end of file for the 2048 bytes sector alignment
// this should be padded with zeros
scan_count = 0;
while (!(*p_scan--)) { if ((scan_count += 1) > (0xfffc<<3)) break; }
scan_count = ALIGN_DOWN(scan_count,8);
// prepare packheader
ph.u_len = (file_data_size - scan_count);
ph.filter = 0;
Filter ft(ph.level);
// compress (max_match = 65535)
compressWithFilters(&ft, 512, 0, NULL, 0, 65535, 0, PS_HDR_SIZE);
if (ph.overlap_overhead <= scan_count)
overlap = 0;
else
{
overlap = ALIGN_UP((ph.overlap_overhead-scan_count),4);
if (!opt->force)
throwCantPack("packed data overlap (try --force)");
else
{
opt->info_mode += !opt->info_mode ? 1 : 0;
infoWarning("%s will load to a %d bytes higher offset",fi->getName(),overlap);
}
}
memcpy(&oh, &ih, sizeof(&ih));
// oki_hdrp->upx_hdr.hdr_adler = upx_adler32(&i_hdrp->exec,sizeof(exec_hdr_t));
const int lsize = getLoaderSize();
const int h_len = lsize-getLoaderSectionStart("PSXPHDR0");
const int e_len = lsize-h_len;
const int d_len = e_len-getLoaderSectionStart("PSXDECO0");
upx_uint pad_code = 0;
upx_uint pad = 0;
MemBuffer loader(lsize);
memcpy(loader,getLoader(),lsize);
pad = !right_file_size ? ih.tx_len : right_file_size;
pad = ALIGN_DOWN(pad,4);
pad_code = CHK_ALIGNED((ph.c_len),4);
upx_uint decomp_data_start = ih.tx_ptr;
// set the offset for compressed stuff at the very end of file
upx_uint comp_data_start = (decomp_data_start+pad)-ph.c_len+(overlap ? overlap : 0);
pad = 0; //clear pad, because of temp use
// align the packed file to mode 2 data sector size (2048)
if (!opt->psx.no_align)
pad = CHK_ALIGNED((ph.c_len+pad_code+e_len),2048);
int entry = (comp_data_start-e_len-pad_code);
patch_mips_le32(loader,e_len,"JPEP",MIPS_JP(ih.epc));
if (scan_count)
patch_mips_le16(loader,e_len,"SC",MIPS_LO(scan_count>>3));
patch_hi_lo(loader,e_len,"OH","OL",decomp_data_start);
// patch_hi_lo(loader,e_len,"LH","LL",ph.u_len+pad_code+pad);
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_mips_le16(loader,e_len,"LS",d_len);
// set the file load address
oh.tx_ptr = entry-pad;
// set the correct file len in header
oh.tx_len = (ph.c_len+e_len+pad+pad_code);
// set the code entry
oh.epc = entry;
// build upx header
// memcpy(&i_hdrp->upx_hdr.id,UPX_VERSION_STRING,sizeof(UPX_VERSION_STRING));
// memcpy(&i_hdrp->upx_hdr.ph_hdr,loader+e_len,h_len);
// patchPackHeader(&i_hdrp->upx_hdr,PS_HDR_SIZE);
// write loader + compressed file
fo->write(ibuf,PS_HDR_SIZE);
// clear ibuf to get padding data (0)
upx_bytep paddata = ibuf+PS_HDR_SIZE;
memset(paddata,0,file_data_size);
// align the file (mode 2 sector data size)
if (pad)
fo->write(paddata,pad);
// entry
fo->write(loader,e_len);
// align the compressed data for the mips runtime code
if (pad_code)
fo->write(paddata,pad_code);
fo->write(obuf,ph.c_len);
#if 0
printf("%-13s: compressed : %8ld bytes\n", getName(), (long) ph.c_len);
printf("%-13s: decompressor : %8ld bytes\n", getName(), (long) e_len);
#endif
}
/*************************************************************************
//
**************************************************************************/
int PackPsx::canUnpack()
{
// FIXME: set ih
if (!readPackHeader(sizeof(ih)))
return false;
if (file_size <= (off_t) ph.c_len)
return false;
return true;
}
/*************************************************************************
//
**************************************************************************/
void PackPsx::unpack(OutputFile *fo)
{
ibuf.alloc(file_size);
// i_hdrp = (ps_x_exe_t*)ibuf.getBuf();
// read the file header
fi->seek(0x0,SEEK_SET);
// and the remaining stuff
fi->readx(ibuf,file_size);
#if 0
// test & restore orig exec hdr
if (i_hdrp->upx_hdr.hdr_adler != upx_adler32(&i_hdrp->upx_hdr.exec_bkup,sizeof(exec_hdr_t)))
throwCantUnpack("file is possibly modified/hacked/protected; take care!");
memcpy(&i_hdrp->exec,&i_hdrp->upx_hdr.exec_bkup,sizeof(exec_hdr_t));
upx_uint pad = (i_hdrp->exec.tx_len)-ph.u_len;
memset(&i_hdrp->upx_hdr,0,sizeof(upx_hdr_t));
obuf.allocForUncompression(ph.u_len+pad);
memset(obuf,0,obuf.getSize());
#endif
// decompress
decompress(ibuf+(file_size-ph.c_len),obuf);
// write decompressed file
if (fo)
{
fo->write(ibuf,PS_HDR_SIZE);
// fo->write(obuf,ph.u_len+pad);
}
}
// functions for marker handling
int PackPsx::patch_mips_le16(void *b, int blen, const void *old, unsigned new_)
{
unsigned char w[2];
set_le16(&w,get_be16(old));
return patch_le16(b, blen, &w, new_);
}
int PackPsx::patch_mips_le32(void *b, int blen, const void *old, unsigned new_)
{
unsigned char w[4];
set_le32(&w,get_be32(old));
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_)
{
patch_mips_le16(b, blen, old_lo, MIPS_LO(new_));
patch_mips_le16(b, blen, old_hi, MIPS_HI(new_));
return 1;
}
/*
vi:ts=4:et:nowrap
*/

123
src/p_psx.h Normal file
View File

@ -0,0 +1,123 @@
/* p_psx.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2001 Laszlo Molnar
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
markus.oberhumer@jk.uni-linz.ac.at ml1050@cdata.tvnet.hu
*/
#ifndef __UPX_P_PSX_H
#define __UPX_P_PSX_H
#include "version.h"
#define MIPS_HI(a) (((a)>>16)/*+((a&0x8000)>>15)*/)
#define MIPS_LO(a) (a&0xffff)
#define MIPS_JP(a) ((0x08<<24)|((a&0xfffffff)>>2))
#define CHK_ALIGNED(a,b) (b-(a%b))
#define PS_HDR_SIZE 2048 //one cd sector in bytes
#define PS_HDR 16
#define HDR_SIZE (sizeof(p_hdr_t))
#define VERSION_ID (sizeof(UPX_VERSION_STRING))
#define PS_MAX_SIZE 0x1e8000
/*************************************************************************
// psx/exe
**************************************************************************/
class PackPsx : public Packer
{
typedef Packer super;
public:
PackPsx(InputFile *f) : super(f) { }
virtual int getVersion() const { return 11; }
virtual int getFormat() const { return UPX_F_PSX_EXE; }
virtual const char *getName() const { return "psx/exe"; }
virtual const int *getCompressionMethods(int method, int level) const;
virtual const int *getFilters() const;
virtual void pack(OutputFile *fo);
virtual void unpack(OutputFile *fo);
virtual bool canPack();
virtual int canUnpack();
protected:
virtual int buildLoader(const Filter *ft);
virtual int patch_mips_le16(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_);
#if 0
typedef struct
{
upx_byte id[VERSION_ID];
upx_byte ph_hdr[32];
LE32 hdr_adler;
exec_hdr_t exec_bkup;
}
upx_hdr_t;
#endif
struct psx_exe_t
{
char id[8];
LE32 text;
LE32 data;
LE32 epc;
LE32 gp;
LE32 tx_ptr;
LE32 tx_len;
LE32 da_ptr;
LE32 da_len;
LE32 bs_ptr;
LE32 bs_len;
LE32 sd_ptr;
LE32 sd_len;
LE32 sp,fp,gp0,ra,k0;
char origin[60];
char pad[14];
};
struct psx_exe_t ih, oh;
upx_uint overlap;
upx_uint scan_count;
upx_uint file_data_size;
upx_uint right_file_size;
MemBuffer pad_data;
};
#endif /* already included */
/*
vi:ts=4:et
*/

View File

@ -49,6 +49,7 @@
#include "p_w16ne.h"
#include "p_w32pe.h"
#include "p_vmlinz.h"
#include "p_psx.h"
/*************************************************************************
@ -210,6 +211,12 @@ static Packer* try_packers(InputFile *f, try_function func)
if ((p = func(new PackLinuxI386(f),f)) != NULL)
return p;
//
// psone
//
if ((p = func(new PackPsx(f),f)) != NULL)
return p;
//
// .sys and .com
//

View File

@ -26,6 +26,7 @@ STUBS = \
l_com.h \
l_djgpp2.h stubify.h \
l_exe.h \
l_psx.h \
l_sys.h \
l_t_n2b.h l_t_n2bs.h l_t_n2d.h l_t_n2ds.h \
l_tmt.h \
@ -56,12 +57,14 @@ override T = $(basename $@)
UCL_UPX = $(UCLDIR)/upx
UCL_I386 = $(UCLDIR)/upx/i386
UCL_M68K = $(UCLDIR)/upx/m68k
UCL_MR3K = $(UCLDIR)/upx/mr3k
.SUFFIXES:
.SUFFIXES: .asm .ash .asx .asy .bin .c .h .s
vpath %.ash $(UCL_I386)
vpath %.ash $(UCL_M68K)
vpath %.ash $(UCL_MR3K)
# /***********************************************************************
@ -104,6 +107,10 @@ APP_68K = perl -w $(srcdir)/scripts/app_68k.pl
ASM_68K = sh $(srcdir)/scripts/asl_68k.sh
endif
# MIPS R3000
APP_R3K = perl -w $(srcdir)/scripts/app_r3k.pl
ASM_R3K = asm5900
# /***********************************************************************
# // main targets
@ -325,6 +332,16 @@ upxd: l_lx_sep.o l_lx_sep86.asm
$(BRANDELF) $@
# /***********************************************************************
# // psx/exe
# ************************************************************************/
l_psx.h: l_psx.asm
$(APP_R3K) $< $T.asx
$(ASM_R3K) $T.asx -i:$(UCL_UPX) -o:$T.bin
$(BIN2H) $T.bin nrv_loader $@
# /***********************************************************************
# // dependencies
# ************************************************************************/

View File

@ -178,7 +178,7 @@ L30: ; process auxv
sub edi, byte 8 ; backup to AT_NULL
add ecx, ecx ; two words per auxv
inc eax ; convert 0 to AT_IGNORE
rep stosd ; allocate and fill
rep stosd ; allocate and fill
dec eax ; convert AT_IGNORE to AT_NULL
stosd ; re-terminate with AT_NULL
stosd

View File

@ -38,14 +38,17 @@ PHDRS
SECTIONS
{
/* 0x00401000: l_lx_elf86.asm assumes 1 page up from 64KB boundary */
/* mfx 2002-07-16: FIXME - something is wrong here
. = 0x00401000 + SIZEOF_HEADERS + 12; /* 12==sizeof(l_info) */
/* mfx 2002-07-16: FIXME - something is wrong here
.text : {
*(.text)
*(.data)
} : text
*/
/* 0x08048000: customary Linux/x86 Elf .text start */
/* PackLinuxI386::buildLinuxLoader will overwrite the address anyway. */
. = 0x08048000 + (0xfff & .);
/* . = 0x08048000 + (0xfff & .); */
.data : {
} : data
}

129
src/stub/l_psx.asm Normal file
View File

@ -0,0 +1,129 @@
; l_psx.asm -- psx/exe program entry & decompressor
;
; This file is part of the UPX executable compressor.
;
; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
; Copyright (C) 1996-2001 Laszlo Molnar
;
; 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
; markus.oberhumer@jk.uni-linz.ac.at ml1050@cdata.tvnet.hu
;
; mips version by ssg
INCLUDE "mr3k/macros.asm"
ORG 0
; =============
; ============= ENTRY POINT
; =============
; __PSXMAIN0__
entry:
addiu at,zero,'LS' ; size of decomp. routine
sub sp,at ; adjust the stack with this size
addi sp,-(8*4)
sw at,0(sp)
sw a0,4(sp)
sw a1,8(sp)
sw a2,12(sp)
sw a3,16(sp)
sw v0,20(sp)
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
copyloop:
lw at,0(a2) ; memcpy *a2 -> at -> *a1
addiu a2,4
addi a0,-4
sw at,0(a1)
bnez a0,copyloop
addiu a1,4
lui a0,'CH' ; load COMPDATA HI offset
ori a0,'CL' ; and the LO part
; lui a1,'LH' ; length of compressed data
; ori a1,'LL' ; HI and LO, but disabled
lui a2,'OH' ; load DECOMPDATA HI offset
jr a3
ori a2,'OL' ; load DECOMPDATA LO offset
; __PSXMAINZ__
; =============
; ============= DECOMPRESSION
; =============
; __PSXDECO0__
; __PSXDECOZ__
; __PSXN2BD0__
INCLUDE "mr3k/n2b_d32.asm"
; __PSXN2BDZ__
; __PSXN2DD0__
INCLUDE "mr3k/n2d_d32.asm"
; __PSXN2DDZ__
; ;_PSXN2ED0__
; INCLUDE "mr3k/n2e_d32.asm"
; ;_PSXN2EDZ__
; __PSXMSET0__
ori a0,zero,'SC' ; amount of removed zero's at eof
sll a0,3 ; (cd mode 2 data sector alignment)
memset:
addi a0,-4
swl zero,3(a2)
swr zero,0(a2)
bnez a0,memset
addiu a2,4
; __PSXMSETZ__
; __PSXEXIT0__
lw at,0(sp)
lw a0,4(sp)
lw a1,8(sp)
lw a2,12(sp)
lw a3,16(sp)
lw v0,20(sp)
lw v1,24(sp)
lw ra,28(sp)
addiu sp,(8*4)
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
DB 161,216,208,213 ; UPX_MAGIC2_LE32
DW 0 ; 8 uncompressed adler32
DW 0 ; 12 compressed adler32
DW 0 ; 16 uncompressed len
DW 0 ; 20 compressed len
DW 0 ; 24 original file size
DB 0 ; 28 filter id
DB 0 ; 29 filter cto
DB 0 ; unsused
DB 45 ; 31 header checksum
; __PSXPHDRZ__
eof:
; section .data
DW -1
DH eof

View File

@ -47,7 +47,7 @@ struct timex;
#include <time.h>
#include <linux/errno.h>
#include <linux/mman.h>
#include <linux/personality.h>
//#include <linux/personality.h>
//#include <linux/timex.h>
#include <linux/unistd.h>

111
src/stub/scripts/app_r3k.pl Normal file
View File

@ -0,0 +1,111 @@
#! /usr/bin/perl -w
#
# app_r3k.pl -- assembly preprocessor for upx
#
# This file is part of the UPX executable compressor.
#
# Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
# Copyright (C) 1996-2001 Laszlo Molnar
# 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
# markus@oberhumer.com ml1050@cdata.tvnet.hu
#
#
# usage: app_r3k.pl infile outfile
#
$in = shift || die;
$ou = shift || die;
open (IN,"<$in") or die;
open (OU,">$ou") or die;
binmode IN;
binmode OU;
@lines = <IN>;
%labels = ();
$i = 0;
$cs = "";
($ilabel = $in) =~ s,^.*[\/\\],,; # get basename
$ilabel =~ s/\W//g;
# 1st pass
for $line (@lines)
{
$labels{$1} = "$cs" if ($line =~ /^(\w+):/ && $cs);
if ($line =~ /__([A-Z0-9]{8})__/) {
$cs = $1;
# verify the line
if ($line =~ /^[\%\;]ifdef/) {
# ok
} elsif ($line =~ /^([\%\;]\w+)?\s*;/) {
# ok
} else {
print STDERR "$in:$i:warning 1:$line"
}
}
if ($line =~ /^[\%\;](if|el|endi)/)
{
if ($line =~ /__([A-Z0-9]{8})__/)
{
$line=";$line" unless ($line =~ /^\;/);
}
else
{
print STDERR "$in:$i:warning 2:$line";
}
}
$line =~ s/\.ash/\.asy/ if ($line =~ /^\s*\%include/);
$i++;
}
$cs = "";
$i = 0;
$test = "";
# 2nd pass
for $line (@lines)
{
$line = ";$line" if ($line =~ /^\s+align\s/);
print OU $line;
if ($line =~ /__([A-Z0-9]{8})__/)
{
print OU "S$1$ilabel:\n";
push @{ $test[++$#test] }, "\t\tDB\t\"$1\"\n\t\tDW\tS$1$ilabel\n";
$cs = $1;
}
$i++;
if ($line =~ /section .data/)
{
for $i ( 0 .. $#test )
{
print OU "@{$test[$i]}";
}
}
}
# vi:ts=4:et

View File

@ -83,6 +83,7 @@ typedef unsigned upx_uint32;
#define UPX_F_VMLINUZ_i386 15
#define UPX_F_BVMLINUZ_i386 16
#define UPX_F_ELKS_8086 17
#define UPX_F_PSX_EXE 18
#define UPX_F_ATARI_TOS 129
#define UPX_F_SOLARIS_SPARC 130

View File

@ -1,4 +1,4 @@
#define UPX_VERSION 0x011104 /* 01.11.04 */
#define UPX_VERSION_STRING "1.11.4"
#define UPX_VERSION_STRING4 "1.11"
#define UPX_VERSION_DATE "Mar 1st 2001"
#define UPX_VERSION 0x019001 /* 01.90.01 */
#define UPX_VERSION_STRING "1.90.1"
#define UPX_VERSION_STRING4 "1.90"
#define UPX_VERSION_DATE "Jul 16th 2002"