This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: PR debug/54568: --eh-frame-hdr should also be enabled for static executable
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 13 Sep 2012 19:46:52 -0700
- Subject: PATCH: PR debug/54568: --eh-frame-hdr should also be enabled for static executable
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
There is no reason why --eh-frame-hdr can't be used with static
executable on Linux. This patch enables --eh-frame-hdr for static
executable on Linux and adds an exception test for static executable.
Other platforms may also work correctly. But I can't verify it.
Tested on Linux/x86-64. OK to install?
Thanks.
H.J.
----
gcc/
2012-09-13 H.J. Lu <hongjiu.lu@intel.com>
PR debug/54568
* config/gnu-user.h (USE_LD_EH_FRAME_HDR_FOR_STATIC): Defined
if HAVE_LD_EH_FRAME_HDR is defined.
(LINK_EH_SPEC): Drop "!static".
gcc/testsuite/
2012-09-13 H.J. Lu <hongjiu.lu@intel.com>
PR debug/54568
* g++.dg/eh/spec3-static.C: New test.
libgcc/
2012-09-13 H.J. Lu <hongjiu.lu@intel.com>
PR debug/54568
* crtstuff.c (USE_PT_GNU_EH_FRAME): Check CRTSTUFFT_O together
with USE_LD_EH_FRAME_HDR_FOR_STATIC.
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index cb45749..aa4e78d 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -82,7 +82,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
#if defined(HAVE_LD_EH_FRAME_HDR)
-#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+#define USE_LD_EH_FRAME_HDR_FOR_STATIC
+#define LINK_EH_SPEC "--eh-frame-hdr "
#endif
#undef LINK_GCC_C_SEQUENCE_SPEC
diff --git a/gcc/testsuite/g++.dg/eh/spec3-static.C b/gcc/testsuite/g++.dg/eh/spec3-static.C
new file mode 100644
index 0000000..15408ef
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/spec3-static.C
@@ -0,0 +1,25 @@
+// PR c++/4381
+// Test that exception-specs work properly for classes with virtual bases.
+
+// { dg-do run }
+// { dg-options "-static" }
+
+class Base {};
+
+struct A : virtual public Base
+{
+ A() {}
+};
+
+struct B {};
+
+void func() throw (B,A)
+{
+ throw A();
+}
+
+int main(void)
+{
+ try { func(); }
+ catch (A& a) { }
+}
diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c
index 973956a..01cf254 100644
--- a/libgcc/crtstuff.c
+++ b/libgcc/crtstuff.c
@@ -84,7 +84,8 @@ call_ ## FUNC (void) \
#if defined(OBJECT_FORMAT_ELF) \
&& !defined(OBJECT_FORMAT_FLAT) \
&& defined(HAVE_LD_EH_FRAME_HDR) \
- && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \
+ && !defined(inhibit_libc) \
+ && (defined(USE_LD_EH_FRAME_HDR_FOR_STATIC) || !defined(CRTSTUFFT_O)) \
&& defined(__FreeBSD__) && __FreeBSD__ >= 7
#include <link.h>
# define USE_PT_GNU_EH_FRAME
@@ -93,7 +94,8 @@ call_ ## FUNC (void) \
#if defined(OBJECT_FORMAT_ELF) \
&& !defined(OBJECT_FORMAT_FLAT) \
&& defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR) \
- && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \
+ && !defined(inhibit_libc) \
+ && (defined(USE_LD_EH_FRAME_HDR_FOR_STATIC) || !defined(CRTSTUFFT_O)) \
&& defined(__sun__) && defined(__svr4__)
#include <link.h>
# define USE_PT_GNU_EH_FRAME
@@ -102,7 +104,8 @@ call_ ## FUNC (void) \
#if defined(OBJECT_FORMAT_ELF) \
&& !defined(OBJECT_FORMAT_FLAT) \
&& defined(HAVE_LD_EH_FRAME_HDR) \
- && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \
+ && !defined(inhibit_libc) \
+ && (defined(USE_LD_EH_FRAME_HDR_FOR_STATIC) || !defined(CRTSTUFFT_O)) \
&& defined(__GLIBC__) && __GLIBC__ >= 2
#include <link.h>
/* uClibc pretends to be glibc 2.2 and DT_CONFIG is defined in its link.h.
@@ -117,7 +120,7 @@ call_ ## FUNC (void) \
#if defined(OBJECT_FORMAT_ELF) \
&& !defined(OBJECT_FORMAT_FLAT) \
&& defined(HAVE_LD_EH_FRAME_HDR) \
- && !defined(CRTSTUFFT_O) \
+ && (defined(USE_LD_EH_FRAME_HDR_FOR_STATIC) || !defined(CRTSTUFFT_O)) \
&& defined(inhibit_libc) \
&& (defined(__GLIBC__) || defined(__gnu_linux__) || defined(__GNU__))
/* On systems using glibc, an inhibit_libc build of libgcc is only