[PATCH 1/4] ld: Add --text-section-ordering-file FILE

Noah Goldstein goldstein.w.n@gmail.com
Mon Jan 22 18:22:39 GMT 2024


On Mon, Jan 22, 2024 at 12:52 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sun, Jan 21, 2024 at 11:37 PM Jan Beulich <jbeulich@suse.com> wrote:
> >
> > On 20.01.2024 00:15, Fangrui Song wrote:
> > > It is a shame that the new feature only applies to .text . Data
> > > sections and other code sections should be reorderable as well.
> >
> > I second this remark. In fact I wonder why it is that text needs
>
> The perf data usually provides guidance for text section layout.
>
> > treating specially here. Can't the option just be
> > --section-ordering-file and then permit covering all kinds of
> > sections?

Another issue with this approach is that it won't work for custom
linker scripts (because the `INCLUDE` of the ordering file has
been manually inserted in the defaults).

A different approach for this patch that may alleviate both concerns
(work for custom linker scripts + for arbitrary sections) would be to
update the logic of `section: NAME` in `ldgram.y`.

We could insert the script contents upon entering any new section.

This might blowup link time (if a link script is inserted at each section),
so we could add another auxiliary option to specify which sections
the config script should apply for and make it default to something like
`.data` and `.text`.
>
> It requires much bigger changes to ld.
>
>
> --
> H.J.


More information about the Binutils mailing list