User`s guide
ELF Linker and Command Language
Linker Command File Syntax
292
Targeting MC56F83xx/DSP5685x Controllers
Deadstrip Prevention
The M56800E linker removes unused code and data from the output file. This process
is called deadstripping. To prevent the linker from deadstripping unreferenced code
and data, use the FORCE_ACTIVE
, KEEP_SECTION, and REF_INCLUDE
directives to preserve them in the output file.
Variables, Expressions, and Integral Types
This section explains variables, expressions, and integral types.
Variables and Symbols
All symbol names within a Linker Command File (LCF) start with the underscore
character (_), followed by letters, digits, or underscore characters. Listing 10.9
shows
examples of valid lines for a command file:
Listing 10.9 Valid Command File Lines
_dec_num = 99999999;
_hex_num_ = 0x9011276;
Variables that are defined within a SECTIONS section can only be used within a
SECTIONS section in a linker command file.
Global Variables
Global variables are accessed in a linker command file with an âFâ prepended to the
symbol name. This is because the compiler adds an âFâ prefix to externally defined
symbols.
Listing 10.10
shows an example of using a global variable in a linker command file.
This example sets the global variable _foot, declared in C with the extern
keyword, to the location of the address location current counter.
Listing 10.10 Using a Global Variable in the LCF
F_foot = .;
If you use a global symbol in an LCF, as in Listing 10.10, you can access it from C
program sources as shown in Listing 10.11
.