From: Samuel Thibault <sthibault@debian.org>
To: Xi Ruoyao <xry111@xry111.site>
Cc: libc-alpha@sourceware.org, glibc@packages.debian.org
Subject: Re: static pie: confusion between _DYNAMIC, crt1.o, Scrt1.o
Date: Sun, 23 Oct 2022 11:43:05 +0200 [thread overview]
Message-ID: <20221023094305.insor2m2732f45uz@begin> (raw)
In-Reply-To: <250879295638ee6c5c0799fe7009efeda642c31a.camel@xry111.site>
Xi Ruoyao, le dim. 23 oct. 2022 10:08:34 +0800, a ecrit:
> On Sat, 2022-10-22 at 16:45 +0200, Samuel Thibault wrote:
> > Is it not possible to make -static -pie get the same behavior? That'd be
> > way more orthogonal for people to understand.
> >
> > As the gnupg example shows, people seem to be expecting it to be
> > static-pie, and I don't think documentation will manage to fix that.
>
> I'm not sure.
It would be really useful to it works, because I see that e.g. on a
pie-by-default distribution such as Debian, when linking with just
-static, we don't get the static-pie benefit, even if the distribution
already enabled pie by default to benefit from ASLR. I.e. we don't
automatically benefit from static-pie's ASLR for static binaries, and
fixing that would be very tedious since it'd mean having to fix each and
every package with static binaries into using -static-pie instead of
-static.
> > That doesn't seem to have been fixed for the hurd case, I will have
> > a look (and that will most probably point me to the piece that makes
> > -static -pie use crt1.o on Linux).
>
[...]
> What does
>
> gcc -dumpspecs | grep 'startfile:' -A1
>
> say on Hurd?
It was
*startfile:
%{!shared: %{pg|p|profile:%{static:gcrt0.o%s;:gcrt1.o%s};pie:Scrt1.o%s;static:crt0.o%s;:crt1.o%s}} crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}
I have now fixed it into
*startfile:
%{!shared: %{pg|p|profile:%{static-pie:grcrt0.o%s;static:gcrt0.o%s;:gcrt1.o%s};static-pie:rcrt0.o%s;static:crt0.o%s;pie:Scrt1.o%s;:crt1.o%s}} crti.o%s %{static:crtbeginT.o%s;shared|pie|static-pie:crtbeginS.o%s;:crtbegin.o%s}
see the patch I have just sent on gcc-patches.
Thanks,
Samuel
next prev parent reply other threads:[~2022-10-23 9:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-22 14:06 Samuel Thibault
2022-10-22 14:25 ` Xi Ruoyao
2022-10-22 14:45 ` Samuel Thibault
2022-10-23 2:08 ` Xi Ruoyao
2022-10-23 9:43 ` Samuel Thibault [this message]
2022-10-24 10:11 ` Florian Weimer
2022-10-24 10:33 ` Samuel Thibault
2022-10-24 11:12 ` Florian Weimer
2022-10-24 15:56 ` Mike Frysinger
2022-10-24 17:36 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221023094305.insor2m2732f45uz@begin \
--to=sthibault@debian.org \
--cc=glibc@packages.debian.org \
--cc=libc-alpha@sourceware.org \
--cc=xry111@xry111.site \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).