9.108 --sort=algorithm

Specifies the sorting algorithm used by the linker to determine the order of sections in an output image.

Syntax

--sort=algorithm
where algorithm is one of the following:
Alignment
Sorts input sections by ascending order of alignment value.
AlignmentLexical
Sorts input sections by ascending order of alignment value, then sorts lexically.
AvgCallDepth
Sorts all Thumb code before ARM code and then sorts according to the approximated average call depth of each section in ascending order.
Use this algorithm to minimize the number of long branch veneers.

Note

The approximation of the average call depth depends on the order of input sections. Therefore, this sorting algorithm is more dependent on the order of input sections than using, say, RunningDepth.
BreadthFirstCallTree
This is similar to the CallTree algorithm except that it uses a breadth-first traversal when flattening the Call Tree into a list.
CallTree
The linker flattens the call tree into a list containing the read-only code sections from all execution regions that have CallTree sorting enabled.
Sections in this list are copied back into their execution regions, followed by all the non read-only code sections, sorted lexically. Doing this ensures that sections calling each other are placed close together.

Note

This sorting algorithm is less dependent on the order of input sections than using either RunningDepth or AvgCallDepth.
Lexical
Sorts according to the name of the section and then by input order if the names are the same.
LexicalAlignment
Sorts input sections lexically, then according to the name of the section, and then by input order if the names are the same.
LexicalState
Sorts Thumb code before ARM code, then sorts lexically.
List
Provides a list of the available sorting algorithms. The linker terminates after displaying the list.
ObjectCode
Sorts code sections by tiebreaker. All other sections are sorted lexically. This is most useful when used with --tiebreaker=cmdline because it attempts to group all the sections from the same object together in the memory map.
RunningDepth
Sorts all Thumb code before ARM code and then sorts according to the running depth of the section in ascending order. The running depth of a section S is the average call depth of all the sections that call S, weighted by the number of times that they call S.
Use this algorithm to minimize the number of long branch veneers.

Usage

The sorting algorithms conform to the standard rules, placing input sections in ascending order by attributes.
You can also specify sort algorithms in a scatter file for individual execution regions. Use the SORTTYPE keyword to do this.

Note

The SORTTYPE execution region attribute overrides any sorting algorithm that you specify with this option.

Default

The default algorithm is --sort=Lexical. In large region mode, the default algorithm is --sort=AvgCallDepth.
Related concepts
3.3 Section placement with the linker
8.4 Execution region descriptions
Related reference
8.4.3 Execution region attributes
9.63 --largeregions, --no_largeregions
9.123 --tiebreaker=option
Non-ConfidentialPDF file icon PDF versionARM DUI0377G
Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights reserved.