summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux
diff options
context:
space:
mode:
authorTobias Anderberg <tobias.anderberg@axis.com>2003-09-19 12:06:05 +0000
committerTobias Anderberg <tobias.anderberg@axis.com>2003-09-19 12:06:05 +0000
commita6f671bc7c89ef6c36e037f319fd45b599f1c893 (patch)
tree1e63578a88a8307006d26ca0474e3bb20c9a440f /libc/sysdeps/linux
parenta436319a3a1e288bfaa0eb79f7066e7290464ba8 (diff)
Added assembler version of startup code. Fix Makefile so it uses the new
code.
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r--libc/sysdeps/linux/cris/Makefile2
-rw-r--r--libc/sysdeps/linux/cris/crt0.S72
2 files changed, 73 insertions, 1 deletions
diff --git a/libc/sysdeps/linux/cris/Makefile b/libc/sysdeps/linux/cris/Makefile
index 8a860f188..dacfb4dc5 100644
--- a/libc/sysdeps/linux/cris/Makefile
+++ b/libc/sysdeps/linux/cris/Makefile
@@ -20,7 +20,7 @@ TOPDIR=../../../../
include $(TOPDIR)Rules.mak
ASFLAGS=$(CFLAGS)
-CRT0_SRC = crt0.c
+CRT0_SRC = crt0.S
CRT0_OBJ = crt0.o crt1.o
SSRC= setjmp.S __longjmp.S clone.S sysdep.S syscall.S
diff --git a/libc/sysdeps/linux/cris/crt0.S b/libc/sysdeps/linux/cris/crt0.S
new file mode 100644
index 000000000..b2f8d02a2
--- /dev/null
+++ b/libc/sysdeps/linux/cris/crt0.S
@@ -0,0 +1,72 @@
+;; Startup code compiant to the ELF CRIS ABI.
+;;
+;; Highly based on code from glibc.
+
+#include <sysdep.h>
+
+ .syntax no_register_prefix
+
+ .text
+ .globl _start
+ .type _start,@function
+
+#if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__
+ .type __uClibc_main,@function
+#else
+ .weak _init
+ .weak _fini
+ .type __uClibc_start_main,@function
+#endif
+
+ ;; Setup a dummy reference to main so that if an application is linking
+ ;; when the main() function is in a static library we can be sure that
+ ;; the main() actually gets linked in.
+ .type main,@function
+
+_start:
+ ;; Clear the frame pointer, to mark the outermost frame.
+ moveq 0, r8
+
+ move.d [sp],r11
+ move.d sp,[sp]
+ move.d sp,r12
+ addq 4,r12
+ push r9
+
+#ifdef __PIC__
+ move.d pc,r0
+ sub.d .:GOTOFF,r0
+ move.d _init:PLTG,r13
+ add.d r0,r13
+ move.d _fini:PLTG,r9
+ add.d r0,r9
+ move.d main:PLTG,r10
+ add.d r0,r10
+#else
+ move.d _init,r13
+ move.d _fini,r9
+ move.d main,r10
+#endif
+
+ push r9
+
+#if (defined L_crt1 || defined L_gcrt1) && defined __UCLIBC_CTOR_DTOR__
+ PLTCALL(__uClibc_start_main)
+#else
+ PLTCALL(__uClibc_main)
+#endif
+
+ ;; Crash if 'exit' returns.
+ test.d [6502]
+0:
+ ba 0b
+ nop
+
+ ;; Define a symbol for the first piece of initialized data.
+ .data
+ .globl __data_start
+
+__data_start:
+ .long 0
+ .weak data_start
+ data_start = __data_start