diff --git a/libc/Android.bp b/libc/Android.bp index 37e0f098b..3e2ee1dcd 100644 --- a/libc/Android.bp +++ b/libc/Android.bp @@ -1525,6 +1525,22 @@ cc_library_static { ], } +// Versions of dl_iterate_phdr and similar APIs used to lookup unwinding information in a static +// executable. +cc_library_static { + name: "libc_unwind_static", + defaults: ["libc_defaults"], + cflags: ["-DLIBC_STATIC"], + + srcs: ["bionic/dl_iterate_phdr_static.cpp"], + arch: { + // arm32-specific dl_unwind_find_exidx and __gnu_Unwind_Find_exidx APIs + arm: { + srcs: ["arch-arm/bionic/exidx_static.c"], + }, + }, +} + // ======================================================== // libc_nomalloc.a // ======================================================== @@ -1537,20 +1553,13 @@ cc_library_static { cc_library_static { name: "libc_nomalloc", - defaults: ["libc_defaults"], - - arch: { - arm: { - srcs: ["arch-arm/bionic/exidx_static.c"], - }, - }, - cflags: ["-DLIBC_STATIC"], whole_static_libs: [ "libc_common_static", "libc_init_static", + "libc_unwind_static", ], } @@ -1572,7 +1581,6 @@ filegroup { filegroup { name: "libc_sources_static", srcs: [ - "bionic/dl_iterate_phdr_static.cpp", "bionic/malloc_common.cpp", "bionic/malloc_limit.cpp", ], @@ -1586,11 +1594,6 @@ filegroup { ], } -filegroup { - name: "libc_sources_static_arm", - srcs: [ "arch-arm/bionic/exidx_static.c" ], -} - // ======================================================== // libc.a + libc.so // ======================================================== @@ -1613,6 +1616,7 @@ cc_library { whole_static_libs: [ "libc_init_static", "libc_common_static", + "libc_unwind_static", ], }, shared: { @@ -1662,9 +1666,6 @@ cc_library { // special for arm cflags: ["-DCRT_LEGACY_WORKAROUND"], }, - static: { - srcs: [":libc_sources_static_arm"], - }, // Arm 32 bit does not produce complete exidx unwind information // so keep the .debug_frame which is relatively small and does diff --git a/libc/arch-arm/bionic/exidx_static.c b/libc/arch-arm/bionic/exidx_static.c index ef3745f85..9830c54de 100644 --- a/libc/arch-arm/bionic/exidx_static.c +++ b/libc/arch-arm/bionic/exidx_static.c @@ -43,7 +43,11 @@ struct exidx_entry { extern struct exidx_entry __exidx_end; extern struct exidx_entry __exidx_start; -_Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr pc __attribute__((unused)), int* pcount) { +_Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc __attribute__((unused)), int* pcount) { *pcount = (&__exidx_end - &__exidx_start); return (_Unwind_Ptr)&__exidx_start; } + +_Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr pc, int *pcount) { + return dl_unwind_find_exidx(pc, pcount); +} diff --git a/libdl/libdl_static.cpp b/libdl/libdl_static.cpp index 0a36e6f16..3bbf96329 100644 --- a/libdl/libdl_static.cpp +++ b/libdl/libdl_static.cpp @@ -41,9 +41,3 @@ int dladdr(const void* /*addr*/, Dl_info* /*info*/) { int dlclose(void* /*handle*/) { return -1; } - -#if defined(__arm__) -_Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr /*pc*/, int* /*pcount*/) { - return 0; -} -#endif