Hi all,

This is a fix for thumb1 build fail on trunk appeared since rev.210515(pr60758).

On thumb1 targets the LR can not be used as argument of POP instruction.
To keep a support of __cxa_end_cleanup backtracing on thumb1
we can make additional register operations before push/pop.
But I guess, this will have a negative effect on __cxa_end_cleanup performance. So, I propose to preserve __cxa_end_cleanup backtracing on thumb2 architectures and revert it on thumb1.

Regtest was finished with no regressions on C/C++ arm-linux-gnueabi(sf).

Best regards,
Merzlyakov Alexey

2014-05-20  Alexey Merzlyakov  <alexey.merzlya...@samsung.com>

	PR target/61223
	* libsupc++/eh_arm.cc (__cxa_end_cleanup): Revert backtracing support
	on thumb1.

diff --git a/libstdc++-v3/libsupc++/eh_arm.cc b/libstdc++-v3/libsupc++/eh_arm.cc
index 6a45af5..8ad327d 100644
--- a/libstdc++-v3/libsupc++/eh_arm.cc
+++ b/libstdc++-v3/libsupc++/eh_arm.cc
@@ -200,7 +200,8 @@ asm (".global __cxa_end_cleanup\n"
 #else
 // Assembly wrapper to call __gnu_end_cleanup without clobbering r1-r3.
 // Also push lr to preserve stack alignment and to allow backtracing.
-#ifdef __thumb__
+// On thumb1 architectures push r4 because pop lr is not available.
+#ifdef __thumb2__
 asm ("  .pushsection .text.__cxa_end_cleanup\n"
 "	.global __cxa_end_cleanup\n"
 "	.type __cxa_end_cleanup, \"function\"\n"
@@ -214,6 +215,17 @@ asm ("  .pushsection .text.__cxa_end_cleanup\n"
 "	bl\t_Unwind_Resume @ Never returns\n"
 "	.fnend\n"
 "	.popsection\n");
+#elif defined(__thumb__)
+asm ("  .pushsection .text.__cxa_end_cleanup\n"
+"	.global __cxa_end_cleanup\n"
+"	.type __cxa_end_cleanup, \"function\"\n"
+"	.thumb_func\n"
+"__cxa_end_cleanup:\n"
+"	push\t{r1, r2, r3, r4}\n"
+"	bl\t__gnu_end_cleanup\n"
+"	pop\t{r1, r2, r3, r4}\n"
+"	bl\t_Unwind_Resume @ Never returns\n"
+"	.popsection\n");
 #else
 asm ("  .pushsection .text.__cxa_end_cleanup\n"
 "	.global __cxa_end_cleanup\n"

Reply via email to