summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2010-11-29 14:14:27 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2010-11-29 14:14:27 +0000
commitd6a72fff81fd3a9e042346d6e958aaf455e2447d (patch)
treef2cbd1289cd13e6043cc2d107baa9d12c8e31379 /cpukit/libcsupport
parent2010-11-26 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff)
downloadrtems-d6a72fff81fd3a9e042346d6e958aaf455e2447d.tar.bz2
2010-11-29 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/src/newlibc_exit.c, score/src/threadhandler.c: Added support for .preinit_array, .init_array and .fini_array sections.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r--cpukit/libcsupport/src/newlibc_exit.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/cpukit/libcsupport/src/newlibc_exit.c b/cpukit/libcsupport/src/newlibc_exit.c
index 818ba884f4..3cf602d62e 100644
--- a/cpukit/libcsupport/src/newlibc_exit.c
+++ b/cpukit/libcsupport/src/newlibc_exit.c
@@ -118,10 +118,13 @@ void libc_wrapup(void)
*/
#include <unistd.h>
+#include <newlib.h>
-/* FIXME: These defines are a blatant hack */
- #define EXIT_SYMBOL _exit
+#if defined(HAVE_INITFINI_ARRAY)
+ extern void __libc_fini_array(void);
+#endif
+/* FIXME: These defines are a blatant hack */
#if defined(__AVR__)
#undef __USE_INIT_FINI__
#endif
@@ -135,8 +138,22 @@ void libc_wrapup(void)
extern void FINI_SYMBOL( void );
#endif
-void EXIT_SYMBOL(int status)
+void _exit(int status)
{
+ #if defined(HAVE_INITFINI_ARRAY)
+ /*
+ * According to
+ *
+ * System V Application Binary Interface
+ * Chapter 5
+ * Initialization and Termination Functions
+ *
+ * we have to call the functions referenced by the .fini_array before the
+ * one referenced by the .fini section.
+ */
+ __libc_fini_array();
+ #endif
+
/*
* If the toolset uses init/fini sections, then we need to
* run the global destructors now.