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 + +// __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__ */