diff options
Diffstat (limited to 'libc/arch-arm/bionic/crtbegin_so.c')
-rw-r--r-- | libc/arch-arm/bionic/crtbegin_so.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libc/arch-arm/bionic/crtbegin_so.c b/libc/arch-arm/bionic/crtbegin_so.c index 57d19bf..36e4b9c 100644 --- a/libc/arch-arm/bionic/crtbegin_so.c +++ b/libc/arch-arm/bionic/crtbegin_so.c @@ -34,10 +34,25 @@ void __on_dlclose() { __cxa_finalize(&__dso_handle); } +/* CRT_LEGACY_WORKAROUND should only be defined when building + * this file as part of the platform's C library. + * + * The C library already defines a function named 'atexit()' + * for backwards compatibility with older NDK-generated binaries. + * + * For newer ones, 'atexit' is actually embedded in the C + * runtime objects that are linked into the final ELF + * binary (shared library or executable), and will call + * __cxa_atexit() in order to un-register any atexit() + * handler when a library is unloaded. + * + * This function must be global *and* hidden. Only the + * code inside the same ELF binary should be able to access it. + */ + #ifdef CRT_LEGACY_WORKAROUND #include "__dso_handle.h" #else -#include "__dso_handle_so.h" -#endif - +#include "__dso_handle_so.c" #include "atexit.h" +#endif |