summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/csky/crt1.S
diff options
context:
space:
mode:
authorGuo Ren <ren_guo@c-sky.com>2017-10-15 20:59:34 +0800
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2017-11-19 09:20:11 +0100
commit2fcffe26e815b7125a357c83b59617ab93c16b41 (patch)
treefe5a973dc4bbf38bce8468a4497f5f656f082a9f /libc/sysdeps/linux/csky/crt1.S
parent9e38e0aa45cca21d5023d0af94377f0e1e41d2f4 (diff)
csky: port to uclibc-ng
Follow the steps to build c-sky uclibc linux system: 1. git clone https://github.com/c-sky/buildroot.git 2. cd buildroot 3. make qemu_csky_ck810_uclibc_defconfig 4. make Follow the buildroot/board/qemu/csky/readme.txt to run. This buildroot toolchain is pre-build, But you can rebuild the c-sky uclibc-ng alone and install it to the buildroot sysroot manually. We'll try our best to improve the uclibc-ng continuously. Signed-off-by: Guo Ren <ren_guo@c-sky.com>
Diffstat (limited to 'libc/sysdeps/linux/csky/crt1.S')
-rw-r--r--libc/sysdeps/linux/csky/crt1.S95
1 files changed, 95 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/csky/crt1.S b/libc/sysdeps/linux/csky/crt1.S
new file mode 100644
index 000000000..ae73843fb
--- /dev/null
+++ b/libc/sysdeps/linux/csky/crt1.S
@@ -0,0 +1,95 @@
+#include <sysdep.h>
+
+ .text
+.global _start
+.type _start,%function
+.global __exit
+.global atexit
+
+.global _init
+.global _fini
+
+.global main
+.global __uClibc_main
+
+/*
+ * argc, argv and envp are on the stack
+ *
+ * Call:
+ * void __uClibc_main(
+ * int (*main)(int, char **, char **),
+ * int argc,
+ * char **argv,
+ * void (*app_init)(void),
+ * void (*app_fini)(void),
+ * void (*rtld_fini)(void),
+ * void *stack_end attribute_unused);
+ */
+
+_start:
+#ifdef __PIC__
+ __GET_GB
+ lrw a0, main@GOT
+ addu a0, gb
+ ldw a0, (a0)
+
+ ldw a1, (sp)
+ mov a2, sp
+ addi a2, 4
+
+ mov a3, sp /* push stack_end */
+ subi sp, 8
+ stw a3, (sp)
+
+ lrw a3, _init@GOT
+ addu a3, gb
+ ldw a3, (a3)
+
+#ifdef __CSKYABIV2__
+ subi sp, 8
+ lrw l4, _fini@GOT
+ addu l4, gb
+ ldw l4, (l4)
+ stw l4, (sp)
+
+ stw r7, (sp, 4) /* push rtld_fini */
+#else
+ lrw a4, _fini@GOT
+ addu a4, gb
+ ldw a4, (a4)
+#endif
+
+ lrw l4, __uClibc_main@PLT
+ addu l4, gb
+ ldw l4, (l4)
+ jsr l4
+
+#else /* __PIC__ */
+ lrw a0, main
+
+ ldw a1, (sp)
+ mov a2, sp
+ addi a2, 4
+
+ mov a3, sp /* push stack_end */
+ subi sp, 8
+ stw a3, (sp)
+
+ lrw a3, _init
+#ifdef __CSKYABIV2__
+ subi sp, 8
+ lrw l4, _fini
+ stw l4, (sp)
+ stw r7, (sp, 4)
+#else
+ lrw a4, _fini
+#endif
+
+ lrw l4, __uClibc_main
+ jsr l4
+#endif /* __PIC__ */
+ bsr __exit
+__exit:
+ DO_CALL(exit, 0)
+ br .
+