From fe892c5e668ec7d4e7994787c6294a5adbc865a8 Mon Sep 17 00:00:00 2001 From: Thomas Veerman Date: Fri, 25 Jan 2013 14:29:29 +0100 Subject: [PATCH] libcsu: store argc and argv on the stack --- lib/csu/arch/earm/crt0.S | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/csu/arch/earm/crt0.S b/lib/csu/arch/earm/crt0.S index 1359874bf..67a872031 100644 --- a/lib/csu/arch/earm/crt0.S +++ b/lib/csu/arch/earm/crt0.S @@ -36,16 +36,32 @@ RCSID("$NetBSD: crt0.S,v 1.1 2012/08/13 02:49:04 matt Exp $") STRONG_ALIAS(_start,__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 */ mov ip, r0 /* ps_strings -> tmp */ mov r0, r2 /* cleanup -> ps_strings */ mov r2, ip /* tmp -> ps_strings */ - +#endif /* __minix */ /* Ensure the stack is properly aligned before calling C code. */ 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), * const Obj_Entry *obj, -- 2.44.0