Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Jackman <sjackman@gmail.com>2006-07-05 19:24:30 +0400
committerShaun Jackman <sjackman@gmail.com>2006-07-05 19:24:30 +0400
commit0b6bb78b345ea7b05149ae86e3f8eb003998bec3 (patch)
tree5f9ad2067c8164edaa98dcc2acb37e1816334c80 /libgloss/arm
parent7bfe2409a0952643b52cbc88382e89269f4befe6 (diff)
2006-07-05 Shaun Jackman <sjackman@gmail.com>
* arm/linux-crt0.S: Remove file. * arm/linux-crt0.c: New file. Supports PIC code.
Diffstat (limited to 'libgloss/arm')
-rw-r--r--libgloss/arm/linux-crt0.S46
-rw-r--r--libgloss/arm/linux-crt0.c39
2 files changed, 39 insertions, 46 deletions
diff --git a/libgloss/arm/linux-crt0.S b/libgloss/arm/linux-crt0.S
deleted file mode 100644
index b3ba5bd0d..000000000
--- a/libgloss/arm/linux-crt0.S
+++ /dev/null
@@ -1,46 +0,0 @@
-/** Linux startup code for the ARM processor.
- * Written by Shaun Jackman <sjackman@gmail.com>.
- * Copyright 2006 Pathway Connectivity
- *
- * Permission to use, copy, modify, and distribute this software
- * is freely granted, provided that this notice is preserved.
- */
-
-.global _start
-.type _start, %function
-_start:
-#if __thumb__
- /* Switch to Thumb mode. */
- adr r0, _start_thumb+1
- bx r0
-.size _start, .-_start
-.global _start_thumb
-.thumb_func
-_start_thumb:
-#endif
-
-#if 0
- /* Clear the BSS. This task is normally handled by the kernel. */
- ldr r0, =__bss_start
- mov r1, #0
- ldr r2, =_end
- sub r2, r2, r0
- bl memset
-#endif
-
- pop {r0} @ argc
- mov r1, sp @ argv
- lsl r2, r0, #2
- add r2, r1
- add r2, #4 @ envp
- ldr r3, =environ
- str r2, [r3]
- bl main
- bl exit
- b .
-
-#if __thumb__
-.size _start_thumb, .-_start_thumb
-#else
-.size _start, .-_start
-#endif
diff --git a/libgloss/arm/linux-crt0.c b/libgloss/arm/linux-crt0.c
new file mode 100644
index 000000000..29f317fd7
--- /dev/null
+++ b/libgloss/arm/linux-crt0.c
@@ -0,0 +1,39 @@
+/** Linux startup code for the ARM processor.
+ * Written by Shaun Jackman <sjackman@gmail.com>.
+ * Copyright 2006 Pathway Connectivity
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+
+static int _main(int argc, char *argv[]) __attribute__((noreturn));
+
+#if __thumb__
+asm("\n"
+ ".code 32\n"
+ ".global _start\n"
+ ".type _start, %function\n"
+ "_start:\n"
+ "\tadr r0, _start_thumb+1\n"
+ "\tbx r0\n"
+ ".size _start, .-_start\n");
+
+__attribute__((naked, used))
+static void _start_thumb(void)
+#else
+__attribute__((naked))
+void _start(void)
+#endif
+{
+ register int *sp asm("sp");
+ _main(*sp, (char **)(sp + 1));
+}
+
+static int _main(int argc, char *argv[])
+{
+ environ = argv + argc + 1;
+ exit(main(argc, argv, environ));
+}