SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
The syntax of assignment statements in the linker is similar to that of assignment 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 Section 8.5.10.3. 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. The cur_tab symbol 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.c.obj /* Input file */
cur_tab = Table1; /* Assign cur_tab to one of the tables */