[PATCH] Linux/x86: Enable --rosegment by default
hev
r@hev.cc
Wed Mar 18 16:17:59 GMT 2026
Hello,
On Wed, Mar 18, 2026 at 11:01 PM Michael Matz <matz@suse.de> wrote:
>
> Hello,
>
> On Wed, 18 Mar 2026, hev wrote:
>
> > This patch looks acceptable to me, and it’s good to see progress here.
> > That said, in some cases, -z noseparate-code can be more helpful for
> > THP. I explained the reasoning in another thread. [1][2]
> >
> > Also, I’m a bit curious: GNU ld with --rosegment doesn’t seem to
> > arrange segments as R, RE, RW. From a security perspective, it would
> > make more sense to put R first so the ELF header is not executable.
>
> I we'd continue to care for gadget avoidance, which Florian tells us is
> not a thing anymore (yippie! :) ).
In practice, GNU ld only enables --separate-code by default for
Linux/x86. That means most Linux distros on other arches are
effectively not using it. I’m not really sure how much security
benefit this actually brings in practice.
>
> > LLVM lld with --rosegment does this by default (R, RE, RW).
>
> But your point in these mails is to align the E part to huge-page borders.
> Putting a read-only blob in front of it defeats that purpose.
Yeah, that’s exactly why I’m concerned that --rosegment in GNU ld
might eventually move toward a more security-oriented layout like lld
(R, RE, RW).
>
> > I wonder whether relying on the current GNU ld --rosegment layout is
> > entirely stable, if it ever shifts towards a more security-driven
> > layout, it might not behave the way we expect here.
>
> Hmm? Your proposal even was to completely merge the read-only and exec
> segment into one. You cannot at the same time care and not care about the
> security implications of merging readonly data and code :)
>From the motivation of this patch, I’m personally leaning toward
performance. If we can’t have both security and performance at the
same time, then maybe the linker should offer both options so users
can choose based on their needs:
* --separate-code + --rosegment: security-oriented. This would also
allow --rosegment to evolve toward a safer layout (RE, R, RW -> R, RE,
RW), similar to what lld does today.
* --noseparate-code: performance-oriented, providing a stable (RE, RW) layout.
Thanks,
Rui
More information about the Binutils
mailing list