Next: , Previous: , Up: Top   [Contents][Index]


10 ELF Symbols

ELF symbols are implemented by the Elf32_Sym and Elf64_Sym struct types.

10.1 Overview

type Elf32_Sym =
  struct
  {
    offset<Elf_Word,B> st_name;
    Elf32_Addr st_value;
    offset<Elf_Word,B> st_size;
    Elf_Sym_Info st_info;
    Elf_Sym_Other_Info st_other;
    Elf_Half st_shndx;
  };
type Elf64_Sym =
  struct
  {
    offset<Elf_Word,B> st_name;
    Elf_Sym_Info st_info;
    Elf_Sym_Other_Info st_other;
    Elf_Half st_shndx;
    Elf64_Addr st_value;
    Elf64_Xword st_size;
  };

10.2 Fields

st_name

Index into the file symbol string table. If this entry is zero it means the symbol has no name.

st_info

The type and the binding attributes of the symbol.

type Elf_Sym_Info =
  struct uint<8>
  {
    uint<4> st_bind;
    uint<4> st_type;
  };

Where:

st_bind

Specifies how the symbol binds. This must be one of ELF_STB_LOCAL, ELF_STB_GLOBAL or ELF_STB_WEAK.

st_type

Specifies the type of the symbol. This must be one of the ELF_STT_* values.

The following symbol types are defined by the core specification:

ELF_STT_NOTYPE

The symbol’s type is not specified.

ELF_STT_OBJECT

The symbol is associated with a data object, such as a variable, an array and so on.

ELF_STT_FUNC

The symbol is associated with a function or other executable code.

ELF_STT_SECTION

The symbol is associated with a section. This is primarily used for relocations.

ELF_STT_FILE

By convention, this symbol’s name gives the name of the source file associated with the object file.

A file symbol has local binding, its section index is ELF_SHN_ABS and it precedes the other local symbols for the file. This is currently not checked by the pickles.

ELF_STT_COMMON

The symbol labels an uninitialized common block.

ELF_STT_TLS

The symbol specifies a Thread-Local Storage entity, in the form of an offset.

st_other

This field specifies the symbol’s visibility. This is one of the ELF_STV_* values.

The list of symbol visibility defined by the core spec are:

ELF_STV_DEFAULT

The visibility of this symbol is defined by its binding. Global and weak symbols are visible outside of heir defining component. Local symbols are hidden.

ELF_STV_PROTECTED

This symbol is visible in other components but it is not preemptable.

A symbol with local binding may not have protected visibility. This is checked by a constraint in Elf_Sym_Info.

ELF_STV_HIDDEN

This symbol is not visible to other components.

ELF_STV_INTERNAL

The meaning of this attribute, if any, is processor specific.

Some machine types define other values that can be used in st_other. See ELF Machines.

st_shndx

Every symbol table entry is defined in relation to some section. This holds the index into the section header table of the section related to this symbol.

However, some values for this field indicate special meanings. These are the ELF_SHN_* values. The core specification defines the following:

ELF_SHN_UNDEF

The symbol is undefined.

ELF_SHN_ABS

The symbol is absolute, meaning its value will not change because of relocation.

ELF_SHN_COMMON

The symbol refers to a common block that has not yet been allocated.

ELF_SHN_XINDEX

The symbol refers to a specific location within a section, but the section header index for that section is too large to e represented directly in this entry. The actual section header index is found in the associated SHT_SYMTAB_SHNDX section.

Some machine types define additional values with special meanings for st_shndx. See ELF Machines.

st_value

Offset from the beginning of the section identified by st_shndx.

st_size

Size associated with the symbol. For example, the size of a data object. Symbols that have no associated size, or unknown size, have zero in this field.


Next: , Previous: , Up: Top   [Contents][Index]