libcsu: store argc and argv on the stack

This commit is contained in:
Thomas Veerman 2013-01-25 14:29:29 +01:00
parent 31c6dc292d
commit fe892c5e66

View file

@ -36,16 +36,32 @@ RCSID("$NetBSD: crt0.S,v 1.1 2012/08/13 02:49:04 matt Exp $")
STRONG_ALIAS(_start,__start) STRONG_ALIAS(_start,__start)
_ENTRY(__start) _ENTRY(__start)
#ifdef __minix
mov r5, r2 /* cleanup */
mov r4, r1 /* obj_main */
mov r3, r0 /* ps_strings */
/* Get argc, argv, and envp from stack */
ldr r0, [sp, #0x0000]
add r1, sp, #0x0004
add r2, r1, r0, lsl #2
add r2, r2, #0x0004
#else
/* /*
* We need to swap ps_strings and cleanup * We need to swap ps_strings and cleanup
*/ */
mov ip, r0 /* ps_strings -> tmp */ mov ip, r0 /* ps_strings -> tmp */
mov r0, r2 /* cleanup -> ps_strings */ mov r0, r2 /* cleanup -> ps_strings */
mov r2, ip /* tmp -> ps_strings */ mov r2, ip /* tmp -> ps_strings */
#endif /* __minix */
/* Ensure the stack is properly aligned before calling C code. */ /* Ensure the stack is properly aligned before calling C code. */
bic sp, sp, #7 bic sp, sp, #7
#ifdef __minix
/* Store argc and argv on the stack */
sub sp, sp, #8
str r5, [sp, #4]
str r4, [sp, #0]
#endif
/* /*
* void ___start(void (*cleanup)(void), * void ___start(void (*cleanup)(void),
* const Obj_Entry *obj, * const Obj_Entry *obj,