From 91da04811259e454dadc9c828024b1548030bd91 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Tue, 4 Feb 2014 09:31:38 +0000 Subject: [PATCH] Ensure libgcc_s unwinder is always used on 64-bit Solaris 10+/x86 (PR target/59788) gcc: PR target/59788 * config/sol2.h (LINK_LIBGCC_MAPFILE_SPEC): Define. (LINK_SPEC): Use it for -shared, -shared-libgcc. libgcc: PR target/59788 * config/t-slibgcc-sld (libgcc-unwind.map): New target. (install-libgcc-unwind-map-forbuild): New target. (all): Depend on install-libgcc-unwind-map-forbuild. (install-libgcc-unwind-map): New target. (install): Depend on install-libgcc-unwind-map. gcc/testsuite: PR target/59788 * g++.dg/eh/unwind-direct.C: New test. toplevel: PR target/59788 * ltmain.sh (opt_duplicate_compiler_generated_deps): Enable on *solaris2*. From-SVN: r207454 --- ChangeLog | 6 ++++++ gcc/ChangeLog | 6 ++++++ gcc/config/sol2.h | 11 ++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/eh/unwind-direct.C | 15 +++++++++++++++ libgcc/ChangeLog | 9 +++++++++ libgcc/config/t-slibgcc-sld | 23 +++++++++++++++++++++++ ltmain.sh | 2 +- 8 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/eh/unwind-direct.C diff --git a/ChangeLog b/ChangeLog index 7e90e0968e1..cc302ab5d29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-02-04 Rainer Orth + + PR target/59788 + * ltmain.sh (opt_duplicate_compiler_generated_deps): Enable on + *solaris2*. + 2014-01-21 John David Anglin * MAINTAINERS: Update my email address. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 237ec964e48..cd8acae396d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-02-04 Rainer Orth + + PR target/59788 + * config/sol2.h (LINK_LIBGCC_MAPFILE_SPEC): Define. + (LINK_SPEC): Use it for -shared, -shared-libgcc. + 2014-02-03 Jan Hubicka PR ipa/59882 diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index a023cfed0d9..2a657db59c1 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -174,12 +174,21 @@ along with GCC; see the file COPYING3. If not see #define RDYNAMIC_SPEC "--export-dynamic" #endif +#ifndef USE_GLD +/* With Sun ld, use mapfile to enforce direct binding to libgcc_s unwinder. */ +#define LINK_LIBGCC_MAPFILE_SPEC \ + "%{shared|shared-libgcc:-M %slibgcc-unwind.map}" +#else +/* GNU ld doesn't support direct binding. */ +#define LINK_LIBGCC_MAPFILE_SPEC "" +#endif + #undef LINK_SPEC #define LINK_SPEC \ "%{h*} %{v:-V} \ %{!shared:%{!static:%{rdynamic: " RDYNAMIC_SPEC "}}} \ %{static:-dn -Bstatic} \ - %{shared:-G -dy %{!mimpure-text:-z text}} \ + %{shared:-G -dy %{!mimpure-text:-z text}} " LINK_LIBGCC_MAPFILE_SPEC " \ %{symbolic:-Bsymbolic -G -dy -z text} \ %(link_arch) \ %{Qy:} %{!Qn:-Qy}" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 66adf758dc4..3c7682fad50 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-02-04 Rainer Orth + + PR target/59788 + * g++.dg/eh/unwind-direct.C: New test. + 2014-02-04 Uros Bizjak * lib/tsan-dg.exp (tsan_init): Set trivial testcase diff --git a/gcc/testsuite/g++.dg/eh/unwind-direct.C b/gcc/testsuite/g++.dg/eh/unwind-direct.C new file mode 100644 index 00000000000..8d2cd772916 --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/unwind-direct.C @@ -0,0 +1,15 @@ +// PR target/59788 +// { dg-do run { target { *-*-solaris2* && { ! gld } } } } +// { dg-options "-Wl,-Bdirect" } + +#include + +int +main(void) +{ + try + { throw std::runtime_error( "Catch me if you can!"); } + catch(...) + { return 0; } + return 1; +} diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 3186d069dec..f561edd2274 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,12 @@ +2014-02-04 Rainer Orth + + PR target/59788 + * config/t-slibgcc-sld (libgcc-unwind.map): New target. + (install-libgcc-unwind-map-forbuild): New target. + (all): Depend on install-libgcc-unwind-map-forbuild. + (install-libgcc-unwind-map): New target. + (install): Depend on install-libgcc-unwind-map. + 2014-02-02 Sandra Loosemore * config/nios2/crti.S (_init): Initialize GOT pointer from diff --git a/libgcc/config/t-slibgcc-sld b/libgcc/config/t-slibgcc-sld index 178700047cc..ec6e5db0a3b 100644 --- a/libgcc/config/t-slibgcc-sld +++ b/libgcc/config/t-slibgcc-sld @@ -3,3 +3,26 @@ SHLIB_LDFLAGS = -Wl,-h,$(SHLIB_SONAME) -Wl,-z,text -Wl,-z,defs \ -Wl,-M,$(SHLIB_MAP) + +# Linker mapfile to enforce direct binding to libgcc_s unwinder +# (PR target/59788). +libgcc-unwind.map: libgcc-std.ver + @(echo "{"; \ + for f in `grep _Unwind_ $< | sort`; do \ + echo " $$f = EXTERN DIRECT;"; \ + done; \ + echo "};" ) > $@ + +# Copy libgcc-unwind.map to the place where gcc will look for it at build-time. +install-libgcc-unwind-map-forbuild: libgcc-unwind.map + dest=$(gcc_objdir)/tmp$$$$-$<; \ + cp $< $$dest; \ + chmod a+r $$dest; \ + sh $(srcdir)/../move-if-change $$dest $(gcc_objdir)/$< + +all: install-libgcc-unwind-map-forbuild + +install-libgcc-unwind-map: libgcc-unwind.map + $(INSTALL_DATA) $< $(DESTDIR)$(slibdir) + +install: install-libgcc-unwind-map diff --git a/ltmain.sh b/ltmain.sh index a03433f1789..9503ec85d70 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -976,7 +976,7 @@ func_enable_tag () case $host in - *cygwin* | *mingw* | *pw32* | *cegcc*) + *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* ) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;;