https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119386

--- Comment #44 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
(In reply to Ard Biesheuvel from comment #43)
> arch/arm64/Makefile specifies '-shared' for the linker flags, but does not
> pass -fpic of -fpie to the compiler. We used to pass '-pie -shared' but that
> was changed a while ago to accommodate lld.

Oof. And you couldn't drop -shared (leaving -pie) because the linker would then
write a useless .interp section? BFD ld now has -static-pie; not sure about
LLD.

I see that that Makefile passes -z notext, as you're trying to link a PIE from
non-PIC objects, and the linker can emit text relocations. Makes sense.

> The goal is to build a PIE (or -shared) executable, so that we get the
> dynamic relocations needed to randomize the placement of the kernel in the
> virtual address space at boot. On arm64, that doesn't currently require
> -fpic of -fpie, and adding those options results in worse code due to all
> the GOT indirections.

(PIE with textrels, crucially, right?)

> Non-PIC might be more efficient, but there are cases where we cannot use it.
> The early startup code on x86 runs from a different virtual mapping than it
> was linked at, and this has been causing lots of issues. Grep for
> RIP_REL_REF() in the Linux source tree and weep :-)

Is x86 somehow special here, or can arm64 find itself in a similar situation?

Thanks for bearing with me!

Reply via email to