[PATCH v8 3/6] elf: Introduce _dl_map_segment_align hook for segment alignment tuning

Wilco Dijkstra Wilco.Dijkstra@arm.com
Thu Apr 9 10:20:10 GMT 2026


Hi HJ,

> > > > > > >   LOAD           0x000000 0x00400000 0x00400000 0x16d110 0x16d110 R   0x1000
> > > > > > >   LOAD           0x16e000 0x0056e000 0x0056e000 0x1055d9 0x1055d9 R E 0x1000
> > > > > > >
> > > > > > > into a single RE THP map.
> >
> > So my question is why do we need to do this in both loaders?
> >
> > Shouldn't the linker just do better here? Eg. it can merge program headers
> > and related read-only data into the text segment even with -zseparate-code.
> 
> x86 linker on master branch no longer does that after the fix for
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=34003

So x86 now starts with R+X load segment by default?

However I'm still not convinced that what you're trying to do is correct - it seems to me you can't
just decide to merge segments when the user requested -zseperate-code or --rosegment. Those
segments exist for a reason.

The loader could support R, R+X load segments and still align for THP without merging them.

Cheers,
Wilco


More information about the Libc-alpha mailing list