This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Regression fix for PR target/61223

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  <>

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

diff --git a/libstdc++-v3/libsupc++/ b/libstdc++-v3/libsupc++/
index 6a45af5..8ad327d 100644
--- a/libstdc++-v3/libsupc++/
+++ b/libstdc++-v3/libsupc++/
@@ -200,7 +200,8 @@ asm (".global __cxa_end_cleanup\n"
 // 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"
+"	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");
 asm ("  .pushsection .text.__cxa_end_cleanup\n"
 "	.global __cxa_end_cleanup\n"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]