[klibc] [PATCH] update crt0.S on ppc32

Olaf Hering olh at suse.de
Sun Dec 7 21:08:43 PST 2003

 On Sat, Nov 29, H. Peter Anvin wrote:

> Olaf Hering wrote:
> >The _start stuff was changed some time ago, but ppc was not updated.
> >This fixes klibc for me. I'm not sure what to do with the second arg to
> >__libc_init, so I set it to 0..
> >
> You need to look at the psABI for the target platform (I don't have the 
> one for PPC) to find out how to get the onexit pointer.  However, it's 
> not a huge deal, as I believe Linux always makes it zero.  You want to 
> at least put in a comment to that effect, though.

I should have looked earlier at this spec. This patch is required to
not overwrite the argv[0].

The stack is linked and a new function will write its address into the
previous frame. If _start doesnt adjust the stack, __libc_init will
write its address to elfdata+4 which is argv[0].
This patch allocates just one frame to avoid this corruption.

--- klibc-0.89/klibc/arch/ppc/crt0.S    2003-11-29 07:19:08.000000000 +0100
+++ klibc/arch/ppc/crt0.S       2003-12-07 20:48:12.000000000 +0100
@@ -7,7 +7,8 @@
        .type _start, at function
        .globl _start
-       mr      3,1
+       stwu    1,-16(1)
+       addi    3,1,16
        li      4,0
        bl      __libc_init

I still dont see anything about onexit in the spec.


USB is for mice, FireWire is for men!


More information about the klibc mailing list