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

The elements of this structure are:

sh_name

The name of the section. Its 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 Table 7-17.

sh_type

Categorizes the section's contents and semantics. Section types and their descriptions are listed in Table 7-12.

sh_flags

Sections support 1-bit flags that describe miscellaneous attributes. Flag definitions are listed in Table 7-14.

sh_addr

If the section is to appear 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 0.

sh_offset

The byte offset from the beginning of the file to the first byte in the section. Section type SHT_NOBITS occupies no space in the file. Its sh_offset member locates the conceptual placement 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 it occupies no space in the file.

sh_link

A section header table index link, whose interpretation depends on the section type. Table 7-15 describes the values.

sh_info

Extra information, whose interpretation depends on the section type. Table 7-15 describes the values.

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. That is, 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 0 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 7-12 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_SUNW_move

0x6ffffffa

SHT_SUNW_COMDAT

0x6ffffffb

SHT_SUNW_syminfo

0x6ffffffc

SHT_SUNW_verdef

0x6ffffffd

SHT_SUNW_verneed

0x6ffffffe

SHT_SUNW_versym

0x6fffffff

SHT_LOPROC

0x70000000

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

Identifies a symbol table. Typically a SHT_SYMTAB section provides symbols for link-editing. As a complete symbol table, it can contain many symbols 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. See "Symbol Table" for details.

SHT_STRTAB, SHT_DYNSTR

Identifies a string table. An object file can have multiple string table sections. See "String Table" 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" for details.

SHT_HASH

Identifies a symbol hash table. All dynamically linked object files 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" 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" 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_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_move

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

SHT_SUNW_syminfo

Identifies additional symbol information. See "Syminfo Table" 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_LOUSER

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

SHT_HIUSER

Specifies the upper boundary of the range of indexes 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 7-13 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

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

Table 7-14 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_MASKOS

0x0ff00000

SHF_ORDERED

0x40000000

SHF_EXCLUDE

0x80000000

SHF_MASKPROC

0xf0000000

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 set to zero.

 
 
 
  Previous   Contents   Next