import preliminary ppc work by rdp.
[musl] / src / ldso / ppc / start.S
1 #include <bits/asm.h>
2         .global _start
3         .type   _start,@function
4 _start:
5         mr      r9, r1                  // Save the original stack pointer.
6         clrrwi  r1, r1, 4               // Align the stack to 16 bytes.
7         lis     r13, _SDA_BASE_@ha      // r13 points to the small data area.
8         addi    r13, r13, _SDA_BASE_@l  //
9         li      r0, 0                   // Zero the frame pointer.
10         lwz     r3, 0(r9)               // and argc...
11         addi    r4, r9, 4               // and argv ...
12         mtlr    r0                      // Clear the link register.
13         // Go to the musl dynamic linker entry point.
14         bl      __dynlink
15         cmpi    r4, 0, r3, 1            // Check for a 1.
16         bne     r4, .                   // Stay here
17         mtlr    r3                      // Set the link address...
18         li      r3, 0
19         blr                             // and go.
20         .end    _start
21         .size   _start, .-_start
22