From 664cd341921007cea52c8891f27ce35927dca378 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Tue, 7 Jan 2014 22:53:38 +0100 Subject: x32 port (diff against vanilla x86_64) --- src/ldso/x32/start.s | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/ldso/x32') diff --git a/src/ldso/x32/start.s b/src/ldso/x32/start.s index 80c1d08d..0fcf46dc 100644 --- a/src/ldso/x32/start.s +++ b/src/ldso/x32/start.s @@ -1,16 +1,24 @@ .text .global _start _start: - mov (%rsp),%rdi - lea 8(%rsp),%rsi + mov (%rsp),%rdi /* move argc into 1st argument slot */ + lea 4(%rsp),%rsi /* move argv into 2nd argument slot */ call __dynlink - pop %rdi + /* in case the dynlinker was called directly, it sets the "consumed" + argv values to -1. so we must loop over the array as long as -1 + is in the top argv slot, decrement argc, and then set the stackpointer + to the new argc as well as argc's new value. + as the x32 abi has longs in the argv array, we cannot use push/pop.*/ + movl (%rsp),%edi /* copy argc into edi */ + xor %rdx,%rdx /* we use rdx as an offset to the current argv member */ 1: dec %edi - pop %rsi - cmp $-1,%rsi + addl $4, %edx + movl (%rsp, %rdx), %esi + cmp $-1,%esi jz 1b inc %edi - push %rsi - push %rdi + subl $4, %edx + lea (%rsp, %rdx), %rsp /* set rsp to new argv[-1] */ + movl %edi, (%rsp) /* write new argc there */ xor %edx,%edx jmp *%rax -- cgit v1.2.1