Contents|Index|Previous|Next
Specifying Output Sections
The SECTIONS command controls exactly where input sections are placed into output
sections, their order in the output file, and to which output sections they are
allocated.
You may use at most one
SECTIONS command in a script file, but you can have as many statements within it as
you wish. Statements within the SECTIONS command can do one of the following three things:
define the entry point;
assign a value to a symbol;
describe the placement of a named output section, and which input sections go
into it.
You can also use the first two operations—defining the entry point and
defining symbols—outside the
SECTIONS command: see The Entry Point and Assignment: Defining Symbols. They are permitted here as well for your convenience in reading the script,
so that symbols and the entry point can be defined at meaningful points in your
output-file layout.
If you do not use a
SECTIONS command, the linker places each input section into an identically named
output section in the order that the sections are first encountered in the input
files. If all input sections are present in the first file, for example, the order
of sections in the output file will match the order in the first input file.