Revert "[ARM] __cxa_end_cleanup should be called instead of _UnwindResume."
This reverts commit da1d1a08694bbfe0ea7a23ea094612436e8a2dd0.
GitOrigin-RevId: 894ddba1c9ed6e1eef940e7ef4cb7df8482339a4
diff --git a/src/cxa_exception.cpp b/src/cxa_exception.cpp
index 593fdbe..35956f1 100644
--- a/src/cxa_exception.cpp
+++ b/src/cxa_exception.cpp
@@ -341,10 +341,8 @@
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 lr in order to
-align the stack to 16 bytes and lr will be used to identify the caller and its
-frame information. _Unwind_Resume never return and we need to keep the original
-lr so just branch to it.
+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.
*/
__attribute__((used)) static _Unwind_Exception *
__cxa_end_cleanup_impl()
@@ -374,15 +372,18 @@
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"
- " push {r1, r2, r3, lr}\n"
+ " push {r1, r2, r3, r4}\n"
" bl __cxa_end_cleanup_impl\n"
- " pop {r1, r2, r3, lr}\n"
- " b _Unwind_Resume\n"
- " .popsection");
+ " pop {r1, r2, r3, r4}\n"
+ " bl _Unwind_Resume\n"
+ " bl abort\n"
+ " .popsection"
+);
#endif // defined(_LIBCXXABI_ARM_EHABI)
/*