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

H.J. Lu hjl.tools@gmail.com
Wed Jan 24 14:41:54 GMT 2024


On Mon, Jan 22, 2024 at 10:45 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Jan 22, 2024 at 10:22 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > 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).
>
> Good point.  I updated the documentation with
>
> This option is supported only for default linker scripts in ELF and PE
> COFF linkers.
>
> > 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 shouldn't do it for linker generated sections, like .plt and .got.
>
> > 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`.
>
> Sounds like a good improvement.

This approach may not be easy to implement in ld.  We can't add
the same INCLUDE file to more than 1 output section.   The first
INCLUDE will always win.

-- 
H.J.


More information about the Binutils mailing list