Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
7.  Object File Format File Format Symbol Table  Previous   Contents   Next 
   
 
SHN_ABS

This symbol has an absolute value that will not change because of relocation.

SHN_COMMON

This symbol labels a common block that has not yet been allocated. The symbol's value gives alignment constraints, similar to a section's sh_addralign member. The link-editor will allocate the storage for the symbol at an address that is a multiple of st_value. The symbol's size tells how many bytes are required.

SHN_UNDEF

This section table index means the symbol is undefined. When the link-editor combines this object file with another that defines the indicated symbol, this file's references to the symbol will be bound to the actual definition.

As mentioned above, the symbol table entry for index 0 (STN_UNDEF) is reserved. This entry holds the values listed in the following table.

Table 7-22 ELF Symbol Table Entry: Index 0

Name

Value

Note

st_name

0

No name

st_value

0

Zero value

st_size

0

No size

st_info

0

No type, local binding

st_other

0

 

st_shndx

SHN_UNDEF

No section

Symbol Values

Symbol table entries for different object file types have slightly different interpretations for the st_value member.

  • In relocatable files, st_value holds alignment constraints for a symbol whose section index is SHN_COMMON.

  • In relocatable files, st_value holds a section offset for a defined symbol. st_value is an offset from the beginning of the section that st_shndx identifies.

  • In executable and shared object files, st_value holds a virtual address. To make these files' symbols more useful for the runtime linker, the section offset (file interpretation) gives way to a virtual address (memory interpretation) for which the section number is irrelevant.

Although the symbol table values have similar meanings for different object files, the data allow efficient access by the appropriate programs.

Register Symbols

The SPARC architecture supports register symbols, which are symbols that initialize a global register. A symbol table entry for a register symbol contains the entries listed in the following table.

Table 7-23 SPARC: ELF Symbol Table Entry: Register Symbol

Field

Meaning

st_name

Index into string table of the name of the symbol, or 0 for a scratch register.

st_value

Register number. See the ABI manual for integer register assignments.

st_size

Unused (0).

st_info

Bind is typically STB_GLOBAL, type must be STT_SPARC_REGISTER.

st_other

Unused (0).

st_shndx

SHN_ABS if this object initializes this register symbol; SHN_UNDEF otherwise.

The register values defined for SPARC are listed in the following table.

Table 7-24 SPARC: ELF Register Numbers

Name

Value

Meaning

STO_SPARC_REGISTER_G2

0x2

%g2

STO_SPARC_REGISTER_G3

0x3

%g3

Absence of an entry for a particular global register means that the particular global register is not used at all by the object.

Syminfo Table

The syminfo section contains multiple entries of the type Elf32_Syminfo or Elf64_Syminfo. There is one entry in the .SUNW_syminfo section for every entry in the associated symbol table (sh_link).

If this section is present in an object, additional symbol information is to be found by taking the symbol index from the associated symbol table and using that to find the corresponding Elf32_Syminfo or Elf64_Syminfo entry in this section. The associated symbol table and the Syminfo table will always have the same number of entries.

Index 0 is used to store the current version of the Syminfo table, which will be SYMINFO_CURRENT. Since symbol table entry 0 is always reserved for the UNDEF symbol table entry, this does not pose any conflicts.

An Symfino entry has the following format, defined in sys/link.h:

typedef struct {
        Elf32_Half      si_boundto;
        Elf32_Half      si_flags;
} Elf32_Syminfo;

typedef struct {
        Elf64_Half      si_boundto;
        Elf64_Half      si_flags;
} Elf64_Syminfo;

The elements of this structure are:

si_boundto

This index is to an entry in the .dynamic section, identified by the sh_info field, that augments the Syminfo flags. For example, a DT_NEEDED entry will identify a dynamic object associated with the Syminfo entry. The entries that follow are reserved values for si_boundto.

Table 7-25 ELF si_boundto Reserved Values

Name

Value

Meaning

SYMINFO_BT_SELF

0xffff

Symbol bound to self.

SYMINFO_BT_PARENT

0xfffe

Symbol bound to parent. The parent is the first object to cause this dynamic object to be loaded.

si_flags

This bit-field can have flags set, as shown in the following table.

Table 7-26 ELF Syminfo Flags

Name

Value

Meaning

SYMINFO_FLG_DIRECT

0x01

Has a direct reference to an external object.

SYMINFO_FLG_COPY

0x04

Is the result of a copy-relocation.

SYMINFO_FLG_LAZYLOAD

0x08

Has a reference to an external, lazy loadable object.

Relocation

Relocation is the process of connecting symbolic references with symbolic definitions. For example, when a program calls a function, the associated call instruction must transfer control to the proper destination address at execution. Relocatable files must have information that describes how to modify their section contents, thus allowing executable and shared object files to hold the right information for a process's program image. Relocation entries are these data.

Relocation entries can have the following structure, defined in sys/elf.h:

typedef struct {
        Elf32_Addr      r_offset;
        Elf32_Word      r_info;
} Elf32_Rel;
 
typedef struct {
        Elf32_Addr      r_offset;
        Elf32_Word      r_info;
        Elf32_Sword     r_addend;
} Elf32_Rela;

typedef struct {
        Elf64_Addr      r_offset;
        Elf64_Xword     r_info;
} Elf64_Rel;
 
typedef struct {
        Elf64_Addr      r_offset;
        Elf64_Xword     r_info;
        Elf64_Sxword    r_addend;
} Elf64_Rela;

The elements of this structure are:

 
 
 
  Previous   Contents   Next