From: Xi Ruoyao <xry111@xry111.site>
To: Samuel Thibault <sthibault@debian.org>
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 10:08:34 +0800 [thread overview]
Message-ID: <250879295638ee6c5c0799fe7009efeda642c31a.camel@xry111.site> (raw)
In-Reply-To: <20221022144548.u5rq3ffgietk4zft@begin>
On Sat, 2022-10-22 at 16:45 +0200, Samuel Thibault wrote:
/* snip */
> > > So this is static pie (-pie -static)
> >
> > No it's not. The GCC option for static PIE is -static-pie (no
> > whitespace between -static and -pie), not -pie -static.
>
> Oh.
>
> 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.
> >
> > A static PIE should use rcrt1.o. If you pass the correct -static-pie
> > option to GCC, GCC will use it.
>
> Ok.
>
> $ gcc test.o -o test -static-pie -v
> [...]
> /usr/lib/gcc/i686-gnu/12/collect2 -plugin /usr/lib/gcc/i686-gnu/12/liblto_plugin.so -plugin-opt=/usr/lib/gcc/i686-gnu/12/lto-wrapper -plugin-opt=-fresolution=/tmp/cclPHnby.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc --build-id --eh-frame-hdr -m elf_i386 --hash-style=gnu --as-needed -static -pie --no-dynamic-linker -z text -pie -o test /usr/lib/gcc/i686-gnu/12/../../../i386-gnu/crt1.o /usr/lib/gcc/i686-gnu/12/../../../i386-gnu/crti.o /usr/lib/gcc/i686-gnu/12/crtbegin.o -L/usr/lib/gcc/i686-gnu/12 -L/usr/lib/gcc/i686-gnu/12/../../../i386-gnu -L/usr/lib/gcc/i686-gnu/12/../../.. -L/lib/i386-gnu -L/usr/lib/i386-gnu test.o --start-group -lgcc -lgcc_eh -lc --end-group /usr/lib/gcc/i686-gnu/12/crtendS.o /usr/lib/gcc/i686-gnu/12/../../../i386-gnu/crtn.o
>
> 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).
Hmm, I don't have a Hurd. On a Linux though:
$ cc hw.c -v -static-pie 2>&1 | grep collect2
/usr/libexec/gcc/x86_64-pc-linux-gnu/12.2.0/collect2 -plugin
/usr/libexec/gcc/x86_64-pc-linux-gnu/12.2.0/liblto_plugin.so -plugin-
opt=/usr/libexec/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper -plugin-
opt=-fresolution=/tmp/ccZqWxf9.res -plugin-opt=-pass-through=-lgcc -
plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc --eh-
frame-hdr -m elf_x86_64 -static -pie --no-dynamic-linker -z text -pie
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../lib/rcrt1.o
^^^^^^^
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../lib/crti.o
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/crtbeginS.o -
L/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0 -L/usr/lib/gcc/x86_64-pc-linux-
gnu/12.2.0/../../../../lib -L/lib/../lib -L/usr/lib/../lib -
L/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../.. /tmp/ccMPRUc3.o --
start-group -lgcc -lgcc_eh -lc --end-group /usr/lib/gcc/x86_64-pc-linux-
gnu/12.2.0/crtendS.o /usr/lib/gcc/x86_64-pc-linux-
gnu/12.2.0/../../../../lib/crtn.o
What does
gcc -dumpspecs | grep 'startfile:' -A1
say on Hurd?
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
next prev parent reply other threads:[~2022-10-23 2:08 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 [this message]
2022-10-23 9:43 ` Samuel Thibault
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=250879295638ee6c5c0799fe7009efeda642c31a.camel@xry111.site \
--to=xry111@xry111.site \
--cc=glibc@packages.debian.org \
--cc=libc-alpha@sourceware.org \
--cc=sthibault@debian.org \
/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).