diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-09 05:59:54 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-09 05:59:54 +0000 |
commit | 5886db3768d5ee82689be428ffa8992ceefd254f (patch) | |
tree | 16dc2f66b45ceecd98af6af3af3117168c020c3d | |
parent | c0113e573dbe569aefb53fad4b05c3fbb04de0df (diff) | |
parent | 9b8c5479211a1a1dc5d35d399f88344fd1f18610 (diff) | |
download | libcxxabi-android13-frc-extservices-release.tar.gz |
Snap for 8558685 from 9b8c5479211a1a1dc5d35d399f88344fd1f18610 to tm-frc-extservices-releaset_frc_ext_330443000android13-frc-extservices-release
Change-Id: I568c2fc532ae88cd7b3ae4565da9af0ffd5f4872
-rw-r--r-- | Android.bp | 27 | ||||
-rw-r--r-- | src/cxa_exception.cpp | 33 |
2 files changed, 50 insertions, 10 deletions
@@ -176,3 +176,30 @@ cc_fuzz { "src/cxa_demangle.cpp", ], } + +// Export libc++abi headers for inclusion in the musl sysroot. +genrule { + name: "libc_musl_sysroot_libc++abi_headers", + visibility: ["//external/musl"], + srcs: [ + "NOTICE", + "include/**/*", + ], + out: ["libc_musl_sysroot_libc++abi_headers.zip"], + tools: [ + "soong_zip", + "zip2zip", + ], + cmd: "LIBCXXABI_DIR=$$(dirname $(location NOTICE)) && " + + "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" + + // NOTICE + " -j -f $(location NOTICE) " + + // headers + " -P include/c++ " + + " -C $${LIBCXXABI_DIR}/include " + + " -D $${LIBCXXABI_DIR}/include " + + " && " + + "$(location zip2zip) -i $(genDir)/sysroot.zip -o $(out) " + + " include/**/*:include " + + " NOTICE:NOTICE.libc++abi", +} diff --git a/src/cxa_exception.cpp b/src/cxa_exception.cpp index 8d30e5c..9e650b5 100644 --- a/src/cxa_exception.cpp +++ b/src/cxa_exception.cpp @@ -343,8 +343,11 @@ unwinding with _Unwind_Resume. According to ARM EHABI 8.4.1, __cxa_end_cleanup() should not clobber any register, thus we have to write this function in assembly so that we can save {r1, r2, r3}. We don't have to save r0 because it is the return value and the -first argument to _Unwind_Resume(). In addition, we are saving r4 in order to -align the stack to 16 bytes, even though it is a callee-save register. +first argument to _Unwind_Resume(). The function also saves/restores r4 to +keep the stack aligned and to provide a temp register. _Unwind_Resume never +returns and we need to keep the original lr so just branch to it. When +targeting bare metal, the function also clobbers ip/r12 to hold the address of +_Unwind_Resume, which may be too far away for an ordinary branch. */ __attribute__((used)) static _Unwind_Exception * __cxa_end_cleanup_impl() @@ -374,20 +377,30 @@ __cxa_end_cleanup_impl() return &exception_header->unwindHeader; } -asm ( - " .pushsection .text.__cxa_end_cleanup,\"ax\",%progbits\n" +asm(" .pushsection .text.__cxa_end_cleanup,\"ax\",%progbits\n" " .globl __cxa_end_cleanup\n" " .type __cxa_end_cleanup,%function\n" "__cxa_end_cleanup:\n" +#if defined(__ARM_FEATURE_BTI_DEFAULT) + " bti\n" +#endif " push {r1, r2, r3, r4}\n" + " mov r4, lr\n" " bl __cxa_end_cleanup_impl\n" + " mov lr, r4\n" +#if defined(LIBCXXABI_BAREMETAL) + " ldr r4, =_Unwind_Resume\n" + " mov ip, r4\n" +#endif " pop {r1, r2, r3, r4}\n" - " bl _Unwind_Resume\n" - " bl abort\n" - " .popsection" -); -#endif // defined(_LIBCXXABI_ARM_EHABI) - +#if defined(LIBCXXABI_BAREMETAL) + " bx ip\n" +#else + " b _Unwind_Resume\n" +#endif + " .popsection"); +#endif // defined(_LIBCXXABI_ARM_EHABI) + /* This routine can catch foreign or native exceptions. If native, the exception can be a primary or dependent variety. This routine may remain blissfully |