summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/csu/crtbegin.c10
-rw-r--r--lib/csu/crtbeginS.c10
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/csu/crtbegin.c b/lib/csu/crtbegin.c
index f594675d78d..bf2c4fb09cd 100644
--- a/lib/csu/crtbegin.c
+++ b/lib/csu/crtbegin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crtbegin.c,v 1.16 2012/09/08 20:08:33 matthew Exp $ */
+/* $OpenBSD: crtbegin.c,v 1.17 2013/12/28 18:38:42 kettenis Exp $ */
/* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */
/*
@@ -84,6 +84,14 @@ void *__dso_handle = NULL;
__asm(".hidden __dso_handle");
long __guard_local __dso_hidden __attribute__((section(".openbsd.randomdata")));
+
+extern int __cxa_atexit(void (*)(void *), void *, void *) __attribute__((weak));
+
+int
+atexit(void (*fn)(void))
+{
+ return (__cxa_atexit((void (*)(void *))fn, NULL, NULL));
+}
#endif
static const init_f __CTOR_LIST__[1]
diff --git a/lib/csu/crtbeginS.c b/lib/csu/crtbeginS.c
index b72698fe2b4..f3c784214a7 100644
--- a/lib/csu/crtbeginS.c
+++ b/lib/csu/crtbeginS.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crtbeginS.c,v 1.13 2012/09/08 20:08:33 matthew Exp $ */
+/* $OpenBSD: crtbeginS.c,v 1.14 2013/12/28 18:38:42 kettenis Exp $ */
/* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */
/*
@@ -72,7 +72,15 @@ __asm(".hidden __dso_handle");
long __guard_local __dso_hidden __attribute__((section(".openbsd.randomdata")));
+extern int __cxa_atexit(void (*)(void *), void *, void *) __attribute__((weak));
extern void __cxa_finalize(void *) __attribute__((weak));
+
+int
+atexit(void (*fn)(void))
+{
+ return (__cxa_atexit((void (*)(void *))fn, NULL, &__dso_handle));
+}
+asm(".hidden atexit");
#endif
static init_f __CTOR_LIST__[1]