From d9bf8a76d9fdab8fbbd85afbbbe6e34e7e315b03 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Fri, 20 Sep 2013 05:22:05 +0200 Subject: [PATCH] Protect against changes from future gas versions in amd64-linux.elf-entry.S. --- src/stub/src/amd64-linux.elf-entry.S | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/stub/src/amd64-linux.elf-entry.S b/src/stub/src/amd64-linux.elf-entry.S index 454acde8..765a3e45 100644 --- a/src/stub/src/amd64-linux.elf-entry.S +++ b/src/stub/src/amd64-linux.elf-entry.S @@ -233,11 +233,22 @@ unfold: XXX: 4GB Note that MOVL $imm32,reg zero-extends to 64-bits. (Use an temporary register to obtain 4GB range on PUSH constant.) */ + +#if 1 +/* INFO: newer gas versions (correctly) encode the "push $IMMEDIATE" into + a R_X86_64_32S instead of R_X86_64_32 relocation type. + Avoid that until tested. +*/ + .byte 0x68; .int JMPU // push $ JMPU (R_X86_64_32) + push %rax // for unmap in fold + .byte 0x68; .int LENU // push $ JMPU (R_X86_64_32) +#else push $ JMPU // for unmap in fold push %rax // for unmap in fold push $ LENU // for unmap in fold +#endif push %rcx // ADRX for upx_main - push %r15 // LENX for upx_main + push %r15 // LENX for upx_main /* 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