The symbol table of an ELF object file holds information to locate and relocate a program's symbolic definitions and references. A symbol table index is a subscript into this array. Index 0 both designates the first entry in the table and serves as the undefined symbol index. The contents of the initial entry are specified below. A symbol table entry has the following format:
typedef struct { |
| |
|
Elf32_Word |
st_name; |
|
Elf32_Addr |
st_value; |
|
Elf32_Word |
st_size; |
|
unsigned char |
st_info; |
|
unsigned char |
st_other; |
|
Elf32_Half |
st_shndx; |
} Elf32_Sym; |
|
st_name Holds an index into the object file's symbol string table, which holds the character representations of the symbol names. If the value is non-zero, it represents a string table index that gives the symbol name. Otherwise, the symbol table entry has no name.
st_value Gives the value of the associated symbol. Depending on the context, this may be an absolute value, an address, etc.
st_size Many symbols have associated sizes. For example, a data object's size is the number of bytes contained in the object. This holds 0 if the symbol has no size or an unknown size.
st_info Specifies the symbol's binding attributes and type, explained in the symbol binding and symbol type sections below. The values and meanings are defined below:
st_other Currently holds 0 and has no defined meaning.
st_shndx Every symbol table entry is "defined" in relation to some section; this holds the relevant section header table index. Some section indexes indicate special meanings. See "Special Section Indexes" for more information.
A symbol's binding determines the linkage visibility and behavior.
Name |
Value |
STB_LOCAL |
0 |
STB_GLOBAL |
1 |
STB_WEAK |
2 |
STB_LOPROC |
13 |
STB_HIPROC |
15 |
Local symbols are not visible outside the object file containing their definition. Local symbols of the same name may exist in multiple files without interfering with each other.
Global symbols are visible to all object files being combined. One file's definition of a global symbol will satisfy another file's undefined reference to the same global symbol.
Weak symbols resemble global symbols, but their definitions have lower precedence.
Values in this inclusive range are reserved for processor-specific semantics. If meanings are specified, the processor supplement explains them.
A symbol's type provides a general classification for the associated entity:
Name |
Value |
STT_NOTYPE |
0 |
STT_OBJECT |
1 |
STT_FUNC |
2 |
STT_SECTION |
3 |
STT_FILE |
4 |
STT_LOPROC |
13 |
STT_HIPROC |
15 |
This symbol's type is not specified.
The symbol is associated with a data object, such as a variable, and array, and so on.
The symbol is associated with a function or other executable.
The symbol is associated with a section. Symbol table entries of this type exist primarily for relocation and normally have STB_LOCAL binding.
Conventionally, this symbol names the source file associated with the object file. A file system has STB_LOCAL binding, its section index is SHN_ABS, and it precedes the other STB_LOCAL symbols for the file, if it is present.
Values in this inclusive range are reserved for processor-specific semantics. If meanings are specified, the processor supplement explains them.
Symbol table entries for different object file types have slightly different interpretations for the st_value member:
Although the symbol table values have similar meanings for different object files, the information allows efficient access by the appropriate programs.