4.14.3.1 Linker Script Symbols
Several symbol are used by the compiler's linker scripts to locate the start and maximum end
addresses of the memory regions in which sections are placed. While it is possible to
redefine these symbols using the
-Wl,--defsym,symbol=address
option, there are typically compiler options that can be more easily used to achieve the
desired goal.
The __TEXT_REGION_LENGTH__
and __DATA_REGION_LENGTH__
symbols, for example, define the maximum length (size) of the regions used to hold
program code and RAM-based objects, respectively. Rather than adjust these directly,
consider using the -mreserve
option (3.6.1.12 Reserve Option), which can be used
to remove memory ranges from consideration when linking. For example, to reduce the
available program memory on a device with 8KB of program memory to only the lower 6 KB,
use the option -mreserve=rom@0x1800:0x2000
.
The __TEXT_REGION_ORIGIN__
and __DATA_REGION_ORIGIN__
symbols define the starting address of the regions used to hold program code and
RAM-based objects, respectively. Rather than adjust these directly, consider using the
-Wl,-Ttext
and -Wl,-Tdata
options, respectively
(4.14.2 Changing and Linking the Allocated Section). For
example, to have all code start at address 0x100, use the option
-Wl,-Ttext=0x100
.