summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/internals/__uClibc_main.c7
-rw-r--r--libc/sysdeps/linux/i386/crt1.S11
-rw-r--r--libc/sysdeps/linux/powerpc/crt1.S44
3 files changed, 30 insertions, 32 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 70dc07328..63302c3a2 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -164,10 +164,11 @@ void attribute_hidden (*__rtld_fini)(void) = NULL;
* 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;
diff --git a/libc/sysdeps/linux/i386/crt1.S b/libc/sysdeps/linux/i386/crt1.S
index 76e71be56..7eee8aea9 100644
--- a/libc/sysdeps/linux/i386/crt1.S
+++ b/libc/sysdeps/linux/i386/crt1.S
@@ -38,8 +38,9 @@ Cambridge, MA 02139, USA. */
.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 @@ _start:
/* 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 @@ _start:
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@GOT(%edx)
pushl _fini@GOT(%edx)
pushl _init@GOT(%edx)
#else
- pushl $main
pushl $_fini
pushl $_init
#endif
@@ -105,8 +104,10 @@ _start:
/* Ok, now run uClibc's main() -- shouldn't return */
#ifdef L_Scrt1
+ pushl main@GOT(%edx)
call *__uClibc_start_main@GOT(%edx)
#else
+ pushl $main
call __uClibc_start_main
#endif
diff --git a/libc/sysdeps/linux/powerpc/crt1.S b/libc/sysdeps/linux/powerpc/crt1.S
index 42040e2ee..916c34a4b 100644
--- a/libc/sysdeps/linux/powerpc/crt1.S
+++ b/libc/sysdeps/linux/powerpc/crt1.S
@@ -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,@function
- .weak _init
- .weak _fini
- .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 _start,%function
+ .type _init,%function
+ .type _fini,%function
.type main,%function
+ .type __uClibc_start_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@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@got(r31)
lwz r7,_fini@got(r31)
- lwz r8,main@got(r31)
+ lwz r3,main@got(r31)
b __uClibc_start_main@plt
# else
lis r6,_init@ha # load top 16 bits
addi r6,r6,_init@l # load bottom 16 bits
- lis r7,_fini@ha # load top 16 bits of &msg
+ lis r7,_fini@ha # load top 16 bits
addi r7,r7,_fini@l # load bottom 16 bits
- lis r8,main@ha # load top 16 bits of &msg
- addi r8,r8,main@l # load bottom 16 bits
+ lis r3,main@ha # load top 16 bits
+ addi r3,r3,main@l # load bottom 16 bits
b __uClibc_start_main
# endif
.size _start,.-_start