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

H.J. Lu hjl.tools@gmail.com
Thu Apr 9 23:44:28 GMT 2026


On Fri, Apr 10, 2026 at 7:19 AM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>
> Hi HJ,
>
> >> > Unless the first R segment is bigger than 2MB,  we need to align from the
> >> > file offset 0 anyway.   That is what my proposal does.
> >>
> >> But it doesn't, that's my issue. It would be perfectly fine to generalize Rui's patch
> >
> > What did you mean by "doesn't"?
>
> It merges load segments which is not the same as aligning.

If the first R segment size is smaller than 2MB, don't you need to
load it from the offset 0 to align the second segment to 2MB?

> >> to remove the condition that the R+X segment must start at zero offset and check
> >
> > The easiest way to implement it is to combine R + RX segments in one segment
> > from the file offset 0.  We only need 1 load, instead of 2.
>
> How? If you want to ignore -zseparate-code/--(no-)rosegment, do it in the linker and
> warn the user that you're merging sections that they explicitly requested to be separate.
>

It goes back to the question of whether THP should be optional or
on by default.

-- 
H.J.


More information about the Libc-alpha mailing list