This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Adding static-PIE support to binutils

> So far, I've been prototyping static PIE support by having GCC pass
> the following options to ld instead of -static -pie:
>         -static -shared -Bsymbolic
> This partly works, but since ld does not know it's producing a main
> executable, it misses important details, including the ability to link
> initial-exec and local-exec model TLS code correctly, as well as
> various linking optimizations. So I think the right way forward is
> making ld accept -static and -pie together to do the right thing.

For the uses you have in mind, -static and -pie together make perfect
sense, but I'd argue that the output file in that case ought to be
ET_EXEC, since it will be in fact a standalone binary to be loaded
directly by the kernel. Not only would you want to omit the .interp
section (actually the PT_INTERP segment), but you also have no need
for the PT_DYNAMIC segment (.dynamic section).

The only thing you need over a standard ET_EXEC file is the dynamic
relocations, with linker-generated symbols bracketing the start and
end of the relocations so that your custom startup code can find them.
It should be reasonably easy to arrange for these.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]