ARM Compiler toolchain Using the Linker - ARM Information Center
ARM Compiler toolchain Using the Linker - ARM Information Center
ARM Compiler toolchain Using the Linker - ARM Information Center
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
4.11 Section placement with <strong>the</strong> linker<br />
Image structure and generation<br />
By default, <strong>the</strong> linker places input sections in <strong>the</strong> following order when generating an image:<br />
1. By attribute as follows:<br />
a. read-only code<br />
b. read-only data<br />
c. read-write code<br />
d. read-write data<br />
e. zero-initialized data.<br />
4.11.1 Handling unassigned sections<br />
2. By input section name if <strong>the</strong>y have <strong>the</strong> same attributes. Names are considered to be<br />
case-sensitive and are compared in alphabetical order using <strong>the</strong> ASCII collation sequence<br />
for characters.<br />
3. By <strong>the</strong>ir relative positions in <strong>the</strong> input file if <strong>the</strong>y have <strong>the</strong> same attributes and section<br />
names., except where overridden by FIRST or LAST.<br />
Portions of <strong>the</strong> image are collected toge<strong>the</strong>r into a minimum number of contiguous regions.<br />
Note<br />
The sorting order is unaffected by ordering within scatter files or object file names.<br />
These rules mean that <strong>the</strong> positions of input sections with identical attributes and names<br />
included from libraries is not predictable. If you require more precise positioning, specify <strong>the</strong><br />
individual modules explicitly in a scatter file, and include <strong>the</strong> modules in <strong>the</strong> input file list for<br />
<strong>the</strong> armlink command.<br />
The base address of each input section is determined by <strong>the</strong> sorting order defined by <strong>the</strong> linker,<br />
and is correctly aligned within <strong>the</strong> output section that contains it.<br />
By default, <strong>the</strong> linker creates an image consisting of an RO output section, an RW output<br />
section, and optionally a ZI output section. The RO output section can be protected at run-time<br />
on systems that have memory management hardware. RO sections can also be placed into ROM<br />
in <strong>the</strong> target.<br />
Alternative sorting orders are available with <strong>the</strong> --sort=algorithm command-line option. The<br />
linker might change <strong>the</strong> algorithm to minimise <strong>the</strong> amount of veneers generated if no algorithm<br />
is chosen.<br />
The linker might not be able to place some input sections in any execution region. When this<br />
happens, <strong>the</strong> linker generates an error message. This might occur because your current scatter<br />
file does not permit all possible module select patterns and input section selectors. How you fix<br />
this depends on <strong>the</strong> importance of placing <strong>the</strong>se sections correctly:<br />
• If <strong>the</strong> sections must be placed at specific locations, <strong>the</strong>n modify your scatter file to include<br />
specific module selectors and input section selectors as required.<br />
• If <strong>the</strong> placement of <strong>the</strong> unassigned sections is not important, you can use one or more ,ANY<br />
module selectors with optional input section selectors.<br />
When <strong>the</strong> linker creates an input section for each ELF section in <strong>the</strong> input objects, it increments<br />
a global counter. The value of this counter is stored in <strong>the</strong> section as <strong>the</strong> creation index. The<br />
creation index is used when placing any unassigned sections that have identical properties.<br />
<strong>ARM</strong> DUI 0474C Copyright © 2010-2011 <strong>ARM</strong>. All rights reserved. 4-19<br />
ID080411 Non-Confidential