busybox segfault in __uClibc_main

Linh Dang linhd at nortel.com
Tue Dec 6 14:04:30 UTC 2005


Rob Landley <rob at landley.net> wrote:
> I'd like to track this down, can you email me an strace of the
> segfaulting cases you've found?  (And you've confirmed that a simple
> "hello world" program works fine with your uclibc toolchain, right?)
>
> Rob

Christopher Murch <cmurch at mrv.com> wrote:

> Hi, I experienced a similiar issue, I don't have a resolution but
> maybe some more useful info.  I'm also running on powerpc using gcc
> 3.4.4 and using uClibc 0.9.28 (all compiled with buildroot).
>
> The issue only occurs for me when the executable is built static
> (DO_DEBUG for uClibc builds staticly).  I did not have any luck
> debugging the issue, instead I worked around it by just using
> dynamic libraries.
>
> My debug attempts with gdb/strace both failed because under the
> context of gdb/strace the issue does not appear repeatable.  The
> segfault appears to happen on call to exit(), if you replace your
> call to exit() with _exit(), the problem seems to disappear.
>
> Any more I can do to help, let me know.
> -Chris
>


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)




More information about the uClibc mailing list