From ce5f9f95eaea57541810a80772b47c32a60af402 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Fri, 20 Sep 2013 06:15:46 +0200 Subject: [PATCH] stub: fix i386 syntax for current gas versions, and add some explicit alignments at the end of the file so that we do not depend on gas defaults. --- src/stub/src/arch/i386/macros.S | 4 ++-- src/stub/src/i086-dos16.exe.S | 8 ++++---- src/stub/src/i386-bsd.elf-fold.S | 1 + src/stub/src/i386-bsd.elf.execve-fold.S | 2 ++ src/stub/src/i386-darwin.dylib-entry.S | 4 ++-- src/stub/src/i386-darwin.macho-fold.S | 1 + src/stub/src/i386-linux.elf-fold.S | 1 + src/stub/src/i386-linux.elf.execve-fold.S | 1 + src/stub/src/i386-linux.elf.interp-fold.S | 1 + src/stub/src/i386-linux.elf.shell-fold.S | 1 + src/stub/src/i386-linux.kernel.vmlinuz.S | 2 +- src/stub/src/i386-linux.shlib-init.S | 8 ++++---- src/stub/src/i386-openbsd.elf-fold.S | 1 + src/stub/tmp/i386-netbsd.elf-fold.map | 3 +-- 14 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/stub/src/arch/i386/macros.S b/src/stub/src/arch/i386/macros.S index 1ac038d8..43b473a5 100644 --- a/src/stub/src/arch/i386/macros.S +++ b/src/stub/src/arch/i386/macros.S @@ -472,7 +472,7 @@ decompr0: section LXJCC010 lxunf2: // have seen 0x80..0x8f of possible recoded 6-byte Jcc - movzwl ebp, [edi] // 2 bytes, zero-extended + movzx ebp, word ptr [edi] // 2 bytes, zero-extended section LXMRU045 // 0!=n_mru sub ebp, __cto8_0f @@ -644,7 +644,7 @@ section LXMRU040 // 0!=n_mru section LXUNF030 lxctloop: - movzxw eax, [edi] // 2 bytes, zero extended + movzx eax, word ptr [edi] // 2 bytes, zero extended add edi, 1 section LXJCC000 cmp al, 0x80 // lo of Jcc diff --git a/src/stub/src/i086-dos16.exe.S b/src/stub/src/i086-dos16.exe.S index 77e75687..aa928049 100644 --- a/src/stub/src/i086-dos16.exe.S +++ b/src/stub/src/i086-dos16.exe.S @@ -112,7 +112,7 @@ addaxds: movsw cld section LONGSUB - subb [cs:si + addaxds + 4], 0x10 + subb cs:[si + addaxds + 4], 0x10 section SHORTSUB .byte 0x2e, 0x80, 0x6c, addaxds + 4, 0x10 section JNCDOCOPY @@ -177,7 +177,7 @@ reloc_0: xor ax, ax reloc_1: add di, ax - add [es:di], bp + add es:[di], bp reloc_2: lodsb dec ax @@ -188,9 +188,9 @@ section EXEREL9A inc di reloc_4: inc di - cmpb [es:di], 0x9a + cmpb es:[di], 0x9a jne reloc_4 - cmp [es:di+3], dx + cmp es:[di+3], dx ja reloc_4 mov al, 3 jmps reloc_1 diff --git a/src/stub/src/i386-bsd.elf-fold.S b/src/stub/src/i386-bsd.elf-fold.S index 8b0d3611..67617585 100644 --- a/src/stub/src/i386-bsd.elf-fold.S +++ b/src/stub/src/i386-bsd.elf-fold.S @@ -202,5 +202,6 @@ L32: pop edi // &auxtab ret +.balign 4,0 // vi:ts=8:et:nowrap diff --git a/src/stub/src/i386-bsd.elf.execve-fold.S b/src/stub/src/i386-bsd.elf.execve-fold.S index 10dd6230..ab4a7b24 100644 --- a/src/stub/src/i386-bsd.elf.execve-fold.S +++ b/src/stub/src/i386-bsd.elf.execve-fold.S @@ -55,4 +55,6 @@ fold_begin: // enter: %ebx= &Elf32_Ehdr of this program .extern upx_main call upx_main // Call the UPX main function hlt // Crash if somehow upx_main does return + +.balign 4,0 // vi:ts=8:et:nowrap diff --git a/src/stub/src/i386-darwin.dylib-entry.S b/src/stub/src/i386-darwin.dylib-entry.S index fdb05907..6e695f1e 100644 --- a/src/stub/src/i386-darwin.dylib-entry.S +++ b/src/stub/src/i386-darwin.dylib-entry.S @@ -209,8 +209,8 @@ dy_uncpr: add esp, (5+1)*4 // (5+1) args to decompress pop edx; pop eax # edx= old dst; eax= old &b_info - movzbl ecx,[1+ b_method + eax]; jecxz dy_uncpr; push ecx # ftid - movzbl ecx,[2+ b_method + eax]; push ecx # cto8 + movzx ecx, byte ptr [1+ b_method + eax]; jecxz dy_uncpr; push ecx # ftid + movzx ecx, byte ptr [2+ b_method + eax]; push ecx # cto8 push [sz_unc + eax] push edx # dst lea eax,[2+ ebp]; call eax # f_unfilter(dst, dstlen, cto8, ftid) diff --git a/src/stub/src/i386-darwin.macho-fold.S b/src/stub/src/i386-darwin.macho-fold.S index 5475522d..fd270dd9 100644 --- a/src/stub/src/i386-darwin.macho-fold.S +++ b/src/stub/src/i386-darwin.macho-fold.S @@ -135,6 +135,7 @@ read: .globl read 0: ret +.balign 2,144 /* vi:ts=8:et:nowrap */ diff --git a/src/stub/src/i386-linux.elf-fold.S b/src/stub/src/i386-linux.elf-fold.S index cd46225b..b95445e3 100644 --- a/src/stub/src/i386-linux.elf-fold.S +++ b/src/stub/src/i386-linux.elf-fold.S @@ -257,5 +257,6 @@ mmap: .globl mmap pop ebx ret +.balign 4,0 // vi:ts=8:et:nowrap diff --git a/src/stub/src/i386-linux.elf.execve-fold.S b/src/stub/src/i386-linux.elf.execve-fold.S index ee1c8d2f..b793da20 100644 --- a/src/stub/src/i386-linux.elf.execve-fold.S +++ b/src/stub/src/i386-linux.elf.execve-fold.S @@ -68,4 +68,5 @@ mmap: .globl mmap pop ebx ret +.balign 4,0 // vi:ts=8:et:nowrap diff --git a/src/stub/src/i386-linux.elf.interp-fold.S b/src/stub/src/i386-linux.elf.interp-fold.S index fb50e3e3..bdf4f9b6 100644 --- a/src/stub/src/i386-linux.elf.interp-fold.S +++ b/src/stub/src/i386-linux.elf.interp-fold.S @@ -125,5 +125,6 @@ mmap: .globl mmap pop ebx ret +.balign 4,0 // vi:ts=8:et:nowrap diff --git a/src/stub/src/i386-linux.elf.shell-fold.S b/src/stub/src/i386-linux.elf.shell-fold.S index b09c352a..f0d544cd 100644 --- a/src/stub/src/i386-linux.elf.shell-fold.S +++ b/src/stub/src/i386-linux.elf.shell-fold.S @@ -172,5 +172,6 @@ mmap: .globl mmap ret +.balign 4,0 // vi:ts=8:et:nowrap diff --git a/src/stub/src/i386-linux.kernel.vmlinuz.S b/src/stub/src/i386-linux.kernel.vmlinuz.S index 8093efcb..a37d2ce9 100644 --- a/src/stub/src/i386-linux.kernel.vmlinuz.S +++ b/src/stub/src/i386-linux.kernel.vmlinuz.S @@ -259,7 +259,7 @@ cmd_exp = 80 // allow kernel to expand command line "in place" by this much cl_nbp202: // use < 2.02 method. in: ebp= real_mode_ptr mov esi,ebp // absolute worst case default cmpw [ebp+ BP_cmd_line_magic],0xA33F; jne cl_move // nothing at all - movzwl esi,[ebp+ BP_cmd_line_offset] + movzx esi, word ptr [ebp+ BP_cmd_line_offset] add esi,ebp jmp cl_move cl_bp202: // try >= 2.02 method diff --git a/src/stub/src/i386-linux.shlib-init.S b/src/stub/src/i386-linux.shlib-init.S index f042fd95..10564ba6 100644 --- a/src/stub/src/i386-linux.shlib-init.S +++ b/src/stub/src/i386-linux.shlib-init.S @@ -201,8 +201,8 @@ p_mprot= -5*4 sub eax,ebx // restore add edi,ebx - movzbl ecx,[esi+b_method-4+1]; push ecx // ftid - movzbl ecx,[esi+b_method-4+2]; push ecx // cto8 + movzx ecx, byte ptr [esi+b_method-4+1]; push ecx // ftid + movzx ecx, byte ptr [esi+b_method-4+2]; push ecx // cto8 push eax; mov ecx,esp // dstlen also for unfilter step 7 push edi // dst param for unfilter step 7 p_unflt= -9*4 @@ -248,12 +248,12 @@ supervise: pop ecx // &dstlen pop edx // discard method,filter,cto,junk add eax,[ecx] // dst += dstlen - mov [dword ptr eax],0xc36180cd // "int 0x80; popa; ret" + mov dword ptr [eax],0xc36180cd // "int 0x80; popa; ret" mov [esp + p_hatch - o_uncpr],eax // hatch at end of .text //o_uncpr pop eax // &decompress //p_unflt - cmp [word ptr esp+3*4],0; je 0f // 0==ftid ==> no filter + cmp word ptr [esp+3*4],0; je 0f // 0==ftid ==> no filter add eax,2; call eax // unfilter {i386 f_unf==(2+f_unc)} 0: add esp,4*4 diff --git a/src/stub/src/i386-openbsd.elf-fold.S b/src/stub/src/i386-openbsd.elf-fold.S index ab9c5488..318911fb 100644 --- a/src/stub/src/i386-openbsd.elf-fold.S +++ b/src/stub/src/i386-openbsd.elf-fold.S @@ -202,5 +202,6 @@ L32: pop edi // &auxtab ret +.balign 4,0 // vi:ts=8:et:nowrap diff --git a/src/stub/tmp/i386-netbsd.elf-fold.map b/src/stub/tmp/i386-netbsd.elf-fold.map index a87e5f92..e33a0fb6 100644 --- a/src/stub/tmp/i386-netbsd.elf-fold.map +++ b/src/stub/tmp/i386-netbsd.elf-fold.map @@ -11,8 +11,7 @@ TARGET(elf32-i386) .text 0x0000000000c01080 0x68c *(.text) - .text 0x0000000000c01080 0xc2 tmp/i386-bsd.elf-fold.o - *fill* 0x0000000000c01142 0x2 00 + .text 0x0000000000c01080 0xc4 tmp/i386-bsd.elf-fold.o .text 0x0000000000c01144 0x558 tmp/i386-bsd.elf-main.o 0x0000000000c01564 upx_main .text 0x0000000000c0169c 0x6d tmp/i386-bsd.syscall.o