x86 Assembly Language Reference Manual

Section Header

The section header table has all of the information necessary to locate and isolate each of the file's sections. A section header entry in a section header table contains information characterizing the contents of the corresponding section, if the file has such a section.

Each entry in the section header table is a section header. A section header is a structure of fixed size and format, consisting of the following fields, or members:

sh_name

Specifies the section name. The value of this field is an index into the section header string table section, wherein it indicates the beginning of a null-terminated string that names the section.

sh_type

Categorizes the section's contents and semantics. Table 3-3 describes the section types.

sh_flags

One-bit descriptions of section attributes. Table 3-2 describes the section attribute flags.

sh_addr

Address where the first byte resides if the section appears in the memory image of a process; a value of 0 indicates the section does not appear in the memory image of a process.

sh_offset

Specifies the byte offset from the beginning of the file to the first byte in the section.


Note -

If the section type is SHT_NOBITS, the corresponding section occupies no space in the file. In this case, sh_offset specifies the location at which the section would have begun if it did occupy space within the file.


sh_size

Specifies the size, in byte units, of the section.


Note -

Even if the section type is SHT_NOBITS, sh_size can be nonzero; however, the corresponding section still occupies no space in the file.


sh_link

Section header table index link. The interpretation of this information depends on the section type, as described in Table 3-3.

sh_info

Extra information. The interpretation of this information depends on the section type, as described in Table 3-3.

sh_addralign

If a section has an address alignment constraint, the value in this field is the modulus, in byte units, by which the value of sh_addr must be congruent to 0; i.e., sh_addr = 0 (mod sh_addralign). For example, if a section contains a long (32 bits), the entire section must be ensured long alignment, so sh_addralign has the value 4. Only 0 and positive integral powers of 2 are currently allowed as values for this field. A value of 0 or 1 indicates no address alignment constraints.

sh_entsize

Size, in byte units, for entries in a section that is a table of fixed-size entries, such as a symbol table. Has the value 0 if the section is not a table of fixed-size entries

Table 3-2 Section Attribute Flags

Flag 

Default Value 

Description 

SHF_WRITE

0x1 

Contains data that is writable during process execution. 

SHF_ALLOC

0x2 

Occupies memory during process execution. This attribute is off if a control section does not reside in the memory image of the object file.

SHF_EXECINSTR

0x4 

Contains executable machine instructions. 

SHF_MASKPROC

0xf0000000 

Reserved for processor-specific semantics. 

Table 3-3 Section Types

Name 

Value 

Description 

Interpretation by 

sh_info 

sh_link 

SHT_NULL

Marks section header as inactive; file has no corresponding section. 

SHN_UNDEF

SHT_PROGBITS

Contains information defined by the program, and in a format and with a meaning determined solely by the program. 

SHN_UNDEF

SHT_SYMTAB

Is a complete symbol table, usually for link editing. This table can also be used for dynamic linking; however, it can contain many unnecessary symbols. 

Note: Only one section of this type is allowed in a file 

One greater than the symbol table index of the last local symbol. 

The section header index of the associated string table. 

SHT_STRTAB

Is a string table. A file can have multiple string table sections. 

SHN_UNDEF

SHT_RELA

Contains relocation entries with explicit addends. A file can have multiple relocation sections. 

The section header index of the section to where the relocation applies. 

The section header index of the associated symbol table. 

SHT_HASH

Is a symbol rehash table. 

Note: Only one section of this type is allowed in a file 

The section header index of the symbol table to which the hash table applies. 

SHT_DYNAMIC

Contains dynamic linking information. 

Note: Only one section of this type is allowed in a file 

The section header index of the string table used by entries in the section. 

SHT_NOTE

Contains information that marks the file. 

SHN_UNDEF

SHT_NOBITS

Contains information defined by the program, and in a format and with a meaning determined by the program. However, a section of this type occupies no space in the file, but the section header's offset field specifies the location at which the section would have begun if it did occupy space within the file.

SHN_UNDEF

SHT_REL

Contains relocation entries without explicit addends. A file can have multiple relocation sections. 

The section header index of the section to where the relocation applies. 

The section header index of the associated symbol table. 

SHT_SHLIB

10 

Reserved. 

SHN_UNDEF

SHT_DYNSYM

11 

Is a symbol table with a minimal set of symbols for dynamic linking.  

Note: Only one section of this type is allowed in a file 

One greater than the symbol table index of the last local symbol. 

The section header index of the associated string table. 

SHT_LOPROC

SHT_HIPROC

0x70000000 

0x7fffffff 

Lower and upper bounds of range of section types reserved for processor-specific semantics. 

SHN_UNDEF 

 

SHT_LOUSER

SHT_HIUSER

0x80000000 

0xffffffff 

Lower and upper bounds of range of section types reserved for application programs. 

Note: Section types in this range can be used by an application without conflicting with system-defined section types. 

SHN_UNDEF


Note -

Some section header table indices are reserved, and the object file does not contain sections for these special indices.