x32 port (diff against vanilla x86_64)
[musl] / src / ldso / x32 / start.s
1 .text
2 .global _start
3 _start:
4         mov (%rsp),%rdi  /* move argc into 1st argument slot */
5         lea 4(%rsp),%rsi /* move argv into 2nd argument slot */
6         call __dynlink
7         /* in case the dynlinker was called directly, it sets the "consumed"
8            argv values to -1. so we must loop over the array as long as -1
9            is in the top argv slot, decrement argc, and then set the stackpointer
10            to the new argc as well as argc's new value.
11            as the x32 abi has longs in the argv array, we cannot use push/pop.*/
12         movl (%rsp),%edi /* copy argc into edi */
13         xor %rdx,%rdx /* we use rdx as an offset to the current argv member */
14 1:      dec %edi
15         addl $4, %edx
16         movl (%rsp, %rdx), %esi
17         cmp $-1,%esi
18         jz 1b
19         inc %edi
20         subl $4, %edx
21         lea (%rsp, %rdx), %rsp /* set rsp to new argv[-1] */
22         movl %edi, (%rsp)      /* write new argc there */
23         xor %edx,%edx
24         jmp *%rax