Whole document tree
3.2.6 Assignment: Defining SymbolsYou may create global symbols, and assign values (addresses) to global symbols, using any of the C assignment operators:
Two things distinguish assignment from other operators in
Assignment statements may appear:
The first two cases are equivalent in effect--both define a symbol with an absolute address. The last case defines a symbol whose address is relative to a particular section (see section 3.4 Specifying Output Sections). When a linker expression is evaluated and assigned to a variable, it is given either an absolute or a relocatable type. An absolute expression type is one in which the symbol contains the value that it will have in the output file; a relocatable expression type is one in which the value is expressed as a fixed offset from the base of a section.
The type of the expression is controlled by its position in the script
file. A symbol assigned within a section definition is created relative
to the base of the section; a symbol assigned in any other place is
created as an absolute symbol. Since a symbol created within a
section definition is relative to the base of the section, it
will remain relocatable if relocatable output is requested. A symbol
may be created with an absolute value even when assigned to within a
section definition by using the absolute assignment function
The linker tries to put off the evaluation of an assignment until all the terms in the source expression are known (see section 3.2.5 Evaluation). For instance, the sizes of sections cannot be known until after allocation, so assignments dependent upon these are not performed until after allocation. Some expressions, such as those depending upon the location counter dot, `.' must be evaluated during allocation. If the result of an expression is required, but the value is not available, then an error results. For example, a script like the following
Non constant expression for initial
address ".
In some cases, it is desirable for a linker script to define a symbol
only if it is referenced, and only if it is not defined by any object
included in the link. For example, traditional linkers defined the
symbol `etext'. However, ANSI C requires that the user be able to
use `etext' as a function name without encountering an error.
The
This document was generated by root on January, 30 2002 using texi2html |