Assigning Symbols at Link Time
7-57
Linker Description
7.14 Assigning Symbols at Link Time
Linker assignment statements allow you to define external (global) symbols
and assign values to them at link time. You can use this feature to initialize a
variable or pointer to an allocation-dependent value.
7.14.1 Syntax of Assignment Statements
The syntax of assignment statements in the linker is similar to that of assign-
ment statements in the C language:
symbol
=
expression; assigns the value of expression to symbol
symbol
+ =
expression; adds the value of expression to symbol
symbol
– =
expression; subtracts the value of expression from symbol
symbol
* =
expression; multiplies symbol by expression
symbol
/ =
expression; divides symbol by expression
The symbol should be defined externally. If it is not, the linker defines a new
symbol and enters it into the symbol table. The expression must follow the
rules defined in subsection 7.14.3,
Assignment Expressions. Assignment
statements
must terminate with a semicolon.
The linker processes assignment statements
after it allocates all the output
sections. Therefore, if an expression contains a symbol, the address used for
that symbol reflects the symbol’s address in the executable output file.
For example, suppose a program reads data from one of two tables identified
by two external symbols, Table1 and Table2. The program uses the symbol
cur_tab as the address of the current table. cur_tab must point to either Table1
or Table2. You could accomplish this in the assembly code, but you would need
to reassemble the program to change tables. Instead, you can use a linker
assignment statement to assign cur_tab at link time:
prog.obj /* Input file */
cur_tab = Table1; /* Assign cur_tab to one of the tables */
Summary of Contents for TMS320C54x
Page 38: ......
Page 39: ......
Page 40: ......
Page 41: ......
Page 42: ......
Page 43: ......
Page 44: ......
Page 45: ......
Page 46: ......
Page 47: ......
Page 48: ......
Page 49: ......
Page 50: ......
Page 51: ......
Page 52: ......
Page 53: ......
Page 54: ......
Page 55: ......
Page 56: ......
Page 57: ......
Page 58: ......
Page 59: ......
Page 60: ......
Page 61: ......
Page 62: ......
Page 276: ......
Page 277: ......
Page 278: ......
Page 279: ......
Page 280: ......
Page 281: ......
Page 282: ......
Page 283: ......
Page 284: ......
Page 285: ......
Page 286: ......
Page 287: ......
Page 288: ......
Page 289: ......
Page 290: ......
Page 291: ......
Page 292: ......
Page 293: ......
Page 294: ......
Page 295: ......
Page 296: ......
Page 297: ......
Page 298: ......
Page 299: ......
Page 300: ......
Page 301: ......
Page 302: ......