diff --git a/src/stub/src/amd64-linux.elf-entry.S b/src/stub/src/amd64-linux.elf-entry.S index 712c0e18..487ac502 100644 --- a/src/stub/src/amd64-linux.elf-entry.S +++ b/src/stub/src/amd64-linux.elf-entry.S @@ -29,10 +29,8 @@ * */ -//#include "arch/i386/macros2.ash" - +#include "arch/amd64/macros.S" #include "arch/amd64/regs.h" -#define section .section sz_Ehdr= 64 sz_Phdr= 56 diff --git a/src/stub/src/amd64-linux.elf-fold.S b/src/stub/src/amd64-linux.elf-fold.S index ceaa6520..1c595fa4 100644 --- a/src/stub/src/amd64-linux.elf-fold.S +++ b/src/stub/src/amd64-linux.elf-fold.S @@ -27,7 +27,7 @@ * */ - .code64 +#include "arch/amd64/macros.S" #include "arch/amd64/regs.h" PAGE_SHIFT= 12 diff --git a/src/stub/src/arch/amd64/macros.S b/src/stub/src/arch/amd64/macros.S new file mode 100644 index 00000000..371d8cc7 --- /dev/null +++ b/src/stub/src/arch/amd64/macros.S @@ -0,0 +1,38 @@ +/* +; macros.S -- +; +; This file is part of the UPX executable compressor. +; +; Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2006 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 +; +; +*/ + + //.altmacro + .code64 + +.macro section name + .section \name + .code64 +.endm + +// vi:ts=8:et:nowrap diff --git a/src/stub/src/arch/arm/v4a/macros.S b/src/stub/src/arch/arm/v4a/macros.S new file mode 100644 index 00000000..a0da8694 --- /dev/null +++ b/src/stub/src/arch/arm/v4a/macros.S @@ -0,0 +1,37 @@ +/* +; macros.S -- +; +; This file is part of the UPX executable compressor. +; +; Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2006 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 +; +; +*/ + + .altmacro + .arm + +.macro section name + .section \name +.endm + +// vi:ts=8:et:nowrap diff --git a/src/stub/src/arch/arm/v4t/macros.S b/src/stub/src/arch/arm/v4t/macros.S new file mode 100644 index 00000000..e6e835b1 --- /dev/null +++ b/src/stub/src/arch/arm/v4t/macros.S @@ -0,0 +1,43 @@ +/* +; macros.S -- +; +; This file is part of the UPX executable compressor. +; +; Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2006 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 +; +; +*/ + + .altmacro + .arm + +.macro section name + .section \name +.endm + + +// in thumb mode we need this S() macro hack to export a symbol which +// is used in a ldr statement +#define S(sym) .globl sym; sym: .L##sym + + +// vi:ts=8:et:nowrap diff --git a/src/stub/src/arch/i086/macros.S b/src/stub/src/arch/i086/macros.S index 2d602657..e088cbe4 100644 --- a/src/stub/src/arch/i086/macros.S +++ b/src/stub/src/arch/i086/macros.S @@ -1,5 +1,5 @@ /* -; macros.ash -- +; macros.S -- ; ; This file is part of the UPX executable compressor. ; @@ -27,8 +27,9 @@ ; */ - .code16 + .altmacro .intel_syntax noprefix + .code16 .macro section name .section \name diff --git a/src/stub/src/arch/i386/lzma_d.S b/src/stub/src/arch/i386/lzma_d.S index 60bfc11f..92cfcae4 100644 --- a/src/stub/src/arch/i386/lzma_d.S +++ b/src/stub/src/arch/i386/lzma_d.S @@ -39,9 +39,6 @@ ; ecx - 0 */ -// CPU 386 - -// // init section LZMA_DEC00 @@ -140,6 +137,8 @@ section LZMA_ELF00 push ebx // &CLzmaDecoderState push eax // return address slot (dummy CALL) +//#undef O_OUTS +//#undef O_INS section LZMA_DEC10 diff --git a/src/stub/src/arch/i386/macros.S b/src/stub/src/arch/i386/macros.S index b7241e9e..c683eeb9 100644 --- a/src/stub/src/arch/i386/macros.S +++ b/src/stub/src/arch/i386/macros.S @@ -1,5 +1,5 @@ /* -; macros.ash -- +; macros.S -- ; ; This file is part of the UPX executable compressor. ; @@ -27,8 +27,9 @@ ; */ - .code32 + .altmacro .intel_syntax noprefix + .code32 .macro section name .section \name @@ -125,6 +126,7 @@ */ .macro cjt32 addvalue + local calltrickloop section CALLTR00 mov ecx, offset filter_length calltrickloop: diff --git a/src/stub/src/arch/i386/nrv2b_d32.S b/src/stub/src/arch/i386/nrv2b_d32.S index 88f64063..027197d2 100644 --- a/src/stub/src/arch/i386/nrv2b_d32.S +++ b/src/stub/src/arch/i386/nrv2b_d32.S @@ -40,17 +40,16 @@ ; ecx - 0 */ -// CPU 386 - .macro getbit_n2b one + local l1 .ifc \one, 1 add ebx, ebx - jnz 1f + jnzs l1 .endif mov ebx, [esi] sub esi, -4 adc ebx, ebx -1: +l1: .endm #undef getbit diff --git a/src/stub/src/arch/i386/nrv2d_d32.S b/src/stub/src/arch/i386/nrv2d_d32.S index 701bf155..de971234 100644 --- a/src/stub/src/arch/i386/nrv2d_d32.S +++ b/src/stub/src/arch/i386/nrv2d_d32.S @@ -40,18 +40,16 @@ ; ecx - 0 */ -// CPU 386 - - .macro getbit_n2d one + local l1 .ifc \one, 1 add ebx, ebx - jnz 1f + jnzs l1 .endif mov ebx, [esi] sub esi, -4 adc ebx, ebx -1: +l1: .endm #undef getbit diff --git a/src/stub/src/arch/i386/nrv2e_d32.S b/src/stub/src/arch/i386/nrv2e_d32.S index 5d001610..15e78cc4 100644 --- a/src/stub/src/arch/i386/nrv2e_d32.S +++ b/src/stub/src/arch/i386/nrv2e_d32.S @@ -40,17 +40,16 @@ ; ecx - 0 */ -// CPU 386 - .macro getbit_n2e one - .ifc \one, 1 + local l1 + .ifc \one, 1 add ebx, ebx - jnz 1f - .endif + jnzs l1 + .endif mov ebx, [esi] sub esi, -4 adc ebx, ebx -1: +l1: .endm #undef getbit diff --git a/src/stub/src/arch/m68k/macros.S b/src/stub/src/arch/m68k/macros.S new file mode 100644 index 00000000..3ee9fcf7 --- /dev/null +++ b/src/stub/src/arch/m68k/macros.S @@ -0,0 +1,36 @@ +/* +; macros.S -- +; +; This file is part of the UPX executable compressor. +; +; Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2006 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 +; +; +*/ + + .altmacro + +.macro section name + .section \name +.endm + +// vi:ts=8:et:nowrap diff --git a/src/stub/src/arch/powerpc/32/macros.S b/src/stub/src/arch/powerpc/32/macros.S new file mode 100644 index 00000000..2ae1f2b3 --- /dev/null +++ b/src/stub/src/arch/powerpc/32/macros.S @@ -0,0 +1,36 @@ +/* +; macros.S -- +; +; This file is part of the UPX executable compressor. +; +; Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2006 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 +; +; +*/ + + //.altmacro + +.macro section name + .section \name +.endm + +// vi:ts=8:et:nowrap diff --git a/src/stub/src/arm-linux.elf-entry.S b/src/stub/src/arm-linux.elf-entry.S index 127cb4a8..cbddccb2 100644 --- a/src/stub/src/arm-linux.elf-entry.S +++ b/src/stub/src/arm-linux.elf-entry.S @@ -28,7 +28,8 @@ * John F. Reiser * */ -#define section .section + +#include "arch/arm/v4a/macros.S" #define bkpt .long 0xe1200070 sz_Elf32_Ehdr = 13*4 diff --git a/src/stub/src/arm-linux.elf-fold.S b/src/stub/src/arm-linux.elf-fold.S index fc0343b0..979e9211 100644 --- a/src/stub/src/arm-linux.elf-fold.S +++ b/src/stub/src/arm-linux.elf-fold.S @@ -27,6 +27,8 @@ @ @ +#include "arch/arm/v4a/macros.S" + sz_Elf32_Ehdr = 13*4 sz_Elf32_Phdr = 8*4 sz_l_info = 12 diff --git a/src/stub/src/arm.v4a-wince.pe.S b/src/stub/src/arm.v4a-wince.pe.S index 323be722..671a66c1 100644 --- a/src/stub/src/arm.v4a-wince.pe.S +++ b/src/stub/src/arm.v4a-wince.pe.S @@ -29,6 +29,8 @@ */ +#include "arch/arm/v4a/macros.S" + // DEBUG == 0 -> none // DEBUG == 1 -> for armpe_tester // DEBUG == 2 -> wince - dumps memory @@ -53,8 +55,6 @@ #endif #endif -#define section .section - // p_armpe.cpp uses the following symbols, so they should be global .globl SRC0 diff --git a/src/stub/src/arm.v4t-wince.pe.S b/src/stub/src/arm.v4t-wince.pe.S index 97782d14..934ac6b7 100644 --- a/src/stub/src/arm.v4t-wince.pe.S +++ b/src/stub/src/arm.v4t-wince.pe.S @@ -29,6 +29,8 @@ */ +#include "arch/arm/v4t/macros.S" + // p_armpe.cpp uses some symbols, so they should be global .globl SRC0 @@ -36,12 +38,6 @@ .globl IATT .globl ENTR -// in thumb mode we need this S() macro hack to export a symbol which -// is used in a ldr statement -#define S(sym) .globl sym; sym: .L##sym - -#define section .section - .arm dst0 .req r9 @ global register diff --git a/src/stub/src/i386-win32.pe.S b/src/stub/src/i386-win32.pe.S index 073aba69..3cf1a307 100644 --- a/src/stub/src/i386-win32.pe.S +++ b/src/stub/src/i386-win32.pe.S @@ -223,11 +223,12 @@ section PEMAIN20 // clear the dirty stack .macro clearstack128 tmp_reg + local loop lea \tmp_reg, [esp - 128] -c1: +loop: push 0 cmp esp, \tmp_reg - jnzs c1 + jnzs loop sub esp, -128 .endm diff --git a/src/stub/src/m68k-atari.tos.S b/src/stub/src/m68k-atari.tos.S index 330dcf64..79add3c4 100644 --- a/src/stub/src/m68k-atari.tos.S +++ b/src/stub/src/m68k-atari.tos.S @@ -27,7 +27,7 @@ ; */ -.altmacro +#include "arch/m68k/macros.S" /* @@ -42,7 +42,6 @@ #define macro(name) .macro name #define endm .endm -#define section .section // global label for cross-section addressing #define GL(l) .globl l; l: diff --git a/src/stub/src/powerpc-darwin.macho-entry.S b/src/stub/src/powerpc-darwin.macho-entry.S index b4263162..70b29011 100644 --- a/src/stub/src/powerpc-darwin.macho-entry.S +++ b/src/stub/src/powerpc-darwin.macho-entry.S @@ -26,8 +26,8 @@ * */ +#include "arch/powerpc/32/macros.S" #include "arch/powerpc/32/ppc_regs.h" -#define section .section section MACOS000 _start: .globl _start diff --git a/src/stub/src/powerpc-darwin.macho-fold.S b/src/stub/src/powerpc-darwin.macho-fold.S index e8a3d65d..afa8696f 100644 --- a/src/stub/src/powerpc-darwin.macho-fold.S +++ b/src/stub/src/powerpc-darwin.macho-fold.S @@ -28,6 +28,8 @@ * John F. Reiser * */ + +#include "arch/powerpc/32/macros.S" #include "arch/powerpc/32/ppc_regs.h" sz_b_info= 12 diff --git a/src/stub/src/powerpc-linux.elf-entry.S b/src/stub/src/powerpc-linux.elf-entry.S index 56f2387a..9e0fd8d3 100644 --- a/src/stub/src/powerpc-linux.elf-entry.S +++ b/src/stub/src/powerpc-linux.elf-entry.S @@ -29,8 +29,8 @@ * */ +#include "arch/powerpc/32/macros.S" #include "arch/powerpc/32/ppc_regs.h" -#define section .section sz_b_info= 12 sz_unc= 0 diff --git a/src/stub/src/powerpc-linux.elf-fold.S b/src/stub/src/powerpc-linux.elf-fold.S index 907f1d66..0b2d6413 100644 --- a/src/stub/src/powerpc-linux.elf-fold.S +++ b/src/stub/src/powerpc-linux.elf-fold.S @@ -1,3 +1,35 @@ +/* powerpc-linux.elf-fold.S -- linkage to C code to process ELF binary +* +* This file is part of the UPX executable compressor. +* +* Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer +* Copyright (C) 1996-2006 Laszlo Molnar +* Copyright (C) 2000-2006 John F. Reiser +* 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 +* +* +* John F. Reiser +* +*/ + +#include "arch/powerpc/32/macros.S" #include "arch/powerpc/32/ppc_regs.h" #define szElf32_Ehdr 0x34