From 4f17b30915dec5b26357d183dc1e0c490506579b Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Wed, 16 Aug 2006 08:13:36 +0200 Subject: [PATCH] Started renaming .asm files to .S. --- src/stub/Makefile | 78 ++--- src/stub/src/amd64-linux.elf-entry.S | 272 ------------------ .../{i086-dos16.com.asm => i086-dos16.com.S} | 0 .../{i086-dos16.exe.asm => i086-dos16.exe.S} | 0 .../{i086-dos16.sys.asm => i086-dos16.sys.S} | 0 ...bsd.elf-entry.asm => i386-bsd.elf-entry.S} | 0 ...6-bsd.elf-fold.asm => i386-bsd.elf-fold.S} | 0 ...6-dos32.djgpp2.asm => i386-dos32.djgpp2.S} | 0 .../{i386-dos32.tmt.asm => i386-dos32.tmt.S} | 0 ...2.watcom.le.asm => i386-dos32.watcom.le.S} | 0 ...x.elf-entry.asm => i386-linux.elf-entry.S} | 0 ...nux.elf-fold.asm => i386-linux.elf-fold.S} | 0 ...ntry.asm => i386-linux.elf.execve-entry.S} | 0 ...-fold.asm => i386-linux.elf.execve-fold.S} | 0 ...ntry.asm => i386-linux.elf.interp-entry.S} | 0 ...-fold.asm => i386-linux.elf.interp-fold.S} | 0 ...entry.asm => i386-linux.elf.shell-entry.S} | 0 ...l-fold.asm => i386-linux.elf.shell-fold.S} | 0 ...mlinux.asm => i386-linux.kernel.vmlinux.S} | 0 ...mlinuz.asm => i386-linux.kernel.vmlinuz.S} | 0 ...d.elf-fold.asm => i386-openbsd.elf-fold.S} | 0 .../{i386-win32.pe.asm => i386-win32.pe.S} | 0 .../{m68k-atari.tos.asm => m68k-atari.tos.S} | 0 ...ipsel.r3000-ps1.asm => mipsel.r3000-ps1.S} | 0 24 files changed, 25 insertions(+), 325 deletions(-) delete mode 100644 src/stub/src/amd64-linux.elf-entry.S rename src/stub/src/{i086-dos16.com.asm => i086-dos16.com.S} (100%) rename src/stub/src/{i086-dos16.exe.asm => i086-dos16.exe.S} (100%) rename src/stub/src/{i086-dos16.sys.asm => i086-dos16.sys.S} (100%) rename src/stub/src/{i386-bsd.elf-entry.asm => i386-bsd.elf-entry.S} (100%) rename src/stub/src/{i386-bsd.elf-fold.asm => i386-bsd.elf-fold.S} (100%) rename src/stub/src/{i386-dos32.djgpp2.asm => i386-dos32.djgpp2.S} (100%) rename src/stub/src/{i386-dos32.tmt.asm => i386-dos32.tmt.S} (100%) rename src/stub/src/{i386-dos32.watcom.le.asm => i386-dos32.watcom.le.S} (100%) rename src/stub/src/{i386-linux.elf-entry.asm => i386-linux.elf-entry.S} (100%) rename src/stub/src/{i386-linux.elf-fold.asm => i386-linux.elf-fold.S} (100%) rename src/stub/src/{i386-linux.elf.execve-entry.asm => i386-linux.elf.execve-entry.S} (100%) rename src/stub/src/{i386-linux.elf.execve-fold.asm => i386-linux.elf.execve-fold.S} (100%) rename src/stub/src/{i386-linux.elf.interp-entry.asm => i386-linux.elf.interp-entry.S} (100%) rename src/stub/src/{i386-linux.elf.interp-fold.asm => i386-linux.elf.interp-fold.S} (100%) rename src/stub/src/{i386-linux.elf.shell-entry.asm => i386-linux.elf.shell-entry.S} (100%) rename src/stub/src/{i386-linux.elf.shell-fold.asm => i386-linux.elf.shell-fold.S} (100%) rename src/stub/src/{i386-linux.kernel.vmlinux.asm => i386-linux.kernel.vmlinux.S} (100%) rename src/stub/src/{i386-linux.kernel.vmlinuz.asm => i386-linux.kernel.vmlinuz.S} (100%) rename src/stub/src/{i386-openbsd.elf-fold.asm => i386-openbsd.elf-fold.S} (100%) rename src/stub/src/{i386-win32.pe.asm => i386-win32.pe.S} (100%) rename src/stub/src/{m68k-atari.tos.asm => m68k-atari.tos.S} (100%) rename src/stub/src/{mipsel.r3000-ps1.asm => mipsel.r3000-ps1.S} (100%) diff --git a/src/stub/Makefile b/src/stub/Makefile index 5f7e3cd8..a72652c4 100644 --- a/src/stub/Makefile +++ b/src/stub/Makefile @@ -134,7 +134,6 @@ tc.default.m-objdump = multiarch-objdump-2.17 $(if $(tc_bfdname),-b $(tc_bfdnam tc.default.m-ld = multiarch-ld-2.17 $(if $(tc_bfdname),-b $(tc_bfdname)) tc.default.m-nm = multiarch-nm-2.17 $(if $(tc_bfdname),--target=$(tc_bfdname)) tc.default.m-readelf = multiarch-readelf-2.17 -tc.default.o2bin = perl $(top_srcdir)/src/stub/scripts/o2bin.pl tc.default.pp-as = i386-linux-gcc-3.4.6 -E -nostdinc -x assembler-with-cpp -Wall tc.default.sstrip = sstrip @@ -271,7 +270,7 @@ arm.v4t-wince.pe.h : $(srcdir)/src/$$T.S i086-dos16.com% : tc_list = arch-i086 default -i086-dos16.com.h : $(srcdir)/src/$$T.asm +i086-dos16.com.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -286,7 +285,7 @@ i086-dos16.com.h : $(srcdir)/src/$$T.asm i086-dos16.exe% : tc_list = arch-i086 default -i086-dos16.exe.h : $(srcdir)/src/$$T.asm +i086-dos16.exe.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -301,7 +300,7 @@ i086-dos16.exe.h : $(srcdir)/src/$$T.asm i086-dos16.sys% : tc_list = arch-i086 default -i086-dos16.sys.h : $(srcdir)/src/$$T.asm +i086-dos16.sys.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -314,24 +313,11 @@ i086-dos16.sys.h : $(srcdir)/src/$$T.asm # // i386-bsd.elf # ************************************************************************/ -i386-bsd.elf% : tc_list = i386-bsd.elf arch-i386 default +# info: we use the tc settings from i386-linux.elf +i386-bsd.elf% : tc_list = i386-linux.elf arch-i386 default i386-bsd.elf% : tc_bfdname = elf32-i386 -tc.i386-bsd.elf.gcc = i386-linux-gcc-3.4.6 -m32 -march=i386 -nostdinc -MMD -tc.i386-bsd.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables -tc.i386-bsd.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror -tc.i386-bsd.elf.gcc += -march=i386 -mtune=k6 -tc.i386-bsd.elf.gcc += -Os -fno-omit-frame-pointer -tc.i386-bsd.elf.gcc += -momit-leaf-frame-pointer -tc.i386-bsd.elf.gcc += -fno-align-functions -fno-align-jumps -fno-align-labels -fno-align-loops -tc.i386-bsd.elf.gcc += -mpreferred-stack-boundary=2 -tc.i386-bsd.elf.gcc += -fweb -tc.i386-bsd.elf.ld = $(call tc,m-ld) -tc.i386-bsd.elf.objcopy = $(call tc,m-objcopy) -tc.i386-bsd.elf.objdump = $(call tc,m-objdump) -tc.i386-bsd.elf.objstrip = $(call tc,objcopy) -R .comment -R .note - -i386-bsd.elf-entry.h : $(srcdir)/src/$$T.asm +i386-bsd.elf-entry.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -346,7 +332,7 @@ i386-bsd.elf-fold.h : tmp/$$T.o tmp/i386-bsd.elf-main.o $(srcdir)/src/$$T.lds $(call tc,brandelf) --elfosabi=freebsd tmp/$T.bin $(call tc,bin2h) --ident=bsd_i386elf_fold tmp/$T.bin $@ -tmp/i386-bsd.elf-fold.o : $(srcdir)/src/$$T.asm +tmp/i386-bsd.elf-fold.o : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.o $(call tc,objstrip) $@ @@ -355,26 +341,12 @@ tmp/i386-bsd.elf-main.o : $(srcdir)/src/$$T.c $(call tc,objstrip) $@ -i386-openbsd.elf% : tc_list = i386-openbsd.elf arch-i386 default +# info: we use the tc settings from i386-linux.elf +i386-openbsd.elf% : tc_list = i386-linux.elf arch-i386 default i386-openbsd.elf% : tc_bfdname = elf32-i386 -tc.i386-openbsd.elf.gcc = i386-linux-gcc-3.4.6 -m32 -march=i386 -nostdinc -MMD -tc.i386-openbsd.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables -tc.i386-openbsd.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror -tc.i386-openbsd.elf.gcc += -march=i386 -mtune=k6 -tc.i386-openbsd.elf.gcc += -Os -fno-omit-frame-pointer -tc.i386-openbsd.elf.gcc += -momit-leaf-frame-pointer -tc.i386-openbsd.elf.gcc += -fno-align-functions -fno-align-jumps -fno-align-labels -fno-align-loops -tc.i386-openbsd.elf.gcc += -mpreferred-stack-boundary=2 -tc.i386-openbsd.elf.gcc += -fweb -tc.i386-openbsd.elf.ld = $(call tc,m-ld) -tc.i386-openbsd.elf.objcopy = $(call tc,m-objcopy) -tc.i386-openbsd.elf.objdump = $(call tc,m-objdump) -tc.i386-openbsd.elf.objstrip = $(call tc,objcopy) -R .comment -R .note - # Note the re-use of i386-bsd.elf-entry.h as output (no separate i386-openbsd.elf-entry.h). # Note the re-use of i386-bsd.elf-fold.lds as input (no separate i386-openbsd.elf-fold.lds). - i386-openbsd.elf-fold.h : tmp/$$T.o tmp/i386-openbsd.elf-main.o $(srcdir)/src/i386-bsd.elf-fold.lds $(call tc,ld) -T $(srcdir)/src/i386-bsd.elf-fold.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^) $(call tc,objstrip) tmp/$T.bin @@ -382,7 +354,7 @@ i386-openbsd.elf-fold.h : tmp/$$T.o tmp/i386-openbsd.elf-main.o $(srcdir)/src/i3 $(call tc,brandelf) --elfosabi=openbsd tmp/$T.bin $(call tc,bin2h) --ident=openbsd_i386elf_fold tmp/$T.bin $@ -tmp/i386-openbsd.elf-fold.o : $(srcdir)/src/$$T.asm +tmp/i386-openbsd.elf-fold.o : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.o $(call tc,objstrip) $@ @@ -397,7 +369,7 @@ tmp/i386-openbsd.elf-main.o : $(srcdir)/src/$$T.c i386-dos32.djgpp2% : tc_list = arch-i386 default -i386-dos32.djgpp2.h : $(srcdir)/src/$$T.asm +i386-dos32.djgpp2.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -416,7 +388,7 @@ i386-dos32.djgpp2-stubify.h : $(srcdir)/src/$$T.asm i386-dos32.tmt% : tc_list = arch-i386 default -i386-dos32.tmt.h : $(srcdir)/src/$$T.asm +i386-dos32.tmt.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -431,7 +403,7 @@ i386-dos32.tmt.h : $(srcdir)/src/$$T.asm i386-dos32.watcom.le% : tc_list = arch-i386 default -i386-dos32.watcom.le.h : $(srcdir)/src/$$T.asm +i386-dos32.watcom.le.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -461,7 +433,7 @@ tc.i386-linux.elf.objcopy = $(call tc,m-objcopy) tc.i386-linux.elf.objdump = $(call tc,m-objdump) tc.i386-linux.elf.objstrip = $(call tc,objcopy) -R .comment -R .note -i386-linux.elf-entry.h : $(srcdir)/src/$$T.asm +i386-linux.elf-entry.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -476,7 +448,7 @@ i386-linux.elf-fold.h : tmp/$$T.o tmp/i386-linux.elf-main.o $(srcdir)/src/$$T.ld $(call tc,brandelf) --elfosabi=linux tmp/$T.bin $(call tc,bin2h) --ident=linux_i386elf_fold tmp/$T.bin $@ -tmp/i386-linux.elf-fold.o : $(srcdir)/src/$$T.asm +tmp/i386-linux.elf-fold.o : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.o $(call tc,objstrip) $@ @@ -491,7 +463,7 @@ tmp/i386-linux.elf-main.o : $(srcdir)/src/$$T.c # note: tc_list settings are inherited from i386-linux.elf -i386-linux.elf.execve-entry.h : $(srcdir)/src/$$T.asm +i386-linux.elf.execve-entry.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -506,7 +478,7 @@ i386-linux.elf.execve-fold.h : tmp/$$T.o tmp/i386-linux.elf.execve-main.o tmp/i3 $(call tc,brandelf) --elfosabi=linux tmp/$T.bin $(call tc,bin2h) --ident=linux_i386exec_fold tmp/$T.bin $@ -tmp/i386-linux.elf.execve-fold.o : $(srcdir)/src/$$T.asm +tmp/i386-linux.elf.execve-fold.o : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.o $(call tc,objstrip) $@ @@ -525,7 +497,7 @@ tmp/i386-linux.elf.execve-upx_itoa.o: $(srcdir)/src/$$T.S # note: tc_list settings are inherited from i386-linux.elf -i386-linux.elf.interp-entry.h : $(srcdir)/src/$$T.asm +i386-linux.elf.interp-entry.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -540,7 +512,7 @@ i386-linux.elf.interp-fold.h : tmp/$$T.o tmp/i386-linux.elf.interp-main.o $(srcd $(call tc,brandelf) --elfosabi=linux tmp/$T.bin $(call tc,bin2h) --ident=linux_i386pti_fold tmp/$T.bin $@ -tmp/i386-linux.elf.interp-fold.o : $(srcdir)/src/$$T.asm +tmp/i386-linux.elf.interp-fold.o : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.o $(call tc,objstrip) $@ @@ -555,7 +527,7 @@ tmp/i386-linux.elf.interp-main.o : $(srcdir)/src/$$T.c # note: tc_list settings are inherited from i386-linux.elf -i386-linux.elf.shell-entry.h : $(srcdir)/src/$$T.asm +i386-linux.elf.shell-entry.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -570,7 +542,7 @@ i386-linux.elf.shell-fold.h : tmp/$$T.o tmp/i386-linux.elf.shell-main.o $(srcdir $(call tc,brandelf) --elfosabi=linux tmp/$T.bin $(call tc,bin2h) --ident=linux_i386sh_fold tmp/$T.bin $@ -tmp/i386-linux.elf.shell-fold.o : $(srcdir)/src/$$T.asm +tmp/i386-linux.elf.shell-fold.o : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.o $(call tc,objstrip) $@ @@ -586,7 +558,7 @@ tmp/i386-linux.elf.shell-main.o : $(srcdir)/src/$$T.c i386-linux.kernel.vmlin% : tc_list = arch-i386 default -i386-linux.kernel%.h : $(srcdir)/src/$$T.asm +i386-linux.kernel%.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -602,7 +574,7 @@ i386-linux.kernel%.h : $(srcdir)/src/$$T.asm i386-win32.pe% : tc_list = arch-i386 default i386-win32.pe% : tc_bfdname = elf32-i386 -i386-win32.pe.h : $(srcdir)/src/$$T.asm +i386-win32.pe.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin @@ -620,7 +592,7 @@ m68k-atari.tos-%.h : tc_bfdname = elf32-m68k tc.m68k-atari.tos.asm-as = m68k-linux-as-20060406 --register-prefix-optional -m68k-atari.tos-nrv%.h : $(srcdir)/src/m68k-atari.tos.asm +m68k-atari.tos-nrv%.h : $(srcdir)/src/m68k-atari.tos.S # call gpp_inc to generate .d file $(call tc,gpp_inc) --mode=c --MMD=$@ --MF=tmp/$T.i.d $< -o /dev/null $(call tc,pp-as) -D__GAS__ $(PP_FLAGS) $< -o tmp/$T.i @@ -650,7 +622,7 @@ mipsel.r3000-ps1.h : tc_bfdname = elf32-littlemips tc.mipsel.r3000-ps1.as = mipsel-elf-as-20060406 -O2 -mno-pdr -mipsel.r3000-ps1.h : $(srcdir)/src/$$T.asm +mipsel.r3000-ps1.h : $(srcdir)/src/$$T.S # call gpp_inc to generate .d file $(call tc,gpp_inc) --mode=c --MMD=$@ --MF=tmp/$T.tmp1.d $< -o /dev/null $(call tc,pp-as) $(PP_FLAGS) $< -o tmp/$T.tmp1 diff --git a/src/stub/src/amd64-linux.elf-entry.S b/src/stub/src/amd64-linux.elf-entry.S deleted file mode 100644 index 63fb1018..00000000 --- a/src/stub/src/amd64-linux.elf-entry.S +++ /dev/null @@ -1,272 +0,0 @@ -/* l_lx_elf64amd.S -- Linux program entry point & decompressor (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 -* -*/ - - .code64 -#include "arch/amd64/regs.h" - -sz_l_info= 12 - l_lsize= 8 - -sz_p_info= 12 - -sz_b_info= 12 - sz_unc= 0 - sz_cpr= 4 - b_method= 8 - -PROT_READ= 1 -PROT_WRITE= 2 -PROT_EXEC= 4 - -MAP_PRIVATE= 2 -MAP_FIXED= 0x10 -MAP_ANONYMOUS= 0x20 - -SYS_mmap= 9 # 64-bit mode only! - -PAGE_SHIFT= 12 -PAGE_MASK= (~0<likely, n==>unlikely} */ -/* Prediction omitted for now. */ -/* On refill: prefetch next byte, for latency reduction on literals and offsets. */ -#define jnextb0np jnextb0yp -#define jnextb0yp GETBITp; jnc -#define jnextb1np jnextb1yp -#define jnextb1yp GETBITp; jc -#define GETBITp \ - addl bits,bits; jnz 0f; \ - movl (%rsi),bits; subq $-4,%rsi; \ - adcl bits,bits; movb (%rsi),%dl; \ -0: -/* Same, but without prefetch (not useful for length of match.) */ -#define jnextb0n jnextb0y -#define jnextb0y GETBIT; jnc -#define jnextb1n jnextb1y -#define jnextb1y GETBIT; jc -#define GETBIT \ - addl bits,bits; jnz 0f; \ - movl (%rsi),bits; subq $-4,%rsi; \ - adcl bits,bits; \ -0: - -/* rotate next bit into bottom bit of reg */ -#define getnextbp(reg) call *%r11; adcl reg,reg -#define getnextb(reg) getnextbp(reg) - - .p2align 3 -getbit: - addl bits,bits; jz refill # Carry= next bit - rep; ret -refill: - movl (%rsi),bits; subq $-4,%rsi # next 32 bits; set Carry - adcl bits,bits # LSB= 1 (CarryIn); CarryOut= next bit - movb (%rsi),%dl # speculate: literal, or bottom 8 bits of offset - rep; ret - -copy: # In: len, %rdi, disp; Out: 0==len, %rdi, disp; trashes %rax, %rdx - leaq (%rdi,disp),%rax; cmpl $5,len # <=3 is forced - movb (%rax),%dl; jbe copy1 # <=5 for better branch predict - cmpq $-4,disp; ja copy1 # 4-byte chunks would overlap - subl $4,len # adjust for termination cases -copy4: - movl (%rax),%edx; addq $4, %rax; subl $4,len - movl %edx,(%rdi); leaq 4(%rdi),%rdi; jnc copy4 - addl $4,len; movb (%rax),%dl; jz copy0 -copy1: - incq %rax; movb %dl,(%rdi); subl $1,len - movb (%rax),%dl - leaq 1(%rdi),%rdi; jnz copy1 -copy0: - rep; ret - -#include "arch/amd64/nrv2e_d.S" -#include "arch/amd64/nrv2b_d.S" - -setup: - cld - pop %r11 # addq $ getbit - ra_setup,%r11 # &getbit - cmpl $ M_NRV2E_LE32,meth; je top_n2e - cmpl $ M_NRV2B_LE32,meth; je top_n2b -eof: - pop %rcx # &input_eof - movq %rsi,%rax; subq %rcx,%rax # src -= eof; // return 0: good; else: bad - pop %rdx; subq %rdx,%rdi # dst -= original dst - pop %rcx; movl %edi,(%rcx) # actual length used at dst XXX: 4GB - pop %rbx; pop %rbp - ret - -/* Temporary until we get the buildLoader stuff working ... */ - .ascii "\n$Id: UPX (C) 1996-2006 the UPX Team. " - .asciz "All Rights Reserved. http://upx.sf.net $\n" - -/* These from /usr/include/asm-x86_64/unistd.h */ -__NR_write = 1 -__NR_exit = 60 - -msg_SELinux: - push $ L71 - L70; pop %arg3 # length - call L71 -L70: - .asciz "PROT_EXEC|PROT_WRITE failed.\n" -L71: - pop %arg2 # message text - push $2; pop %arg1 # fd stderr - push $ __NR_write; pop %rax - syscall -die: - push $127; pop %arg1 - push $ __NR_exit; pop %rax - syscall - -/* Decompress the rest of this loader, and jump to it. - Map a page to hold the decompressed bytes. Logically this could - be done by setting .p_memsz for our first PT_LOAD. But as of 2005-11-09, - linux 2.6.14 only does ".bss expansion" on the PT_LOAD that describes the - highest address. [I regard this as a bug, and it makes the kernel's - fs/binfmt_elf.c complicated, buggy, and insecure.] For us, that is the 2nd - PT_LOAD, which is the only way that linux allows to set the brk() for the - uncompressed program. [This is a significant kernel misfeature.] -*/ -unfold: - pop %rbx # &b_info - -/* Get some pages. If small, then get 1 page located just after the end - of the first PT_LOAD of the compressed program. This will still be below - all of the uncompressed program. If large (>=3MB compressed), then get enough - to duplicate the entire compressed PT_LOAD, plus 1 page, located just after - the brk() of the _un_compressed program. The address and length are pre- - calculated by PackLinuxElf64amd::pack3(), and patched in at compress time. -*/ - .byte 7+0xB8; .ascii "ADRM" # movl $'ADRM',%edi XXX: 4GB - push $ PROT_READ | PROT_WRITE | PROT_EXEC; pop %arg3 - .byte 6+0xB8; .ascii "LENM" # movl $'LENM',%esi XXX: 4GB - push $ MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS; pop %sys4 - subl %arg5l,%arg5l #; subl %arg6l,%arg6l # MAP_ANON ==> ignore offset - push $ SYS_mmap; pop %rax - syscall # %rax= result; trashes %rcx,%r11 only - cmpl %eax,%edi; jne msg_SELinux # XXX: 4GB - -/* Load the addresses and lengths that ::pack3() patched in. - XXX: 2GB Note that PUSH $imm32 sign-extends to 64 bits. - XXX: 4GB Note that MOVL $imm32,reg zero-extends to 64-bits. - (Use an temporary register to obtain 4GB range on PUSH constant.) -*/ - .byte 0x68; .ascii "JMPU" # push $'JMPU' # for unmap in fold - .byte 0x68; .ascii "ADRU" # push $'ADRU' # for unmap in fold - .byte 6+0xB8; .ascii "ADRC" # movl $'ADRC',%esi - .byte 0x68; .ascii "LENU" # push $'LENU' # for unmap in fold - .byte 1+0xB8; .ascii "CNTC" # movl $'CNTC',%ecx - .byte 0x68; .ascii "ADRX" # push $'ADRX' # for upx_main - .byte 0x68; .ascii "LENX" # push $'LENX' # for upx_main - -/* Move and relocate if compressed overlaps uncompressed. - Move by 0 when total compressed executable is < 3MB. -*/ - movl %edi,%edx # ADRM - subl %esi,%edx # (ADRM - ADRC) == relocation amount - addl %edx,%ebp # update &decompress - addl %edx,%ebx # update &b_info - - cld - rep; movsq - xchgl %eax,%edi - -/* Decompress the folded part of this stub, then execute it. */ - movl %ebx,%esi # %arg2l= &b_info (relocated) - push %rax # ret_addr after decompression - xchgl %eax,%arg3l # %arg3= dst for unfolding XXX: 4GB - lodsl; push %rax # allocate slot on stack - movq %rsp,%arg4 # &len_dst ==> &do_not_care - lodsl; xchgl %eax,%arg1l # sz_cpr XXX: 4GB - lodsl; movzbl %al,%arg5l # b_method - xchg %arg1l,%arg2l # XXX: 4GB - call *%rbp # decompress - pop %rcx # discard len_dst - ret - -main: - # int3 # uncomment for debugging - pop %rbp # &decompress - call unfold # push &b_info - /* { b_info={sz_unc, sz_cpr, {4 char}}, folded_loader...} */ - -/*__XTHEENDX__*/ - -/* -vi:ts=8:et:nowrap -*/ - diff --git a/src/stub/src/i086-dos16.com.asm b/src/stub/src/i086-dos16.com.S similarity index 100% rename from src/stub/src/i086-dos16.com.asm rename to src/stub/src/i086-dos16.com.S diff --git a/src/stub/src/i086-dos16.exe.asm b/src/stub/src/i086-dos16.exe.S similarity index 100% rename from src/stub/src/i086-dos16.exe.asm rename to src/stub/src/i086-dos16.exe.S diff --git a/src/stub/src/i086-dos16.sys.asm b/src/stub/src/i086-dos16.sys.S similarity index 100% rename from src/stub/src/i086-dos16.sys.asm rename to src/stub/src/i086-dos16.sys.S diff --git a/src/stub/src/i386-bsd.elf-entry.asm b/src/stub/src/i386-bsd.elf-entry.S similarity index 100% rename from src/stub/src/i386-bsd.elf-entry.asm rename to src/stub/src/i386-bsd.elf-entry.S diff --git a/src/stub/src/i386-bsd.elf-fold.asm b/src/stub/src/i386-bsd.elf-fold.S similarity index 100% rename from src/stub/src/i386-bsd.elf-fold.asm rename to src/stub/src/i386-bsd.elf-fold.S diff --git a/src/stub/src/i386-dos32.djgpp2.asm b/src/stub/src/i386-dos32.djgpp2.S similarity index 100% rename from src/stub/src/i386-dos32.djgpp2.asm rename to src/stub/src/i386-dos32.djgpp2.S diff --git a/src/stub/src/i386-dos32.tmt.asm b/src/stub/src/i386-dos32.tmt.S similarity index 100% rename from src/stub/src/i386-dos32.tmt.asm rename to src/stub/src/i386-dos32.tmt.S diff --git a/src/stub/src/i386-dos32.watcom.le.asm b/src/stub/src/i386-dos32.watcom.le.S similarity index 100% rename from src/stub/src/i386-dos32.watcom.le.asm rename to src/stub/src/i386-dos32.watcom.le.S diff --git a/src/stub/src/i386-linux.elf-entry.asm b/src/stub/src/i386-linux.elf-entry.S similarity index 100% rename from src/stub/src/i386-linux.elf-entry.asm rename to src/stub/src/i386-linux.elf-entry.S diff --git a/src/stub/src/i386-linux.elf-fold.asm b/src/stub/src/i386-linux.elf-fold.S similarity index 100% rename from src/stub/src/i386-linux.elf-fold.asm rename to src/stub/src/i386-linux.elf-fold.S diff --git a/src/stub/src/i386-linux.elf.execve-entry.asm b/src/stub/src/i386-linux.elf.execve-entry.S similarity index 100% rename from src/stub/src/i386-linux.elf.execve-entry.asm rename to src/stub/src/i386-linux.elf.execve-entry.S diff --git a/src/stub/src/i386-linux.elf.execve-fold.asm b/src/stub/src/i386-linux.elf.execve-fold.S similarity index 100% rename from src/stub/src/i386-linux.elf.execve-fold.asm rename to src/stub/src/i386-linux.elf.execve-fold.S diff --git a/src/stub/src/i386-linux.elf.interp-entry.asm b/src/stub/src/i386-linux.elf.interp-entry.S similarity index 100% rename from src/stub/src/i386-linux.elf.interp-entry.asm rename to src/stub/src/i386-linux.elf.interp-entry.S diff --git a/src/stub/src/i386-linux.elf.interp-fold.asm b/src/stub/src/i386-linux.elf.interp-fold.S similarity index 100% rename from src/stub/src/i386-linux.elf.interp-fold.asm rename to src/stub/src/i386-linux.elf.interp-fold.S diff --git a/src/stub/src/i386-linux.elf.shell-entry.asm b/src/stub/src/i386-linux.elf.shell-entry.S similarity index 100% rename from src/stub/src/i386-linux.elf.shell-entry.asm rename to src/stub/src/i386-linux.elf.shell-entry.S diff --git a/src/stub/src/i386-linux.elf.shell-fold.asm b/src/stub/src/i386-linux.elf.shell-fold.S similarity index 100% rename from src/stub/src/i386-linux.elf.shell-fold.asm rename to src/stub/src/i386-linux.elf.shell-fold.S diff --git a/src/stub/src/i386-linux.kernel.vmlinux.asm b/src/stub/src/i386-linux.kernel.vmlinux.S similarity index 100% rename from src/stub/src/i386-linux.kernel.vmlinux.asm rename to src/stub/src/i386-linux.kernel.vmlinux.S diff --git a/src/stub/src/i386-linux.kernel.vmlinuz.asm b/src/stub/src/i386-linux.kernel.vmlinuz.S similarity index 100% rename from src/stub/src/i386-linux.kernel.vmlinuz.asm rename to src/stub/src/i386-linux.kernel.vmlinuz.S diff --git a/src/stub/src/i386-openbsd.elf-fold.asm b/src/stub/src/i386-openbsd.elf-fold.S similarity index 100% rename from src/stub/src/i386-openbsd.elf-fold.asm rename to src/stub/src/i386-openbsd.elf-fold.S diff --git a/src/stub/src/i386-win32.pe.asm b/src/stub/src/i386-win32.pe.S similarity index 100% rename from src/stub/src/i386-win32.pe.asm rename to src/stub/src/i386-win32.pe.S diff --git a/src/stub/src/m68k-atari.tos.asm b/src/stub/src/m68k-atari.tos.S similarity index 100% rename from src/stub/src/m68k-atari.tos.asm rename to src/stub/src/m68k-atari.tos.S diff --git a/src/stub/src/mipsel.r3000-ps1.asm b/src/stub/src/mipsel.r3000-ps1.S similarity index 100% rename from src/stub/src/mipsel.r3000-ps1.asm rename to src/stub/src/mipsel.r3000-ps1.S