From patchwork Tue May 26 09:13:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 476447 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 297421402B5 for ; Tue, 26 May 2015 23:13:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=VIqMfqKg; 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=JgWT0n5Lc6XCXbPBT nnKRHAYh6F4aHxSZcH0Gon1pI5lzxS7AB1FYbKXC7XBcQC9Slob7FMaVSPVBsXd5 U4EcrFm/ruZ2k3AD/bpsUpG+7URVfIvVYo0H2Rii/tMKviSWJNN5nuiNfQ9iWSd2 J1JDUT3zrjmIHovSro+3jmX2U8= 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=bke+PrEJXlvhAOtF/SIsnM1 vwVo=; b=VIqMfqKggqgQZADbOMIrXontrIrUlHsxkzxqXUIgJ23xnFVgPyReLL3 2XZl2I691GHPS0QRxUepihmuuQyVVCbAUglNMx6nmbxcY//lHCwEa2QD+gY6bsln oG8Pfgk7679aKDevFfxAnO2qqirpR7/d6yjQXu/gWIPRczn2wL/c= Received: (qmail 21821 invoked by alias); 26 May 2015 09:14:12 -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 21808 invoked by uid 89); 26 May 2015 09:14:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_05, FREEMAIL_FROM, NO_DNS_FOR_FROM autolearn=no version=3.3.2 X-HELO: mail-yh0-f46.google.com Received: from Unknown (HELO mail-yh0-f46.google.com) (209.85.213.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 26 May 2015 09:13:45 +0000 Received: by yhda23 with SMTP id a23so28936396yhd.2 for ; Tue, 26 May 2015 02:13:37 -0700 (PDT) X-Received: by 10.170.209.205 with SMTP id a196mr4737353ykf.112.1432631617479; Tue, 26 May 2015 02:13:37 -0700 (PDT) Received: from msticlxl57.ims.intel.com (fmdmzpr04-ext.fm.intel.com. [192.55.55.39]) by mx.google.com with ESMTPSA id e47sm10979818yhj.38.2015.05.26.02.13.34 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 May 2015 02:13:37 -0700 (PDT) Date: Tue, 26 May 2015 12:13:27 +0300 From: Ilya Enkovich To: Jeff Law Cc: Sandra Loosemore , Joseph Myers , Richard Biener , gcc-patches Subject: Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX Message-ID: <20150526091327.GI47912@msticlxl57.ims.intel.com> References: <20150318115630.GA64546@msticlxl57.ims.intel.com> <20150331094702.GC52842@msticlxl57.ims.intel.com> <5521E515.2030802@codesourcery.com> <20150406151742.GA43634@msticlxl57.ims.intel.com> <5522A636.9030000@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5522A636.9030000@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On 06 Apr 09:28, Jeff Law wrote: > On 04/06/2015 09:17 AM, Ilya Enkovich wrote: > >> > >>To tell the truth, I can't figure out what this means from a user > >>perspective. How does a user know whether the linker option is > >>being ignored, or if they have a new enough linker? If the linker > >>available at configuration time doesn't support the option, does > >>that mean the option will never be passed and users will never know > >>that there are gaping holes in the pointer bounds checking? > >> > >>My suggestion would be to pass the option unconditionally and make > >>the documentation say something like > > > >This option was rejected. > Right. There really isn't a good option here because we don't have > the infrastructure to query the linker's capabilities at link time. > > Though I do wonder if we could issue a warning in the case where the > configure test indicated -z bndplt was not supported. > > It'd obviously mean a link warning every time an end user tried to > use that toolchain to create a DSO or executable with MPX > protection. But that may be better than silently leaving some code > unprotected. > > > Jeff > Hi, Here is a patch to add a note in case we build dynamic MPX codes and don't pass '-z bndplt'. Does it look OK? Thanks, Ilya --- gcc/ 2015-05-26 Ilya Enkovich * config/i386/linux-common.h (MPX_SPEC): Add link warning. libmpx/ 2015-05-26 Ilya Enkovich * configure.ac: Add link_mpx_warning. * libmpx.spec.in: Likewise. * configure: Regenerate. diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h index dd79ec6..fcaab81 100644 --- a/gcc/config/i386/linux-common.h +++ b/gcc/config/i386/linux-common.h @@ -61,7 +61,8 @@ along with GCC; see the file COPYING3. If not see #ifndef MPX_SPEC #define MPX_SPEC "\ - %{mmpx:%{fcheck-pointer-bounds:%{!static:%:include(libmpx.spec)%(link_mpx)}}}" + %{mmpx:%{fcheck-pointer-bounds:%{!static:%:include(libmpx.spec)%(link_mpx) \ + %(link_mpx_warning)}}}" #endif #ifndef LIBMPX_SPEC diff --git a/libmpx/configure.ac b/libmpx/configure.ac index 463e855..7e9ef86 100644 --- a/libmpx/configure.ac +++ b/libmpx/configure.ac @@ -40,17 +40,22 @@ AM_CONDITIONAL(LIBMPX_SUPPORTED, [test "x$LIBMPX_SUPPORTED" = "xyes"]) link_libmpx="-lpthread" link_mpx="" +link_mpx_warning="" 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" + link_mpx_warning="%{mmpx:}" else AC_MSG_RESULT([no]) + link_mpx="%{mmpx:}" + link_mpx_warning="%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." fi AC_SUBST(link_libmpx) AC_SUBST(link_mpx) +AC_SUBST(link_mpx_warning) 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..854f13d 100644 --- a/libmpx/libmpx.spec.in +++ b/libmpx/libmpx.spec.in @@ -3,3 +3,5 @@ *link_libmpx: @link_libmpx@ *link_mpx: @link_mpx@ + +*link_mpx_warning: @link_mpx_warning@