summaryrefslogtreecommitdiff
path: root/os/src
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2011-01-24 08:54:54 +0100
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2011-01-24 08:57:27 +0100
commite46ea682c1aa214ccb59c9871914993c9375e5c2 (patch)
tree6cb321024598fcc2a6cb9b3968834d7655bb26b1 /os/src
parent6a6e8752bdf9b7c11921c502f2433b8fdbf0c525 (diff)
Fixing a few templates, and making the various needed functions available.
Diffstat (limited to 'os/src')
-rw-r--r--os/src/init.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/os/src/init.c b/os/src/init.c
index e69de29..d161355 100644
--- a/os/src/init.c
+++ b/os/src/init.c
@@ -0,0 +1,23 @@
+#include <stdlib.h>
+
+extern void __libc_init_array(void) __attribute__ ((weak));
+extern void __libc_fini_array(void) __attribute__ ((weak));
+extern void exit(int) __attribute__ ((noreturn, weak));
+extern void __main() __attribute__ ((weak));
+extern int main(int, char **, char **);
+
+void _start() {
+ if (__libc_init_array)
+ __libc_init_array();
+
+ if (__main)
+ __main();
+
+ int return_code = main(0, NULL, NULL);
+
+ if (__libc_fini_array)
+ __libc_fini_array();
+
+ if (exit)
+ exit(return_code);
+}