From 76e705e7ee5c5d86ad534acfce54eb1ddf558868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Moln=C3=A1r?= Date: Fri, 7 Jul 2006 09:20:43 +0200 Subject: [PATCH] more atari/tos work --- src/p_tos.cpp | 45 ++++++++++++++++++++++++++++++--- src/stub/src/m68k-atari.tos.asm | 4 +-- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/p_tos.cpp b/src/p_tos.cpp index e77e1d4d..f0a7bce7 100644 --- a/src/p_tos.cpp +++ b/src/p_tos.cpp @@ -78,7 +78,34 @@ const int *PackTos::getFilters() const Linker* PackTos::newLinker() const { - return new SimpleBELinker; + class ElfLinkerM68k : public ElfLinker + { + typedef ElfLinker super; + + virtual void relocate1(Relocation *rel, upx_byte *location, + unsigned value, const char *type) + { + if (strncmp(type, "R_68K_", 6)) + return super::relocate1(rel, location, value, type); + type += 6; + + if (strncmp(type, "PC", 2) == 0) + { + value -= rel->section->offset + rel->offset; + type += 2; + } + if (strcmp(type, "8") == 0) + *location += value; + if (strcmp(type, "16") == 0) + set_be16(location, get_be16(location) + value); + else if (strcmp(type, "32") == 0) + set_be32(location, get_be32(location) + value); + else + super::relocate1(rel, location, value, type); + } + }; + + return new ElfLinkerM68k; } @@ -101,10 +128,20 @@ int PackTos::buildLoader(const Filter *ft) p = opt->small ? nrv2e_loader_small : nrv2e_loader; l = opt->small ? sizeof(nrv2e_loader_small) : sizeof(nrv2e_loader); } + initLoader(p, l); + + addLoader("tos0", + true ? "subql_1d0" : "subqw_1d0", + "s_bneloop0", + true ? "subql_1d6" : "subqw_1d6", + "s_bneloop3", + "IDENTSTR,+40,UP1HEAD", + "CUTPOINT", + true ? "reloc" : "", + "jmpastack", + NULL + ); - delete linker; - linker = newLinker(); - linker->init(p, l, -1); freezeLoader(); return getLoaderSize(); } diff --git a/src/stub/src/m68k-atari.tos.asm b/src/stub/src/m68k-atari.tos.asm index c3cd91a8..7e87c4da 100644 --- a/src/stub/src/m68k-atari.tos.asm +++ b/src/stub/src/m68k-atari.tos.asm @@ -475,7 +475,7 @@ clear_bss_end: // relocations and the original fileheader). **************************************************************************/ -cutpoint: +section CUTPOINT // ------------- decompress (from a3 to a4) @@ -536,7 +536,7 @@ L(loopx2): move.b (a0)+,d3 reloc_end: - +section jmpastack // ------------- clear dirty bss & start program // We are currently running in the dirty bss.