3.3 Locations
A location is a specific position within a section. Each location is identified by a section and a byte offset from the beginning of the section. The current location is the location within the current section where code is generated.
A location counter tracks the current offset within each section where code or data is being generated. When a section control directive (for example, the .section pseudo-op) is processed, the location information from the location counter associated with the new section is assigned to and stored with the name and value of the current location.
The current location is updated at the end of processing each statement, but can be updated during processing of data-generating assembler directives (for example, the .word pseudo-op).
Note - Each section has one location counter; if more than one section is present, only one location can be current at any time.
3.4 Addresses
Locations represent addresses in memory if a section is allocatable; that is, its contents are to be placed in memory at program runtime. Symbolic references to these locations must be changed to addresses by the SPARC link editor.
3.5 Relocation Tables
The assembler produces a companion relocation table for each relocatable section. The table contains a list of relocations (that is, adjustments to data in the section) to be performed by the link editor.
3.6 Symbol Tables
A symbol table contains information to locate and relocate symbolic definitions and references. The SPARC assembler creates a symbol table section for the object file. It makes an entry in the symbol table for each symbol that is defined or referenced in the input file and is needed during linking. The symbol table is then used by the SPARC link editor during relocation. The section header contains the symbol table index for the first non-local symbol.
A symbol table contains the following information:
name
Index into the object file symbol string table. A value of zero indicates the symbol table entry has no name; otherwise, the value represents the string table index that gives the symbol name.
value
Value of the associated symbol. This value is dependent on the context; for example, it may be an address, or it may be an absolute value.
size
Size of symbol. A value of 0 indicates that the symbol has either no size or an unknown size.
info
Specifies the symbol type and binding attributes. Table 3-6 and Table 3-7 describe these values.
other
Undefined meaning. Current value is 0.
shndx
Contains the section header table index to another relevant section, if specified. As a section moves during relocation, references to the symbol will continue to point to the same location because the value of the symbol will change as well.
Table 3-6
Value | Type | Description |
---|---|---|
0 | notype | Type not specified. |
1 | object | Symbol is associated with a data object; for example, a variable or an array. |
2 | func | Symbol is associated with a function or other executable code. When another object file references a function from a shared object, the link editor automatically creates a procedure linkage table entry for the referenced symbol. |
3 | section | Symbol is associated with a section. These types of symbols are primarily used for relocation. |
4 | file | Gives the name of the source file associated with the object file. |
13 15 | loproc hiproc | Values reserved for processor-specific semantics. |
Table 3-7 shows the symbol binding attributes.
Table 3-7
Value | Binding | Description |
---|---|---|
0 | local | Symbol is defined in the object file and not accessible in other files. Local symbols of the same name may exist in multiple files. |
1 | global | Symbol is either defined externally or defined in the object file and accessible in other files. |
2 | weak | Symbol is either defined externally or defined in the object file and accessible in other files; however, these definitions have a lower precedence than globally defined symbols. |
13 15 | loproc hiproc | Values reserved for processor-specific semantics. |
3.7 String Tables
A string table is a section which contains null-terminated variable-length character sequences, or strings, in the object file; for example, symbol names and file names. The strings are referenced in the section header as indexes into the string table section.
A string table index may refer to any byte in the section.
Empty string table sections are permitted; however, the index referencing this section must contain zero.
A string may appear multiple times and may also be referenced multiple times. References to substrings may exist, and unreferenced strings are allowed.
3.8 Assembler Directives
Assembler directives, or pseudo-operations (pseudo-ops), are commands to the assembler that may or may not result in the generation of code. The different types of assembler directives are:
Section Control Directives
Symbol Attribute Directives
Assignment Directives
Data Generating Directives
Optimizer Directives
See Appendix A, Pseudo-Operations for a complete description of the pseudo-ops supported by the SPARC assembler.
3.8.1 Section Control Directives
When a section is created, a section header is generated and entered in the ELF object file section header table. The section control pseudo-ops allow you to make entries in this table. Sections that can be manipulated with the section control directives are known as user sections. You can also use the section control directives to change the user section in which code or data is generated.
Note - The symbol table, relocation table, and string table sections are created implicitly. The section control pseudo-ops cannot be used to manipulate these sections.
The section control directives also create a section symbol which is associated with the location at the beginning of each created section. The section symbol has an offset value of zero.
3.8.2 Symbol Attribute Directives
The symbol attribute pseudo-ops declare the symbol type and size and whether it is local or global.
3.8.3 Assignment Directive
The assignment directive associates the value and type of expression with the symbol and creates a symbol table entry for the symbol. This directive constitutes a definition of the symbol and, therefore, must be the only definition of the symbol.
3.8.4 Data Generating Directives
The data generating directives are used for allocating storage and loading values.