From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53386 invoked by alias); 30 Mar 2015 02:25:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 53374 invoked by uid 89); 30 Mar 2015 02:25:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pa0-f43.google.com Received: from mail-pa0-f43.google.com (HELO mail-pa0-f43.google.com) (209.85.220.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 30 Mar 2015 02:25:30 +0000 Received: by pacgg7 with SMTP id gg7so23561622pac.0 for ; Sun, 29 Mar 2015 19:25:28 -0700 (PDT) X-Received: by 10.68.238.200 with SMTP id vm8mr22362679pbc.15.1427682328682; Sun, 29 Mar 2015 19:25:28 -0700 (PDT) Received: from gnu-tools-1.localdomain (c-24-7-26-57.hsd1.ca.comcast.net. [24.7.26.57]) by mx.google.com with ESMTPSA id bv5sm8705321pbb.61.2015.03.29.19.25.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Mar 2015 19:25:28 -0700 (PDT) Received: by gnu-tools-1.localdomain (Postfix, from userid 1000) id 12D3C20093; Sun, 29 Mar 2015 19:25:27 -0700 (PDT) Date: Mon, 30 Mar 2015 02:25:00 -0000 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak Subject: PATCH] PR target/65612: Multiversioning doesn't work with DSO nor PIE Message-ID: <20150330022527.GA4148@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg01520.txt.bz2 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