public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PATCH] PR target/65612: Multiversioning doesn't work with DSO nor PIE
@ 2015-03-30  2:25 H.J. Lu
  2015-03-30  2:34 ` H.J. Lu
  0 siblings, 1 reply; 46+ messages in thread
From: H.J. Lu @ 2015-03-30  2:25 UTC (permalink / raw)
  To: gcc-patches; +Cc: Uros Bizjak

We shouldn't call external function, __cpu_indicator_init, while an object
is being relocated since its .got.plt section hasn't been updated.  It
works for non-PIE since no update on .got.plt section is required.  This
patch hides __cpu_indicator_init/__cpu_model from linker to force linker
to resolve __cpu_indicator_init/__cpu_model to their hidden definitions
in libgcc.a while providing backward binary compatibility.

OK for trunk, 4.9 and 4.9 branches?

Thanks.


H.J.
---
libgcc/

	PR target/65612
	* config/i386/cpuinfo.c (__cpu_model): Initialize.
	(__cpu_indicator_init@GCC_4.8.0): New.
	(__cpu_model@GCC_4.8.0): Likewise.

gcc/testsuite/

	PR target/65612
	* g++.dg/ext/mv18.C: New test.
	* g++.dg/ext/mv19.C: Likewise.
	* g++.dg/ext/mv20.C: Likewise.
---
 gcc/testsuite/g++.dg/ext/mv18.C | 7 +++++++
 gcc/testsuite/g++.dg/ext/mv19.C | 7 +++++++
 gcc/testsuite/g++.dg/ext/mv20.C | 7 +++++++
 libgcc/config/i386/cpuinfo.c    | 7 ++++++-
 4 files changed, 27 insertions(+), 1 deletion(-)
 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

diff --git a/gcc/testsuite/g++.dg/ext/mv18.C b/gcc/testsuite/g++.dg/ext/mv18.C
new file mode 100644
index 0000000..1f024de
--- /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 0000000..d1ea788
--- /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 0000000..98f7408
--- /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/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
index eaf2f10..9639c8d 100644
--- a/libgcc/config/i386/cpuinfo.c
+++ b/libgcc/config/i386/cpuinfo.c
@@ -109,7 +109,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.  */
@@ -424,3 +424,8 @@ __cpu_indicator_init (void)
 
   return 0;
 }
+
+#if defined SHARED && !defined _WIN32
+__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
+#endif
-- 
2.1.0

^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2015-07-22 20:56 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-30  2:25 PATCH] PR target/65612: Multiversioning doesn't work with DSO nor PIE H.J. Lu
2015-03-30  2:34 ` H.J. Lu
2015-03-30  2:40   ` H.J. Lu
2015-03-30 22:26     ` H.J. Lu
2015-03-31  0:54       ` Jack Howarth
2015-03-31  2:08         ` H.J. Lu
2015-03-31  2:42           ` H.J. Lu
2015-03-31  3:14             ` Jack Howarth
2015-03-31  3:09           ` Jack Howarth
2015-03-31  4:04             ` H.J. Lu
2015-03-31  5:39           ` Jakub Jelinek
2015-03-31  6:20             ` Rainer Orth
2015-03-31 10:39             ` H.J. Lu
2015-03-31 14:25               ` Jack Howarth
2015-03-31 15:58                 ` H.J. Lu
2015-03-31 16:10                   ` Jack Howarth
2015-03-31 16:15                     ` H.J. Lu
2015-03-31 16:39                       ` Jack Howarth
2015-03-31 17:00                         ` H.J. Lu
2015-03-31 18:33                           ` Jack Howarth
2015-04-14 15:07                             ` H.J. Lu
2015-04-16 16:29                               ` Mike Stump
2015-04-17  8:05                                 ` Uros Bizjak
2015-04-17 10:36                                   ` H.J. Lu
2015-04-17 11:04                                     ` Uros Bizjak
2015-04-17 11:12                                       ` Uros Bizjak
2015-04-17 11:38                                       ` Jakub Jelinek
2015-04-17 11:48                                         ` H.J. Lu
2015-04-17 12:00                                           ` Jakub Jelinek
2015-04-17 12:36                                             ` H.J. Lu
2015-04-17 12:40                                               ` Jakub Jelinek
2015-05-08 23:00                                               ` Rich Felker
2015-05-08 23:59                                                 ` H.J. Lu
2015-05-09 14:31                                               ` Szabolcs Nagy
2015-05-09 17:41                                                 ` H.J. Lu
2015-05-09 18:57                                                   ` Szabolcs Nagy
2015-05-11 10:20                                                     ` Szabolcs Nagy
2015-05-11 10:32                                                       ` Jakub Jelinek
2015-05-11 12:39                                                         ` Szabolcs Nagy
2015-05-11 13:05                                                           ` Jakub Jelinek
2015-05-11 15:30                                                             ` Szabolcs Nagy
2015-05-11 14:12                                                         ` Rich Felker
2015-05-09 19:36                                                   ` Rich Felker
2015-05-09 19:54                                                     ` Jakub Jelinek
2015-07-22 21:14                                               ` Sriraman Tallam
2015-04-17 12:23                                   ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).