about summary refs log tree commit diff
path: root/stdlib/cxa_atexit.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-12-18 17:32:37 +0000
committerUlrich Drepper <drepper@redhat.com>2005-12-18 17:32:37 +0000
commita3c88553729c1c4dcd4f893a96b4668bce640ee5 (patch)
treed6660a25aa0a3a8b86fccfe2efbd2155e0893e97 /stdlib/cxa_atexit.c
parent3467f5c369a10ef19c8df38fb282c7763f36d66f (diff)
downloadglibc-a3c88553729c1c4dcd4f893a96b4668bce640ee5.tar.gz
glibc-a3c88553729c1c4dcd4f893a96b4668bce640ee5.tar.xz
glibc-a3c88553729c1c4dcd4f893a96b4668bce640ee5.zip
* stdlib/cxa_atexit.c: Use PTR_MANGLE on function pointer. Fill in
	flavor field last and protect with memory barrier.
	* stdlib/on_exit.c: Likewise.
	* stdlib/cxa_finalize.c: Use PTR_DEMANGLE on function pointer before
	using it.
	* stdlib/exit.c: Likewise.
Diffstat (limited to 'stdlib/cxa_atexit.c')
-rw-r--r--stdlib/cxa_atexit.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/stdlib/cxa_atexit.c b/stdlib/cxa_atexit.c
index 490776105f..9b7a932b85 100644
--- a/stdlib/cxa_atexit.c
+++ b/stdlib/cxa_atexit.c
@@ -21,6 +21,8 @@
 
 #include <bits/libc-lock.h>
 #include "exit.h"
+#include <atomic.h>
+#include <sysdep.h>
 
 #undef __cxa_atexit
 
@@ -35,10 +37,14 @@ __cxa_atexit (void (*func) (void *), void *arg, void *d)
   if (new == NULL)
     return -1;
 
-  new->flavor = ef_cxa;
+#ifdef PTR_MANGLE
+  PTR_MANGLE (func);
+#endif
   new->func.cxa.fn = (void (*) (void *, int)) func;
   new->func.cxa.arg = arg;
   new->func.cxa.dso_handle = d;
+  atomic_write_barrier ();
+  new->flavor = ef_cxa;
   return 0;
 }
 INTDEF(__cxa_atexit)