From b58a631942341b6ccb62ab400e862f404e22dbbf Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 1 Oct 2002 05:30:25 +0000 Subject: This commit contains a patch from Stefan Allius to change how uClibc handles _init and _fini, allowing shared lib constructors and destructors to initialize things in the correct sequence. Stefan ported the SH architecture. I then ported x86, arm, and mips. x86 and arm are working fine, but I don't think I quite got things correct for mips. --- libc/sysdeps/linux/i386/crt0.S | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'libc/sysdeps/linux/i386') diff --git a/libc/sysdeps/linux/i386/crt0.S b/libc/sysdeps/linux/i386/crt0.S index 3623fe821..97f1fde63 100644 --- a/libc/sysdeps/linux/i386/crt0.S +++ b/libc/sysdeps/linux/i386/crt0.S @@ -33,11 +33,11 @@ Cambridge, MA 02139, USA. */ .text .align 4 -.globl _start - .type _start,@function + .globl _start + .type _start,@function _start: - /* First locate the start of the environment variables */ + /* locate the start of the environment variables */ popl %ecx /* Store argc into %ecx */ movl %esp,%ebx /* Store argv into ebx */ movl %esp,%eax /* Store argv into eax as well*/ @@ -52,7 +52,6 @@ _start: %eax = env ; argv + (argc * 4) + 4 */ - /* Set up an invalid (NULL return address, NULL frame pointer) callers stack frame so anybody unrolling the stack knows where to stop */ @@ -62,20 +61,18 @@ _start: pushl %ebp /* callers %ebp (frame pointer) */ movl %esp,%ebp /* mark callers stack frame as invalid */ - /* Now set the environment, argc, and argv where the app can get to them */ - pushl %eax /* Environment pointer */ - pushl %ebx /* Argument pointer */ - pushl %ecx /* And the argument count */ + /* Push .init and .fini arguments to __uClibc_start_main() on the stack */ + pushl $_fini + pushl $_init -#if 0 - /* Make sure we are not using iBCS2 personality. (i.e. force linux). */ - movl $136,%eax - sub %ebx,%ebx - int $0x80 -#endif + /* Push envp, argc, and argc arguments to __uClibc_start_main() on the stack */ + pushl %eax /* Environment pointer */ + pushl %ebx /* Argument pointer */ + pushl %ecx /* And the argument count */ /* Ok, now run uClibc's main() -- shouldn't return */ - call __uClibc_main + call __uClibc_start_main + /* Crash if somehow `exit' returns anyways. */ hlt -- cgit v1.2.3