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 02:11:55PM -0400, DJ Delorie wrote:
> 
> > 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.
> 
> I think the semantics here need to be reversed.  If this were a real
> programming language, the SORT_BY_NAME would happen last, and override
> any previous (inner) sorting.
> 
> Thus, these would be equivalent:
> 
> SORT_BY_NAME (SORT_BY_ALIGNMENT (*.text))
> 
> SORT_BY_NAME (*.text) with -sort-sections=alignment

Here is the updated proposal. Any other comments?


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 name first, then by alignment if 2
sections have the same name.
3.2. SORT_BY_ALIGNMENT (SORT_BY_NAME (wildcard section pattern)). It
will sort the input sections by alignment first, then by name if 2
sections have the same alignment.
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.2.1. SORT_BY_NAME (wildcard section pattern ) with --sort-sections
alignment is equivalent to SORT_BY_NAME (SORT_BY_ALIGNMENT (wildcard
section pattern)).
4.2.2. SORT_BY_ALIGNMENT (wildcard section pattern) with .sort-section
name is equivalent to SORT_BY_ALIGNMENT (SORT_BY_NAME (wildcard section
pattern)).
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]