This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Add --sort-section to ld


On Thu, Aug 26, 2004 at 09:13:34AM -0400, DJ Delorie wrote:
> 
> > How do we deal with SORT in linker script and --sort-section alignment?
> > Which one should be preferred? Should there be SORT_ALIGN?
> 
> IMHO...
> 
> The linker script always overrides the command line.
> 
> However, it would make sense for the --sort-section function to be
> used by the explicit SORT* routine for cases when the two sections
> would otherwise sort equally, so sections whose order would otherwise
> be unspecified would become specified.

How about this proposal?


H.J.
----
New input section sorting options in linker

1. New linker script section sorting commands.

1.1. Rename SORT to SORT_BY_NAME and make SORT an alias of
SORT_BY_NAME.
1.2. Add SORT_BY_ALIGNMENT, which appears before a wildcard pattern in
parentheses (.e.g. `SORT_BY_ALIGNMENT (.text*).). It will sort sections
into ascending order by alignment before placing them into the output
file.

2. New linker command line option. 

2.1. --sort-section name. It will apply SORT_BY_NAME to all wildcard
section patterns in the linker script. 
2.2. --sort-section alignment. It will apply SORT_BY_ALIGMENT to all
wildcard section patterns in the linker script.

3. Nesting of section sorting commands in linker script. There can be
at most 1 level of nesting for section sorting commands. 

3.1. SORT_BY_NAME (SORT_BY_ALIGNMENT (wildcard section pattern)). It
will sort the input sections by alignment first, then by name if 2
sections have the same alignment.
3.2. SORT_BY_ALIGNMENT (SORT_BY_NAME (wildcard section pattern)). It
will sort the input sections by name first, then by alignment if 2
sections have the same name.
3.3. SORT_BY_NAME (SORT_BY_NAME (wildcard section pattern)) is treated
the same as SORT_BY_NAME (wildcard section pattern).
3.4. SORT_BY_ALIGNMENT (SORT_BY_ALIGMENT (wildcard section pattern)) is
treated the same as SORT_BY_ALIGMENT (wildcard section pattern).
3.5. All other nested section sorting commands are invalid.

4. --sort-section command line option vs. section sorting command in
linker script.

4.1. Section sorting commands always take precedent over the command
line option.
4.2. If the section sorting command in linker script isn.t nested, the
command line option will make the section sorting command to be treated
as nested sorting command.
4.3. If the section sorting command in linker script is nested, the
command line option will be ignored.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]