9.5.6 Other Linker Script Commands
There are several other linker script commands, which are described below.
Assert Command
The ASSERT(exp, message)
command ensures that exp
is non-zero. If it is zero, then exit the linker with an error code, and print message
.
Entry Command
The ENTRY(symbol)
command specifies symbol
as the first instruction to execute in the program. The linker will record the address of this symbol in the output object file header. This does not affect the Reset instruction at address zero, which must be generated in some other way. By convention, the 32-bit linker scripts construct a GOTO _ _reset
instruction at address zero.
Extern Command
The EXTERN(symbol symbol ...)
command forces symbol
to be entered in the output file as an undefined symbol. Doing this may, for example, trigger linking of additional modules from standard libraries. Several symbols may be listed for each EXTERN
, and EXTERN
may appear multiple times. This command has the same effect as the -u
command line option.
Force_common_allocation Command
The FORCE_COMMON_ALLOCATION
command has the same effect as the -d
command line option: to make 32-bit linker assign space to common symbols even if a relocatable output file is specified (-r
).
Nocrossrefs Command
The NOCROSSREFS(section section ...)
command may be used to tell 32-bit linker to issue an error about any references among certain output sections. In certain types of programs, when one section is loaded into memory, another section will not be. Any direct references between the two sections would be errors.
The NOCROSSREFS
command takes a list of output section names. If the linker detects any cross references between the sections, it reports an error and returns a non-zero exit status. The NOCROSSREFS
command uses output section names, not input section names.
Output_arch Command
The OUTPUT_ARCH(bfdarch)
command specifies a particular output machine architecture. The bfdarch
value is pic32mx
for Microchip PIC32 MCUs, for example. Other values for ARm-based devices include armv5tej
, armv6s-m
, armv7
, armv7e-m
, armv8-m.base
and armv8-m.main
.
Output_format Command
The OUTPUT_FORMAT(format_name)
command names the object file format to use for the output file. The format_name
value is always elf32-tradlittlemips
for Microchip PIC32 MCUs.
Target Command
The TARGET(format_name)
command names the object file format to use when reading input files. It affects subsequent INPUT
and GROUP
commands. The format_name
value should remain elf32-tradlittlemips
for Microchip PIC32 MCUs.