diff options
author | Dan Albert <danalbert@google.com> | 2018-01-24 13:19:08 -0800 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2018-01-24 16:37:48 -0800 |
commit | 2e2c72d61f1c8bc12d0adf483b3c9b9524ca2a7f (patch) | |
tree | b049352340c231d716a88fee3b4e56105f61c85b | |
parent | 73871ad09be8a8259171d606c4e3e3cf08d4733c (diff) | |
download | android_bionic-2e2c72d61f1c8bc12d0adf483b3c9b9524ca2a7f.tar.gz android_bionic-2e2c72d61f1c8bc12d0adf483b3c9b9524ca2a7f.tar.bz2 android_bionic-2e2c72d61f1c8bc12d0adf483b3c9b9524ca2a7f.zip |
Pre-M and GCC compatibility for crtbegin.
We're going to start using the bionic sources for the NDK CRT
objects, so we need to avoid using symbols that weren't around in
early versions of Android. The NDK is currently building the CRT
objects with GCC as well (there were some segfaults that have yet to
be diagnosed), so move `__used` to the GCC compatible location.
Test: treehugger
Bug: None
Change-Id: I1f5c23eafadc2e3bc0b84bc3305f79a04d35c7d8
-rw-r--r-- | libc/arch-common/bionic/crtbegin.c | 2 | ||||
-rw-r--r-- | libc/arch-common/bionic/pthread_atfork.h | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/libc/arch-common/bionic/crtbegin.c b/libc/arch-common/bionic/crtbegin.c index 45c9ea707..0921f4faf 100644 --- a/libc/arch-common/bionic/crtbegin.c +++ b/libc/arch-common/bionic/crtbegin.c @@ -36,7 +36,7 @@ SECTION(".init_array") void (*__INIT_ARRAY__)(void) = (void (*)(void)) -1; SECTION(".fini_array") void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1; #undef SECTION -static void _start_main(void* raw_args) __used { +__used static void _start_main(void* raw_args) { structors_array_t array; array.preinit_array = &__PREINIT_ARRAY__; array.init_array = &__INIT_ARRAY__; diff --git a/libc/arch-common/bionic/pthread_atfork.h b/libc/arch-common/bionic/pthread_atfork.h index 0c48a1269..c6a33ffe0 100644 --- a/libc/arch-common/bionic/pthread_atfork.h +++ b/libc/arch-common/bionic/pthread_atfork.h @@ -14,6 +14,12 @@ * limitations under the License. */ +#include <android/api-level.h> + +// __register_atfork wasn't available until android-23. We need to build a +// pre-23 and 23+ version of crtbegin. +#if __ANDROID_API__ >= __ANDROID_API_M__ + extern void* __dso_handle; extern int __register_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void), void* dso); @@ -27,3 +33,4 @@ int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(vo return __register_atfork(prepare, parent, child, &__dso_handle); } +#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */ |