From 00521879dd7f83a83dd6936164d6e7d2b5ef09bb Mon Sep 17 00:00:00 2001 From: Sriraman Tallam Date: Mon, 27 Jul 2015 21:12:40 +0000 Subject: Backport trunk rev. 222178 to fix a bug with now binding and libgcc: https://gcc.gnu.org/ml/gcc-patches/2015-04/msg00878.html Also, make these local changes to libgcc/config/i386/t-linux and libgcc/config/i386/cpuinfo.c * Force building of libgcc_s.so.1 with compat-ld and avoid gold to work around gold bug : https://sourceware.org/bugzilla/show_bug.cgi?id=18703 * Force symbol __cpu_indicator_init to be hidden in libgcc.a. Trunk hides all symbols in libgcc.a whereas this config does not. --- libgcc/config/i386/cpuinfo.c (revision 226260) +++ libgcc/config/i386/cpuinfo.c (working copy) @@ -34,6 +34,9 @@ #endif int __cpu_indicator_init (void) +#if !defined(SHARED) + __attribute__ ((visibility("hidden"))) +#endif Index: libgcc/config/i386/t-linux =================================================================== --- libgcc/config/i386/t-linux (revision 226260) +++ libgcc/config/i386/t-linux (working copy) @@ -3,4 +3,8 @@ # t-slibgcc-elf-ver and t-linux SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver -HOST_LIBGCC2_CFLAGS += -mlong-double-80 +# Work around gold bug: +# https://sourceware.org/bugzilla/show_bug.cgi?id=18703 +SHLIB_LDFLAGS += -fuse-ld=bfd git-svn-id: https://gcc.gnu.org/svn/gcc/branches/google/gcc-4_9@226272 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/g++.dg/ext/mv18.C | 7 +++++++ gcc/testsuite/g++.dg/ext/mv19.C | 7 +++++++ gcc/testsuite/g++.dg/ext/mv20.C | 7 +++++++ gcc/testsuite/g++.dg/ext/mv21.C | 7 +++++++ gcc/testsuite/g++.dg/ext/mv22.C | 7 +++++++ gcc/testsuite/g++.dg/ext/mv23.C | 7 +++++++ libgcc/config.host | 2 +- libgcc/config/i386/cpuinfo.c | 13 ++++++++++++- libgcc/config/i386/t-linux | 6 +++++- 9 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/mv18.C create mode 100644 gcc/testsuite/g++.dg/ext/mv19.C create mode 100644 gcc/testsuite/g++.dg/ext/mv20.C create mode 100644 gcc/testsuite/g++.dg/ext/mv21.C create mode 100644 gcc/testsuite/g++.dg/ext/mv22.C create mode 100644 gcc/testsuite/g++.dg/ext/mv23.C diff --git a/gcc/testsuite/g++.dg/ext/mv18.C b/gcc/testsuite/g++.dg/ext/mv18.C new file mode 100644 index 00000000000..1f024de9b95 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/mv18.C @@ -0,0 +1,7 @@ +/* Test case to check if Multiversioning works. */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-ifunc "" } */ +/* { dg-require-effective-target pie } */ +/* { dg-options "-O2 -fPIE -pie" } */ + +#include "mv1.C" diff --git a/gcc/testsuite/g++.dg/ext/mv19.C b/gcc/testsuite/g++.dg/ext/mv19.C new file mode 100644 index 00000000000..d1ea788745f --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/mv19.C @@ -0,0 +1,7 @@ +/* Test case to check if Multiversioning works. */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-ifunc "" } */ +/* { dg-require-effective-target pie } */ +/* { dg-options "-O2 -fPIE -pie -march=x86-64" } */ + +#include "mv14.C" diff --git a/gcc/testsuite/g++.dg/ext/mv20.C b/gcc/testsuite/g++.dg/ext/mv20.C new file mode 100644 index 00000000000..98f7408e1fc --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/mv20.C @@ -0,0 +1,7 @@ +/* Test case to check if Multiversioning works. */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-ifunc "" } */ +/* { dg-require-effective-target pie } */ +/* { dg-options "-O2 -fPIE -pie -march=x86-64" } */ + +#include "mv15.C" diff --git a/gcc/testsuite/g++.dg/ext/mv21.C b/gcc/testsuite/g++.dg/ext/mv21.C new file mode 100644 index 00000000000..9708ad95019 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/mv21.C @@ -0,0 +1,7 @@ +/* Test case to check if Multiversioning works. */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-ifunc "" } */ +/* { dg-require-effective-target static } */ +/* { dg-options "-O2 -static" } */ + +#include "mv1.C" diff --git a/gcc/testsuite/g++.dg/ext/mv22.C b/gcc/testsuite/g++.dg/ext/mv22.C new file mode 100644 index 00000000000..2550136fdac --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/mv22.C @@ -0,0 +1,7 @@ +/* Test case to check if Multiversioning works. */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-ifunc "" } */ +/* { dg-require-effective-target static } */ +/* { dg-options "-O2 -static -march=x86-64" } */ + +#include "mv14.C" diff --git a/gcc/testsuite/g++.dg/ext/mv23.C b/gcc/testsuite/g++.dg/ext/mv23.C new file mode 100644 index 00000000000..f00afb01f15 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/mv23.C @@ -0,0 +1,7 @@ +/* Test case to check if Multiversioning works. */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-ifunc "" } */ +/* { dg-require-effective-target static } */ +/* { dg-options "-O2 -static -march=x86-64" } */ + +#include "mv15.C" diff --git a/libgcc/config.host b/libgcc/config.host index e520441c582..0638db3f60a 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -1245,7 +1245,7 @@ i[34567]86-*-linux* | x86_64-*-linux* | \ i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu | \ i[34567]86-*-knetbsd*-gnu | \ i[34567]86-*-gnu*) - tmake_file="${tmake_file} t-tls i386/t-linux" + tmake_file="${tmake_file} t-tls i386/t-linux t-slibgcc-libgcc" if test "$libgcc_cv_cfi" = "yes"; then tmake_file="${tmake_file} t-stack i386/t-stack-i386" fi diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c index 6ff7502bb9a..f04e20f6664 100644 --- a/libgcc/config/i386/cpuinfo.c +++ b/libgcc/config/i386/cpuinfo.c @@ -34,6 +34,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif int __cpu_indicator_init (void) +#if !defined(SHARED) + __attribute__ ((visibility("hidden"))) +#endif __attribute__ ((constructor CONSTRUCTOR_PRIORITY)); /* Processor Vendor and Models. */ @@ -105,7 +108,7 @@ struct __processor_model unsigned int __cpu_type; unsigned int __cpu_subtype; unsigned int __cpu_features[1]; -} __cpu_model; +} __cpu_model = { }; /* Get the specific type of AMD CPU. */ @@ -321,6 +324,9 @@ __get_cpuid_output (unsigned int __level, needs to be called explicitly there. */ int __attribute__ ((constructor CONSTRUCTOR_PRIORITY)) +#if !defined(SHARED) + __attribute__ ((visibility("hidden"))) +#endif __cpu_indicator_init (void) { unsigned int eax, ebx, ecx, edx; @@ -403,3 +409,8 @@ __cpu_indicator_init (void) return 0; } + +#if defined SHARED && defined USE_ELF_SYMVER +__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0"); +__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0"); +#endif diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux index 4f47f7bfa59..12aab16b6f1 100644 --- a/libgcc/config/i386/t-linux +++ b/libgcc/config/i386/t-linux @@ -3,4 +3,8 @@ # t-slibgcc-elf-ver and t-linux SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver -HOST_LIBGCC2_CFLAGS += -mlong-double-80 +# Work around gold bug: +# https://sourceware.org/bugzilla/show_bug.cgi?id=18703 +SHLIB_LDFLAGS += -fuse-ld=bfd + +HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER -- cgit v1.2.3