summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-05-27 01:50:28 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-05-27 01:50:28 -0700
commit1ff2ee440bddc84e3216de3c9965943e0b2f020a (patch)
tree020e7a3b9bb8cc37790b2cbaf799157b8de42ce5
parentb572dc4b518c7283eb60f43c927b9149f31366e3 (diff)
parent5c106fcaa5b9d0a3ebeb2e8cdca589129d6a7ebd (diff)
downloadbionic-1ff2ee440bddc84e3216de3c9965943e0b2f020a.zip
bionic-1ff2ee440bddc84e3216de3c9965943e0b2f020a.tar.gz
bionic-1ff2ee440bddc84e3216de3c9965943e0b2f020a.tar.bz2
am 5c106fca: Merge change 1852 into donut
Merge commit '5c106fcaa5b9d0a3ebeb2e8cdca589129d6a7ebd' * commit '5c106fcaa5b9d0a3ebeb2e8cdca589129d6a7ebd': Fix __eabi_atexit() implementation, as well as a bug in the BSD-originated __cxa_finalize() implementation
-rw-r--r--libc/bionic/eabi.c11
-rw-r--r--libc/stdlib/atexit.c9
2 files changed, 18 insertions, 2 deletions
diff --git a/libc/bionic/eabi.c b/libc/bionic/eabi.c
index 2e0c99c..a5f6627 100644
--- a/libc/bionic/eabi.c
+++ b/libc/bionic/eabi.c
@@ -32,13 +32,20 @@ extern int __cxa_atexit(void (*)(void*), void*, void* );
void* __dso_handle = 0;
+/* The "C++ ABI for ARM" document states that static C++ constructors,
+ * which are called from the .init_array, should manually call
+ * __aeabi_atexit() to register static destructors explicitely.
+ *
+ * Note that 'dso_handle' is the address of a magic linker-generate
+ * variable from the shared object that contains the constructor/destructor
+ */
+
/* Make this a weak symbol to avoid a multiple definition error when linking
* with libstdc++-v3. */
int __attribute__((weak))
__aeabi_atexit (void *object, void (*destructor) (void *), void *dso_handle)
{
- return 0;
- //return __cxa_atexit(destructor, object, dso_handle);
+ return __cxa_atexit(destructor, object, dso_handle);
}
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c
index 5bf82ba..4ba2177 100644
--- a/libc/stdlib/atexit.c
+++ b/libc/stdlib/atexit.c
@@ -147,10 +147,19 @@ __cxa_finalize(void *dso)
p->fns[n].fn_ptr.cxa_func = NULL;
mprotect(p, pgsize, PROT_READ);
}
+#if ANDROID
+ /* it looks like we should always call the function
+ * with an argument, even if dso is not NULL. Otherwise
+ * static destructors will not be called properly on
+ * the ARM.
+ */
+ (*fn.fn_ptr.cxa_func)(fn.fn_arg);
+#else /* !ANDROID */
if (dso != NULL)
(*fn.fn_ptr.cxa_func)(fn.fn_arg);
else
(*fn.fn_ptr.std_func)();
+#endif /* !ANDROID */
}
}