diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2005-02-09 08:42:13 +0000 |
---|---|---|
committer | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2005-02-09 08:42:13 +0000 |
commit | 439fc76c8d321d10018aad3a9a5d9562906c58ad (patch) | |
tree | 330775bad28c6ab360f420c84960329879b0139a /libc/sysdeps/linux | |
parent | 41d65c1c06be54140ec2b218c0c11a67305614fe (diff) |
Implement _start completely in assembler. Otherwise the compiler will
push the frame pointer when DO_DEBUG is enabled (and thus incorrect
argc, argv and envp will be passed to the program).
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r-- | libc/sysdeps/linux/cris/crt0.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/libc/sysdeps/linux/cris/crt0.c b/libc/sysdeps/linux/cris/crt0.c index 166d30b60..a676ee908 100644 --- a/libc/sysdeps/linux/cris/crt0.c +++ b/libc/sysdeps/linux/cris/crt0.c @@ -8,22 +8,26 @@ static void start1 (int argc, char **argv) __attribute__ ((used, noreturn)); /* * It is important that this be the first function. * This file is the first thing in the text section. + * This is implemented completely in assembler to avoid that the + * compiler pushes stuff on the stack (e.g. the frame pointer when + * debuging). */ -void -_start (void) -{ - /* - * On the stack we have argc. We can calculate argv/envp - * from that and the succeeding stack location, but fix so - * we get the right calling convention (regs in r10/r11). - * - * Please view linux/fs/binfmt_elf.c for a complete - * understanding of this. - */ - __asm__ volatile("pop $r10"); - __asm__ volatile("move.d $sp, $r11"); - __asm__ volatile("jump start1"); -} + +/* + * On the stack we have argc. We can calculate argv/envp + * from that and the succeeding stack location, but fix so + * we get the right calling convention (regs in r10/r11). + * + * Please view linux/fs/binfmt_elf.c for a complete + * understanding of this. + */ +__asm__ ( \ + ".text\n\t" \ + ".global _start\n\t" \ + "_start:\n\t" \ + "pop $r10\n\t" \ + "move.d $sp, $r11\n\t" \ + "jump start1\n\t"); #include <features.h> |