Chapter 33. Linker Command Language

Table of Contents
33.1. Linker Scripts
33.2. Expressions
33.3. Memory Layout
33.4. Specifying Output Sections
33.5. The Entry Point
33.6. Version Script
33.7. Option Commands

The command language provides explicit control over the link process, allowing complete specification of the mapping between the linker's input files and its output. It controls:

You may supply a command file (also known as a linker script) to the linker either explicitly through the “-T” option, or implicitly as an ordinary file. Normally you should use the “-T” option. An implicit linker script should only be used when you want to augment, rather than replace, the default linker script; typically an implicit linker script would consist only of INPUT or GROUP commands.

If the linker opens a file that it cannot recognize as a supported object or archive format, nor as a linker script, it reports an error.

33.1. Linker Scripts

The linker command language is a collection of statements; some are simple keywords setting a particular option, some are used to select and group input files or name output files; and two statement types have a fundamental and pervasive impact on the linking process.

The most fundamental command of the linker command language is the SECTIONS command (see Section 33.4.). Every meaningful command script must have a SECTIONS command: it specifies a "picture" of the output file's layout, in varying degrees of detail. No other command is required in all cases.

The MEMORY command complements SECTIONS by describing the available memory in the target architecture. This command is optional; if you don't use a MEMORY command, the linker assumes sufficient memory is available in a contiguous block for all output. See Section 33.3.

You may include comments in linker scripts just as in C: delimited by “/*” and “*/”. As in C, comments are syntactically equivalent to white-space.