From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48382 invoked by alias); 18 Mar 2015 14:03:42 -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 48373 invoked by uid 89); 18 Mar 2015 14:03:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_50 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 18 Mar 2015 14:03:31 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8862D1162C2; Wed, 18 Mar 2015 10:03:29 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id XeDsTprU-H-G; Wed, 18 Mar 2015 10:03:29 -0400 (EDT) Received: from [192.168.88.4] (burl-mse-71-255-143-190.static.ngn.east.myfairpoint.net [71.255.143.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 4165D1160FD; Wed, 18 Mar 2015 10:03:29 -0400 (EDT) Message-ID: <550985AE.4040904@adacore.com> Date: Wed, 18 Mar 2015 14:03:00 -0000 From: Robert Dewar User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Ilya Enkovich , "H.J. Lu" CC: Richard Biener , GCC Patches , Uros Bizjak Subject: Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX References: <20150318115630.GA64546@msticlxl57.ims.intel.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00943.txt.bz2 Do we really want to quote to this level? This message has 11 levels of quotes, the most I have ever seen. If everyone does this, the whole thread is in every message and that seems unnecessary. I don't know if there are gcc guidelines on this??? On 3/18/2015 9:59 AM, Ilya Enkovich wrote: > 2015-03-18 16:52 GMT+03:00 H.J. Lu : >> On Wed, Mar 18, 2015 at 6:41 AM, Ilya Enkovich wrote: >>> 2015-03-18 16:31 GMT+03:00 H.J. Lu : >>>> On Wed, Mar 18, 2015 at 6:24 AM, Ilya Enkovich wrote: >>>>> 2015-03-18 15:42 GMT+03:00 Richard Biener : >>>>>> On Wed, Mar 18, 2015 at 1:25 PM, H.J. Lu wrote: >>>>>>> On Wed, Mar 18, 2015 at 5:13 AM, Ilya Enkovich wrote: >>>>>>>> 2015-03-18 15:08 GMT+03:00 H.J. Lu : >>>>>>>>> On Wed, Mar 18, 2015 at 5:05 AM, Ilya Enkovich wrote: >>>>>>>>>> 2015-03-18 15:02 GMT+03:00 H.J. Lu : >>>>>>>>>>> On Wed, Mar 18, 2015 at 4:56 AM, Ilya Enkovich wrote: >>>>>>>>>>>> Hi, >>>>>>>>>>>> >>>>>>>>>>>> This patch fixes PR target/65444 by passing '-z bndplt' to linker when appropriate. Bootstrapped and tested on x86_64-unknown-linux-gnu. Will commit it to trunk in a couple of days if no objections arise. >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> Ilya >>>>>>>>>>>> -- >>>>>>>>>>>> gcc/ >>>>>>>>>>>> >>>>>>>>>>>> 2015-03-18 Ilya Enkovich >>>>>>>>>>>> >>>>>>>>>>>> PR driver/65444 >>>>>>>>>>>> * config/i386/linux-common.h (MPX_SPEC): New. >>>>>>>>>>>> (CHKP_SPEC): Add MPX_SPEC. >>>>>>>>>>>> >>>>>>>>>>>> libmpx/ >>>>>>>>>>>> >>>>>>>>>>>> 2015-03-18 Ilya Enkovich >>>>>>>>>>>> >>>>>>>>>>>> PR driver/65444 >>>>>>>>>>>> * configure.ac: Add check for '-z bndplt' support >>>>>>>>>>>> by linker. Add link_mpx output variable. >>>>>>>>>>>> * libmpx.spec.in (link_mpx): New. >>>>>>>>>>>> * configure: Regenerate. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h >>>>>>>>>>>> index 9c6560b..dd79ec6 100644 >>>>>>>>>>>> --- a/gcc/config/i386/linux-common.h >>>>>>>>>>>> +++ b/gcc/config/i386/linux-common.h >>>>>>>>>>>> @@ -59,6 +59,11 @@ along with GCC; see the file COPYING3. If not see >>>>>>>>>>>> %:include(libmpx.spec)%(link_libmpx)" >>>>>>>>>>>> #endif >>>>>>>>>>>> >>>>>>>>>>>> +#ifndef MPX_SPEC >>>>>>>>>>>> +#define MPX_SPEC "\ >>>>>>>>>>>> + %{mmpx:%{fcheck-pointer-bounds:%{!static:%:include(libmpx.spec)%(link_mpx)}}}" >>>>>>>>>>>> +#endif >>>>>>>>>>>> + >>>>>>>>>>>> #ifndef LIBMPX_SPEC >>>>>>>>>>>> #if defined(HAVE_LD_STATIC_DYNAMIC) >>>>>>>>>>>> #define LIBMPX_SPEC "\ >>>>>>>>>>>> @@ -89,5 +94,5 @@ along with GCC; see the file COPYING3. If not see >>>>>>>>>>>> >>>>>>>>>>>> #ifndef CHKP_SPEC >>>>>>>>>>>> #define CHKP_SPEC "\ >>>>>>>>>>>> -%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" >>>>>>>>>>>> +%{!nostdlib:%{!nodefaultlibs:" LIBMPX_SPEC LIBMPXWRAPPERS_SPEC "}}" MPX_SPEC >>>>>>>>>>>> #endif >>>>>>>>>>>> diff --git a/libmpx/configure.ac b/libmpx/configure.ac >>>>>>>>>>>> index fe0d3f2..3f8b50f 100644 >>>>>>>>>>>> --- a/libmpx/configure.ac >>>>>>>>>>>> +++ b/libmpx/configure.ac >>>>>>>>>>>> @@ -40,7 +40,18 @@ 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) >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Without -z bndplt, MPX won't work correctly. We should always pass -z bndplt >>>>>>>>>>> to linker. If linker doesn't support it, ld will issue a warning, not >>>>>>>>>>> error and users >>>>>>>>>>> will know their linker is too old. When they update linker, they don't have to >>>>>>>>>>> rebuild GCC. >>>>>>>>>> >>>>>>>>>> If ld issues a warning instead of an error, then configure test passes >>>>>>>>>> and we pass '-z bndplt' to linker. >>>>>>>>>> >>>>>>>>> >>>>>>>>> Can you verify it with an older linker? The unknown XXX in -z XXX is always >>>>>>>>> warned and ignored in Linux linker. If testing it on Linux always passes, >>>>>>>>> it is useless. >>>>>>>> >>>>>>>> Old ld issues a warning: >>>>>>>> >>>>>>>> ld: warning: -z bndplt ignored. >>>>>>> >>>>>>> Does configure test pass? >>>>>>> >>>>>>>> But gold issues an error: >>>>>>>> >>>>>>>> ld.gold: bndplt: unknown -z option >>>>>>>> ld.gold: use the --help option for usage information >>>>>>> >>>>>>> If gold is used, MPX won't work. What should we do here? >>>>>>> Should we hardcode -fuse-ld=bfd for MPX? >>>>>> >>>>>> Is MPX disabled when the host linker is gold and gld isn't available? >>>>> >>>>> No. You may use MPX with gold and old ld but you would loose passed >>>>> bounds when make a call via plt. >>>>> >>>> >>>> If gold is default linker, the configure test will fail and we never pass >>>> -z bndplt to linker even if ld.bfd is available and ld.gold is fixed later. >>>> I'd rather always pass -z bndplt to ld. >>> >>> If gold is used and it doesn't support '-z bndplt' then it doesn't >>> mean user can't use MPX. >> >> They can use -fuse-ld=bfd to select bfd linker if gold fails to generate >> proper MPX binary. > > Which is a weird thing to do just to have a warning instead of an > error. You don't guarantee MPX PLT generation by always passing '-z > bndplt' but remove an opportunity to use gold at all. With current > check you may use any linker and manually provide additional options > if you want to. > > Ilya > >> >> >> -- >> H.J.