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

Added experimental app_68k.pl.

committer: mfx <mfx> 978635857 +0000
This commit is contained in:
Markus F.X.J. Oberhumer
2001-01-04 19:17:37 +00:00
parent 3d371be0e5
commit 0979848bdc
3 changed files with 210 additions and 32 deletions

View File

@ -36,6 +36,9 @@ STUBS = \
l_sh_n2b.h l_sh_n2d.h \
l_vmlinz.h
# experimental:
##STUBS += l_t_x2b.h l_t_x2bs.h l_t_x2d.h l_t_x2ds.h
# util var for use in the rules - basename of the current target
override T = $(basename $@)
@ -84,12 +87,15 @@ CC_LINUX = gcc -Os -march=i386 -mcpu=i386 -malign-functions=0 -malign-jumps=0
ifeq (1,1)
# Preprocessor for the a68k 68000-assembler.
CPP_A68K = gcc -I$(UCL_UPX) -E -x assembler-with-cpp -Wall -Wp,-P,-C,-traditional -D__A68K__
A68K = a68k -q -x
CPP_68K = gcc -I$(UCL_UPX) -E -x assembler-with-cpp -Wall -Wp,-P,-C,-traditional -D__A68K__
##CPP_68K = cpp -I$(UCL_UPX) -x assembler-with-cpp -P -C -traditional -nostdinc -D__A68K__
APP_68K = perl -w $(srcdir)/scripts/app_68k.pl
ASM_68K = a68k -q -x
else
# Preprocessor for the asl 68000-assembler.
CPP_A68K = gcc -I$(UCL_UPX) -E -x assembler-with-cpp -Wall -Wp,-P,-C,-traditional -D__ASL__
A68K = sh $(srcdir)/scripts/asl_68k.sh
CPP_68K = gcc -I$(UCL_UPX) -E -x assembler-with-cpp -Wall -Wp,-P,-C,-traditional -D__ASL__
APP_68K = perl -w $(srcdir)/scripts/app_68k.pl
ASM_68K = sh $(srcdir)/scripts/asl_68k.sh
endif
@ -157,30 +163,6 @@ l_sys.h: l_sys.asx
$(NASM) -f bin -o $T.bin $<
$(BIN2H) $T.bin nrv2b_loader $@
l_t_n2b.h: l_tos.s
$(CPP_A68K) -DNRV2B -o $T.i $<
$(A68K) $T.i
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2b_loader $@
l_t_n2bs.h: l_tos.s
$(CPP_A68K) -DNRV2B -DSMALL -o $T.i $<
$(A68K) $T.i
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2b_loader_small $@
l_t_n2d.h: l_tos.s
$(CPP_A68K) -DNRV2D -o $T.i $<
$(A68K) $T.i
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2d_loader $@
l_t_n2ds.h: l_tos.s
$(CPP_A68K) -DNRV2D -DSMALL -o $T.i $<
$(A68K) $T.i
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2d_loader_small $@
l_tmt.h: l_tmt.asx
$(NASM) -f bin -o $T.bin $<
$(BIN2H) $T.bin nrv_loader $@
@ -202,6 +184,64 @@ l_w32pe.h: l_w32pe.asx
$(BIN2H) $T.bin nrv_loader $@
# /***********************************************************************
# // atari/tos rules
# ************************************************************************/
l_t_n2b.h: l_tos.s
$(CPP_68K) -DNRV2B -o $T.i $<
$(ASM_68K) $T.i
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2b_loader $@
l_t_n2bs.h: l_tos.s
$(CPP_68K) -DNRV2B -DSMALL -o $T.i $<
$(ASM_68K) $T.i
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2b_loader_small $@
l_t_n2d.h: l_tos.s
$(CPP_68K) -DNRV2D -o $T.i $<
$(ASM_68K) $T.i
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2d_loader $@
l_t_n2ds.h: l_tos.s
$(CPP_68K) -DNRV2D -DSMALL -o $T.i $<
$(ASM_68K) $T.i
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2d_loader_small $@
# experimental:
l_t_x2b.h: l_tos2.s
$(CPP_68K) -DNRV2B -o $T.i $<
$(APP_68K) $T.i $T.asx
$(ASM_68K) $T.asx
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2b_loader $@
l_t_x2bs.h: l_tos2.s
$(CPP_68K) -DNRV2B -DSMALL -o $T.i $<
$(APP_68K) $T.i $T.asx
$(ASM_68K) $T.asx
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2b_loader_small $@
l_t_x2d.h: l_tos2.s
$(CPP_68K) -DNRV2D -o $T.i $<
$(APP_68K) $T.i $T.asx
$(ASM_68K) $T.asx
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2d_loader $@
l_t_x2ds.h: l_tos2.s
$(CPP_68K) -DNRV2D -DSMALL -o $T.i $<
$(APP_68K) $T.i $T.asx
$(ASM_68K) $T.asx
$(O2BIN) $T.o $T.bin 'UPX1' 'UPX9'
$(BIN2H) $T.bin nrv2d_loader_small $@
# /***********************************************************************
# // linux rules (exec, elf, sh, sep)
# ************************************************************************/

View File

@ -55,20 +55,20 @@ for $line (@lines)
if ($line =~ /__([A-Z0-9]{8})__/) {
$cs = $1;
# verify the line
if ($line =~ /^\%ifdef/) {
if ($line =~ /^[\%\;]ifdef/) {
# ok
} elsif ($line =~ /^(\%\w+)?\s*;/) {
} elsif ($line =~ /^([\%\;]\w+)?\s*;/) {
# ok
} else {
print STDERR "$in:$i:warning 1:$line"
}
}
if ($line =~ /^\%(if|el|endi)/)
if ($line =~ /^[\%\;](if|el|endi)/)
{
if ($line =~ /__([A-Z0-9]{8})__/)
{
$line=";$line";
$line=";$line" unless ($line =~ /^\;/);
}
else
{

138
src/stub/scripts/app_68k.pl Normal file
View File

@ -0,0 +1,138 @@
#! /usr/bin/perl -w
#
# app_68k.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_68k.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;
@data = ();
# 2nd pass
for $line (@lines)
{
if ($line =~ /^\s+(b[\w\.]+|db[\w\.]+)\s+(\w*)/)
{
$label = $2;
##print STDERR "$label $cs\n"; # debug
if (defined $labels{$label})
{
$ts = $labels{$label};
if ($ts ne $cs)
{
$line =~ s/$label/J$i$ilabel/;
print OU $line;
print OU "J$i$ilabel:\n";
$d = "dc.l\t0, J$i$ilabel";
push(@data, $d);
$d = "dc.b\t'$ts'";
push(@data, $d);
$d = "dc.l\t$label - S$ts$ilabel";
push(@data, $d);
$line = "";
}
}
}
$line = ";$line" if ($line =~ /^\s+align\b/);
$line = ";$line" if ($line =~ /^\s+even\b/);
$line = ";$line" if ($line =~ /^\s+end\b/);
print OU $line;
if ($line =~ /__([A-Z0-9]{8})__/)
{
print OU "S$1$ilabel:\n";
$cs = $1;
$d = "dc.b\t'$1'";
push(@data, $d);
$d = "dc.l\tS$1$ilabel";
push(@data, $d);
}
$i++;
}
# print data section
print OU "\n\n\t\tsection_data\n";
for $d (@data) {
print OU "\t\t$d\n";
}
print OU "\t\tdc.b\t'UPX9'\n";
print OU "\t\tend\n";
# vi:ts=4:et