[PATCH] ld: Disable separate code by default for Linux/x86
Florian Weimer
fweimer@redhat.com
Tue Mar 17 12:00:49 GMT 2026
* H. J. Lu:
> On Mon, Mar 16, 2026 at 7:20 AM WANG Rui <r@hev.cc> wrote:
>>
>> Years ago, commit f6aec96dce1d ("ld: Add --enable-separate-code") introduced
>> -z separate-code, mainly to avoid mixing code and data in the same segment
>> for better cache performance, and enabled it by default for Linux/x86.
>
> -z separate-code reduces cache pollution and
64 byte section alignment would achieve the same thing, I believe.
But maybe there's impact on TLB slots? But then separate-code seems to
make page coalescing more difficult.
> improves security by avoiding putting read-only data in the same page
> with code.
I think we've moved on from gadget avoidance as a security hardening
approach, so I'm not sure that's relevant anymore.
> Should ld.so map read-only data segment plus code segment into the same huge
> page? This should have the similar effect as -z noseparate-code.
Would it? Lots of objects have segments smaller than 2 MiB.
Thanks,
Florian
More information about the Libc-alpha
mailing list