From patchwork Fri Jun 5 14:01:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 481283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3AD1F1401F6 for ; Sat, 6 Jun 2015 00:02:57 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=wM/HHrs4; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=PFh2GNb4eCpFFMgNY wrRVGTuEV2Q/1HneM8AOQSx4Y7DwT5wFNNxJqK10JEajTCsX3LxJiuP8xfPOByvP PqDy3Uv2wDX3lpqN5+MU/lqebkB2T47RcHi+Z9HL5anN2jLfcO3SchsU6siZZSxX 10kGQft5jMXHxpGD0+pb6lnDyw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=GvzPfYCQPydpFbgWCmkIxLl /0ec=; b=wM/HHrs4wU5HX5f4JLG6Bis8Vo0hd8Edaob6lRHxNRqDKTX0bMpJdlI 9nCMdINuogRCVsiY7LyemA6Ezme8LFUlyxcZIVdLlc2ZV15X1wxp07G8vsCphN90 5f99/Zn3E8fF3UZIE4Cdb1oU8S/PikOjoONSISn1A9HxFTE0jqjk= Received: (qmail 17891 invoked by alias); 5 Jun 2015 14:02:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 17808 invoked by uid 89); 5 Jun 2015 14:02:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS, URIBL_BLACK autolearn=no version=3.3.2 X-HELO: mail-ie0-f169.google.com Received: from mail-ie0-f169.google.com (HELO mail-ie0-f169.google.com) (209.85.223.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 05 Jun 2015 14:02:37 +0000 Received: by iebgx4 with SMTP id gx4so58303889ieb.0 for ; Fri, 05 Jun 2015 07:02:34 -0700 (PDT) X-Received: by 10.50.43.131 with SMTP id w3mr12545438igl.8.1433512954768; Fri, 05 Jun 2015 07:02:34 -0700 (PDT) Received: from msticlxl57.ims.intel.com (fmdmzpr04-ext.fm.intel.com. [192.55.55.39]) by mx.google.com with ESMTPSA id r4sm1414221igh.9.2015.06.05.07.02.31 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jun 2015 07:02:33 -0700 (PDT) Date: Fri, 5 Jun 2015 17:01:02 +0300 From: Ilya Enkovich To: Joseph Myers Cc: Jeff Law , Sandra Loosemore , Richard Biener , gcc-patches Subject: Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX Message-ID: <20150605140102.GA16897@msticlxl57.ims.intel.com> References: <20150406151742.GA43634@msticlxl57.ims.intel.com> <5522A636.9030000@redhat.com> <20150526091327.GI47912@msticlxl57.ims.intel.com> <5565E07E.2070703@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On 04 Jun 15:53, Joseph Myers wrote: > On Thu, 4 Jun 2015, Ilya Enkovich wrote: > > > 2015-06-03 18:59 GMT+03:00 Joseph Myers : > > > You could, for example, have > > > > > > #if SOMETHING > > > #define MSG "%nsome msg" > > > #else > > > #define MSG "" > > > #endif > > > > > > and have another spec using MSG - that should work. > > > > In this case I should define SOMETHING in configure of gcc, not in > > configure of libmpx, right? But it would mean I check host linker, not > > target. > > gcc/ configure tests on the linker generally test the build-x-target > linker, which is required to have the same version and be configured the > same as the host-x-target linker. (The tests mustn't actually try to link > anything, but they can e.g. see if a particular option is mentioned in > --help output. In general they also have version number checks for the > case of an in-tree linker build.) > > -- > Joseph S. Myers > joseph@codesourcery.com Thanks for help! Here is a new patch version with a check moved into gcc/configure. Does it look OK? Thanks, Ilya --- gcc/ 2015-06-05 Ilya Enkovich * config/i386/linux-common.h (LINK_MPX): New. (MPX_SPEC): Use LINK_MPX instead of %(link_mpx). * configure.ac: Add HAVE_LD_BNDPLT_SUPPORT macro indicating '-z bndplt' support by linker. * configure: Regenerate. * config.in: Regenerate. libmpx/ 2015-06-05 Ilya Enkovich * configure.ac: Remove link_mpx. * libmpx.spec.in: Likewise. * configure: Regenerate. diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h index dd79ec6..63dd8d8 100644 --- a/gcc/config/i386/linux-common.h +++ b/gcc/config/i386/linux-common.h @@ -59,9 +59,20 @@ along with GCC; see the file COPYING3. If not see %:include(libmpx.spec)%(link_libmpx)" #endif +#ifndef LINK_MPX +#if defined (HAVE_LD_BNDPLT_SUPPORT) +#define LINK_MPX "-z bndplt " +#else +#define LINK_MPX \ + "%nGCC was configured with a linker with no '-z bndplt' support. " \ + "It significantly reduces MPX coverage for dynamic codes. " \ + "It is strongly recommended to use GCC properly configured for MPX." +#endif +#endif + #ifndef MPX_SPEC #define MPX_SPEC "\ - %{mmpx:%{fcheck-pointer-bounds:%{!static:%:include(libmpx.spec)%(link_mpx)}}}" + %{mmpx:%{fcheck-pointer-bounds:%{!static:" LINK_MPX "}}}" #endif #ifndef LIBMPX_SPEC diff --git a/gcc/configure.ac b/gcc/configure.ac index b27433e..7306a70 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5859,6 +5859,27 @@ if test "$gcc_cv_no_pie" = "yes"; then fi AC_SUBST([NO_PIE_FLAG]) +# Check linker supports '-z bndplt' +ld_bndplt_support=no +AC_MSG_CHECKING(linker -z bndplt option) +if test x"$ld_is_gold" = xno; then + if test $in_tree_ld = yes ; then + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 25 -o "$gcc_cv_gld_major_version" -gt 2; then + ld_bndplt_support=yes + fi + elif test x$gcc_cv_ld != x; then + # Check if linker supports -a bndplt option + if $gcc_cv_ld --help 2>/dev/null | grep -- '-z bndplt' > /dev/null; then + ld_bndplt_support=yes + fi + fi +fi +if test x"$ld_bndplt_support" = xyes; then + AC_DEFINE(HAVE_LD_BNDPLT_SUPPORT, 1, + [Define if your linker supports -z bndplt]) +fi +AC_MSG_RESULT($ld_bndplt_support) + # Configure the subdirectories # AC_CONFIG_SUBDIRS($subdirs) diff --git a/libmpx/configure.ac b/libmpx/configure.ac index 463e855..18ba687 100644 --- a/libmpx/configure.ac +++ b/libmpx/configure.ac @@ -39,18 +39,7 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED) AM_CONDITIONAL(LIBMPX_SUPPORTED, [test "x$LIBMPX_SUPPORTED" = "xyes"]) link_libmpx="-lpthread" -link_mpx="" -AC_MSG_CHECKING([whether ld accepts -z bndplt]) -echo "int main() {};" > conftest.c -if AC_TRY_COMMAND([${CC} ${CFLAGS} -Wl,-z,bndplt -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD]) -then - AC_MSG_RESULT([yes]) - link_mpx="$link_mpx -z bndplt" -else - AC_MSG_RESULT([no]) -fi AC_SUBST(link_libmpx) -AC_SUBST(link_mpx) AM_INIT_AUTOMAKE(foreign no-dist no-dependencies) AM_ENABLE_MULTILIB(, ..) diff --git a/libmpx/libmpx.spec.in b/libmpx/libmpx.spec.in index 34d0bdf..a80bba7 100644 --- a/libmpx/libmpx.spec.in +++ b/libmpx/libmpx.spec.in @@ -1,5 +1,3 @@ # This spec file is read by gcc when linking. It is used to specify the # standard libraries we need in order to link with libmpx. *link_libmpx: @link_libmpx@ - -*link_mpx: @link_mpx@