Go to main content

Oracle® Solaris 11.4 Linkers and Libraries Guide

Exit Print View

Updated: March 2019
 
 

Section Headers

An object file's section header table allows you to locate all of the sections of the file. The section header table is an array of Elf32_Shdr or Elf64_Shdr structures. A section header table index is a subscript into this array. The ELF header's e_shoff member indicates the byte offset from the beginning of the file to the section header table. The e_shnum member indicates how many entries that the section header table contains. The e_shentsize member indicates the size in bytes of each entry.

If the number of sections is greater than or equal to SHN_LORESERVE (0xff00), e_shnum has the value SHN_UNDEF (0). The actual number of section header table entries is contained in the sh_size field of the section header at index 0. Otherwise, the sh_size member of the initial entry contains the value zero. See Extended Section Header.

Some section header table indexes are reserved in contexts where index size is restricted. For example, the st_shndx member of a symbol table entry and the e_shnum and e_shstrndx members of the ELF header. In such contexts, the reserved values do not represent actual sections in the object file. Also in such contexts, an escape value indicates that the actual section index is to be found elsewhere, in a larger field.

Table 15  ELF Special Section Indexes
Name
Value
SHN_UNDEF
0
SHN_LORESERVE
0xff00
SHN_LOPROC
0xff00
SHN_BEFORE
0xff00
SHN_AFTER
0xff01
SHN_AMD64_LCOMMON
0xff02
SHN_HIPROC
0xff1f
SHN_LOOS
0xff20
SHN_LOSUNW
0xff3f
SHN_SUNW_IGNORE
0xff3f
SHN_HISUNW
0xff3f
SHN_HIOS
0xff3f
SHN_ABS
0xfff1
SHN_COMMON
0xfff2
SHN_XINDEX
0xffff
SHN_HIRESERVE
0xffff

Note -  Although index 0 is reserved as the undefined value, the section header table contains an entry for index 0. That is, if the e_shnum member of the ELF header indicates a file has 6 entries in the section header table, the sections have the indexes 0 through 5. The contents of the initial entry are specified later in this section.
SHN_UNDEF

An undefined, missing, irrelevant, or otherwise meaningless section reference. For example, a symbol defined relative to section number SHN_UNDEF is an undefined symbol.

SHN_LORESERVE

The lower boundary of the range of reserved indexes.

SHN_LOPROC - SHN_HIPROC

Values in this inclusive range are reserved for processor-specific semantics.

SHN_LOOS - SHN_HIOS

Values in this inclusive range are reserved for operating system-specific semantics.

SHN_LOSUNW - SHN_HISUNW

Values in this inclusive range are reserved for Sun-specific semantics.

SHN_SUNW_IGNORE

This section index provides a temporary symbol definition within relocatable objects. Reserved for internal use by dtrace(8).

SHN_BEFORE, SHN_AFTER

Provide for initial and final section ordering in conjunction with SHF_LINK_ORDER section flags. See Figure 18, Table 18, ELF Section Attribute Flags. SHN_BEFORE and SHN_AFTER are incompatible with objects that use extended section indexes. They are considered deprecated, and their use is discouraged. See Extended Section Header.

SHN_AMD64_LCOMMON

x64 specific common block label. This label is similar to SHN_COMMON, but provides for identifying a large common block.

SHN_ABS

Absolute values for the corresponding reference. For example, symbols defined relative to section number SHN_ABS have absolute values and are not affected by relocation.

SHN_COMMON

Symbols defined relative to this section are common symbols, such as FORTRAN COMMON or unallocated C external variables. These symbols are sometimes referred to as tentative.

SHN_XINDEX

An escape value indicating that the actual section header index is too large to fit in the containing field. The header section index is found in another location specific to the structure where the section index appears. See Extended Section Header.

SHN_HIRESERVE

The upper boundary of the range of reserved indexes. The system reserves indexes between SHN_LORESERVE and SHN_HIRESERVE, inclusive. The values do not reference the section header table. The section header table does not contain entries for the reserved indexes.

Sections contain all information in an object file except the ELF header, the program header table, and the section header table. Moreover, the sections in object files satisfy several conditions.

  • Every section in an object file has exactly one section header describing the section. Section headers can exist that do not have a section.

  • Each section occupies one contiguous, possibly empty, sequence of bytes within a file.

  • Sections in a file cannot overlap. No byte in a file resides in more than one section.

  • An object file can have inactive space. The various headers and the sections might not cover every byte in an object file. The contents of the inactive data are unspecified.

A section header has the following structure. See sys/elf.h.

typedef struct {
        elf32_Word      sh_name;
        Elf32_Word      sh_type;
        Elf32_Word      sh_flags;
        Elf32_Addr      sh_addr;
        Elf32_Off       sh_offset;
        Elf32_Word      sh_size;
        Elf32_Word      sh_link;
        Elf32_Word      sh_info;
        Elf32_Word      sh_addralign;
        Elf32_Word      sh_entsize;
} Elf32_Shdr;

typedef struct {
        Elf64_Word      sh_name;
        Elf64_Word      sh_type;
        Elf64_Xword     sh_flags;
        Elf64_Addr      sh_addr;
        Elf64_Off       sh_offset;
        Elf64_Xword     sh_size;
        Elf64_Word      sh_link;
        Elf64_Word      sh_info;
        Elf64_Xword     sh_addralign;
        Elf64_Xword     sh_entsize;
} Elf64_Shdr;
sh_name

The name of the section. This members value is an index into the section header string table section giving the location of a null-terminated string. Section names and their descriptions are listed in Figure 23, Table 23, ELF Special Sections.

sh_type

Categorizes the section's contents and semantics. Section types and their descriptions are listed in Figure 16, Table 16, ELF Section Types, sh_type.

sh_flags

Sections support 1-bit flags that describe miscellaneous attributes. Flag definitions are listed in Figure 18, Table 18, ELF Section Attribute Flags.

sh_addr

If the section appears in the memory image of a process, this member gives the address at which the section's first byte should reside. Otherwise, the member contains the value zero.

sh_offset

The byte offset from the beginning of the file to the first byte in the section. For a SHT_NOBITS section, this member indicates the conceptual offset in the file, as the section occupies no space in the file.

sh_size

The section's size in bytes. Unless the section type is SHT_NOBITS, the section occupies sh_size bytes in the file. A section of type SHT_NOBITS can have a nonzero size, but the section occupies no space in the file.

sh_link

A section header table index link, whose interpretation depends on the section type. Figure 19, Table 19, ELF sh_link and sh_info Interpretation describes the values.

sh_info

Extra information, whose interpretation depends on the section type. Figure 19, Table 19, ELF sh_link and sh_info Interpretation describes the values. If the sh_flags field for this section header includes the attribute SHF_INFO_LINK, then this member represents a section header table index.

sh_addralign

Some sections have address alignment constraints. For example, if a section holds a double-word, the system must ensure double-word alignment for the entire section. In this case, the value of sh_addr must be congruent to 0, modulo the value of sh_addralign. Currently, only 0 and positive integral powers of two are allowed. Values 0 and 1 mean the section has no alignment constraints.

sh_entsize

Some sections hold a table of fixed-size entries, such as a symbol table. For such a section, this member gives the size in bytes of each entry. The member contains the value zero if the section does not hold a table of fixed-size entries.

A section header's sh_type member specifies the section's semantics, as shown in the following table.

Table 16  ELF Section Types, sh_type
Name
Value
SHT_NULL
0
SHT_PROGBITS
1
SHT_SYMTAB
2
SHT_STRTAB
3
SHT_RELA
4
SHT_HASH
5
SHT_DYNAMIC
6
SHT_NOTE
7
SHT_NOBITS
8
SHT_REL
9
SHT_SHLIB
10
SHT_DYNSYM
11
SHT_INIT_ARRAY
14
SHT_FINI_ARRAY
15
SHT_PREINIT_ARRAY
16
SHT_GROUP
17
SHT_SYMTAB_SHNDX
18
SHT_LOOS
0x60000000
SHT_LOSUNW
0x6fffffed
SHT_SUNW_phname
0x6fffffed
SHT_SUNW_ancillary
0x6fffffee
SHT_SUNW_capchain
0x6fffffef
SHT_SUNW_capinfo
0x6ffffff0
SHT_SUNW_symsort
0x6ffffff1
SHT_SUNW_tlssort
0x6ffffff2
SHT_SUNW_LDYNSYM
0x6ffffff3
SHT_SUNW_dof
0x6ffffff4
SHT_SUNW_cap
0x6ffffff5
SHT_SUNW_SIGNATURE
0x6ffffff6
SHT_SUNW_ANNOTATE
0x6ffffff7
SHT_SUNW_DEBUGSTR
0x6ffffff8
SHT_SUNW_DEBUG
0x6ffffff9
SHT_SUNW_move
0x6ffffffa
SHT_SUNW_COMDAT
0x6ffffffb
SHT_SUNW_syminfo
0x6ffffffc
SHT_SUNW_verdef
0x6ffffffd
SHT_SUNW_verneed
0x6ffffffe
SHT_SUNW_versym
0x6fffffff
SHT_HISUNW
0x6fffffff
SHT_HIOS
0x6fffffff
SHT_LOPROC
0x70000000
SHT_SPARC_GOTDATA
0x70000000
SHT_AMD64_UNWIND
0x70000001
SHT_HIPROC
0x7fffffff
SHT_LOUSER
0x80000000
SHT_HIUSER
0xffffffff
SHT_NULL

Identifies the section header as inactive. This section header does not have an associated section. Other members of the section header have undefined values.

SHT_PROGBITS

Identifies information defined by the program, whose format and meaning are determined solely by the program.

SHT_SYMTAB, SHT_DYNSYM, SHT_SUNW_LDYNSYM

Identifies a symbol table. Typically, a SHT_SYMTAB section provides symbols for link-editing. As a complete symbol table, the table can contain many symbols that are unnecessary for dynamic linking. Consequently, an object file can also contain a SHT_DYNSYM section, which holds a minimal set of dynamic linking symbols, to save space.

SHT_DYNSYM can also be augmented with a SHT_SUNW_LDYNSYM section. This additional section provides local function symbols to the runtime environment, but is not required for dynamic linking. This section allows debuggers to produce accurate stack traces in runtime contexts when the non-allocable SHT_SYMTAB is not available, or has been stripped from the file. This section also provides the runtime environment with additional symbolic information for use with dladdr(3C).

When both a SHT_SUNW_LDYNSYM section and a SHT_DYNSYM section exist, the link-editor places their data regions immediately adjacent to each other. The SHT_SUNW_LDYNSYM section precedes the SHT_DYNSYM section. This placement allows the two tables to be viewed as a single larger contiguous symbol table, containing a reduced set of symbols from SHT_SYMTAB.

See Symbol Table Section for details.

SHT_STRTAB, SHT_DYNSTR

Identifies a string table. An object file can have multiple string table sections. See String Table Section for details.

SHT_RELA

Identifies relocation entries with explicit addends, such as type Elf32_Rela for the 32-bit class of object files. An object file can have multiple relocation sections. See Relocation Sections for details.

SHT_HASH

Identifies a symbol hash table. A dynamically linked object file must contain a symbol hash table. Currently, an object file can have only one hash table, but this restriction might be relaxed in the future. See Hash Table Section for details.

SHT_DYNAMIC

Identifies information for dynamic linking. Currently, an object file can have only one dynamic section. See Dynamic Section for details.

SHT_NOTE

Identifies information that marks the file in some way. See Note Section for details.

SHT_NOBITS

Identifies a section that occupies no space in the file but otherwise resembles SHT_PROGBITS. Although this section contains no bytes, the sh_offset member contains the conceptual file offset.

SHT_REL

Identifies relocation entries without explicit addends, such as type Elf32_Rel for the 32-bit class of object files. An object file can have multiple relocation sections. See Relocation Sections for details.

SHT_SHLIB

Identifies a reserved section which has unspecified semantics. Programs that contain a section of this type do not conform to the ABI.

SHT_INIT_ARRAY

Identifies a section containing an array of pointers to initialization functions. Each pointer in the array is taken as a parameterless procedure with a void return. See Initialization and Termination Sections for details.

SHT_FINI_ARRAY

Identifies a section containing an array of pointers to termination functions. Each pointer in the array is taken as a parameterless procedure with a void return. See Initialization and Termination Sections for details.

SHT_PREINIT_ARRAY

Identifies a section containing an array of pointers to functions that are invoked before all other initialization functions. Each pointer in the array is taken as a parameterless procedure with a void return. See Initialization and Termination Sections for details.

SHT_GROUP

Identifies a section group. A section group identifies a set of related sections that must be treated as a unit by the link-editor. Sections of type SHT_GROUP can appear only in relocatable objects. See Group Section for details.

SHT_SYMTAB_SHNDX

Identifies a section containing extended section indexes, that are associated with a symbol table. If any section header indexes referenced by a symbol table, contain the escape value SHN_XINDEX (0xffff), an associated SHT_SYMTAB_SHNDX entry is required. See Extended Section Header.

SHT_LOOSSHT_HIOS

Values in this inclusive range are reserved for operating system-specific semantics.

SHT_LOSUNWSHT_HISUNW

Values in this inclusive range are reserved for Oracle Solaris OS semantics.

SHT_SUNW_phname

An array of string table indices, one per program header element, that associate program headers to names within the dynamic string table. See Program Header Name Section for details.

SHT_SUNW_ancillary

Indicates that the object is part of a group of ancillary objects. Contains information required to identify all the files that make up the group. See Ancillary Section for details.

SHT_SUNW_capchain

An array of indices that collect capability family members. The first element of the array is the chain version number. Following this element are a chain of 0 terminated capability symbol indices. Each 0 terminated group of indices represents a capabilities family. The first element of each family is the capabilities lead symbol. The following elements point to family members. See Capabilities Section for details.

SHT_SUNW_capinfo

An array of indices that associate symbol table entries to capabilities requirements, and their lead capabilities symbol. An object that defines symbol capabilities contains a SHT_SUNW_cap section. The SHT_SUNW_cap section header information points to the associated SHT_SUNW_capinfo section. The SHT_SUNW_capinfo section header information points to the associated symbol table section. See Capabilities Section for details.

SHT_SUNW_symsort

An array of indices into the dynamic symbol table that is formed by the adjacent SHT_SUNW_LDYNSYM section and SHT_DYNSYM section. These indices are relative to the start of the SHT_SUNW_LDYNSYM section. The indices reference those symbols that contain memory addresses. The indices are sorted such that the indices reference the symbols by increasing address.

SHT_SUNW_tlssort

An array of indices into the dynamic symbol table that is formed by the adjacent SHT_SUNW_LDYNSYM section and SHT_DYNSYM section. These indices are relative to the start of the SHT_SUNW_LDYNSYM section. The indices reference thread-local storage symbols. See Thread-Local Storage. The indices are sorted such that the indices reference the symbols by increasing offset.

SHT_SUNW_LDYNSYM

Dynamic symbol table for non-global symbols. See previous SHT_SYMTAB, SHT_DYNSYM, SHT_SUNW_LDYNSYM description.

SHT_SUNW_dof

Reserved for internal use by dtrace(8).

SHT_SUNW_cap

Specifies capability requirements. See Capabilities Section for details.

SHT_SUNW_SIGNATURE

Identifies module verification signature.

SHT_SUNW_ANNOTATE

The processing of an annotate section follows all of the default rules for processing a section. The only exception occurs if the annotate section is in non-allocatable memory. If the section header flag SHF_ALLOC is not set, the link-editor silently ignores any unsatisfied relocations against this section.

SHT_SUNW_DEBUGSTR, SHT_SUNW_DEBUG

Identifies debugging information. Sections of this type are stripped from the object using the link-editor's –z strip-class option, or after the link-edit using strip(1).

SHT_SUNW_move

Identifies data to handle partially initialized symbols. See Move Section for details.

SHT_SUNW_COMDAT

Identifies a section that allows multiple copies of the same data to be reduced to a single copy. See COMDAT Section for details.

SHT_SUNW_syminfo

Identifies additional symbol information. See Syminfo Table Section for details.

SHT_SUNW_verdef

Identifies fine-grained versions defined by this file. See Version Definition Section for details.

SHT_SUNW_verneed

Identifies fine-grained dependencies required by this file. See Version Dependency Section for details.

SHT_SUNW_versym

Identifies a table describing the relationship of symbols to the version definitions offered by the file. See Version Symbol Section for details.

SHT_LOPROC - SHT_HIPROC

Values in this inclusive range are reserved for processor-specific semantics.

SHT_SPARC_GOTDATA

Identifies SPARC specific data, referenced using GOT-relative addressing. That is, offsets relative to the address assigned to the symbol _GLOBAL_OFFSET_TABLE_. For 64-bit SPARC, data in this section must be bound at link-edit time to locations within {+-} 2^32 bytes of the GOT address.

SHT_AMD64_UNWIND

Identifies x64 specific data, containing unwind function table entries for stack unwinding.

SHT_LOUSER

Specifies the lower boundary of the range of indexes that are reserved for application programs.

SHT_HIUSER

Specifies the upper boundary of the range of indexes that are reserved for application programs. Section types between SHT_LOUSER and SHT_HIUSER can be used by the application without conflicting with current or future system-defined section types.

Other section-type values are reserved. As mentioned before, the section header for index 0 (SHN_UNDEF) exists, even though the index marks undefined section references. The following table shows the values.

Table 17  ELF Section Header Table Entry: Index 0
Name
Value
Note
sh_name
0
No name
sh_type
SHT_NULL
Inactive
sh_flags
0
No flags
sh_addr
0
No address
sh_offset
0
No file offset
sh_size
0
No size
sh_link
SHN_UNDEF
No link information
sh_info
0
No auxiliary information
sh_addralign
0
No alignment
sh_entsize
0
No entries

Should the number of sections or program headers exceed the ELF header data sizes, elements of section header 0 are used to define extended ELF header attributes. See Extended Section Header.

A section header's sh_flags member holds 1-bit flags that describe the section's attributes.

Table 18  ELF Section Attribute Flags
Name
Value
SHF_WRITE
0x1
SHF_ALLOC
0x2
SHF_EXECINSTR
0x4
SHF_MERGE
0x10
SHF_STRINGS
0x20
SHF_INFO_LINK
0x40
SHF_LINK_ORDER
0x80
SHF_OS_NONCONFORMING
0x100
SHF_GROUP
0x200
SHF_TLS
0x400
SHF_COMPRESSED
0x800
SHF_MASKOS
0x0ff00000
SHF_SUNW_NODISCARD
0x00100000
SHF_SUNW_ABSENT
0x00200000
SHF_SUNW_PRIMARY
0x00400000
SHF_MASKPROC
0xf0000000
SHF_AMD64_LARGE
0x10000000
SHF_ORDERED
0x40000000
SHF_EXCLUDE
0x80000000

If a flag bit is set in sh_flags, the attribute is on for the section. Otherwise, the attribute is off, or does not apply. Undefined attributes are reserved and are set to zero.

SHF_WRITE

Identifies a section that should be writable during process execution.

SHF_ALLOC

Identifies a section that occupies memory during process execution. Some control sections do not reside in the memory image of an object file. This attribute is off for those sections.

SHF_EXECINSTR

Identifies a section that contains executable machine instructions.

SHF_MERGE

Identifies a section containing data that can be merged to eliminate duplication. Unless the SHF_STRINGS flag is also set, the data elements in the section are of a uniform size. The size of each element is specified in the section header's sh_entsize field. If the SHF_STRINGS flag is also set, the data elements consist of null-terminated character strings. The size of each character is specified in the section header's sh_entsize field.

SHF_STRINGS

Identifies a section that consists of null-terminated character strings. The size of each character is specified in the section header's sh_entsize field.

SHF_INFO_LINK

This section header's sh_info field holds a section header table index.

SHF_LINK_ORDER

This section adds special ordering requirements for link-editors. The requirements apply to the referenced section identified by the sh_link field of this section's header. If this section is combined with other sections in the output file, the section must appear in the same relative order with respect to those sections, as the referenced section appears with respect to sections the referenced section is combined with. The linked-to section must be unordered, and cannot in turn specify SHF_LINK_ORDER or SHF_ORDERED.

A typical use of this flag is to build a table that references text or data sections in address order.

In addition to adding ordering requirements, SHF_LINK_ORDER indicates that the section contains metadata describing the referenced section. When performing unused section elimination, the link editor ensures that both the section and the referenced section are retained or discarded together. Relocations from an SHF_LINK_ORDER section to its referenced section do not, by themselves, indicate that the referenced section is used.

In the absence of the sh_link ordering information, sections from a single input file combined within one section of the output file are contiguous. These sections have the same relative ordering as the sections did in the input file. The contributions from multiple input files appear in link-line order.


Note -  The special sh_link values SHN_BEFORE and SHN_AFTER imply that the sorted section is to precede or follow, respectively, all other sections in the set being ordered. See Figure 15, Table 15, ELF Special Section Indexes. Input file link-line order is preserved if multiple sections in an ordered set have one of these special values. SHN_BEFORE and SHN_AFTER are incompatible with objects that use extended section indexes. They are considered deprecated, and their use is discouraged. See Extended Section Header.
SHF_OS_NONCONFORMING

This section requires special OS-specific processing beyond the standard linking rules to avoid incorrect behavior. If this section has either an sh_type value or contains sh_flags bits in the OS-specific ranges for those fields, and the link-editor does not recognize these values, then the object file containing this section is rejected with an error.

SHF_GROUP

This section is a member, perhaps the only member, of a section group. The section must be referenced by a section of type SHT_GROUP. The SHF_GROUP flag can be set only for sections that are contained in relocatable objects. See Group Section for details.

SHF_TLS

This section holds thread-local storage. Each thread within a process has a distinct instance of this data. See Thread-Local Storage for details.

SHF_COMPRESSED

Identifies a section containing compressed data. SHF_COMPRESSED applies only to non-allocable sections, and cannot be used in conjunction with SHF_ALLOC. In addition, SHF_COMPRESSED cannot be applied to sections of type SHT_NOBITS. See Section Compression for details.

SHF_MASKOS

All bits that are included in this mask are reserved for operating system-specific semantics.

SHF_SUNW_NODISCARD

The link-editor's –z discard-unused option can result in unreferenced SHF_ALLOC sections being discarded from a link-edit. SHF_SUNW_NODISCARD ensures that an SHF_ALLOC section is not discarded using the –z discard-unused option, even if the section is unreferenced.

SHF_SUNW_ABSENT

Indicates that the data for this section is not present in this file. When ancillary objects are created, the primary object and any ancillary objects, all have the same section header array. This organization facilitates the merging of the information contained in these objects, and allows the use of a single symbol table. Each file contains a subset of the section data. The data for allocable sections is written to the primary object while the data for non-allocable sections is written to an ancillary file. The SHF_SUNW_ABSENT flag indicates that the data for the section is not present in the object being examined. When the SHF_SUNW_ABSENT flag is set, the sh_size field of the section header must be 0. An application encountering an SHF_SUNW_ABSENT section can choose to ignore the section, or to search for the section data within one of the related ancillary files. See Debugger Access and Use of Ancillary Objects.

SHF_SUNW_PRIMARY

The default behavior when ancillary objects are created is to write all allocable sections to the primary object and all non-allocable sections to the ancillary objects. The SHF_SUNW_PRIMARY flag overrides this behavior. Any output section containing one more input section with the SHF_SUNW_PRIMARY flag set is written to the primary object.

SHF_MASKPROC

All bits that are included in this mask are reserved for processor-specific semantics.

SHF_AMD64_LARGE

The default compilation model for x64 only provides for 32-bit displacements. This displacement limits the size of sections, and eventually segments, to 2 Gbytes. This attribute flag identifies a section that can hold more than 2 Gbyte. This flag allows the linking of object files that use different code models.

An x64 object file section that does not contain the SHF_AMD64_LARGE attribute flag can be freely referenced by objects using small code models. A section that contains this flag can only be referenced by objects that use larger code models. For example, an x64 medium code model object can refer to data in sections that contain the attribute flag and sections that do not contain the attribute flag. However, an x64 small code model object can only refer to data in a section that does not contain this flag.

SHF_ORDERED

SHF_ORDERED is an older version of the functionality provided by SHF_LINK_ORDER, and has been superseded by SHF_LINK_ORDER. SHF_ORDERED is no longer supported. The following information is provided for historical context.

SHF_ORDERED offers two distinct and separate abilities. First, an output section can be specified, and second, special ordering requirements are required from the link-editor.

The sh_link field of an SHF_ORDERED section forms a linked list of sections. This list is terminated by a final section with a sh_link that points at itself. All sections in this list are assigned to the output section with the name of the final section in the list.

If the sh_info entry of the ordered section is a valid section within the same input file, the ordered section is sorted based on the relative ordering within the output file of the section pointed to by the sh_info entry. The section pointed at by the sh_info entry must be unordered, and cannot in turn specify SHF_LINK_ORDER or SHF_ORDERED.

In the absence of the sh_info ordering information, sections from a single input file combined within one section of the output file are contiguous. These sections have the same relative ordering as the sections appear in the input file. The contributions from multiple input files appear in link-line order.


Note -  The special sh_info values SHN_BEFORE and SHN_AFTER imply that the sorted section is to precede or follow, respectively, all other sections in the set being ordered. See Figure 15, Table 15, ELF Special Section Indexes. Input file link-line order is preserved if multiple sections in an ordered set have one of these special values. SHN_BEFORE and SHN_AFTER are incompatible with objects that use extended section indexes. They are considered deprecated, and their use is discouraged. See Extended Section Header.
SHF_EXCLUDE

This section is excluded from input to the link-edit of an executable or shared object. This flag is ignored if the SHF_ALLOC flag is also set, or if relocations exist against the section.

Two members in the section header, sh_link and sh_info, hold special information, depending on section type.

Table 19  ELF sh_link and sh_info Interpretation
sh_type
sh_link
sh_info
SHT_DYNAMIC
The section header index of the associated string table.
0
SHT_HASH
The section header index of the associated symbol table.
0
SHT_REL
SHT_RELA
The section header index of the associated symbol table.
The section header index of the section to which the relocation applies, otherwise 0. See also Figure 23, Table 23, ELF Special Sections and Relocation Sections.
SHT_SYMTAB
SHT_DYNSYM
The section header index of the associated string table.
One greater than the symbol table index of the last local symbol, STB_LOCAL.
SHT_GROUP
The section header index of the associated symbol table.
The symbol table index of an entry in the associated symbol table. The name of the specified symbol table entry provides a signature for the section group.
SHT_SYMTAB_SHNDX
The section header index of the associated symbol table.
0
SHT_SUNW_phname
The section header index of the associated string table. This index is the same string table used by the SHT_DYNAMIC section.
0
SHT_SUNW_ancillary
The section header index of the associated string table.
0
SHT_SUNW_cap
If symbol capabilities exist, the section header index of the associated SHT_SUNW_capinfo table, otherwise 0.
If any capabilities refer to named strings, the section header index of the associated string table, otherwise 0.
SHT_SUNW_capinfo
The section header index of the associated symbol table.
For a dynamic object, the section header index of the associated SHT_SUNW_capchain table, otherwise 0.
SHT_SUNW_symsort
The section header index of the associated symbol table.
0
SHT_SUNW_tlssort
The section header index of the associated symbol table.
0
SHT_SUNW_LDYNSYM
The section header index of the associated string table. This index is the same string table used by the SHT_DYNSYM section.
One greater than the symbol table index of the last local symbol, STB_LOCAL. Since SHT_SUNW_LDYNSYM only contains local symbols, sh_info is equivalent to the number of symbols in the table.
SHT_SUNW_move
The section header index of the associated symbol table.
0
SHT_SUNW_COMDAT
0
0
SHT_SUNW_syminfo
The section header index of the associated symbol table.
The section header index of the associated .dynamic section.
SHT_SUNW_verdef
The section header index of the associated string table.
The number of version definitions within the section.
SHT_SUNW_verneed
The section header index of the associated string table.
The number of version dependencies within the section.
SHT_SUNW_versym
The section header index of the associated symbol table.
0

Extended Section Header

There are limitations on the number of sections that can be represented by standard ELF data structures.

The e_shnum and e_shstrndx elements of the ELF header are both limited to being able to represent 65535 sections.

In addition, symbol table entries can reference their associated section using the st_shndx element, which is limited to being able to represent 65279 sections. Although the size of this element could represent 65535 sections, a range of values is reserved for special symbol types, SHN_LORESERVE (0xff00) - SHN_HIRESERVE (0xffff).

To allow an ELF object to contain more than 65279 sections, a number of special definitions and a special section type are provided. The resultant ELF object is said to contain extended section header information.

In a standard ELF object, the first section header is zero filled. See Figure 35, Table 35, ELF Symbol Table Entry: Index 0. When the number of sections exceed the ELF header data sizes, elements of section header 0 are used to define extended ELF header attributes. The following table shows the values.

Table 20  ELF Extended Section Header Table Entry: Index 0
Name
Value
Note
sh_name
0
No name
sh_type
SHT_NULL
Inactive
sh_flags
0
No flags
sh_addr
0
No address
sh_offset
0
No file offset
sh_size
e_shnum
The number of entries in the section header table
sh_link
e_shstrndx
The section header index of the entry that is associated with the section name string table
sh_info
e_phnum
The number of entries in the program header table
sh_addralign
0
No alignment
sh_entsize
0
No entries

When this section header 0 information is used, the ELF header e_shnum element is set to 0, and the e_shstrndx element is set to SHN_XINDEX (0xffff).

For a symbol table to be able to reference more than 65279 sections, an extended section header index table, identified as SHT_SYMTAB_SHNDX, is created.

The SHT_SYMTAB_SHNDX section is an array of Elf32_Word values. Each value corresponds one to one with a symbol table entry and appears in the same order as the symbol table entries. The values represent the section header indexes against which the symbol table entries are defined. Only if the st_shndx field of a symbol table entry contains the escape value SHN_XINDEX (0xffff), does the corresponding SHT_SYMTAB_SHNDX entry hold the actual section header index. Otherwise, the SHT_SYMTAB_SHNDX entry must be SHN_UNDEF (0).

Should an ELF file require more than 65534 program headers, the sh_info element of section header 0 is used to define the number of program headers, and the e_phnum element of the ELF header contains PN_XNUM (0xffff).

To aid in the processing of extended section header information, the libelf routines elf_getphdrnum(3ELF), elf_getshdrnum(3ELF), and elf_getshdrstrndx(3ELF) are provided.