input section ordering

Ian Lance Taylor ian@zembu.com
Thu Jun 21 09:37:00 GMT 2001


Alan Modra <amodra@bigpond.net.au> writes:

> ld.info,  Node: Input Section Basics says this:
> 
> "There are two ways to include more than one section:
>      *(.text .rdata)
>      *(.text) *(.rdata)
> 
> The difference between these is the order in which the `.text' and
> `.rdata' input sections will appear in the output section.  In the
> first example, they will be intermingled.  In the second example, all
> `.text' input sections will appear first, followed by all `.rdata'
> input sections."
> 
> This paragraph was the basis for my suggestion to Geoff Keating re
> .eh_frame data.  The trouble is, I can't see how the linker accomplishes
> the above difference in input section order.  In fact, looking at
> ldgram.y:input_section_spec, I think the linker treats both of the
> above input section statements exactly the same.  Can anyone tell me
> otherwise?

Hmmm.  You might be right.  I might have been confused when I wrote
the above paragraph.  I'm sure I was thinking of something, but now
I'm not sure what it was.

> The next question is how to go about implementing a fix.  I figure we
> need some sort of structure to handle the file name spec ('*' above),
> that has a list of children handling the sections (specified above
> inside the parentheses).  Then it's a matter of modifying most of
> the functions that play with lang_input_statement_type structures.
> And about here is where I start to mumble.

This would just be a change to lang_wild_statement, I think.  Instead
of creating a new lang_wild_statement for each filename, keep a list
of filenames within one *(A B C) construct.  Then check the whole list
in walk_wild_section and perhaps a few other places.

Ian



More information about the Binutils mailing list