[uClibc-cvs] svn commit: trunk/uClibc/libc: misc/internals sysdeps/linux/i386 sysdep etc...
jocke at uclibc.org
jocke at uclibc.org
Wed May 25 23:42:40 UTC 2005
Author: jocke
Date: 2005-05-25 17:42:40 -0600 (Wed, 25 May 2005)
New Revision: 10400
Log:
Adapt startup code in x86 and PPC to almost match glibc. _init vs. __libc_csu_init and
_fini vs. __libc_csu_fini remains to do.
Modified:
trunk/uClibc/libc/misc/internals/__uClibc_main.c
trunk/uClibc/libc/sysdeps/linux/i386/crt1.S
trunk/uClibc/libc/sysdeps/linux/powerpc/crt1.S
Changeset:
Modified: trunk/uClibc/libc/misc/internals/__uClibc_main.c
===================================================================
--- trunk/uClibc/libc/misc/internals/__uClibc_main.c 2005-05-25 07:15:34 UTC (rev 10399)
+++ trunk/uClibc/libc/misc/internals/__uClibc_main.c 2005-05-25 23:42:40 UTC (rev 10400)
@@ -164,10 +164,11 @@
* are initialized, just before we call the application's main function.
*/
void __attribute__ ((__noreturn__))
-__uClibc_start_main(int argc, char **argv, char **envp,
+__uClibc_start_main(int (*main)(int argc, char **argv, char **envp),
+ int argc, char **argv, char **envp,
void (*app_init)(void), void (*app_fini)(void),
- int (*main)(int argc, char **argv, char **envp),
- void (*rtld_fini)(void))
+ void (*rtld_fini)(void),
+ void *stack_end)
{
#ifdef __ARCH_HAS_MMU__
unsigned long *aux_dat;
Modified: trunk/uClibc/libc/sysdeps/linux/i386/crt1.S
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/i386/crt1.S 2005-05-25 07:15:34 UTC (rev 10399)
+++ trunk/uClibc/libc/sysdeps/linux/i386/crt1.S 2005-05-25 23:42:40 UTC (rev 10400)
@@ -38,8 +38,9 @@
.global _start
.type _start,%function
- .weak _init
- .weak _fini
+ .type _init,%function
+ .type _fini,%function
+ .type main,%function
.type __uClibc_start_main,%function
_start:
@@ -69,7 +70,6 @@
/* Push NULL to make sure stack ptr
is 16 byte aligned when calling __uClibc_start_main */
pushl %ebp
- pushl %ebp
/* Set up an invalid (NULL return address, NULL frame pointer)
callers stack frame so anybody unrolling the stack knows where
@@ -85,15 +85,14 @@
pop %edx
addl $_GLOBAL_OFFSET_TABLE_+[.-.L0],%edx
#endif
+ pushl %esp /* push stack ptr */
pushl %esi /* Push FINI pointer */
/* Push apps .init, .fini and main arguments to __uClibc_start_main() on the stack */
#ifdef L_Scrt1
- pushl main at GOT(%edx)
pushl _fini at GOT(%edx)
pushl _init at GOT(%edx)
#else
- pushl $main
pushl $_fini
pushl $_init
#endif
@@ -105,8 +104,10 @@
/* Ok, now run uClibc's main() -- shouldn't return */
#ifdef L_Scrt1
+ pushl main at GOT(%edx)
call *__uClibc_start_main at GOT(%edx)
#else
+ pushl $main
call __uClibc_start_main
#endif
Modified: trunk/uClibc/libc/sysdeps/linux/powerpc/crt1.S
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/powerpc/crt1.S 2005-05-25 07:15:34 UTC (rev 10399)
+++ trunk/uClibc/libc/sysdeps/linux/powerpc/crt1.S 2005-05-25 23:42:40 UTC (rev 10400)
@@ -27,60 +27,56 @@
#define r7 7
#define r8 8
#define r9 9
+#define r10 10
#define r13 13
#define r31 31
#include <features.h>
- .section ".text"
+.text
.globl _start
- .type _start, at function
- .weak _init
- .weak _fini
+ .type _start,%function
+ .type _init,%function
+ .type _fini,%function
+ .type main,%function
.type __uClibc_start_main,%function
-/* Stick in a dummy reference to main(), so that if an application
- * is linking when the main() function is in a static library (.a)
- * we can be sure that main() actually gets linked in */
- .type main,%function
-
_start:
- /* Save the stack pointer, in case we're statically linked under Linux. */
- mr r9,r1
+ mr r9,r1 /* Save the stack pointer */
+ clrrwi r1,r1,4 /* Align stack ptr to 16 bytes */
+ mr r10,r1 /* Pass aligned stack ptr */
#if defined L_Scrt1
bl _GLOBAL_OFFSET_TABLE_-4 at local
mflr r31
#endif
/* Set up an initial stack frame, and clear the LR. */
- clrrwi r1,r1,4
li r0,0
stwu r1,-16(r1)
mtlr r0
stw r0,0(r1)
-
/* find argc from the stack pointer */
- lwz r3,0(r9)
+ lwz r4,0(r9)
/* find argv one word offset from the stack pointer */
- addi r4,r9,4
+ addi r5,r9,4
/* find environment pointer (argv+argc+1) */
- lwz r5,0(r9)
- addi r5,r5,1
- rlwinm r5,r5,2,0,29
- add r5,r5,r4
- mr r9,r7 /* Pass _dl_fini from ldso */
+ lwz r6,0(r9)
+ addi r6,r6,1
+ rlwinm r6,r6,2,0,29
+ add r6,r6,r5
+ mr r9,r7 /* Pass _dl_fini from ldso or NULL if statically linked */
/* Ok, now run uClibc's main() -- shouldn't return */
# ifdef L_Scrt1
lwz r6,_init at got(r31)
lwz r7,_fini at got(r31)
- lwz r8,main at got(r31)
+ lwz r3,main at got(r31)
b __uClibc_start_main at plt
# else
lis r6,_init at ha # load top 16 bits
addi r6,r6,_init at l # load bottom 16 bits
- lis r7,_fini at ha # load top 16 bits of &msg
+ lis r7,_fini at ha # load top 16 bits
addi r7,r7,_fini at l # load bottom 16 bits
- lis r8,main at ha # load top 16 bits of &msg
- addi r8,r8,main at l # load bottom 16 bits
+ lis r3,main at ha # load top 16 bits
+ addi r3,r3,main at l # load bottom 16 bits
b __uClibc_start_main
# endif
.size _start,.-_start
More information about the uClibc-cvs
mailing list