[Midnightbsd-cvs] src [8614] trunk/contrib/gcc4/unwind-dw2.c: add ugly hack to ligcc unwind code to make it behave properly at runtime on amd64 when compiled by clang
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 25 13:39:47 EDT 2016
Revision: 8614
http://svnweb.midnightbsd.org/src/?rev=8614
Author: laffer1
Date: 2016-09-25 13:39:47 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
add ugly hack to ligcc unwind code to make it behave properly at runtime on amd64 when compiled by clang
Modified Paths:
--------------
trunk/contrib/gcc4/unwind-dw2.c
Modified: trunk/contrib/gcc4/unwind-dw2.c
===================================================================
--- trunk/contrib/gcc4/unwind-dw2.c 2016-09-25 17:38:53 UTC (rev 8613)
+++ trunk/contrib/gcc4/unwind-dw2.c 2016-09-25 17:39:47 UTC (rev 8614)
@@ -1438,6 +1438,17 @@
context->ra = __builtin_extract_return_addr (outer_ra);
}
+#if defined(__clang__) && defined(__amd64__)
+/* Some versions of clang don't save and restore all callee registers, if a
+ __builtin_eh_return() intrinsic is used in a function. This is particularly
+ bad on amd64. For now, use the following ugly hack to force it to assume
+ those registers are clobbered, when invoking __builtin_eh_return(), so it
+ will emit code to save and restore them. */
+#define CLOBBER_REGS_HACK \
+ __asm __volatile(" " : : : "r15", "r14", "r13", "r12", "rbx", "rdx", "rax");
+#else
+#define CLOBBER_REGS_HACK
+#endif /* __clang__ */
/* Install TARGET into CURRENT so that we can return to it. This is a
macro because __builtin_eh_return must be invoked in the context of
@@ -1448,6 +1459,7 @@
{ \
long offset = uw_install_context_1 ((CURRENT), (TARGET)); \
void *handler = __builtin_frob_return_addr ((TARGET)->ra); \
+ CLOBBER_REGS_HACK \
__builtin_eh_return (offset, handler); \
} \
while (0)
More information about the Midnightbsd-cvs
mailing list