From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9287 invoked by alias); 31 Jan 2018 15:44:19 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 9277 invoked by uid 89); 31 Jan 2018 15:44:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*f:sk:MQmJ8Sn, H*i:sk:uDZjDZY, H*f:sk:uDZjDZY, H*i:sk:MQmJ8Sn X-HELO: mail-ot0-f180.google.com Received: from mail-ot0-f180.google.com (HELO mail-ot0-f180.google.com) (74.125.82.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Jan 2018 15:44:17 +0000 Received: by mail-ot0-f180.google.com with SMTP id x15so13785763ote.1 for ; Wed, 31 Jan 2018 07:44:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=pQdXA/Mb0wyeMIeSQ5Gd7wfWX+gGlPcjRLpeonZ4LmQ=; b=iGQAuAvnfu6pUfLaL16gR8pjKN/tJEysfDALLLDzsNrIcsg/qBCyLHoJ0+1sGPS9Bt notOIk1PmxNiF6DeyYP7dxH6hgqxVJ9VSPe2gGo0+Kb/ImIZnyYIRJDsacp8fQz7o7zr CPKdvHLJx0VHa2tZ7UgBcekT+nRqcU5hYU5wmx+kKhbbjJTElr0uB97WKpiT69BeMK3t inQngntKbqtPA1e7jeYKa0gtS/QBMWMun/R0F+Jj31CLx5EoQ7WFdYTMMt5WzbzQU7D1 Ax1mwL5VUqxnRtXxf//f6eJE/Q26xHGV7tVMmnqWLbOkjH/QveUqPfj37ybGmqJzLQOn 5+wg== X-Gm-Message-State: AKwxytcncy+2cnwn/lf6jU0ehgOOSL5fDCLP1DF9JP8VUnHIhA9jk5DO 0zuIkZdyvDvQxkxaodnIWUbpMYzsAsq7AAXP5p5/LA== X-Google-Smtp-Source: AH8x227cDG07YE3kh0tPZdoSNIR6ovPtdbvupty8ZiwYCT+T5rLNnhg3CWRqj9zlGJ1qcQsbc4BhZ+u7CVXU1QTrUGQ= X-Received: by 10.157.60.137 with SMTP id z9mr10489336otc.198.1517413455709; Wed, 31 Jan 2018 07:44:15 -0800 (PST) MIME-Version: 1.0 Reply-To: lists@coryfields.com Received: by 10.74.193.13 with HTTP; Wed, 31 Jan 2018 07:44:15 -0800 (PST) In-Reply-To: References: From: Cory Fields Date: Wed, 31 Jan 2018 15:44:00 -0000 Message-ID: Subject: Re: -static-pie and -static -pie To: "H.J. Lu" Cc: GCC Development Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00259.txt.bz2 After looking at this for quite a while, I'm afraid I'm unsure how to proceed. As of now, static and static-pie are mutually exclusive. So given the GNU_USER_TARGET_STARTFILE_SPEC you pasted earlier, "static" matches before "static-pie", causing the wrong start files. It seems to me that the static-pie target complicates things more than matching against static+pie individually. If I convert -static + -pie to -static-pie, then "static" won't be matched in specs, where maybe it otherwise should. Same for -pie. Would you prefer to swallow -static and -pie and pass along only -static-pie? Or forward them all along, and fix the specs which look for static before static-pie ? Regards, Cory On Tue, Jan 30, 2018 at 2:36 PM, H.J. Lu wrote: > On Tue, Jan 30, 2018 at 11:18 AM, Cory Fields wrote: >> On Tue, Jan 30, 2018 at 2:14 PM, H.J. Lu wrote: >>> On Tue, Jan 30, 2018 at 11:07 AM, Cory Fields wrote: >>>> On Tue, Jan 30, 2018 at 1:35 PM, H.J. Lu wrote: >>>>> On Tue, Jan 30, 2018 at 10:26 AM, Cory Fields wrote: >>>>>> Hi list >>>>>> >>>>>> I'm playing with -static-pie and musl, which seems to be in good shape >>>>>> for 8.0.0. Nice work :) >>>>>> >>>>>> However, the fact that "gcc -static -pie" and "gcc -static-pie" >>>>>> produce different results is very unexpected. I understand the case >>>>>> for the new link-type, but merging the options when possible would be >>>>>> a huge benefit to existing buildsystems that already cope with both >>>>>> individually. >>>>>> >>>>>> My use-case: >>>>>> I'd like to build with --enable-default-pie, and by adding "-static" >>>>> >>>>> Why not adding "-static-pie" instead of "-static"? >>>>> >>>>>> to my builds, produce static-pie binaries. But at the moment, that >>>>>> attempts to add an interp section. >>>>>> >>>>>> So my question is, if no conflicting options are found, why not hoist >>>>>> "-static -pie" to "-static-pie" ? >>>>>> >>>>>> Regards, >>>>>> Cory >>>>> >>>>> >>>>> >>>>> -- >>>>> H.J. >>>> >>>> My build system, and plenty of others I'm sure, already handle -static >>>> and -pie. Having that understood to mean "static-pie" would mean that >>>> the combination would now just work. >>>> >>>> Asking a different way, if I request -static and -pie, without -nopie, >>>> quietly creating non-pie binary seems like a bug. Is there a reason >>>> _not_ to interpret it as -static-pie in that case? >>> >>> GNU_USER_TARGET_STARTFILE_SPEC is defined as >>> >>> #define GNU_USER_TARGET_STARTFILE_SPEC \ >>> "%{shared:; \ >>> pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \ >>> static:crt1.o%s; \ >>> static-pie:rcrt1.o%s; \ >>> " PIE_SPEC ":Scrt1.o%s; \ >>> :crt1.o%s} \ >>> crti.o%s \ >>> %{static:crtbeginT.o%s; \ >>> shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \ >>> :crtbegin.o%s} \ >>> %{fvtable-verify=none:%s; \ >>> fvtable-verify=preinit:vtv_start_preinit.o%s; \ >>> fvtable-verify=std:vtv_start.o%s} \ >>> " CRTOFFLOADBEGIN >>> >>> to pick a suitable crt1.o for static PIE when -static-pie is used. >>> >>> If gcc.c can convert ... -static ... -pie and ... -pie ... -static ... to >>> -static-pic for GNU_USER_TARGET_STARTFILE_SPEC, it >>> should work. >>> >>> -- >>> H.J. >> >> Great, that's how I've fixed it locally. Would you consider accepting >> a patch for this? > > I'd like to see it in GCC 8. Please open a GCC bug and submit your > patch against it. > > Thanks. > > -- > H.J.