* 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 via email to