From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75672 invoked by alias); 17 Jul 2017 12:33:35 -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 75307 invoked by uid 89); 17 Jul 2017 12:33:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Hx-languages-length:3059 X-HELO: mail-pg0-f66.google.com Received: from mail-pg0-f66.google.com (HELO mail-pg0-f66.google.com) (74.125.83.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Jul 2017 12:33:32 +0000 Received: by mail-pg0-f66.google.com with SMTP id d193so19342879pgc.2 for ; Mon, 17 Jul 2017 05:33:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vhgrYxqFwqhQz65mJT0s3bkEq3Mloc1zsu5zILarf0w=; b=D1lkrxryZS1PmSCuvlpgG7mb5rPr8NVaTo191uAm7UJJTAokg54GKiicY8vGZcGZLN NPafSmLf/QH45TLK+vKcEZsD8Nd+Ptv3rWzdOe2TiPmzPUryREst+xkhtw+RAhgqnMLE 9e26B9peSj2SlZuJ4UA8JyhXFQe4ERQTdB0l1xnqhk+w6vlS3eyVkgkWd3B0/3bkgV1A yFreCzY9C+p+wAYP/N8LGfeDVKGDpYxs/NhD8U+q9C5yV68yQzCoHygykSq/m5B0ovHN mr/xGj2/UkwhcLLUmlyPbHdt1/Ml9CRv2TOw+dwDzlcAfOx6NIluO08YeBrv2lFng0jB nSag== X-Gm-Message-State: AIVw110gjHxjMVYZl20vxRsxYGs2eFjtMmlLRwcaTSnkAU3gEJx81Ed2 H41qrzUIuLT2q7ft X-Received: by 10.84.174.3 with SMTP id q3mr30191633plb.289.1500294810235; Mon, 17 Jul 2017 05:33:30 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-71-80.tyqh2.lon.bigpond.net.au. [58.160.71.80]) by smtp.gmail.com with ESMTPSA id e77sm31943787pfk.123.2017.07.17.05.33.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 05:33:29 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id AB8CAC04D4; Mon, 17 Jul 2017 22:03:25 +0930 (ACST) Date: Mon, 17 Jul 2017 12:33:00 -0000 From: Alan Modra To: "H.J. Lu" Cc: GCC Patches Subject: Re: [PATCH] Fix pr80044, -static and -pie insanity, and pr81170 Message-ID: <20170717123325.GG14520@bubble.grove.modra.org> References: <20170622152859.GG8406@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00972.txt.bz2 On Sat, Jul 15, 2017 at 06:32:40AM -0700, H.J. Lu wrote: > On Thu, Jun 22, 2017 at 8:28 AM, Alan Modra wrote: > > PR80044 notes that -static and -pie together behave differently when > > gcc is configured with --enable-default-pie as compared to configuring > > without (or --disable-default-pie). This patch removes that > > difference. In both cases you now will have -static completely > > overriding -pie. > > > > Fixing this wasn't quite as simple as you'd expect, due to poor > > separation of functionality. PIE_SPEC didn't just mean that -pie was > > on explicitly or by default, but also -r and -shared were *not* on. > > Fortunately the three files touched by this patch are the only places > > PIE_SPEC and NO_PIE_SPEC are used, so it isn't too hard to see that > > the reason PIE_SPEC and NO_PIE_SPEC are not inverses is the use of > > PIE_SPEC in LINK_PIE_SPEC. So, move the inelegant symmetry breaking > > addition, to LINK_PIE_SPEC where it belongs. Doing that showed > > another problem in gnu-user.h, with PIE_SPEC and NO_PIE_SPEC selection > > of crtbegin*.o not properly hooked into a chain of if .. elseif .. > > conditions, which required both PIE_SPEC and NO_PIE_SPEC to exclude > > -static and -shared. Fixing that particular problem finally allows > > PIE_SPEC to serve just one purpose, and NO_PIE_SPEC to disappear. > > > > Bootstrapped and regression tested powerpc64le-linux c,c++. No > > regressions and a bunch of --enable-default-pie failures squashed. > > OK mainline and active branches? > > > > Incidentally, there is a fairly strong case to be made for adding > > -static to the -shared, -pie, -no-pie chain of RejectNegative's in > > common.opt. Since git 0d6378a9e (svn r48039) 2001-11-15, -static has > > done more than just the traditional "prevent linking with dynamic > > libraries", as -static selects crtbeginT.o rather than crtbegin.o > > on GNU systems. Realizing this is what led me to close pr80044, which > > I'd opened with the aim of making -pie -static work together (with the > > traditional meaning of -static). I don't that is worth doing, but > > mention pr80044 in the changelog due to fixing the insane output > > produced by -pie -static with --disable-default-pie. > > > > On x86-64, without --enable-default-pie, "-static -pie" and "-pie -static" > never worked since both -static and -pie are passed to linker, which > uses libc.a to build PIE. Yes, it's broken. > With --enable-default-pie, -static and -pie > override each other. No they don't. -static overrides -pie. > What does your patch do on x86-64? Make > with and without --enable-default-pie behave the same? Yes, as I said in my original post first paragraph. > Does it > mean that both fail to create executable? I try to leave that sort of patch to those better qualified. Bootstrap and regression testing on x86_64-linux both --enable-default-pie and --disable-default-pie was complete June 23. -- Alan Modra Australia Development Lab, IBM