diff options
Diffstat (limited to 'static/freebsd/man5/elf.5 3.html')
| -rw-r--r-- | static/freebsd/man5/elf.5 3.html | 1172 |
1 files changed, 1172 insertions, 0 deletions
diff --git a/static/freebsd/man5/elf.5 3.html b/static/freebsd/man5/elf.5 3.html new file mode 100644 index 00000000..195189f0 --- /dev/null +++ b/static/freebsd/man5/elf.5 3.html @@ -0,0 +1,1172 @@ +<table class="head"> + <tr> + <td class="head-ltitle">ELF(5)</td> + <td class="head-vol">File Formats Manual</td> + <td class="head-rtitle">ELF(5)</td> + </tr> +</table> +<div class="manual-text"> +<section class="Sh"> +<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1> +<p class="Pp"><code class="Nm">elf</code> — <span class="Nd">format of + ELF executable binary files</span></p> +</section> +<section class="Sh"> +<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1> +<p class="Pp"><code class="In">#include + <<a class="In">elf.h</a>></code></p> +</section> +<section class="Sh"> +<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1> +<p class="Pp">The header file + <code class="In"><<a class="In">elf.h</a>></code> defines the format + of ELF executable binary files. Amongst these files are normal executable + files, relocatable object files, core files and shared libraries.</p> +<p class="Pp">An executable file using the ELF file format consists of an ELF + header, followed by a program header table or a section header table, or + both. The ELF header is always at offset zero of the file. The program + header table and the section header table's offset in the file are defined + in the ELF header. The two tables describe the rest of the particularities + of the file.</p> +<p class="Pp">Applications which wish to process ELF binary files for their + native architecture only should include + <code class="In"><<a class="In">elf.h</a>></code> in their source + code. These applications should need to refer to all the types and + structures by their generic names “Elf_xxx” and to the macros + by “ELF_xxx”. Applications written this way can be compiled on + any architecture, regardless whether the host is 32-bit or 64-bit.</p> +<p class="Pp">Should an application need to process ELF files of an unknown + architecture then the application needs to include both + <code class="In"><<a class="In">sys/elf32.h</a>></code> and + <code class="In"><<a class="In">sys/elf64.h</a>></code> instead of + <code class="In"><<a class="In">elf.h</a>></code>. Furthermore, all + types and structures need to be identified by either + “Elf32_xxx” or “Elf64_xxx”. The macros need to + be identified by “ELF32_xxx” or “ELF64_xxx”.</p> +<p class="Pp">Whatever the system's architecture is, it will always include + <code class="In"><<a class="In">sys/elf_common.h</a>></code> as well + as <code class="In"><<a class="In">sys/elf_generic.h</a>></code>.</p> +<p class="Pp">These header files describe the above mentioned headers as C + structures and also include structures for dynamic sections, relocation + sections and symbol tables.</p> +<p class="Pp">The following types are being used for 32-bit architectures:</p> +<div class="Bd Pp Bd-indent Li"> +<pre>Elf32_Addr Unsigned 32-bit program address +Elf32_Half Unsigned 16-bit field +Elf32_Lword Unsigned 64-bit field +Elf32_Off Unsigned 32-bit file offset +Elf32_Sword Signed 32-bit field or integer +Elf32_Word Unsigned 32-bit field or integer</pre> +</div> +<p class="Pp">For 64-bit architectures we have the following types:</p> +<div class="Bd Pp Bd-indent Li"> +<pre>Elf64_Addr Unsigned 64-bit program address +Elf64_Half Unsigned 16-bit field +Elf64_Lword Unsigned 64-bit field +Elf64_Off Unsigned 64-bit file offset +Elf64_Sword Signed 32-bit field +Elf64_Sxword Signed 64-bit field or integer +Elf64_Word Unsigned 32-bit field +Elf64_Xword Unsigned 64-bit field or integer</pre> +</div> +<p class="Pp">All data structures that the file format defines follow the + “natural” size and alignment guidelines for the relevant + class. If necessary, data structures contain explicit padding to ensure + 4-byte alignment for 4-byte objects, to force structure sizes to a multiple + of 4, etc.</p> +<p class="Pp">The ELF header is described by the type Elf32_Ehdr or + Elf64_Ehdr:</p> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} Elf32_Ehdr;</pre> +</div> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +} Elf64_Ehdr;</pre> +</div> +<p class="Pp">The fields have the following meanings:</p> +<p class="Pp"></p> +<div class="Bd-indent"> +<dl class="Bl-tag Bl-compact"> + <dt id="e_ident"><a class="permalink" href="#e_ident"><code class="Dv">e_ident</code></a></dt> + <dd>This array of bytes specifies to interpret the file, independent of the + processor or the file's remaining contents. Within this array everything + is named by macros, which start with the prefix + <a class="permalink" href="#EI_"><b class="Sy" id="EI_">EI_</b></a> and + may contain values which start with the prefix + <a class="permalink" href="#ELF"><b class="Sy" id="ELF">ELF</b></a>. The + following macros are defined: + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="EI_MAG0"><a class="permalink" href="#EI_MAG0"><code class="Dv">EI_MAG0</code></a></dt> + <dd>The first byte of the magic number. It must be filled with + <a class="permalink" href="#ELFMAG0"><b class="Sy" id="ELFMAG0">ELFMAG0</b></a>.</dd> + <dt id="EI_MAG1"><a class="permalink" href="#EI_MAG1"><code class="Dv">EI_MAG1</code></a></dt> + <dd>The second byte of the magic number. It must be filled with + <a class="permalink" href="#ELFMAG1"><b class="Sy" id="ELFMAG1">ELFMAG1</b></a>.</dd> + <dt id="EI_MAG2"><a class="permalink" href="#EI_MAG2"><code class="Dv">EI_MAG2</code></a></dt> + <dd>The third byte of the magic number. It must be filled with + <a class="permalink" href="#ELFMAG2"><b class="Sy" id="ELFMAG2">ELFMAG2</b></a>.</dd> + <dt id="EI_MAG3"><a class="permalink" href="#EI_MAG3"><code class="Dv">EI_MAG3</code></a></dt> + <dd>The fourth byte of the magic number. It must be filled with + <a class="permalink" href="#ELFMAG3"><b class="Sy" id="ELFMAG3">ELFMAG3</b></a>.</dd> + <dt id="EI_CLASS"><a class="permalink" href="#EI_CLASS"><code class="Dv">EI_CLASS</code></a></dt> + <dd>The fifth byte identifies the architecture for this binary: + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="ELFCLASSNONE"><a class="permalink" href="#ELFCLASSNONE"><code class="Dv">ELFCLASSNONE</code></a></dt> + <dd>This class is invalid.</dd> + <dt id="ELFCLASS32"><a class="permalink" href="#ELFCLASS32"><code class="Dv">ELFCLASS32</code></a></dt> + <dd>This defines the 32-bit architecture. It supports machines with + files and virtual address spaces up to 4 Gigabytes.</dd> + <dt id="ELFCLASS64"><a class="permalink" href="#ELFCLASS64"><code class="Dv">ELFCLASS64</code></a></dt> + <dd>This defines the 64-bit architecture.</dd> + </dl> + </dd> + <dt id="EI_DATA"><a class="permalink" href="#EI_DATA"><code class="Dv">EI_DATA</code></a></dt> + <dd>The sixth byte specifies the data encoding of the processor-specific + data in the file. Currently these encodings are supported: + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="ELFDATANONE"><a class="permalink" href="#ELFDATANONE"><code class="Dv">ELFDATANONE</code></a></dt> + <dd>Unknown data format.</dd> + <dt id="ELFDATA2LSB"><a class="permalink" href="#ELFDATA2LSB"><code class="Dv">ELFDATA2LSB</code></a></dt> + <dd>Two's complement, little-endian.</dd> + <dt id="ELFDATA2MSB"><a class="permalink" href="#ELFDATA2MSB"><code class="Dv">ELFDATA2MSB</code></a></dt> + <dd>Two's complement, big-endian.</dd> + </dl> + </dd> + <dt id="EI_VERSION"><a class="permalink" href="#EI_VERSION"><code class="Dv">EI_VERSION</code></a></dt> + <dd>The version number of the ELF specification: + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="EV_NONE"><a class="permalink" href="#EV_NONE"><code class="Dv">EV_NONE</code></a></dt> + <dd>Invalid version.</dd> + <dt id="EV_CURRENT"><a class="permalink" href="#EV_CURRENT"><code class="Dv">EV_CURRENT</code></a></dt> + <dd>Current version.</dd> + </dl> + </dd> + <dt id="EI_OSABI"><a class="permalink" href="#EI_OSABI"><code class="Dv">EI_OSABI</code></a></dt> + <dd>This byte identifies the operating system and ABI to which the object + is targeted. Some fields in other ELF structures have flags and values + that have platform specific meanings; the interpretation of those + fields is determined by the value of this byte. The following values + are currently defined: + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="ELFOSABI_SYSV"><a class="permalink" href="#ELFOSABI_SYSV"><code class="Dv">ELFOSABI_SYSV</code></a></dt> + <dd>UNIX System V ABI.</dd> + <dt id="ELFOSABI_HPUX"><a class="permalink" href="#ELFOSABI_HPUX"><code class="Dv">ELFOSABI_HPUX</code></a></dt> + <dd>HP-UX operating system ABI.</dd> + <dt id="ELFOSABI_NETBSD"><a class="permalink" href="#ELFOSABI_NETBSD"><code class="Dv">ELFOSABI_NETBSD</code></a></dt> + <dd><span class="Ux">NetBSD</span> operating system ABI.</dd> + <dt id="ELFOSABI_LINUX"><a class="permalink" href="#ELFOSABI_LINUX"><code class="Dv">ELFOSABI_LINUX</code></a></dt> + <dd>GNU/Linux operating system ABI.</dd> + <dt id="ELFOSABI_HURD"><a class="permalink" href="#ELFOSABI_HURD"><code class="Dv">ELFOSABI_HURD</code></a></dt> + <dd>GNU/Hurd operating system ABI.</dd> + <dt id="ELFOSABI_86OPEN"><a class="permalink" href="#ELFOSABI_86OPEN"><code class="Dv">ELFOSABI_86OPEN</code></a></dt> + <dd>86Open Common IA32 ABI.</dd> + <dt id="ELFOSABI_SOLARIS"><a class="permalink" href="#ELFOSABI_SOLARIS"><code class="Dv">ELFOSABI_SOLARIS</code></a></dt> + <dd>Solaris operating system ABI.</dd> + <dt id="ELFOSABI_MONTEREY"><a class="permalink" href="#ELFOSABI_MONTEREY"><code class="Dv">ELFOSABI_MONTEREY</code></a></dt> + <dd>Monterey project ABI.</dd> + <dt id="ELFOSABI_IRIX"><a class="permalink" href="#ELFOSABI_IRIX"><code class="Dv">ELFOSABI_IRIX</code></a></dt> + <dd>IRIX operating system ABI.</dd> + <dt id="ELFOSABI_FREEBSD"><a class="permalink" href="#ELFOSABI_FREEBSD"><code class="Dv">ELFOSABI_FREEBSD</code></a></dt> + <dd><span class="Ux">FreeBSD</span> operating system ABI.</dd> + <dt id="ELFOSABI_TRU64"><a class="permalink" href="#ELFOSABI_TRU64"><code class="Dv">ELFOSABI_TRU64</code></a></dt> + <dd>TRU64 UNIX operating system ABI.</dd> + <dt id="ELFOSABI_ARM"><a class="permalink" href="#ELFOSABI_ARM"><code class="Dv">ELFOSABI_ARM</code></a></dt> + <dd>ARM architecture ABI.</dd> + <dt id="ELFOSABI_STANDALONE"><a class="permalink" href="#ELFOSABI_STANDALONE"><code class="Dv">ELFOSABI_STANDALONE</code></a></dt> + <dd>Standalone (embedded) ABI.</dd> + </dl> + </dd> + <dt id="EI_ABIVERSION"><a class="permalink" href="#EI_ABIVERSION"><code class="Dv">EI_ABIVERSION</code></a></dt> + <dd>This byte identifies the version of the ABI to which the object is + targeted. This field is used to distinguish among incompatible + versions of an ABI. The interpretation of this version number is + dependent on the ABI identified by the EI_OSABI field. Applications + conforming to this specification use the value 0.</dd> + <dt id="EI_PAD"><a class="permalink" href="#EI_PAD"><code class="Dv">EI_PAD</code></a></dt> + <dd>Start of padding. These bytes are reserved and set to zero. Programs + which read them should ignore them. The value for EI_PAD will change + in the future if currently unused bytes are given meanings.</dd> + <dt id="EI_BRAND"><a class="permalink" href="#EI_BRAND"><code class="Dv">EI_BRAND</code></a></dt> + <dd>Start of architecture identification.</dd> + <dt id="EI_NIDENT"><a class="permalink" href="#EI_NIDENT"><code class="Dv">EI_NIDENT</code></a></dt> + <dd>The size of the e_ident array.</dd> + </dl> + <p class="Pp"></p> + </dd> + <dt id="e_type"><a class="permalink" href="#e_type"><code class="Dv">e_type</code></a></dt> + <dd>This member of the structure identifies the object file type: + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="ET_NONE"><a class="permalink" href="#ET_NONE"><code class="Dv">ET_NONE</code></a></dt> + <dd>An unknown type.</dd> + <dt id="ET_REL"><a class="permalink" href="#ET_REL"><code class="Dv">ET_REL</code></a></dt> + <dd>A relocatable file.</dd> + <dt id="ET_EXEC"><a class="permalink" href="#ET_EXEC"><code class="Dv">ET_EXEC</code></a></dt> + <dd>An executable file.</dd> + <dt id="ET_DYN"><a class="permalink" href="#ET_DYN"><code class="Dv">ET_DYN</code></a></dt> + <dd>A shared object.</dd> + <dt id="ET_CORE"><a class="permalink" href="#ET_CORE"><code class="Dv">ET_CORE</code></a></dt> + <dd>A core file.</dd> + </dl> + <p class="Pp"></p> + </dd> + <dt id="e_machine"><a class="permalink" href="#e_machine"><code class="Dv">e_machine</code></a></dt> + <dd>This member specifies the required architecture for an individual file: + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="EM_NONE"><a class="permalink" href="#EM_NONE"><code class="Dv">EM_NONE</code></a></dt> + <dd>An unknown machine.</dd> + <dt id="EM_M32"><a class="permalink" href="#EM_M32"><code class="Dv">EM_M32</code></a></dt> + <dd>AT&T WE 32100.</dd> + <dt id="EM_SPARC"><a class="permalink" href="#EM_SPARC"><code class="Dv">EM_SPARC</code></a></dt> + <dd>Sun Microsystems SPARC.</dd> + <dt id="EM_386"><a class="permalink" href="#EM_386"><code class="Dv">EM_386</code></a></dt> + <dd>Intel 80386.</dd> + <dt id="EM_68K"><a class="permalink" href="#EM_68K"><code class="Dv">EM_68K</code></a></dt> + <dd>Motorola 68000.</dd> + <dt id="EM_88K"><a class="permalink" href="#EM_88K"><code class="Dv">EM_88K</code></a></dt> + <dd>Motorola 88000.</dd> + <dt id="EM_486"><a class="permalink" href="#EM_486"><code class="Dv">EM_486</code></a></dt> + <dd>Intel 80486.</dd> + <dt id="EM_860"><a class="permalink" href="#EM_860"><code class="Dv">EM_860</code></a></dt> + <dd>Intel 80860.</dd> + <dt id="EM_MIPS"><a class="permalink" href="#EM_MIPS"><code class="Dv">EM_MIPS</code></a></dt> + <dd>MIPS RS3000 (big-endian only).</dd> + <dt id="EM_MIPS_RS4_BE"><a class="permalink" href="#EM_MIPS_RS4_BE"><code class="Dv">EM_MIPS_RS4_BE</code></a></dt> + <dd>MIPS RS4000 (big-endian only).</dd> + <dt id="EM_SPARC64"><a class="permalink" href="#EM_SPARC64"><code class="Dv">EM_SPARC64</code></a></dt> + <dd>SPARC v9 64-bit unofficial.</dd> + <dt id="EM_PARISC"><a class="permalink" href="#EM_PARISC"><code class="Dv">EM_PARISC</code></a></dt> + <dd>HPPA.</dd> + <dt id="EM_PPC"><a class="permalink" href="#EM_PPC"><code class="Dv">EM_PPC</code></a></dt> + <dd>PowerPC.</dd> + <dt id="EM_ALPHA"><a class="permalink" href="#EM_ALPHA"><code class="Dv">EM_ALPHA</code></a></dt> + <dd>Compaq [DEC] Alpha.</dd> + </dl> + <p class="Pp"></p> + </dd> + <dt id="e_version"><a class="permalink" href="#e_version"><code class="Dv">e_version</code></a></dt> + <dd>This member identifies the file version: + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="EV_NONE~2"><a class="permalink" href="#EV_NONE~2"><code class="Dv">EV_NONE</code></a></dt> + <dd>Invalid version</dd> + <dt id="EV_CURRENT~2"><a class="permalink" href="#EV_CURRENT~2"><code class="Dv">EV_CURRENT</code></a></dt> + <dd>Current version</dd> + </dl> + </dd> + <dt id="e_entry"><a class="permalink" href="#e_entry"><code class="Dv">e_entry</code></a></dt> + <dd>This member gives the virtual address to which the system first transfers + control, thus starting the process. If the file has no associated entry + point, this member holds zero.</dd> + <dt id="e_phoff"><a class="permalink" href="#e_phoff"><code class="Dv">e_phoff</code></a></dt> + <dd>This member holds the program header table's file offset in bytes. If the + file has no program header table, this member holds zero.</dd> + <dt id="e_shoff"><a class="permalink" href="#e_shoff"><code class="Dv">e_shoff</code></a></dt> + <dd>This member holds the section header table's file offset in bytes. If the + file has no section header table this member holds zero.</dd> + <dt id="e_flags"><a class="permalink" href="#e_flags"><code class="Dv">e_flags</code></a></dt> + <dd>This member holds processor-specific flags associated with the file. Flag + names take the form EF_`machine_flag'. Currently no flags have been + defined.</dd> + <dt id="e_ehsize"><a class="permalink" href="#e_ehsize"><code class="Dv">e_ehsize</code></a></dt> + <dd>This member holds the ELF header's size in bytes.</dd> + <dt id="e_phentsize"><a class="permalink" href="#e_phentsize"><code class="Dv">e_phentsize</code></a></dt> + <dd>This member holds the size in bytes of one entry in the file's program + header table; all entries are the same size.</dd> + <dt id="e_phnum"><a class="permalink" href="#e_phnum"><code class="Dv">e_phnum</code></a></dt> + <dd>This member holds the number of entries in the program header table. If + the file is using extended program header numbering, then the + <b class="Sy">e_phnum</b> member will contain the value + <code class="Dv">PN_XNUM</code> and the actual number of program header + table entries will be stored in the <b class="Sy">sh_info</b> member of + the section header at index <code class="Dv">SHN_UNDEF</code>. The product + of <b class="Sy">e_phentsize</b> and the number of program header table + entries gives the program header table's size in bytes. If a file has no + program header, <b class="Sy">e_phnum</b> holds the value zero.</dd> + <dt id="e_shentsize"><a class="permalink" href="#e_shentsize"><code class="Dv">e_shentsize</code></a></dt> + <dd>This member holds a sections header's size in bytes. A section header is + one entry in the section header table; all entries are the same size.</dd> + <dt id="e_shnum"><a class="permalink" href="#e_shnum"><code class="Dv">e_shnum</code></a></dt> + <dd>This member holds the number of entries in the section header table. If + the file is using extended section numbering, then the + <b class="Sy">e_shnum</b> member will be zero and the actual section + number will be stored in the <b class="Sy">sh_size</b> member of the + section header at index <code class="Dv">SHN_UNDEF</code>. If a file has + no section header table, both the <b class="Sy">e_shnum</b> and the + <b class="Sy">e_shoff</b> fields of the ELF header will be zero. The + product of <b class="Sy">e_shentsize</b> and the number of sections in the + file gives the section header table's size in bytes.</dd> + <dt id="e_shstrndx"><a class="permalink" href="#e_shstrndx"><code class="Dv">e_shstrndx</code></a></dt> + <dd>This member holds the section header table index of the entry associated + with the section name string table. If extended section numbering is being + used, this field will hold the value + <a class="permalink" href="#SHN_XINDEX"><b class="Sy" id="SHN_XINDEX">SHN_XINDEX</b></a>, + and the actual section header table index will be present in the + <b class="Sy">sh_link</b> field of the section header entry at index + <code class="Dv">SHN_UNDEF</code>. If the file has no section name string + table, this member holds the value <b class="Sy">SHN_UNDEF</b>.</dd> +</dl> +</div> +<p class="Pp" id="segment">An executable or shared object file's program header + table is an array of structures, each describing a segment or other + information the system needs to prepare the program for execution. An object + file <a class="permalink" href="#segment"><i class="Em">segment</i></a> + contains one or more + <a class="permalink" href="#sections"><i class="Em" id="sections">sections</i></a>. + Program headers are meaningful only for executable and shared object files. + A file specifies its own program header size with the ELF header's + <b class="Sy">e_phentsize</b> and <b class="Sy">e_phnum</b> members. As with + the Elf executable header, the program header also has different versions + depending on the architecture:</p> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} Elf32_Phdr;</pre> +</div> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +} Elf64_Phdr;</pre> +</div> +<p class="Pp">The main difference between the 32-bit and the 64-bit program + header lies only in the location of a <b class="Sy">p_flags</b> member in + the total struct.</p> +<p class="Pp"></p> +<div class="Bd-indent"> +<dl class="Bl-tag Bl-compact"> + <dt id="p_type"><a class="permalink" href="#p_type"><code class="Dv">p_type</code></a></dt> + <dd>This member of the Phdr struct tells what kind of segment this array + element describes or how to interpret the array element's information. + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="PT_NULL"><a class="permalink" href="#PT_NULL"><code class="Dv">PT_NULL</code></a></dt> + <dd>The array element is unused and the other members' values are + undefined. This lets the program header have ignored entries.</dd> + <dt id="PT_LOAD"><a class="permalink" href="#PT_LOAD"><code class="Dv">PT_LOAD</code></a></dt> + <dd>The array element specifies a loadable segment, described by + <b class="Sy">p_filesz</b> and <b class="Sy">p_memsz</b>. The bytes + from the file are mapped to the beginning of the memory segment. If + the segment's memory size (<b class="Sy">p_memsz</b>) is larger than + the file size (<b class="Sy">p_filesz</b>), the “extra” + bytes are defined to hold the value 0 and to follow the segment's + initialized area. The file size may not be larger than the memory + size. Loadable segment entries in the program header table appear in + ascending order, sorted on the <b class="Sy">p_vaddr</b> member.</dd> + <dt id="PT_DYNAMIC"><a class="permalink" href="#PT_DYNAMIC"><code class="Dv">PT_DYNAMIC</code></a></dt> + <dd>The array element specifies dynamic linking information.</dd> + <dt id="PT_INTERP"><a class="permalink" href="#PT_INTERP"><code class="Dv">PT_INTERP</code></a></dt> + <dd>The array element specifies the location and size of a null-terminated + path name to invoke as an interpreter. This segment type is meaningful + only for executable files (though it may occur for shared objects). + However it may not occur more than once in a file. If it is present it + must precede any loadable segment entry.</dd> + <dt id="PT_NOTE"><a class="permalink" href="#PT_NOTE"><code class="Dv">PT_NOTE</code></a></dt> + <dd>The array element specifies the location and size for auxiliary + information.</dd> + <dt id="PT_SHLIB"><a class="permalink" href="#PT_SHLIB"><code class="Dv">PT_SHLIB</code></a></dt> + <dd>This segment type is reserved but has unspecified semantics. Programs + that contain an array element of this type do not conform to the + ABI.</dd> + <dt id="PT_PHDR"><a class="permalink" href="#PT_PHDR"><code class="Dv">PT_PHDR</code></a></dt> + <dd>The array element, if present, specifies the location and size of the + program header table itself, both in the file and in the memory image + of the program. This segment type may not occur more than once in a + file. Moreover, it may only occur if the program header table is part + of the memory image of the program. If it is present it must precede + any loadable segment entry.</dd> + <dt id="PT_LOPROC"><a class="permalink" href="#PT_LOPROC"><code class="Dv">PT_LOPROC</code></a></dt> + <dd>This value up to and including <b class="Sy">PT_HIPROC</b> are + reserved for processor-specific semantics.</dd> + <dt id="PT_HIPROC"><a class="permalink" href="#PT_HIPROC"><code class="Dv">PT_HIPROC</code></a></dt> + <dd>This value down to and including <b class="Sy">PT_LOPROC</b> are + reserved for processor-specific semantics.</dd> + </dl> + <p class="Pp"></p> + </dd> + <dt id="p_offset"><a class="permalink" href="#p_offset"><code class="Dv">p_offset</code></a></dt> + <dd>This member holds the offset from the beginning of the file at which the + first byte of the segment resides.</dd> + <dt id="p_vaddr"><a class="permalink" href="#p_vaddr"><code class="Dv">p_vaddr</code></a></dt> + <dd>This member holds the virtual address at which the first byte of the + segment resides in memory.</dd> + <dt id="p_paddr"><a class="permalink" href="#p_paddr"><code class="Dv">p_paddr</code></a></dt> + <dd>On systems for which physical addressing is relevant, this member is + reserved for the segment's physical address. Under + <span class="Ux">BSD</span> this member is not used and must be zero.</dd> + <dt id="p_filesz"><a class="permalink" href="#p_filesz"><code class="Dv">p_filesz</code></a></dt> + <dd>This member holds the number of bytes in the file image of the segment. It + may be zero.</dd> + <dt id="p_memsz"><a class="permalink" href="#p_memsz"><code class="Dv">p_memsz</code></a></dt> + <dd>This member holds the number of bytes in the memory image of the segment. + It may be zero.</dd> + <dt id="p_flags"><a class="permalink" href="#p_flags"><code class="Dv">p_flags</code></a></dt> + <dd>This member holds flags relevant to the segment: + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="PF_X"><a class="permalink" href="#PF_X"><code class="Dv">PF_X</code></a></dt> + <dd>An executable segment.</dd> + <dt id="PF_W"><a class="permalink" href="#PF_W"><code class="Dv">PF_W</code></a></dt> + <dd>A writable segment.</dd> + <dt id="PF_R"><a class="permalink" href="#PF_R"><code class="Dv">PF_R</code></a></dt> + <dd>A readable segment.</dd> + </dl> + <p class="Pp">A text segment commonly has the flags <b class="Sy">PF_X</b> + and <b class="Sy">PF_R</b>. A data segment commonly has + <b class="Sy">PF_X</b>, <b class="Sy">PF_W</b> and + <b class="Sy">PF_R</b>.</p> + </dd> + <dt id="p_align"><a class="permalink" href="#p_align"><code class="Dv">p_align</code></a></dt> + <dd>This member holds the value to which the segments are aligned in memory + and in the file. Loadable process segments must have congruent values for + <b class="Sy">p_vaddr</b> and <b class="Sy">p_offset</b>, modulo the page + size. Values of zero and one mean no alignment is required. Otherwise, + <b class="Sy">p_align</b> should be a positive, integral power of two, and + <b class="Sy">p_vaddr</b> should equal <b class="Sy">p_offset</b>, modulo + <b class="Sy">p_align</b>.</dd> +</dl> +</div> +<p class="Pp">An file's section header table lets one locate all the file's + sections. The section header table is an array of Elf32_Shdr or Elf64_Shdr + structures. The ELF header's <b class="Sy">e_shoff</b> member gives the byte + offset from the beginning of the file to the section header table. + <b class="Sy">e_shnum</b> holds the number of entries the section header + table contains. <b class="Sy">e_shentsize</b> holds the size in bytes of + each entry.</p> +<p class="Pp">A section header table index is a subscript into this array. Some + section header table indices are reserved. An object file does not have + sections for these special indices:</p> +<p class="Pp"></p> +<dl class="Bl-tag Bl-compact"> + <dt id="SHN_UNDEF"><a class="permalink" href="#SHN_UNDEF"><code class="Dv">SHN_UNDEF</code></a></dt> + <dd>This value marks an undefined, missing, irrelevant, or otherwise + meaningless section reference. For example, a symbol + “defined” relative to section number + <b class="Sy">SHN_UNDEF</b> is an undefined symbol.</dd> + <dt id="SHN_LORESERVE"><a class="permalink" href="#SHN_LORESERVE"><code class="Dv">SHN_LORESERVE</code></a></dt> + <dd>This value specifies the lower bound of the range of reserved + indices.</dd> + <dt id="SHN_LOPROC"><a class="permalink" href="#SHN_LOPROC"><code class="Dv">SHN_LOPROC</code></a></dt> + <dd>This value up to and including <b class="Sy">SHN_HIPROC</b> are reserved + for processor-specific semantics.</dd> + <dt id="SHN_HIPROC"><a class="permalink" href="#SHN_HIPROC"><code class="Dv">SHN_HIPROC</code></a></dt> + <dd>This value down to and including <b class="Sy">SHN_LOPROC</b> are reserved + for processor-specific semantics.</dd> + <dt id="SHN_ABS"><a class="permalink" href="#SHN_ABS"><code class="Dv">SHN_ABS</code></a></dt> + <dd>This value specifies absolute values for the corresponding reference. For + example, symbols defined relative to section number + <b class="Sy">SHN_ABS</b> have absolute values and are not affected by + relocation.</dd> + <dt id="SHN_COMMON"><a class="permalink" href="#SHN_COMMON"><code class="Dv">SHN_COMMON</code></a></dt> + <dd>Symbols defined relative to this section are common symbols, such as + FORTRAN COMMON or unallocated C external variables.</dd> + <dt id="SHN_HIRESERVE"><a class="permalink" href="#SHN_HIRESERVE"><code class="Dv">SHN_HIRESERVE</code></a></dt> + <dd>This value specifies the upper bound of the range of reserved indices. The + system reserves indices between <b class="Sy">SHN_LORESERVE</b> and + <b class="Sy">SHN_HIRESERVE</b>, inclusive. The section header table does + not contain entries for the reserved indices.</dd> +</dl> +<p class="Pp">The section header has the following structure:</p> +<div class="Bd Pp Bd-indent Li"> +<pre>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;</pre> +</div> +<div class="Bd Pp Bd-indent Li"> +<pre>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;</pre> +</div> +<p class="Pp"></p> +<dl class="Bl-tag Bl-compact"> + <dt id="sh_name"><a class="permalink" href="#sh_name"><code class="Dv">sh_name</code></a></dt> + <dd>This member specifies 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.</dd> + <dt id="sh_type"><a class="permalink" href="#sh_type"><code class="Dv">sh_type</code></a></dt> + <dd>This member categorizes the section's contents and semantics. + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="SHT_NULL"><a class="permalink" href="#SHT_NULL"><code class="Dv">SHT_NULL</code></a></dt> + <dd>This value marks the section header as inactive. It does not have an + associated section. Other members of the section header have undefined + values.</dd> + <dt id="SHT_PROGBITS"><a class="permalink" href="#SHT_PROGBITS"><code class="Dv">SHT_PROGBITS</code></a></dt> + <dd>The section holds information defined by the program, whose format and + meaning are determined solely by the program.</dd> + <dt id="SHT_SYMTAB"><a class="permalink" href="#SHT_SYMTAB"><code class="Dv">SHT_SYMTAB</code></a></dt> + <dd>This section holds a symbol table. Typically, + <b class="Sy">SHT_SYMTAB</b> provides symbols for link editing, though + it may also be used for dynamic linking. As a complete symbol table, + it may contain many symbols unnecessary for dynamic linking. An object + file can also contain a + <a class="permalink" href="#SHN_DYNSYM"><b class="Sy" id="SHN_DYNSYM">SHN_DYNSYM</b></a> + section.</dd> + <dt id="SHT_STRTAB"><a class="permalink" href="#SHT_STRTAB"><code class="Dv">SHT_STRTAB</code></a></dt> + <dd>This section holds a string table. An object file may have multiple + string table sections.</dd> + <dt id="SHT_RELA"><a class="permalink" href="#SHT_RELA"><code class="Dv">SHT_RELA</code></a></dt> + <dd>This section holds relocation entries with explicit addends, such as + type + <a class="permalink" href="#Elf32_Rela"><b class="Sy" id="Elf32_Rela">Elf32_Rela</b></a> + for the 32-bit class of object files. An object may have multiple + relocation sections.</dd> + <dt id="SHT_HASH"><a class="permalink" href="#SHT_HASH"><code class="Dv">SHT_HASH</code></a></dt> + <dd>This section holds a symbol hash table. All object participating in + dynamic linking must contain a symbol hash table. An object file may + have only one hash table.</dd> + <dt id="SHT_DYNAMIC"><a class="permalink" href="#SHT_DYNAMIC"><code class="Dv">SHT_DYNAMIC</code></a></dt> + <dd>This section holds information for dynamic linking. An object file may + have only one dynamic section.</dd> + <dt id="SHT_NOTE"><a class="permalink" href="#SHT_NOTE"><code class="Dv">SHT_NOTE</code></a></dt> + <dd>This section holds information that marks the file in some way.</dd> + <dt id="SHT_NOBITS"><a class="permalink" href="#SHT_NOBITS"><code class="Dv">SHT_NOBITS</code></a></dt> + <dd>A section of this type occupies no space in the file but otherwise + resembles + <a class="permalink" href="#SHN_PROGBITS"><b class="Sy" id="SHN_PROGBITS">SHN_PROGBITS</b></a>. + Although this section contains no bytes, the + <b class="Sy">sh_offset</b> member contains the conceptual file + offset.</dd> + <dt id="SHT_REL"><a class="permalink" href="#SHT_REL"><code class="Dv">SHT_REL</code></a></dt> + <dd>This section holds relocation offsets without explicit addends, such + as type + <a class="permalink" href="#Elf32_Rel"><b class="Sy" id="Elf32_Rel">Elf32_Rel</b></a> + for the 32-bit class of object files. An object file may have multiple + relocation sections.</dd> + <dt id="SHT_SHLIB"><a class="permalink" href="#SHT_SHLIB"><code class="Dv">SHT_SHLIB</code></a></dt> + <dd>This section is reserved but has unspecified semantics.</dd> + <dt id="SHT_DYNSYM"><a class="permalink" href="#SHT_DYNSYM"><code class="Dv">SHT_DYNSYM</code></a></dt> + <dd>This section holds a minimal set of dynamic linking symbols. An object + file can also contain a + <a class="permalink" href="#SHN_SYMTAB"><b class="Sy" id="SHN_SYMTAB">SHN_SYMTAB</b></a> + section.</dd> + <dt id="SHT_LOPROC"><a class="permalink" href="#SHT_LOPROC"><code class="Dv">SHT_LOPROC</code></a></dt> + <dd>This value up to and including <b class="Sy">SHT_HIPROC</b> are + reserved for processor-specific semantics.</dd> + <dt id="SHT_HIPROC"><a class="permalink" href="#SHT_HIPROC"><code class="Dv">SHT_HIPROC</code></a></dt> + <dd>This value down to and including <b class="Sy">SHT_LOPROC</b> are + reserved for processor-specific semantics.</dd> + <dt id="SHT_LOUSER"><a class="permalink" href="#SHT_LOUSER"><code class="Dv">SHT_LOUSER</code></a></dt> + <dd>This value specifies the lower bound of the range of indices reserved + for application programs.</dd> + <dt id="SHT_HIUSER"><a class="permalink" href="#SHT_HIUSER"><code class="Dv">SHT_HIUSER</code></a></dt> + <dd>This value specifies the upper bound of the range of indices reserved + for application programs. Section types between + <b class="Sy">SHT_LOUSER</b> and <b class="Sy">SHT_HIUSER</b> may be + used by the application, without conflicting with current or future + system-defined section types.</dd> + </dl> + <p class="Pp"></p> + </dd> + <dt id="sh_flags"><a class="permalink" href="#sh_flags"><code class="Dv">sh_flags</code></a></dt> + <dd>Sections support one-bit flags that describe miscellaneous attributes. If + a flag bit is set in <b class="Sy">sh_flags</b>, the attribute is + “on” for the section. Otherwise, the attribute is + “off” or does not apply. Undefined attributes are set to + zero. + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="SHF_WRITE"><a class="permalink" href="#SHF_WRITE"><code class="Dv">SHF_WRITE</code></a></dt> + <dd>This section contains data that should be writable during process + execution.</dd> + <dt id="SHF_ALLOC"><a class="permalink" href="#SHF_ALLOC"><code class="Dv">SHF_ALLOC</code></a></dt> + <dd>The section 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.</dd> + <dt id="SHF_EXECINSTR"><a class="permalink" href="#SHF_EXECINSTR"><code class="Dv">SHF_EXECINSTR</code></a></dt> + <dd>The section contains executable machine instructions.</dd> + <dt id="SHF_MASKPROC"><a class="permalink" href="#SHF_MASKPROC"><code class="Dv">SHF_MASKPROC</code></a></dt> + <dd>All bits included in this mask are reserved for processor-specific + semantics.</dd> + <dt id="SHF_COMPRESSED"><a class="permalink" href="#SHF_COMPRESSED"><code class="Dv">SHF_COMPRESSED</code></a></dt> + <dd>The section data is compressed.</dd> + </dl> + <p class="Pp"></p> + </dd> + <dt id="sh_addr"><a class="permalink" href="#sh_addr"><code class="Dv">sh_addr</code></a></dt> + <dd>If the section will appear in the memory image of a process, this member + holds the address at which the section's first byte should reside. + Otherwise, the member contains zero.</dd> + <dt id="sh_offset"><a class="permalink" href="#sh_offset"><code class="Dv">sh_offset</code></a></dt> + <dd>This member's value holds the byte offset from the beginning of the file + to the first byte in the section. One section type, + <b class="Sy">SHT_NOBITS</b>, occupies no space in the file, and its + <b class="Sy">sh_offset</b> member locates the conceptual placement in the + file.</dd> + <dt id="sh_size"><a class="permalink" href="#sh_size"><code class="Dv">sh_size</code></a></dt> + <dd>This member holds the section's size in bytes. Unless the section type is + <b class="Sy">SHT_NOBITS</b>, the section occupies + <b class="Sy">sh_size</b> bytes in the file. A section of type + <b class="Sy">SHT_NOBITS</b> may have a non-zero size, but it occupies no + space in the file.</dd> + <dt id="sh_link"><a class="permalink" href="#sh_link"><code class="Dv">sh_link</code></a></dt> + <dd>This member holds a section header table index link, whose interpretation + depends on the section type.</dd> + <dt id="sh_info"><a class="permalink" href="#sh_info"><code class="Dv">sh_info</code></a></dt> + <dd>This member holds extra information, whose interpretation depends on the + section type.</dd> + <dt id="sh_addralign"><a class="permalink" href="#sh_addralign"><code class="Dv">sh_addralign</code></a></dt> + <dd>Some sections have address alignment constraints. If a section holds a + doubleword, the system must ensure doubleword alignment for the entire + section. That is, the value of <b class="Sy">sh_addr</b> must be congruent + to zero, modulo the value of <b class="Sy">sh_addralign</b>. Only zero and + positive integral powers of two are allowed. Values of zero or one mean + the section has no alignment constraints.</dd> + <dt id="sh_entsize"><a class="permalink" href="#sh_entsize"><code class="Dv">sh_entsize</code></a></dt> + <dd>Some sections hold a table of fixed-sized entries, such as a symbol table. + For such a section, this member gives the size in bytes for each entry. + This member contains zero if the section does not hold a table of + fixed-size entries.</dd> +</dl> +<p class="Pp">Various sections hold program and control information:</p> +<dl class="Bl-tag Bl-compact"> + <dt>.bss</dt> + <dd>(Block Started by Symbol) This section holds uninitialized data that + contributes to the program's memory image. By definition, the system + initializes the data with zeros when the program begins to run. This + section is of type <b class="Sy">SHT_NOBITS</b>. The attributes types are + <b class="Sy">SHF_ALLOC</b> and <b class="Sy">SHF_WRITE</b>.</dd> + <dt>.comment</dt> + <dd>This section holds version control information. This section is of type + <b class="Sy">SHT_PROGBITS</b>. No attribute types are used.</dd> + <dt>.ctors</dt> + <dd>This legacy section holds pointers to initialization routines, executed + before calling the main program entry point. This section is of type + <b class="Sy">SHT_PROGBITS</b>. The attributes used are + <b class="Sy">SHF_ALLOC</b>.</dd> + <dt>.data</dt> + <dd>This section holds initialized data that contribute to the program's + memory image. This section is of type <b class="Sy">SHT_PROGBITS</b>. The + attribute types are <b class="Sy">SHF_ALLOC</b> and + <b class="Sy">SHF_WRITE</b>.</dd> + <dt>.data1</dt> + <dd>This section holds initialized data that contribute to the program's + memory image. This section is of type <b class="Sy">SHT_PROGBITS</b>. The + attribute types are <b class="Sy">SHF_ALLOC</b> and + <b class="Sy">SHF_WRITE</b>.</dd> + <dt>.debug</dt> + <dd>This section holds information for symbolic debugging. The contents are + unspecified. This section is of type <b class="Sy">SHT_PROGBITS</b>. No + attribute types are used.</dd> + <dt>.dtors</dt> + <dd>This legacy section holds pointers to finalization routines, executed when + the program exits normally. This section is of type + <b class="Sy">SHT_PROGBITS</b>. The attributes used are + <b class="Sy">SHF_ALLOC</b>.</dd> + <dt>.dynamic</dt> + <dd>This section holds dynamic linking information. The section's attributes + will include the <b class="Sy">SHF_ALLOC</b> bit. Whether the + <b class="Sy">SHF_WRITE</b> bit is set is processor-specific. This section + is of type <b class="Sy">SHT_DYNAMIC</b>. See the attributes above.</dd> + <dt>.dynstr</dt> + <dd>This section holds strings needed for dynamic linking, most commonly the + strings that represent the names associated with symbol table entries. + This section is of type <b class="Sy">SHT_STRTAB</b>. The attribute type + used is <b class="Sy">SHF_ALLOC</b>.</dd> + <dt>.dynsym</dt> + <dd>This section holds the dynamic linking symbol table. This section is of + type <b class="Sy">SHT_DYNSYM</b>. The attribute used is + <b class="Sy">SHF_ALLOC</b>.</dd> + <dt>.fini</dt> + <dd>This legacy section holds executable instructions that contribute to the + process termination code. When a program exits normally the system + arranges to execute the code in this section. This section is of type + <b class="Sy">SHT_PROGBITS</b>. The attributes used are + <b class="Sy">SHF_ALLOC</b> and <b class="Sy">SHF_EXECINSTR</b>.</dd> + <dt id="SHT_FINI_ARRAY">.fini_array</dt> + <dd>This section holds pointers to finalization routines. When a program exits + normally <a class="Xr">rtld(1)</a> executes the code referenced by this + section. This section is of type + <a class="permalink" href="#SHT_FINI_ARRAY"><b class="Sy">SHT_FINI_ARRAY</b></a>. + The attributes used are <b class="Sy">SHF_ALLOC</b>. Refer to + <code class="Dv">NT_FREEBSD_NOINIT_TAG</code> (below) for a description of + how initialization and finalization code is invoked.</dd> + <dt>.got</dt> + <dd>This section holds the global offset table. This section is of type + <b class="Sy">SHT_PROGBITS</b>. The attributes are + processor-specific.</dd> + <dt>.hash</dt> + <dd>This section holds a symbol hash table. This section is of type + <b class="Sy">SHT_HASH</b>. The attribute used is + <b class="Sy">SHF_ALLOC</b>.</dd> + <dt>.init</dt> + <dd>This legacy section holds executable instructions that contribute to the + process initialization code. When a program starts to run the system + arranges to execute the code in this section before calling the main + program entry point. This section is of type + <b class="Sy">SHT_PROGBITS</b>. The attributes used are + <b class="Sy">SHF_ALLOC</b> and <b class="Sy">SHF_EXECINSTR</b>.</dd> + <dt id="SHT_INIT_ARRAY">.init_array</dt> + <dd>This section holds pointers to initialization routines. When a program + starts to run <a class="Xr">rtld(1)</a> executes the code referenced by + this section before calling the program entry point. This section is of + type + <a class="permalink" href="#SHT_INIT_ARRAY"><b class="Sy">SHT_INIT_ARRAY</b></a>. + The attributes used are <b class="Sy">SHF_ALLOC</b>. Refer to + <code class="Dv">NT_FREEBSD_NOINIT_TAG</code> (below) for a description of + how initialization and finalization code is invoked.</dd> + <dt>.interp</dt> + <dd>This section holds the pathname of a program interpreter. If the file has + a loadable segment that includes the section, the section's attributes + will include the <b class="Sy">SHF_ALLOC</b> bit. Otherwise, that bit will + be off. This section is of type <b class="Sy">SHT_PROGBITS</b>.</dd> + <dt>.line</dt> + <dd>This section holds line number information for symbolic debugging, which + describes the correspondence between the program source and the machine + code. The contents are unspecified. This section is of type + <b class="Sy">SHT_PROGBITS</b>. No attribute types are used.</dd> + <dt>.note</dt> + <dd>This section holds information in the “Note Section” format + described below. This section is of type <b class="Sy">SHT_NOTE</b>. No + attribute types are used.</dd> + <dt>.plt</dt> + <dd>This section holds the procedure linkage table. This section is of type + <b class="Sy">SHT_PROGBITS</b>. The attributes are + processor-specific.</dd> + <dt id=".rel.text">.relNAME</dt> + <dd>This section holds relocation information as described below. If the file + has a loadable segment that includes relocation, the section's attributes + will include the <b class="Sy">SHF_ALLOC</b> bit. Otherwise the bit will + be off. By convention, “NAME” is supplied by the section to + which the relocations apply. Thus a relocation section for + <b class="Sy">.text</b> normally would have the name + <a class="permalink" href="#.rel.text"><b class="Sy">.rel.text</b></a>. + This section is of type <b class="Sy">SHT_REL</b>.</dd> + <dt id=".rela.text">.relaNAME</dt> + <dd>This section holds relocation information as described below. If the file + has a loadable segment that includes relocation, the section's attributes + will include the <b class="Sy">SHF_ALLOC</b> bit. Otherwise the bit will + be off. By convention, “NAME” is supplied by the section to + which the relocations apply. Thus a relocation section for + <b class="Sy">.text</b> normally would have the name + <a class="permalink" href="#.rela.text"><b class="Sy">.rela.text</b></a>. + This section is of type <b class="Sy">SHT_RELA</b>.</dd> + <dt>.rodata</dt> + <dd>This section holds read-only data that typically contributes to a + non-writable segment in the process image. This section is of type + <b class="Sy">SHT_PROGBITS</b>. The attribute used is + <b class="Sy">SHF_ALLOC</b>.</dd> + <dt>.rodata1</dt> + <dd>This section holds read-only data that typically contributes to a + non-writable segment in the process image. This section is of type + <b class="Sy">SHT_PROGBITS</b>. The attribute used is + <b class="Sy">SHF_ALLOC</b>.</dd> + <dt>.shstrtab</dt> + <dd>This section holds section names. This section is of type + <b class="Sy">SHT_STRTAB</b>. No attribute types are used.</dd> + <dt>.strtab</dt> + <dd>This section holds strings, most commonly the strings that represent the + names associated with symbol table entries. If the file has a loadable + segment that includes the symbol string table, the section's attributes + will include the <b class="Sy">SHF_ALLOC</b> bit. Otherwise the bit will + be off. This section is of type <b class="Sy">SHT_STRTAB</b>.</dd> + <dt>.symtab</dt> + <dd>This section holds a symbol table. If the file has a loadable segment that + includes the symbol table, the section's attributes will include the + <b class="Sy">SHF_ALLOC</b> bit. Otherwise the bit will be off. This + section is of type <b class="Sy">SHT_SYMTAB</b>.</dd> + <dt>.text</dt> + <dd>This section holds the “text”, or executable instructions, + of a program. This section is of type <b class="Sy">SHT_PROGBITS</b>. The + attributes used are <b class="Sy">SHF_ALLOC</b> and + <b class="Sy">SHF_EXECINSTR</b>.</dd> + <dt>.jcr</dt> + <dd>This section holds information about Java classes that must be registered. + It is obsolete and binaries created for <span class="Ux">FreeBSD 15</span> + or later do not process it.</dd> + <dt>.eh_frame</dt> + <dd>This section holds information used for C++ exception-handling.</dd> +</dl> +<p class="Pp">A section with the <code class="Dv">SHF_COMPRESSED</code> flag set + contains a compressed copy of the section data. Compressed section data + begins with an <var class="Vt">Elf64_Chdr</var> or + <var class="Vt">Elf32_Chdr structure</var> which encodes the compression + algorithm and some characteristics of the uncompressed data.</p> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + Elf32_Word ch_type; + Elf32_Word ch_size; + Elf32_Word ch_addralign; +} Elf32_Chdr;</pre> +</div> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + Elf64_Word ch_type; + Elf64_Word ch_reserved; + Elf64_Xword ch_size; + Elf64_Xword ch_addralign; +} Elf64_Chdr;</pre> +</div> +<p class="Pp"></p> +<dl class="Bl-tag Bl-compact"> + <dt id="ch_type"><a class="permalink" href="#ch_type"><code class="Dv">ch_type</code></a></dt> + <dd>The compression algorithm used. A value of + <code class="Dv">ELFCOMPRESS_ZLIB</code> indicates that the data is + compressed using <a class="Xr">zlib(3)</a>. A value of + <code class="Dv">ELFCOMPRESS_ZSTD</code> indicates that the data is + compressed using Zstandard.</dd> + <dt id="ch_size"><a class="permalink" href="#ch_size"><code class="Dv">ch_size</code></a></dt> + <dd>The size, in bytes, of the uncompressed section data. This corresponds to + the <b class="Sy">sh_size</b> field of a section header containing + uncompressed data.</dd> + <dt id="ch_addralign"><a class="permalink" href="#ch_addralign"><code class="Dv">ch_addralign</code></a></dt> + <dd>The address alignment of the uncompressed section data. This corresponds + to the <b class="Sy">sh_addralign</b> field of a section header containing + uncompressed data.</dd> +</dl> +<p class="Pp">String table sections hold null-terminated character sequences, + commonly called strings. The object file uses these strings to represent + symbol and section names. One references a string as an index into the + string table section. The first byte, which is index zero, is defined to + hold a null character. Similarly, a string table's last byte is defined to + hold a null character, ensuring null termination for all strings.</p> +<p class="Pp">An object file's symbol table holds information needed to locate + and relocate a program's symbolic definitions and references. A symbol table + index is a subscript into this array.</p> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + Elf32_Half st_shndx; +} Elf32_Sym;</pre> +</div> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + Elf64_Word st_name; + unsigned char st_info; + unsigned char st_other; + Elf64_Half st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; +} Elf64_Sym;</pre> +</div> +<p class="Pp"></p> +<dl class="Bl-tag Bl-compact"> + <dt id="st_name"><a class="permalink" href="#st_name"><code class="Dv">st_name</code></a></dt> + <dd>This member holds an index into the object file's symbol string table, + which holds character representations of the symbol names. If the value is + non-zero, it represents a string table index that gives the symbol name. + Otherwise, the symbol table has no name.</dd> + <dt id="st_value"><a class="permalink" href="#st_value"><code class="Dv">st_value</code></a></dt> + <dd>This member gives the value of the associated symbol.</dd> + <dt id="st_size"><a class="permalink" href="#st_size"><code class="Dv">st_size</code></a></dt> + <dd>Many symbols have associated sizes. This member holds zero if the symbol + has no size or an unknown size.</dd> + <dt id="st_info"><a class="permalink" href="#st_info"><code class="Dv">st_info</code></a></dt> + <dd>This member specifies the symbol's type and binding attributes: + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="STT_NOTYPE"><a class="permalink" href="#STT_NOTYPE"><code class="Dv">STT_NOTYPE</code></a></dt> + <dd>The symbol's type is not defined.</dd> + <dt id="STT_OBJECT"><a class="permalink" href="#STT_OBJECT"><code class="Dv">STT_OBJECT</code></a></dt> + <dd>The symbol is associated with a data object.</dd> + <dt id="STT_FUNC"><a class="permalink" href="#STT_FUNC"><code class="Dv">STT_FUNC</code></a></dt> + <dd>The symbol is associated with a function or other executable + code.</dd> + <dt id="STT_SECTION"><a class="permalink" href="#STT_SECTION"><code class="Dv">STT_SECTION</code></a></dt> + <dd>The symbol is associated with a section. Symbol table entries of this + type exist primarily for relocation and normally have + <b class="Sy">STB_LOCAL</b> bindings.</dd> + <dt id="STT_FILE"><a class="permalink" href="#STT_FILE"><code class="Dv">STT_FILE</code></a></dt> + <dd>By convention the symbol's name gives the name of the source file + associated with the object file. A file symbol has + <b class="Sy">STB_LOCAL</b> bindings, its section index is + <b class="Sy">SHN_ABS</b>, and it precedes the other + <b class="Sy">STB_LOCAL</b> symbols of the file, if it is + present.</dd> + <dt id="STT_LOPROC"><a class="permalink" href="#STT_LOPROC"><code class="Dv">STT_LOPROC</code></a></dt> + <dd>This value up to and including <b class="Sy">STT_HIPROC</b> are + reserved for processor-specific semantics.</dd> + <dt id="STT_HIPROC"><a class="permalink" href="#STT_HIPROC"><code class="Dv">STT_HIPROC</code></a></dt> + <dd>This value down to and including <b class="Sy">STT_LOPROC</b> are + reserved for processor-specific semantics.</dd> + </dl> + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="STB_LOCAL"><a class="permalink" href="#STB_LOCAL"><code class="Dv">STB_LOCAL</code></a></dt> + <dd>Local symbols are not visible outside the object file containing their + definition. Local symbols of the same name may exist in multiple file + without interfering with each other.</dd> + <dt id="STB_GLOBAL"><a class="permalink" href="#STB_GLOBAL"><code class="Dv">STB_GLOBAL</code></a></dt> + <dd>Global symbols are visible to all object files being combined. One + file's definition of a global symbol will satisfy another file's + undefined reference to the same symbol.</dd> + <dt id="STB_WEAK"><a class="permalink" href="#STB_WEAK"><code class="Dv">STB_WEAK</code></a></dt> + <dd>Weak symbols resemble global symbols, but their definitions have lower + precedence.</dd> + <dt id="STB_LOPROC"><a class="permalink" href="#STB_LOPROC"><code class="Dv">STB_LOPROC</code></a></dt> + <dd>This value up to and including <b class="Sy">STB_HIPROC</b> are + reserved for processor-specific semantics.</dd> + <dt id="STB_HIPROC"><a class="permalink" href="#STB_HIPROC"><code class="Dv">STB_HIPROC</code></a></dt> + <dd>This value down to and including <b class="Sy">STB_LOPROC</b> are + reserved for processor-specific semantics. + <p class="Pp">There are macros for packing and unpacking the binding and + type fields:</p> + <p class="Pp"></p> + <dl class="Bl-tag Bl-compact"> + <dt id="ELF32_ST_BIND"><a class="permalink" href="#ELF32_ST_BIND"><code class="Fn">ELF32_ST_BIND</code></a>(<var class="Fa">info</var>)</dt> + <dd>or + <a class="permalink" href="#ELF64_ST_BIND"><code class="Fn" id="ELF64_ST_BIND">ELF64_ST_BIND</code></a>(<var class="Fa">info</var>) + extract a binding from an st_info value.</dd> + <dt id="ELF64_ST_TYPE"><a class="permalink" href="#ELF64_ST_TYPE"><code class="Fn">ELF64_ST_TYPE</code></a>(<var class="Fa">info</var>)</dt> + <dd>or + <a class="permalink" href="#ELF32_ST_TYPE"><code class="Fn" id="ELF32_ST_TYPE">ELF32_ST_TYPE</code></a>(<var class="Fa">info</var>) + extract a type from an st_info value.</dd> + <dt id="ELF32_ST_INFO"><a class="permalink" href="#ELF32_ST_INFO"><code class="Fn">ELF32_ST_INFO</code></a>(<var class="Fa">bind</var>, + <var class="Fa">type</var>)</dt> + <dd>or + <a class="permalink" href="#ELF64_ST_INFO"><code class="Fn" id="ELF64_ST_INFO">ELF64_ST_INFO</code></a>(<var class="Fa">bind</var>, + <var class="Fa">type</var>) convert a binding and a type into an + st_info value.</dd> + </dl> + </dd> + </dl> + <p class="Pp"></p> + </dd> + <dt id="st_other"><a class="permalink" href="#st_other"><code class="Dv">st_other</code></a></dt> + <dd>This member currently holds zero and has no defined meaning.</dd> + <dt id="st_shndx"><a class="permalink" href="#st_shndx"><code class="Dv">st_shndx</code></a></dt> + <dd>Every symbol table entry is “defined” in relation to some + section. This member holds the relevant section header table index.</dd> +</dl> +<p class="Pp">Relocation is the process of connecting symbolic references with + symbolic definitions. 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' program image. + Relocation entries are these data.</p> +<p class="Pp">Relocation structures that do not need an addend:</p> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; +} Elf32_Rel;</pre> +</div> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; +} Elf64_Rel;</pre> +</div> +<p class="Pp">Relocation structures that need an addend:</p> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} Elf32_Rela;</pre> +</div> +<div class="Bd Pp Bd-indent Li"> +<pre>typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; + Elf64_Sxword r_addend; +} Elf64_Rela;</pre> +</div> +<p class="Pp"></p> +<dl class="Bl-tag Bl-compact"> + <dt id="r_offset"><a class="permalink" href="#r_offset"><code class="Dv">r_offset</code></a></dt> + <dd>This member gives the location at which to apply the relocation action. + For a relocatable file, the value is the byte offset from the beginning of + the section to the storage unit affected by the relocation. For an + executable file or shared object, the value is the virtual address of the + storage unit affected by the relocation.</dd> + <dt id="r_info"><a class="permalink" href="#r_info"><code class="Dv">r_info</code></a></dt> + <dd>This member gives both the symbol table index with respect to which the + relocation must be made and the type of relocation to apply. Relocation + types are processor-specific. When the text refers to a relocation entry's + relocation type or symbol table index, it means the result of applying + <a class="permalink" href="#ELF__32_64__R_TYPE"><b class="Sy" id="ELF__32_64__R_TYPE">ELF_[32|64]_R_TYPE</b></a> + or + <a class="permalink" href="#ELF_32_64__R_SYM"><b class="Sy" id="ELF_32_64__R_SYM">ELF[32|64]_R_SYM</b></a>, + respectively to the entry's <b class="Sy">r_info</b> member.</dd> + <dt id="r_addend"><a class="permalink" href="#r_addend"><code class="Dv">r_addend</code></a></dt> + <dd>This member specifies a constant addend used to compute the value to be + stored into the relocatable field.</dd> +</dl> +<section class="Ss"> +<h2 class="Ss" id="Note_Section"><a class="permalink" href="#Note_Section">Note + Section</a></h2> +<p class="Pp">ELF note sections consist of entries with the following + format:</p> +<table class="Bl-column Bd-indent"> + <tr id="Field"> + <td><a class="permalink" href="#Field"><b class="Sy">Field</b></a></td> + <td><a class="permalink" href="#Size"><b class="Sy" id="Size">Size</b></a></td> + <td><a class="permalink" href="#Description"><b class="Sy" id="Description">Description</b></a></td> + </tr> + <tr id="namesz"> + <td><var class="Va">namesz</var></td> + <td>32 bits</td> + <td>Size of name</td> + </tr> + <tr id="descsz"> + <td><var class="Va">descsz</var></td> + <td>32 bits</td> + <td>Size of desc</td> + </tr> + <tr id="type"> + <td><var class="Va">type</var></td> + <td>32 bits</td> + <td>OS-dependent note type</td> + </tr> + <tr id="name"> + <td><var class="Va">name</var></td> + <td><var class="Va">namesz</var></td> + <td>Null-terminated originator name</td> + </tr> + <tr id="desc"> + <td><var class="Va">desc</var></td> + <td><var class="Va">descsz</var></td> + <td>OS-dependent note data</td> + </tr> +</table> +<p class="Pp">The <var class="Va">name</var> and <var class="Va">desc</var> + fields are padded to ensure 4-byte alignment. <var class="Va">namesz</var> + and <var class="Va">descsz</var> specify the unpadded length.</p> +<p class="Pp"><span class="Ux">FreeBSD</span> defines the following ELF note + types (with corresponding interpretation of <var class="Va">desc</var>):</p> +<dl class="Bl-tag"> + <dt id="NT_FREEBSD_ABI_TAG"><a class="permalink" href="#NT_FREEBSD_ABI_TAG"><code class="Dv">NT_FREEBSD_ABI_TAG</code></a> + (Value: 1)</dt> + <dd>Indicates the OS ABI version in a form of a 32-bit integer containing + expected ABI version (i.e., + <code class="Dv">__FreeBSD_version</code>).</dd> + <dt id="NT_FREEBSD_NOINIT_TAG"><a class="permalink" href="#NT_FREEBSD_NOINIT_TAG"><code class="Dv">NT_FREEBSD_NOINIT_TAG</code></a> + (Value: 2)</dt> + <dd>Indicates that the C startup does not call initialization routines, and + thus <a class="Xr">rtld(1)</a> must do so. <var class="Va">desc</var> is + ignored.</dd> + <dt id="NT_FREEBSD_ARCH_TAG"><a class="permalink" href="#NT_FREEBSD_ARCH_TAG"><code class="Dv">NT_FREEBSD_ARCH_TAG</code></a> + (Value: 3)</dt> + <dd>Contains the MACHINE_ARCH that the executable was built for.</dd> + <dt id="NT_FREEBSD_FEATURE_CTL"><a class="permalink" href="#NT_FREEBSD_FEATURE_CTL"><code class="Dv">NT_FREEBSD_FEATURE_CTL</code></a> + (Value: 4)</dt> + <dd>Contains a bitmask of mitigations and features to enable: + <dl class="Bl-tag"> + <dt>NT_FREEBSD_FCTL_ASLR_DISABLE (Value: 0x01)</dt> + <dd>Request that address randomization (ASLR) not be performed. See + <a class="Xr">security(7)</a>.</dd> + <dt>NT_FREEBSD_FCTL_PROTMAX_DISABLE (Value: 0x02)</dt> + <dd>Request that <a class="Xr">mmap(2)</a> calls not set PROT_MAX to the + initial value of the <var class="Fa">prot</var> argument.</dd> + <dt>NT_FREEBSD_FCTL_STKGAP_DISABLE (Value: 0x04)</dt> + <dd>Disable stack gap.</dd> + <dt>NT_FREEBSD_FCTL_WXNEEDED (Value: 0x08)</dt> + <dd>Indicate that the binary requires mappings that are simultaneously + writeable and executable.</dd> + <dt>NT_FREEBSD_FCTL_LA48 (Value: 0x10)</dt> + <dd>Request 48-bit linear address space on amd64.</dd> + <dt>NT_FREEBSD_FCTL_LA57 (Value: 0x40)</dt> + <dd>Accept 57-bit linear address space on amd64.</dd> + </dl> + </dd> +</dl> +</section> +</section> +<section class="Sh"> +<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE + ALSO</a></h1> +<p class="Pp"><a class="Xr">as(1)</a>, <a class="Xr">gdb(1)</a> + (<span class="Pa">ports/devel/gdb</span>), <a class="Xr">ld(1)</a>, + <a class="Xr">objdump(1)</a>, <a class="Xr">readelf(1)</a>, + <a class="Xr">execve(2)</a>, <a class="Xr">zlib(3)</a>, + <a class="Xr">ar(5)</a>, <a class="Xr">core(5)</a></p> +<p class="Pp"><cite class="Rs"><span class="RsA">Hewlett Packard</span>, + <i class="RsB">Elf-64 Object File Format</i>.</cite></p> +<p class="Pp"><cite class="Rs"><span class="RsA">Santa Cruz Operation</span>, + <i class="RsB">System V Application Binary Interface</i>.</cite></p> +<p class="Pp"><cite class="Rs"><span class="RsA">Unix System + Laboratories</span>, <span class="RsT">Object Files</span>, + <i class="RsB">Executable and Linking Format (ELF)</i>.</cite></p> +</section> +<section class="Sh"> +<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1> +<p class="Pp">The ELF header files made their appearance in + <span class="Ux">FreeBSD 2.2.6</span>. ELF in itself first appeared in + <span class="Ux">AT&T System V UNIX</span>. The ELF format is an + adopted standard.</p> +</section> +<section class="Sh"> +<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1> +<p class="Pp">This manual page was written by <span class="An">Jeroen Ruigrok + van der Werven</span> + <<a class="Mt" href="mailto:asmodai@FreeBSD.org">asmodai@FreeBSD.org</a>> + with inspiration from BSDi's <span class="Ux">BSD/OS</span> + <code class="Nm">elf</code> manpage.</p> +</section> +</div> +<table class="foot"> + <tr> + <td class="foot-date">May 26, 2025</td> + <td class="foot-os">FreeBSD 15.0</td> + </tr> +</table> |
