ld -r frustration

Richard Earnshaw rearnsha@gcc.gnu.org
Thu Jul 29 09:04:00 GMT 2004


On Thu, 2004-07-29 at 03:31, Alan Modra wrote:

> Incidentally, one of the nasty effects of ld -r on any arch is the fact
> that it can reorder code.  eg. If compiling with -ffunction-sections,
> all static functions called "setup" in different files will be grouped
> into the one section.  This loses code locality and can affect cache
> performance.

I would expect that to happen on a normal link too.  The linkers
collating rules will cause it to happen.  It's effectively a consequence
of the fact that gas can't really support multiple sections called .text
in a single object file (I've still to look into HJ's comment about
section groups, but in the general case we don't want to be creating
those).

I have wondered whether it might make sense to tweak the gas .section
operation to take a second name, something like (but the syntax could be
better)

.section abc=.text, ....
# code for abc
.section abc
# code for abc
.section def=.text,...
# code for def
.section abc
# code for abc
.section def
# code for def

this would generate two sections in an object file, both called .text
but the first containing the named group abc, the second the named group
def.

R.



More information about the Binutils mailing list