aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gcc-4.6/gcc/config.in6
-rw-r--r--gcc-4.6/gcc/config/alpha/elf.h3
-rw-r--r--gcc-4.6/gcc/config/gnu-user.h4
-rw-r--r--gcc-4.6/gcc/config/openbsd.h4
-rw-r--r--gcc-4.6/gcc/config/rs6000/sysv4.h6
-rwxr-xr-xgcc-4.6/gcc/configure36
-rw-r--r--gcc-4.6/gcc/configure.ac29
-rw-r--r--gcc-4.6/gcc/crtstuff.c9
-rw-r--r--gcc-4.6/gcc/testsuite/g++.dg/eh/spec3-static.C25
-rw-r--r--gcc-4.7/gcc/config.in6
-rw-r--r--gcc-4.7/gcc/config/alpha/elf.h3
-rw-r--r--gcc-4.7/gcc/config/freebsd.h4
-rw-r--r--gcc-4.7/gcc/config/gnu-user.h4
-rw-r--r--gcc-4.7/gcc/config/openbsd.h4
-rw-r--r--gcc-4.7/gcc/config/rs6000/sysv4.h6
-rwxr-xr-xgcc-4.7/gcc/configure36
-rw-r--r--gcc-4.7/gcc/configure.ac29
-rw-r--r--gcc-4.7/gcc/testsuite/g++.dg/eh/spec3-static.C25
-rw-r--r--gcc-4.7/libgcc/crtstuff.c9
19 files changed, 240 insertions, 8 deletions
diff --git a/gcc-4.6/gcc/config.in b/gcc-4.6/gcc/config.in
index f7541ec66..3294f0dcd 100644
--- a/gcc-4.6/gcc/config.in
+++ b/gcc-4.6/gcc/config.in
@@ -1752,6 +1752,12 @@
#endif
+/* Define if your system supports PT_GNU_EH_FRAME for static executable. */
+#ifndef USED_FOR_TARGET
+#undef USE_EH_FRAME_HDR_FOR_STATIC
+#endif
+
+
/* Define to 1 if the 'long long' (or '__int64') is wider than 'long' but
still efficiently supported by the host hardware. */
#ifndef USED_FOR_TARGET
diff --git a/gcc-4.6/gcc/config/alpha/elf.h b/gcc-4.6/gcc/config/alpha/elf.h
index 0293f26ee..9c05f7c5c 100644
--- a/gcc-4.6/gcc/config/alpha/elf.h
+++ b/gcc-4.6/gcc/config/alpha/elf.h
@@ -438,6 +438,9 @@ extern int alpha_this_gpdisp_sequence_number;
I imagine that other systems will catch up. In the meantime, it
doesn't harm to make sure that the data exists to be used later. */
#if defined(HAVE_LD_EH_FRAME_HDR)
+#ifdef USE_EH_FRAME_HDR_FOR_STATIC
+#define LINK_EH_SPEC "--eh-frame-hdr "
+#else
#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
#endif
diff --git a/gcc-4.6/gcc/config/gnu-user.h b/gcc-4.6/gcc/config/gnu-user.h
index 703afb5c7..e16aaeff2 100644
--- a/gcc-4.6/gcc/config/gnu-user.h
+++ b/gcc-4.6/gcc/config/gnu-user.h
@@ -84,8 +84,12 @@ 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)
+#ifdef USE_EH_FRAME_HDR_FOR_STATIC
+#define LINK_EH_SPEC "--eh-frame-hdr "
+#else
#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
#endif
+#endif
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC \
diff --git a/gcc-4.6/gcc/config/openbsd.h b/gcc-4.6/gcc/config/openbsd.h
index ae08ed8b5..d49723c12 100644
--- a/gcc-4.6/gcc/config/openbsd.h
+++ b/gcc-4.6/gcc/config/openbsd.h
@@ -137,8 +137,12 @@ while (0)
#define LIB_SPEC OBSD_LIB_SPEC
#if defined(HAVE_LD_EH_FRAME_HDR)
+#ifdef USE_EH_FRAME_HDR_FOR_STATIC
+#define LINK_EH_SPEC "--eh-frame-hdr "
+#else
#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
#endif
+#endif
#undef LIB_SPEC
#define LIB_SPEC OBSD_LIB_SPEC
diff --git a/gcc-4.6/gcc/config/rs6000/sysv4.h b/gcc-4.6/gcc/config/rs6000/sysv4.h
index aeb934f6e..95fab1054 100644
--- a/gcc-4.6/gcc/config/rs6000/sysv4.h
+++ b/gcc-4.6/gcc/config/rs6000/sysv4.h
@@ -835,7 +835,11 @@ extern int fixuplabelno;
-dynamic-linker " LINUX_DYNAMIC_LINKER "}}"
#if defined(HAVE_LD_EH_FRAME_HDR)
-# define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+# ifdef USE_EH_FRAME_HDR_FOR_STATIC
+# define LINK_EH_SPEC "--eh-frame-hdr "
+# else
+# define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+# endif
#endif
#define CPP_OS_LINUX_SPEC "-D__unix__ -D__gnu_linux__ -D__linux__ \
diff --git a/gcc-4.6/gcc/configure b/gcc-4.6/gcc/configure
index 9e040d9e0..529c33471 100755
--- a/gcc-4.6/gcc/configure
+++ b/gcc-4.6/gcc/configure
@@ -910,6 +910,7 @@ enable_gnu_indirect_function
enable_initfini_array
enable_comdat
enable_gnu_unique_object
+enable_eh_frame_hdr_for_static
enable_linker_build_id
with_long_double_128
with_gc
@@ -1622,6 +1623,9 @@ Optional Features:
--enable-gnu-unique-object
enable the use of the @gnu_unique_object ELF
extension on glibc systems
+ --enable-eh-frame-hdr-for-static
+ enable linker PT_GNU_EH_FRAME support for static
+ executable
--enable-linker-build-id
compiler will always pass --build-id to linker
--enable-maintainer-mode
@@ -25517,6 +25521,38 @@ if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
$as_echo "#define HAVE_LD_EH_FRAME_HDR 1" >>confdefs.h
+ # Check whether --enable-eh-frame-hdr-for-static was given.
+if test "${enable_eh_frame_hdr_for_static+set}" = set; then :
+ enableval=$enable_eh_frame_hdr_for_static; case $enable_eh_frame_hdr_for_static in
+ yes | no) ;;
+ *) as_fn_error "'$enable_eh_frame_hdr_for_static' is an invalid
+value for --enable-eh-frame-hdr-for-static.
+Valid choices are 'yes' and 'no'." "$LINENO" 5 ;;
+ esac
+else
+ # Only support for glibc 2.3.0 or higher with AT_PHDR/AT_PHNUM from
+# Linux kernel.
+ if test x$host = x$build -a x$host = x$target &&
+ ldd --version 2>&1 >/dev/null &&
+ glibcver=`ldd --version 2>/dev/null | sed 's/.* //;q'`; then
+ glibcmajor=`expr "$glibcver" : "\([0-9]*\)"`
+ glibcminor=`expr "$glibcver" : "[2-9]*\.\([0-9]*\)"`
+ glibcnum=`expr $glibcmajor \* 1000 + $glibcminor`
+ if test "$glibcnum" -ge 2003 ; then
+ auvx=`LD_SHOW_AUXV=1 ldd 2>/dev/null`
+ if echo "$auvx" | grep AT_PHDR > /dev/null &&
+ echo "$auvx" | grep AT_PHNUM > /dev/null; then
+ enable_eh_frame_hdr_for_static=yes
+ fi
+ fi
+ fi
+fi
+
+ if test x$enable_eh_frame_hdr_for_static = xyes; then
+
+$as_echo "#define USE_EH_FRAME_HDR_FOR_STATIC 1" >>confdefs.h
+
+ fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_eh_frame_hdr" >&5
$as_echo "$gcc_cv_ld_eh_frame_hdr" >&6; }
diff --git a/gcc-4.6/gcc/configure.ac b/gcc-4.6/gcc/configure.ac
index 87314e700..6b6f07358 100644
--- a/gcc-4.6/gcc/configure.ac
+++ b/gcc-4.6/gcc/configure.ac
@@ -4050,6 +4050,35 @@ GCC_TARGET_TEMPLATE([HAVE_LD_EH_FRAME_HDR])
if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
AC_DEFINE(HAVE_LD_EH_FRAME_HDR, 1,
[Define if your linker supports .eh_frame_hdr.])
+ AC_ARG_ENABLE(eh-frame-hdr-for-static,
+ [AS_HELP_STRING([--enable-eh-frame-hdr-for-static],
+ [enable linker PT_GNU_EH_FRAME support for static executable])],
+ [case $enable_eh_frame_hdr_for_static in
+ yes | no) ;;
+ *) AC_MSG_ERROR(['$enable_eh_frame_hdr_for_static' is an invalid
+value for --enable-eh-frame-hdr-for-static.
+Valid choices are 'yes' and 'no'.]) ;;
+ esac],
+# Only support for glibc 2.3.0 or higher with AT_PHDR/AT_PHNUM from
+# Linux kernel.
+ [[if test x$host = x$build -a x$host = x$target &&
+ ldd --version 2>&1 >/dev/null &&
+ glibcver=`ldd --version 2>/dev/null | sed 's/.* //;q'`; then
+ glibcmajor=`expr "$glibcver" : "\([0-9]*\)"`
+ glibcminor=`expr "$glibcver" : "[2-9]*\.\([0-9]*\)"`
+ glibcnum=`expr $glibcmajor \* 1000 + $glibcminor`
+ if test "$glibcnum" -ge 2003 ; then
+ auvx=`LD_SHOW_AUXV=1 ldd 2>/dev/null`
+ if echo "$auvx" | grep AT_PHDR > /dev/null &&
+ echo "$auvx" | grep AT_PHNUM > /dev/null; then
+ enable_eh_frame_hdr_for_static=yes
+ fi
+ fi
+ fi]])
+ if test x$enable_eh_frame_hdr_for_static = xyes; then
+ AC_DEFINE(USE_EH_FRAME_HDR_FOR_STATIC, 1,
+[Define if your system supports PT_GNU_EH_FRAME for static executable.])
+ fi
fi
AC_MSG_RESULT($gcc_cv_ld_eh_frame_hdr)
diff --git a/gcc-4.6/gcc/crtstuff.c b/gcc-4.6/gcc/crtstuff.c
index 010d47276..d25a9529a 100644
--- a/gcc-4.6/gcc/crtstuff.c
+++ b/gcc-4.6/gcc/crtstuff.c
@@ -83,7 +83,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_EH_FRAME_HDR_FOR_STATIC) || !defined(CRTSTUFFT_O)) \
&& defined(__FreeBSD__) && __FreeBSD__ >= 7
#include <link.h>
# define USE_PT_GNU_EH_FRAME
@@ -92,7 +93,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_EH_FRAME_HDR_FOR_STATIC) || !defined(CRTSTUFFT_O)) \
&& defined(__sun__) && defined(__svr4__)
#include <link.h>
# define USE_PT_GNU_EH_FRAME
@@ -101,7 +103,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_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.
diff --git a/gcc-4.6/gcc/testsuite/g++.dg/eh/spec3-static.C b/gcc-4.6/gcc/testsuite/g++.dg/eh/spec3-static.C
new file mode 100644
index 000000000..15408effa
--- /dev/null
+++ b/gcc-4.6/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/gcc-4.7/gcc/config.in b/gcc-4.7/gcc/config.in
index 2e632b242..8b08685e0 100644
--- a/gcc-4.7/gcc/config.in
+++ b/gcc-4.7/gcc/config.in
@@ -1799,6 +1799,12 @@
#endif
+/* Define if your system supports PT_GNU_EH_FRAME for static executable. */
+#ifndef USED_FOR_TARGET
+#undef USE_EH_FRAME_HDR_FOR_STATIC
+#endif
+
+
/* Define to 1 if the 'long long' (or '__int64') is wider than 'long' but
still efficiently supported by the host hardware. */
#ifndef USED_FOR_TARGET
diff --git a/gcc-4.7/gcc/config/alpha/elf.h b/gcc-4.7/gcc/config/alpha/elf.h
index 3b5ec08e9..5b3f0bd11 100644
--- a/gcc-4.7/gcc/config/alpha/elf.h
+++ b/gcc-4.7/gcc/config/alpha/elf.h
@@ -440,6 +440,9 @@ extern int alpha_this_gpdisp_sequence_number;
I imagine that other systems will catch up. In the meantime, it
doesn't harm to make sure that the data exists to be used later. */
#if defined(HAVE_LD_EH_FRAME_HDR)
+#ifdef USE_EH_FRAME_HDR_FOR_STATIC
+#define LINK_EH_SPEC "--eh-frame-hdr "
+#else
#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
#endif
diff --git a/gcc-4.7/gcc/config/freebsd.h b/gcc-4.7/gcc/config/freebsd.h
index f9a47132c..e7d615d1c 100644
--- a/gcc-4.7/gcc/config/freebsd.h
+++ b/gcc-4.7/gcc/config/freebsd.h
@@ -46,8 +46,12 @@ along with GCC; see the file COPYING3. If not see
#define LIB_SPEC FBSD_LIB_SPEC
#if defined(HAVE_LD_EH_FRAME_HDR)
+#ifdef USE_EH_FRAME_HDR_FOR_STATIC
+#define LINK_EH_SPEC "--eh-frame-hdr "
+#else
#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
#endif
+#endif
#ifdef TARGET_LIBC_PROVIDES_SSP
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared}"
diff --git a/gcc-4.7/gcc/config/gnu-user.h b/gcc-4.7/gcc/config/gnu-user.h
index 644a1a8a2..419c472c3 100644
--- a/gcc-4.7/gcc/config/gnu-user.h
+++ b/gcc-4.7/gcc/config/gnu-user.h
@@ -84,8 +84,12 @@ 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)
+#ifdef USE_EH_FRAME_HDR_FOR_STATIC
+#define LINK_EH_SPEC "--eh-frame-hdr "
+#else
#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
#endif
+#endif
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC \
diff --git a/gcc-4.7/gcc/config/openbsd.h b/gcc-4.7/gcc/config/openbsd.h
index fad29154c..558613f6e 100644
--- a/gcc-4.7/gcc/config/openbsd.h
+++ b/gcc-4.7/gcc/config/openbsd.h
@@ -137,8 +137,12 @@ while (0)
#define LIB_SPEC OBSD_LIB_SPEC
#if defined(HAVE_LD_EH_FRAME_HDR)
+#ifdef USE_EH_FRAME_HDR_FOR_STATIC
+#define LINK_EH_SPEC "--eh-frame-hdr "
+#else
#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
#endif
+#endif
#undef LIB_SPEC
#define LIB_SPEC OBSD_LIB_SPEC
diff --git a/gcc-4.7/gcc/config/rs6000/sysv4.h b/gcc-4.7/gcc/config/rs6000/sysv4.h
index aed2a29f5..09a4af665 100644
--- a/gcc-4.7/gcc/config/rs6000/sysv4.h
+++ b/gcc-4.7/gcc/config/rs6000/sysv4.h
@@ -819,7 +819,11 @@ extern int fixuplabelno;
-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
#if defined(HAVE_LD_EH_FRAME_HDR)
-# define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+# ifdef USE_EH_FRAME_HDR_FOR_STATIC
+# define LINK_EH_SPEC "--eh-frame-hdr "
+# else
+# define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+# endif
#endif
#define CPP_OS_LINUX_SPEC "-D__unix__ -D__gnu_linux__ -D__linux__ \
diff --git a/gcc-4.7/gcc/configure b/gcc-4.7/gcc/configure
index f7a75ca25..248370b0c 100755
--- a/gcc-4.7/gcc/configure
+++ b/gcc-4.7/gcc/configure
@@ -909,6 +909,7 @@ enable_gnu_indirect_function
enable_initfini_array
enable_comdat
enable_gnu_unique_object
+enable_eh_frame_hdr_for_static
enable_linker_build_id
with_long_double_128
with_gc
@@ -1620,6 +1621,9 @@ Optional Features:
--enable-gnu-unique-object
enable the use of the @gnu_unique_object ELF
extension on glibc systems
+ --enable-eh-frame-hdr-for-static
+ enable linker PT_GNU_EH_FRAME support for static
+ executable
--enable-linker-build-id
compiler will always pass --build-id to linker
--enable-maintainer-mode
@@ -26355,6 +26359,38 @@ if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
$as_echo "#define HAVE_LD_EH_FRAME_HDR 1" >>confdefs.h
+ # Check whether --enable-eh-frame-hdr-for-static was given.
+if test "${enable_eh_frame_hdr_for_static+set}" = set; then :
+ enableval=$enable_eh_frame_hdr_for_static; case $enable_eh_frame_hdr_for_static in
+ yes | no) ;;
+ *) as_fn_error "'$enable_eh_frame_hdr_for_static' is an invalid
+value for --enable-eh-frame-hdr-for-static.
+Valid choices are 'yes' and 'no'." "$LINENO" 5 ;;
+ esac
+else
+ # Only support for glibc 2.3.0 or higher with AT_PHDR/AT_PHNUM from
+# Linux kernel.
+ if test x$host = x$build -a x$host = x$target &&
+ ldd --version 2>&1 >/dev/null &&
+ glibcver=`ldd --version 2>/dev/null | sed 's/.* //;q'`; then
+ glibcmajor=`expr "$glibcver" : "\([0-9]*\)"`
+ glibcminor=`expr "$glibcver" : "[2-9]*\.\([0-9]*\)"`
+ glibcnum=`expr $glibcmajor \* 1000 + $glibcminor`
+ if test "$glibcnum" -ge 2003 ; then
+ auvx=`LD_SHOW_AUXV=1 ldd 2>/dev/null`
+ if echo "$auvx" | grep AT_PHDR > /dev/null &&
+ echo "$auvx" | grep AT_PHNUM > /dev/null; then
+ enable_eh_frame_hdr_for_static=yes
+ fi
+ fi
+ fi
+fi
+
+ if test x$enable_eh_frame_hdr_for_static = xyes; then
+
+$as_echo "#define USE_EH_FRAME_HDR_FOR_STATIC 1" >>confdefs.h
+
+ fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_eh_frame_hdr" >&5
$as_echo "$gcc_cv_ld_eh_frame_hdr" >&6; }
diff --git a/gcc-4.7/gcc/configure.ac b/gcc-4.7/gcc/configure.ac
index f0167ae30..0497dee1c 100644
--- a/gcc-4.7/gcc/configure.ac
+++ b/gcc-4.7/gcc/configure.ac
@@ -4290,6 +4290,35 @@ GCC_TARGET_TEMPLATE([HAVE_LD_EH_FRAME_HDR])
if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
AC_DEFINE(HAVE_LD_EH_FRAME_HDR, 1,
[Define if your linker supports .eh_frame_hdr.])
+ AC_ARG_ENABLE(eh-frame-hdr-for-static,
+ [AS_HELP_STRING([--enable-eh-frame-hdr-for-static],
+ [enable linker PT_GNU_EH_FRAME support for static executable])],
+ [case $enable_eh_frame_hdr_for_static in
+ yes | no) ;;
+ *) AC_MSG_ERROR(['$enable_eh_frame_hdr_for_static' is an invalid
+value for --enable-eh-frame-hdr-for-static.
+Valid choices are 'yes' and 'no'.]) ;;
+ esac],
+# Only support for glibc 2.3.0 or higher with AT_PHDR/AT_PHNUM from
+# Linux kernel.
+ [[if test x$host = x$build -a x$host = x$target &&
+ ldd --version 2>&1 >/dev/null &&
+ glibcver=`ldd --version 2>/dev/null | sed 's/.* //;q'`; then
+ glibcmajor=`expr "$glibcver" : "\([0-9]*\)"`
+ glibcminor=`expr "$glibcver" : "[2-9]*\.\([0-9]*\)"`
+ glibcnum=`expr $glibcmajor \* 1000 + $glibcminor`
+ if test "$glibcnum" -ge 2003 ; then
+ auvx=`LD_SHOW_AUXV=1 ldd 2>/dev/null`
+ if echo "$auvx" | grep AT_PHDR > /dev/null &&
+ echo "$auvx" | grep AT_PHNUM > /dev/null; then
+ enable_eh_frame_hdr_for_static=yes
+ fi
+ fi
+ fi]])
+ if test x$enable_eh_frame_hdr_for_static = xyes; then
+ AC_DEFINE(USE_EH_FRAME_HDR_FOR_STATIC, 1,
+[Define if your system supports PT_GNU_EH_FRAME for static executable.])
+ fi
fi
AC_MSG_RESULT($gcc_cv_ld_eh_frame_hdr)
diff --git a/gcc-4.7/gcc/testsuite/g++.dg/eh/spec3-static.C b/gcc-4.7/gcc/testsuite/g++.dg/eh/spec3-static.C
new file mode 100644
index 000000000..15408effa
--- /dev/null
+++ b/gcc-4.7/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/gcc-4.7/libgcc/crtstuff.c b/gcc-4.7/libgcc/crtstuff.c
index 5d820fa45..0e31f1988 100644
--- a/gcc-4.7/libgcc/crtstuff.c
+++ b/gcc-4.7/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_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_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_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.