From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13575 invoked by alias); 30 Jan 2018 19:15:00 -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 13565 invoked by uid 89); 30 Jan 2018 19:14:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-ot0-f172.google.com Received: from mail-ot0-f172.google.com (HELO mail-ot0-f172.google.com) (74.125.82.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 30 Jan 2018 19:14:58 +0000 Received: by mail-ot0-f172.google.com with SMTP id a7so8132428otk.9 for ; Tue, 30 Jan 2018 11:14:58 -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:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+4xNP/P+pTSrCbInoONjIBRRylRwjwA5rsf5ltjl174=; b=rphNpNpIBb7Qf4XDUNLleThIzoWj0yHmW+s8YUud/+1ZG8JQ7fYsKkF8QF5m53ioeJ +uowdSR8QRKVMdJmDAQ8wZrgj7GN5l5T9QwYFeuw7mkwRQpNJCxbmnMocUp/FjCoW2lw StpBS8mtr/lSeV7aaL6awytX4w8PvwxPFn1jXX6jVZLNm7uyHezv/TomNkUukLv4/AlT vG+i7mGaVoIcVnF+uF8nALGyahT4tHh/EkpKupGtyTjlGwLYNmzKcqYCnwMY+U8cuzg3 b4qy6Q4RGxHEQ/QeNS0D0P8nkzjZUEJyE8Ar1KFD+9wkin8srBrgp1EuZg7XYg/c5kkB igcg== X-Gm-Message-State: AKwxytecDV/ch+mSkUVk3sy3PyqTpg6L6ySfHk/LPmKMU/po5DbRIBJ3 CNCOfPPPtQDIYoh1gqi75+wC8Kg9BMEHqt2qypE= X-Google-Smtp-Source: AH8x2256ckqUYMX3V1LWW8RmqLfNWS8CcHHOX+Zd92anFG8Ff0mJG+cT+fIVol76NvEc+lN97UmebDhZXNAo/SlxbPU= X-Received: by 10.157.91.73 with SMTP id e9mr5865216otj.383.1517339696644; Tue, 30 Jan 2018 11:14:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.74.177.2 with HTTP; Tue, 30 Jan 2018 11:14:56 -0800 (PST) In-Reply-To: References: From: "H.J. Lu" Date: Tue, 30 Jan 2018 19:15:00 -0000 Message-ID: Subject: Re: -static-pie and -static -pie To: lists@coryfields.com Cc: GCC Development Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00255.txt.bz2 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.