[PATCH 4/8] section-select: Completely rebuild matches
Michael Matz
matz@suse.de
Tue Nov 29 13:23:18 GMT 2022
Hey,
On Tue, 29 Nov 2022, Alan Modra wrote:
> > > That's a problem. The got header is created in the .got of "linker
> > > stubs", and code setting the value of .TOC. assumes that the header
> > > will be located first in the .got output section. This ties in with
> > > where ld.so expects to find the header too.
> >
> > I see. But then why is the testcase (and linker script?) not using
> >
> > .got { *(.got) *(.toc) }
> >
> > ? The way it's written right now means "for each file, first its .got
> > then its .toc, intermixed", i.e. file1.got, file1.toc, file2.got,
> > file2.toc ...
>
> Yes. That's the way we want it. When linking small model code with a
> total GOT/TOC of over 64k, the linker splits the TOC into multiple
> pieces with r2 adjusting stubs inserted on calls between files that
> use different pieces of the TOC. That scheme wouldn't work if a
> file's .got entries were placed in a different piece of the TOC to the
> file's .toc entries.
Ah, nifty. Something like that occurred to me yesterday as well, and
either way, rewriting the linker script like above wouldn't have helped
this problem anyway, as long as "linker stubs".got would have been created
late it would always have been placed at the end of the list.
Although one could pedantically argue that those late-created sections
being placed at the end would indeed conform to "as they are found in the
linker input", I won't belabor that point. Complete rebuilding it is,
performance-wise it's a wash :)
Ciao,
Michael.
More information about the Binutils
mailing list