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
+17
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
# ************************************************************************/
+1 -1
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
+4 -1
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
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
+1 -1
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
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