public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
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: Mon, 24 Oct 2022 19:36:38 +0200	[thread overview]
Message-ID: <878rl52kex.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <Y1a1w+ajIQlSGBO8@vapier> (Mike Frysinger via Libc-alpha's message of "Mon, 24 Oct 2022 21:41:51 +0545")

* Mike Frysinger via Libc-alpha:

> On 24 Oct 2022 13:12, Florian Weimer via Libc-alpha wrote:
>> * Samuel Thibault:
>> > Florian Weimer, le lun. 24 oct. 2022 12:11:03 +0200, a ecrit:
>> >> * Samuel Thibault:
>> >> 
>> >> > Is it not possible to make -static -pie get the same behavior? That'd be
>> >> > way more orthogonal for people to understand.
>> >> 
>> >> I think you want -static to mean -static-pie if GCC defaults to PIE,
>> >> right?
>> >
>> > That would actually provide the pie benefit automatically for all
>> > static executable, yes. Otherwise static pie will be a nice thing, but
>> > not actually largely used in practice. And most people won't actually
>> > realize it.
>> 
>> That's true.
>> 
>> Fedora uses a specs file fragment that turns -static into -static-pie
>> under certain conditions.
>> 
>> >> That will break a few things that use gcc -static to build binaries for
>> >> quasi-bare-metal targets using the GNU ELF toolchain (where glibc's
>> >> startup code is not use).
>> >
>> > But then the piece which is saying that glibc's startup code is not in
>> > use can be fixed into not using static-pie, can't it?
>> 
>> In theory, yes.  How hard it will be depends on the specs file change
>> for --enable-default-pie.
>
> i don't see a problem with -static DTRT.  people abusing a compiler for a
> target it wasn't designed for means they get the pieces.  it's not like
> they're using -static in the first place to pull in the C library & gcc
> internal libs (which also depend/assume the corresponding OS & C lib).
>
> plus, -static -no-pie would get you back to a non-PIE static binary.

The last part depends on the specs file, it has to be put there
explicitly I think.  And perhaps -Wl,-no-pie as well?

Maybe also do -no-pie implicitly with -static -nostartfiles?

Thanks,
Florian


      reply	other threads:[~2022-10-24 17:36 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
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 [this message]

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=878rl52kex.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --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).