From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23495 invoked by alias); 30 Jan 2018 19:18:17 -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 23464 invoked by uid 89); 30 Jan 2018 19:18:12 -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:QSaa8Gc, H*i:sk:QSaa8Gc 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; Tue, 30 Jan 2018 19:18:11 +0000 Received: by mail-ot0-f180.google.com with SMTP id d9so11023794oth.6 for ; Tue, 30 Jan 2018 11:18:10 -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=k0bRx0HsxZhfGC8CAyODAPAyOe3b1kYSqEQXhbrTgGc=; b=RTIO/u87OnEl06wcU6Cd6+5dUOdusCjFU9rbAjVJ+P70CpQY9A0Lao6W38vawWefJ0 p+f1Y5LavK6KTLjrHHVLjwqF0dAQfJ99U8A4zfqIT8saS6MjpULkmQzQn99i1V8YC/RL QDgQrK5aDQLKsOKjQHURPF1ONc0FlrGyjTGUOvx2HO32sXJOulJt+KdVD2N3CwW4Uxb0 3TOEYjeBP0rLyICQ9mph2ZeG5laYpGOKz9h3e1mD42yK8dSl6fiYuPtfd4rd/5jP1Cnp jaGOj+9GttQVcjju1NOVf6g0KphAe3odlVgfzYbxAw+AAB9t5ywz6WDYVJGkKifCr3yQ Ap4g== X-Gm-Message-State: AKwxytdkOFrGi3Ldmee1YigRKrrAr5aYmaxL7UmqpQ2Bz+/FV6QCannX TRNcZu3nbyhUO2l3ev/X9BlGd0zIoSvOFCOzpzfv4Q== X-Google-Smtp-Source: AH8x225EcCP1XAGPhHxrEiNF5vbN8DFbzWRBP4/l7oEOB77re8rpW5MdsjaQtKlcW8e6ApX/bXBDS27PsovMkE+Dd0M= X-Received: by 10.157.31.90 with SMTP id x26mr804433otx.56.1517339889330; Tue, 30 Jan 2018 11:18:09 -0800 (PST) MIME-Version: 1.0 Reply-To: lists@coryfields.com Received: by 10.74.193.13 with HTTP; Tue, 30 Jan 2018 11:18:08 -0800 (PST) In-Reply-To: References: From: Cory Fields Date: Tue, 30 Jan 2018 19:18: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/msg00256.txt.bz2 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?