Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
7.  Object File Format File Format Sections  Previous   Contents   Next 
   
 
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 may 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 headers sh_info field holds a section header table index.

SHF_LINK_ORDER

This section adds special ordering requirements to the link-editor. The requirements apply if the sh_link field of this section's header references another section, the linked-to section. If this section is combined with other sections in the output file, it will appear in the same relative order with respect to those sections. Similarly the linked-to section appears with respect to sections the linked-to section is combined with.

The special sh_link values SHN_BEFORE and SHN_AFTER (see Table 7-11) imply that the sorted section is to precede or follow, respectively, all other sections in the set being ordered. Input file link-line order is preserved if multiple sections in an ordered set have one of these special values.

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

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

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 link-editor will reject the object file containing this section with an error.

SHF_GROUP

This section is a member, perhaps the only one, 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 contained in relocatable objects, objects with the ELF header e_type member set to ET_REL. See "Section Groups" for further details.

SHF_MASKOS

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

SHF_ORDERED

This section requires ordering in relation to other sections of the same type. Ordered sections are combined within the section pointed to by the sh_link entry. The sh_link entry of an ordered section can point to itself.

If the sh_info entry of the ordered section is a valid section within the same input file, the ordered section will be sorted based on the relative ordering within the output file of the section pointed to by the sh_info entry.

The special sh_info values SHN_BEFORE and SHN_AFTER (see Table 7-11) imply that the sorted section is to precede or follow, respectively, all other sections in the set being ordered. Input file link-line order is preserved if multiple sections in an ordered set have one of these special values.

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

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.

SHF_MASKPROC

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

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

Table 7-15 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. See also Table 7-17 and "Relocation".

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 (binding 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_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

Section Groups

Some sections occur in interrelated groups. For example, an out-of-line definition of an inline function might require, in addition to the section containing its executable instructions, a read-only data section containing literals referenced, one or more debugging information sections and other informational sections. Furthermore, there may be internal references among these sections that would not make sense if one of the sections were removed or replaced by a duplicate from another object. Therefore, such groups must be included or omitted from the linked object as a unit.

A section of type SHT_GROUP defines such a grouping of sections. The name of a symbol from one of the containing object's symbol tables provides a signature for the section group. The section header of the SHT_GROUP section specifies the identifying symbol entry. The sh_link member contains the section header index of the symbol table section that contains the entry. The sh_info member contains the symbol table index of the identifying entry. The sh_flags member of the section header contains 0. The name of the section (sh_name) is not specified.

The section data of a SHT_GROUP section is an array of Elf32_Word entries. The first entry is a flag word. The remaining entries are a sequence of section header indices.

The following flag is currently defined:

Table 7-16 ELF Section Group Flag

Name

Value

GRP_COMDAT

0x1

GRP_COMDAT

This is a COMDAT group. It may duplicate another COMDAT group in another object file, where duplication is defined as having the same group signature. In such cases, only one of the duplicate groups will be retained by the link-editor, and the members of the remaining groups will be discarded.

The section header indices in the SHT_GROUP section identify the sections that make up the group. Each such section must have the SHF_GROUP flag set in its sh_flags section header member. If the link-editor decides to remove the section group, it will remove all members of the group.

To facilitate removing a group without leaving dangling references and with only minimal processing of the symbol table, the following rules are followed:

  • References to the sections comprising a group from sections outside of the group must be made through symbol table entries with STB_GLOBAL or STB_WEAK binding and section index SHN_UNDEF. If there is a definition of the same symbol in the object containing the references, it must have a separate symbol table entry from the references. Sections outside of the group may not reference symbols with STB_LOCAL binding for addresses contained in the group's sections, including symbols with type STT_SECTION.

  • There may not be non-symbol references to the sections comprising a group from outside the group. For example, you cannot use a group member's section header index in an sh_link or sh_info member.

  • A symbol table entry that is defined relative to one of the group's sections and that is contained in a symbol table section that is not part of the group, will be removed if the group members are discarded.

Special Sections

Various sections hold program and control information. Sections in the following table are used by the system and have the indicated types and attributes.

Table 7-17 ELF Special Sections

Name

Type

Attribute

.bss

SHT_NOBITS

SHF_ALLOC + SHF_WRITE

.comment

SHT_PROGBITS

None

.data

SHT_PROGBITS

SHF_ALLOC + SHF_WRITE

.data1

SHT_PROGBITS

SHF_ALLOC + SHF_WRITE

.dynamic

SHT_DYNAMIC

SHF_ALLOC + SHF_WRITE

.dynstr

SHT_STRTAB

SHF_ALLOC

.dynsym

SHT_DYNSYM

SHF_ALLOC

.fini

SHT_PROGBITS

SHF_ALLOC + SHF_EXECINSTR

.fini_array

SHT_FINI_ARRAY

SHF_ALLOC + SHF_WRITE

.got

SHT_PROGBITS

See "Global Offset Table (Processor-Specific)"

.hash

SHT_HASH

SHF_ALLOC

.init

SHT_PROGBITS

SHF_ALLOC + SHF_EXECINSTR

.init_array

SHT_INIT_ARRAY

SHF_ALLOC + SHF_WRITE

.interp

SHT_PROGBITS

See "Program Interpreter"

.note

SHT_NOTE

None

.plt

SHT_PROGBITS

See "Procedure Linkage Table (Processor-Specific)"

.preinit_array

SHT_PREINIT_ARRAY

SHF_ALLOC + SHF_WRITE

.rela

SHT_RELA

None

.relname

SHT_REL

See "Relocation"

.relaname

SHT_RELA

See "Relocation"

.rodata

SHT_PROGBITS

SHF_ALLOC

.rodata1

SHT_PROGBITS

SHF_ALLOC

.shstrtab

SHT_STRTAB

None

.strtab

SHT_STRTAB

See description below

.symtab

SHT_SYMTAB

See "Symbol Table"

.text

SHT_PROGBITS

SHF_ALLOC + SHF_EXECINSTR

.SUNW_bss

SHT_NOBITS

SHF_ALLOC + SHF_WRITE

.SUNW_heap

SHT_PROGBITS

SHF_ALLOC + SHF_WRITE

.SUNW_move

SHT_SUNW_move

SHF_ALLOC

.SUNW_reloc

SHT_REL

SHT_RELA

SHF_ALLOC

.SUNW_syminfo

SHT_SUNW_syminfo

SHF_ALLOC

.SUNW_version

SHT_SUNW_verdef

SHT_SUNW_verneed

SHT_SUNW_versym

SHF_ALLOC

 
 
 
  Previous   Contents   Next