aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2014-04-14 15:59:47 -0700
committerAndrew Hsieh <andrewhsieh@google.com>2014-04-22 16:16:33 -0700
commitc16207898bba39af7a6ec6159ceee8623dcfb951 (patch)
treeaedbd5b68b2e3f6c0a22d0ff9c1237e35ee58852 /gcc-4.9/gcc
parent5399988ba7d9906878c5f5b6d9390e3595a6e915 (diff)
downloadtoolchain_gcc-c16207898bba39af7a6ec6159ceee8623dcfb951.tar.gz
toolchain_gcc-c16207898bba39af7a6ec6159ceee8623dcfb951.tar.bz2
toolchain_gcc-c16207898bba39af7a6ec6159ceee8623dcfb951.zip
[4.9] Always enable --eh-frame-hdr for static executable
See 5e6cdf76af295c9a39b695ca228cff675e8ff4ae and 23e3137ee2897464b051599b85a09f130d3ad05d Change-Id: Ibda473188e5a10f2a0592f2494ad00ad1f91e04b
Diffstat (limited to 'gcc-4.9/gcc')
-rw-r--r--gcc-4.9/gcc/config.in6
-rw-r--r--gcc-4.9/gcc/config/alpha/elf.h4
-rw-r--r--gcc-4.9/gcc/config/freebsd.h4
-rw-r--r--gcc-4.9/gcc/config/gnu-user.h4
-rw-r--r--gcc-4.9/gcc/config/openbsd.h4
-rw-r--r--gcc-4.9/gcc/config/rs6000/sysv4.h6
-rw-r--r--gcc-4.9/gcc/config/sol2.h4
-rwxr-xr-xgcc-4.9/gcc/configure36
-rw-r--r--gcc-4.9/gcc/configure.ac29
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/eh/spec3-static.C25
10 files changed, 121 insertions, 1 deletions
diff --git a/gcc-4.9/gcc/config.in b/gcc-4.9/gcc/config.in
index af02866dd..df7a3455f 100644
--- a/gcc-4.9/gcc/config.in
+++ b/gcc-4.9/gcc/config.in
@@ -1872,6 +1872,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.9/gcc/config/alpha/elf.h b/gcc-4.9/gcc/config/alpha/elf.h
index 5a6803aba..6ae4065bc 100644
--- a/gcc-4.9/gcc/config/alpha/elf.h
+++ b/gcc-4.9/gcc/config/alpha/elf.h
@@ -164,5 +164,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
+#endif
diff --git a/gcc-4.9/gcc/config/freebsd.h b/gcc-4.9/gcc/config/freebsd.h
index c872a6da4..7c032a510 100644
--- a/gcc-4.9/gcc/config/freebsd.h
+++ b/gcc-4.9/gcc/config/freebsd.h
@@ -45,8 +45,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.9/gcc/config/gnu-user.h b/gcc-4.9/gcc/config/gnu-user.h
index a1955a7e7..2af0a54ed 100644
--- a/gcc-4.9/gcc/config/gnu-user.h
+++ b/gcc-4.9/gcc/config/gnu-user.h
@@ -94,8 +94,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.9/gcc/config/openbsd.h b/gcc-4.9/gcc/config/openbsd.h
index 7150d49aa..600474834 100644
--- a/gcc-4.9/gcc/config/openbsd.h
+++ b/gcc-4.9/gcc/config/openbsd.h
@@ -136,8 +136,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.9/gcc/config/rs6000/sysv4.h b/gcc-4.9/gcc/config/rs6000/sysv4.h
index d04e6e4a0..3fb6bd59f 100644
--- a/gcc-4.9/gcc/config/rs6000/sysv4.h
+++ b/gcc-4.9/gcc/config/rs6000/sysv4.h
@@ -778,7 +778,11 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
-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.9/gcc/config/sol2.h b/gcc-4.9/gcc/config/sol2.h
index 2a657db59..eb8e0b91f 100644
--- a/gcc-4.9/gcc/config/sol2.h
+++ b/gcc-4.9/gcc/config/sol2.h
@@ -202,7 +202,11 @@ along with GCC; see the file COPYING3. If not see
/* Solaris 11 build 135+ implements dl_iterate_phdr. GNU ld needs
--eh-frame-hdr to create the required .eh_frame_hdr sections. */
#if defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
+#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 /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */
#endif
diff --git a/gcc-4.9/gcc/configure b/gcc-4.9/gcc/configure
index 2c5df6d84..7b07b1b53 100755
--- a/gcc-4.9/gcc/configure
+++ b/gcc-4.9/gcc/configure
@@ -921,6 +921,7 @@ enable_initfini_array
enable_comdat
with_glibc_version
enable_gnu_unique_object
+enable_eh_frame_hdr_for_static
enable_linker_build_id
with_long_double_128
with_gc
@@ -1638,6 +1639,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
@@ -26793,6 +26797,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.9/gcc/configure.ac b/gcc-4.9/gcc/configure.ac
index 49dfb62f1..c7a593f52 100644
--- a/gcc-4.9/gcc/configure.ac
+++ b/gcc-4.9/gcc/configure.ac
@@ -4568,6 +4568,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.9/gcc/testsuite/g++.dg/eh/spec3-static.C b/gcc-4.9/gcc/testsuite/g++.dg/eh/spec3-static.C
new file mode 100644
index 000000000..15408effa
--- /dev/null
+++ b/gcc-4.9/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) { }
+}