From 165b1cf57bab5db9716ea79e546d329b46159a3f Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Wed, 13 Feb 2019 14:10:10 -0800 Subject: [PATCH] Switch libc to libcrt.builtins With the switch to libcrt.builtins, some symbols no longer becomes exported. Add dummy references to them to force them to be exported. This is to maintain backwards binary compatibility with ancient Android versions. x86 and x86_64 crashes with libcrt, keep using libgcc for now. Test: bionic-unit-tests Bug: 29275768 Bug: 122993569 Change-Id: Ieab5af354e3924af4a03d888b28c6e75090cb613 --- libc/Android.bp | 15 +++++++++++---- .../bionic/{libgcc_compat.c => libcrt_compat.c} | 8 +++++++- .../bionic/{libgcc_compat.c => libcrt_compat.c} | 2 +- .../bionic/{libgcc_compat.c => libcrt_compat.c} | 2 +- libc/libc.map.txt | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) rename libc/arch-arm/bionic/{libgcc_compat.c => libcrt_compat.c} (95%) rename libc/arch-mips/bionic/{libgcc_compat.c => libcrt_compat.c} (97%) rename libc/arch-x86/bionic/{libgcc_compat.c => libcrt_compat.c} (97%) diff --git a/libc/Android.bp b/libc/Android.bp index 1487975a6..489918b06 100644 --- a/libc/Android.bp +++ b/libc/Android.bp @@ -77,8 +77,15 @@ cc_defaults { native_coverage: false, recovery_available: true, + arch: { + x86: { + no_libcrt: true, + }, + x86_64: { + no_libcrt: true, + }, + }, // TODO(ivanlozano): Remove after b/118321713 - no_libcrt: true, xom: false, } @@ -765,7 +772,7 @@ cc_library_static { "arch-arm/bionic/atomics_arm.c", "arch-arm/bionic/__bionic_clone.S", "arch-arm/bionic/_exit_with_stack_teardown.S", - "arch-arm/bionic/libgcc_compat.c", + "arch-arm/bionic/libcrt_compat.c", "arch-arm/bionic/popcount_tab.c", "arch-arm/bionic/__restore.S", "arch-arm/bionic/setjmp.S", @@ -849,7 +856,7 @@ cc_library_static { "arch-mips/bionic/__bionic_clone.S", "arch-mips/bionic/cacheflush.cpp", "arch-mips/bionic/_exit_with_stack_teardown.S", - "arch-mips/bionic/libgcc_compat.c", + "arch-mips/bionic/libcrt_compat.c", "arch-mips/bionic/setjmp.S", "arch-mips/bionic/syscall.S", "arch-mips/bionic/vfork.S", @@ -919,7 +926,7 @@ cc_library_static { "arch-x86/bionic/__bionic_clone.S", "arch-x86/bionic/_exit_with_stack_teardown.S", - "arch-x86/bionic/libgcc_compat.c", + "arch-x86/bionic/libcrt_compat.c", "arch-x86/bionic/__restore.S", "arch-x86/bionic/setjmp.S", "arch-x86/bionic/syscall.S", diff --git a/libc/arch-arm/bionic/libgcc_compat.c b/libc/arch-arm/bionic/libcrt_compat.c similarity index 95% rename from libc/arch-arm/bionic/libgcc_compat.c rename to libc/arch-arm/bionic/libcrt_compat.c index abd142232..22a338730 100644 --- a/libc/arch-arm/bionic/libgcc_compat.c +++ b/libc/arch-arm/bionic/libcrt_compat.c @@ -90,6 +90,8 @@ extern char __floatunsidf; extern char __floatunsisf; extern char __gedf2; extern char __gtdf2; +extern char __gnu_ldivmod_helper; +extern char __gnu_uldivmod_helper; extern char __ledf2; extern char __ltdf2; extern char __muldf3; @@ -101,10 +103,11 @@ extern char __popcountsi2; extern char __subdf3; extern char __subsf3; extern char __truncdfsf2; +extern char __udivdi3; extern char __unorddf2; extern char __unordsf2; -void* __bionic_libgcc_compat_symbols[] = { +void* __bionic_libcrt_compat_symbols[] = { &__adddf3, &__addsf3, &__aeabi_cdcmpeq, @@ -169,6 +172,8 @@ void* __bionic_libgcc_compat_symbols[] = { &__floatunsisf, &__gedf2, &__gtdf2, + &__gnu_ldivmod_helper, + &__gnu_uldivmod_helper, &__ledf2, &__ltdf2, &__muldf3, @@ -180,6 +185,7 @@ void* __bionic_libgcc_compat_symbols[] = { &__subdf3, &__subsf3, &__truncdfsf2, + &__udivdi3, &__unorddf2, &__unordsf2, }; diff --git a/libc/arch-mips/bionic/libgcc_compat.c b/libc/arch-mips/bionic/libcrt_compat.c similarity index 97% rename from libc/arch-mips/bionic/libgcc_compat.c rename to libc/arch-mips/bionic/libcrt_compat.c index 1a0f5662b..cfa41f261 100644 --- a/libc/arch-mips/bionic/libgcc_compat.c +++ b/libc/arch-mips/bionic/libcrt_compat.c @@ -32,7 +32,7 @@ extern char __popcountsi2; extern char __udivdi3; extern char __umoddi3; -void* __bionic_libgcc_compat_symbols[] = { +void* __bionic_libcrt_compat_symbols[] = { &__divdi3, &__moddi3, &__popcountsi2, diff --git a/libc/arch-x86/bionic/libgcc_compat.c b/libc/arch-x86/bionic/libcrt_compat.c similarity index 97% rename from libc/arch-x86/bionic/libgcc_compat.c rename to libc/arch-x86/bionic/libcrt_compat.c index 1a0f5662b..cfa41f261 100644 --- a/libc/arch-x86/bionic/libgcc_compat.c +++ b/libc/arch-x86/bionic/libcrt_compat.c @@ -32,7 +32,7 @@ extern char __popcountsi2; extern char __udivdi3; extern char __umoddi3; -void* __bionic_libgcc_compat_symbols[] = { +void* __bionic_libcrt_compat_symbols[] = { &__divdi3, &__moddi3, &__popcountsi2, diff --git a/libc/libc.map.txt b/libc/libc.map.txt index 6a6ea7d3f..62aea27bc 100644 --- a/libc/libc.map.txt +++ b/libc/libc.map.txt @@ -1561,7 +1561,7 @@ LIBC_PRIVATE { __ashldi3; # arm __ashrdi3; # arm __bionic_brk; # arm x86 mips - __bionic_libgcc_compat_symbols; # arm x86 + __bionic_libcrt_compat_symbols; # arm x86 __cmpdf2; # arm __divdf3; # arm __divdi3; # arm x86 mips