busybox segfault in __uClibc_main

Joakim Tjernlund joakim.tjernlund at transmode.se
Tue Dec 6 17:32:31 UTC 2005


> 
> Joakim Tjernlund <joakim.tjernlund at transmode.se> wrote:
> >> Christopher, thanx for the hints. Rob, I think I found the problem.
> >> I made the following changes and it works (for me!):
> >>
> >>
> >> --- uClibc-0.9.28.orig/libc/sysdeps/linux/powerpc/crt1.S	
> >> 2005-12-05 21:19:20.000000000 -0500
> >> +++ uClibc-0.9.28/libc/sysdeps/linux/powerpc/crt1.S	
> >> 2005-12-05 21:19:09.000000000 -0500
> >> @@ -61,6 +61,10 @@ _start:
> >> 	/* find argv one word offset from the stack pointer */
> >> 	addi	r5,r9,4
> >> 	mr	r8,r7 /* Pass _dl_fini from ldso or NULL if 
> >> statically linked */
> >> +        mr.     r4,r4 /* abi said top of stack must be NULL */
> >> +        beq     from_ldso
> >> +        li      r8,0
> >> +from_ldso:      
> >> 	/* Ok, now run uClibc's main() -- shouldn't return */
> >> #ifdef __PIC__
> >> 	lwz	r6,_init at got(r31)
> >
> > uh, this looks strange, I checked in 2.4 that linux cleared all
> > relevant registers(r7 in this case) before calling user space. Why
> > is this not true anymore in 2.6? hmm, I can run 2.6.15-rc1 here so I
> > think you kernel is broken.
> 
> I run vanilla 2.6.14 and I dont think it's broken.
> 
> >
> > Anyhow this patch is wrong and won't work for the non static case,
> > r8 will always be cleared and thus no destructors will be executed
> > during exit().
> 
> Did you test it? it works for me both static and dynamic (i.e
> rtld_fini got called in a dynamic linked prog)

Nope, didn't test it.

> 
> I think you mis-read the patch.

Maybe(need to check my assembler skills I guess), I read it as:
if(r4)
   r8 = 0;

r4 holds argc and I don't get how it can be anything but non zero so
this should always clear r8 and you don't want that for dynamic apps.

 Jocke



More information about the uClibc mailing list