1 .\" $OpenBSD: elf.5,v 1.12 2003/10/27 20:23:58 jmc Exp $
2 .\"Copyright (c) 1999 Jeroen Ruigrok van der Werven
3 .\"All rights reserved.
5 .\" %%%LICENSE_START(PERMISSIVE_MISC)
6 .\"Redistribution and use in source and binary forms, with or without
7 .\"modification, are permitted provided that the following conditions
9 .\"1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\"2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\"THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\"ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\"ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\"FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\"DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\"OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\"HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\"LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\"OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" $FreeBSD: src/share/man/man5/elf.5,v 1.21 2001/10/01 16:09:23 ru Exp $
30 .\" Slightly adapted - aeb, 2004-01-01
31 .\" 2005-07-15, Mike Frysinger <vapier@gentoo.org>, various fixes
32 .\" 2007-10-11, Mike Frysinger <vapier@gentoo.org>, various fixes
33 .\" 2007-12-08, mtk, Converted from mdoc to man macros
35 .TH ELF 5 2021-03-22 "Linux" "Linux Programmer's Manual"
37 elf \- format of Executable and Linking Format (ELF) files
40 .\" .B #include <elf_abi.h>
46 defines the format of ELF executable binary files.
47 Amongst these files are
48 normal executable files, relocatable object files, core files, and shared
51 An executable file using the ELF file format consists of an ELF header,
52 followed by a program header table or a section header table, or both.
53 The ELF header is always at offset zero of the file.
55 table and the section header table's offset in the file are defined in the
57 The two tables describe the rest of the particularities of
60 .\" Applications which wish to process ELF binary files for their native
61 .\" architecture only should include
63 .\" in their source code.
64 .\" These applications should need to refer to
65 .\" all the types and structures by their generic names
67 .\" and to the macros by
69 .\" Applications written this way can be compiled on any architecture,
70 .\" regardless of whether the host is 32-bit or 64-bit.
72 .\" Should an application need to process ELF files of an unknown
73 .\" architecture, then the application needs to explicitly use either
77 .\" type and structure names.
78 .\" Likewise, the macros need to be identified by
83 This header file describes the above mentioned headers as C structures
84 and also includes structures for dynamic sections, relocation sections and
88 The following types are used for N-bit architectures (N=32,64,
102 ElfN_Addr Unsigned program address, uintN_t
103 ElfN_Off Unsigned file offset, uintN_t
104 ElfN_Section Unsigned section index, uint16_t
105 ElfN_Versym Unsigned version symbol information, uint16_t
106 Elf_Byte unsigned char
112 .\" Elf32_Size Unsigned object size
116 (Note: the *BSD terminology is a bit different.
126 In order to avoid confusion these types are replaced by explicit ones
129 All data structures that the file format defines follow the
131 size and alignment guidelines for the relevant class.
133 data structures contain explicit padding to ensure 4-byte alignment
134 for 4-byte objects, to force structure sizes to a multiple of 4, and so on.
136 .SS ELF header (Ehdr)
137 The ELF header is described by the type
147 unsigned char e_ident[EI_NIDENT];
156 uint16_t e_phentsize;
158 uint16_t e_shentsize;
165 The fields have the following meanings:
170 This array of bytes specifies how to interpret the file,
171 independent of the processor or the file's remaining contents.
172 Within this array everything is named by macros, which start with
175 and may contain values which start with the prefix
177 The following macros are defined:
181 The first byte of the magic number.
182 It must be filled with
187 The second byte of the magic number.
188 It must be filled with
193 The third byte of the magic number.
194 It must be filled with
199 The fourth byte of the magic number.
200 It must be filled with
205 The fifth byte identifies the architecture for this binary:
210 This class is invalid.
213 This defines the 32-bit architecture.
214 It supports machines with files
215 and virtual address spaces up to 4 Gigabytes.
218 This defines the 64-bit architecture.
223 The sixth byte specifies the data encoding of the processor-specific
225 Currently, these encodings are supported:
233 Two's complement, little-endian.
236 Two's complement, big-endian.
241 The seventh byte is the version number of the ELF specification:
256 The eighth byte identifies the operating system
257 and ABI to which the object is targeted.
258 Some fields in other ELF structures have flags
259 and values that have platform-specific meanings;
260 the interpretation of those fields is determined by the value of this byte.
266 Same as ELFOSABI_SYSV
272 .\" synonym: ELFOSABI_NONE
286 .\" .BR ELFOSABI_HURD
290 .\" .BR ELFOSABI_86OPEN
291 .\" 86Open Common IA32 ABI
298 .\" .BR ELFOSABI_MONTEREY
299 .\" Monterey project ABI
324 .BR ELFOSABI_STANDALONE
325 Stand-alone (embedded) ABI
331 The ninth byte identifies the version of the ABI
332 to which the object is targeted.
333 This field is used to distinguish among incompatible versions of an ABI.
334 The interpretation of this version number
335 is dependent on the ABI identified by the
338 Applications conforming to this specification use the value 0.
342 These bytes are reserved and set to zero.
344 which read them should ignore them.
348 the future if currently unused bytes are given meanings.
349 .\" As reported by Yuri Kozlov and confirmed by Mike Frysinger, EI_BRAND is
350 .\" not in GABI (http://www.sco.com/developers/gabi/latest/ch4.eheader.html)
351 .\" It looks to be a BSDism
354 .\" Start of architecture identification.
363 This member of the structure identifies the object file type:
385 This member specifies the required architecture for an individual file.
399 Sun Microsystems SPARC
423 MIPS RS3000 (big-endian only)
428 .\" .BR EM_MIPS_RS4_BE
429 .\" MIPS RS4000 (big-endian only). Deprecated
431 .\" EM_MIPS_RS3_LE (MIPS R3000 little-endian)
439 SPARC with enhanced instruction set
455 Advanced RISC Machines
481 .\" Compaq [DEC] Alpha
484 .\" Compaq [DEC] Alpha with enhanced instruction set
489 This member identifies the file version:
502 This member gives the virtual address to which the system first transfers
503 control, thus starting the process.
504 If the file has no associated entry
505 point, this member holds zero.
508 This member holds the program header table's file offset in bytes.
510 the file has no program header table, this member holds zero.
513 This member holds the section header table's file offset in bytes.
515 file has no section header table, this member holds zero.
518 This member holds processor-specific flags associated with the file.
519 Flag names take the form EF_`machine_flag'.
520 Currently, no flags have been defined.
523 This member holds the ELF header's size in bytes.
526 This member holds the size in bytes of one entry in the file's
527 program header table; all entries are the same size.
530 This member holds the number of entries in the program header
536 gives the table's size
538 If a file has no program header,
540 holds the value zero.
542 If the number of entries in the program header table is
543 larger than or equal to
544 .\" This is a Linux extension, added in Linux 2.6.34.
546 (0xffff), this member holds
548 (0xffff) and the real number of entries in the program header table is held
551 member of the initial entry in section header table.
554 member of the initial entry contains the value zero.
558 This is defined as 0xffff, the largest number
560 can have, specifying where the actual number of program headers is assigned.
565 This member holds a sections header's size in bytes.
566 A section header is one
567 entry in the section header table; all entries are the same size.
570 This member holds the number of entries in the section header table.
576 gives the section header table's size in bytes.
577 If a file has no section
580 holds the value of zero.
582 If the number of entries in the section header table is
583 larger than or equal to
587 holds the value zero and the real number of entries in the section header
590 member of the initial entry in section header table.
593 member of the initial entry in the section header table holds
597 This member holds the section header table index of the entry associated
598 with the section name string table.
599 If the file has no section name string
600 table, this member holds the value
603 If the index of section name string table section is
604 larger than or equal to
606 (0xff00), this member holds
608 (0xffff) and the real index of the section name string table section
611 member of the initial entry in section header table.
614 member of the initial entry in section header table contains the value zero.
616 .SS Program header (Phdr)
617 An executable or shared object file's program header table is an array of
618 structures, each describing a segment or other information the system needs
619 to prepare the program for execution.
624 Program headers are meaningful only for executable and shared object files.
625 A file specifies its own program header size with the ELF header's
630 The ELF program header is described by the type
634 depending on the architecture:
666 The main difference between the 32-bit and the 64-bit program header lies
667 in the location of the
669 member in the total struct.
672 This member of the structure indicates what kind of segment this array
673 element describes or how to interpret the array element's information.
677 The array element is unused and the other members' values are undefined.
678 This lets the program header have ignored entries.
681 The array element specifies a loadable segment, described by
685 The bytes from the file are mapped to the beginning of the memory
687 If the segment's memory size
689 is larger than the file size
693 bytes are defined to hold the value 0 and to follow the segment's
695 The file size may not be larger than the memory size.
696 Loadable segment entries in the program header table appear in ascending
702 The array element specifies dynamic linking information.
705 The array element specifies the location and size of a null-terminated
706 pathname to invoke as an interpreter.
707 This segment type is meaningful
708 only for executable files (though it may occur for shared objects).
709 However it may not occur more than once in a file.
710 If it is present, it must precede any loadable segment entry.
713 The array element specifies the location of notes (ElfN_Nhdr).
716 This segment type is reserved but has unspecified semantics.
718 contain an array element of this type do not conform to the ABI.
721 The array element, if present,
722 specifies the location and size of the program header table itself,
723 both in the file and in the memory image of the program.
724 This segment type may not occur more than once in a file.
726 occur only if the program header table is part of the memory image of the
728 If it is present, it must precede any loadable segment entry.
730 .BR PT_LOPROC ", " PT_HIPROC
731 Values in the inclusive range
732 .RB [ PT_LOPROC ", " PT_HIPROC ]
733 are reserved for processor-specific semantics.
736 GNU extension which is used by the Linux kernel to control the state of the
737 stack via the flags set in the
743 This member holds the offset from the beginning of the file at which
744 the first byte of the segment resides.
747 This member holds the virtual address at which the first byte of the
748 segment resides in memory.
751 On systems for which physical addressing is relevant, this member is
752 reserved for the segment's physical address.
756 not used and must be zero.
759 This member holds the number of bytes in the file image of the segment.
763 This member holds the number of bytes in the memory image of the segment.
767 This member holds a bit mask of flags relevant to the segment:
772 An executable segment.
782 A text segment commonly has the flags
786 A data segment commonly has
792 This member holds the value to which the segments are aligned in memory
794 Loadable process segments must have congruent values for
798 modulo the page size.
799 Values of zero and one mean no alignment is required.
802 should be a positive, integral power of two, and
809 .SS Section header (Shdr)
810 A file's section header table lets one locate all the file's sections.
812 section header table is an array of
820 member gives the byte offset from the beginning of the file to the section
823 holds the number of entries the section header table contains.
825 holds the size in bytes of each entry.
827 A section header table index is a subscript into this array.
829 header table indices are reserved:
830 the initial entry and the indices between
834 The initial entry is used in ELF extensions for
839 in other cases, each field in the initial entry is set to zero.
840 An object file does not have sections for
841 these special indices:
844 This value marks an undefined, missing, irrelevant,
845 or otherwise meaningless section reference.
848 This value specifies the lower bound of the range of reserved indices.
850 .BR SHN_LOPROC ", " SHN_HIPROC
851 Values greater in the inclusive range
852 .RB [ SHN_LOPROC ", " SHN_HIPROC ]
853 are reserved for processor-specific semantics.
856 This value specifies the absolute value for the corresponding reference.
858 example, a symbol defined relative to section number
860 has an absolute value and is not affected by relocation.
863 Symbols defined relative to this section are common symbols,
864 such as FORTRAN COMMON or unallocated C external variables.
867 This value specifies the upper bound of the range of reserved indices.
869 system reserves indices between
874 The section header table does not contain entries for the
877 The section header has the following structure:
890 uint32_t sh_addralign;
907 uint64_t sh_addralign;
913 No real differences exist between the 32-bit and 64-bit section headers.
916 This member specifies the name of the section.
917 Its value is an index
918 into the section header string table section, giving the location of
919 a null-terminated string.
922 This member categorizes the section's contents and semantics.
926 This value marks the section header as inactive.
928 have an associated section.
929 Other members of the section header
930 have undefined values.
933 This section holds information defined by the program, whose
934 format and meaning are determined solely by the program.
937 This section holds a symbol table.
940 provides symbols for link editing, though it may also be used
942 As a complete symbol table, it may contain
943 many symbols unnecessary for dynamic linking.
950 This section holds a string table.
951 An object file may have multiple
952 string table sections.
955 This section holds relocation entries with explicit addends, such
958 for the 32-bit class of object files.
959 An object may have multiple
963 This section holds a symbol hash table.
964 An object participating in
965 dynamic linking must contain a symbol hash table.
967 have only one hash table.
970 This section holds information for dynamic linking.
972 have only one dynamic section.
975 This section holds notes (ElfN_Nhdr).
978 A section of this type occupies no space in the file but otherwise
981 Although this section contains no bytes, the
983 member contains the conceptual file offset.
986 This section holds relocation offsets without explicit addends, such
989 for the 32-bit class of object files.
990 An object file may have multiple
994 This section is reserved but has unspecified semantics.
997 This section holds a minimal set of dynamic linking symbols.
999 object file can also contain a
1003 .BR SHT_LOPROC ", " SHT_HIPROC
1004 Values in the inclusive range
1005 .RB [ SHT_LOPROC ", " SHT_HIPROC ]
1006 are reserved for processor-specific semantics.
1009 This value specifies the lower bound of the range of indices reserved for
1010 application programs.
1013 This value specifies the upper bound of the range of indices reserved for
1014 application programs.
1015 Section types between
1019 may be used by the application, without conflicting with current or future
1020 system-defined section types.
1024 Sections support one-bit flags that describe miscellaneous attributes.
1025 If a flag bit is set in
1030 Otherwise, the attribute is
1033 Undefined attributes are set to zero.
1037 This section contains data that should be writable during process
1041 This section occupies memory during process execution.
1043 sections do not reside in the memory image of an object file.
1045 attribute is off for those sections.
1048 This section contains executable machine instructions.
1051 All bits included in this mask are reserved for processor-specific
1056 If this section appears in the memory image of a process, this member
1057 holds the address at which the section's first byte should reside.
1058 Otherwise, the member contains zero.
1061 This member's value holds the byte offset from the beginning of the file
1062 to the first byte in the section.
1065 occupies no space in the file, and its
1067 member locates the conceptual placement in the file.
1070 This member holds the section's size in bytes.
1071 Unless the section type
1074 the section occupies
1079 may have a nonzero size, but it occupies no space in the file.
1082 This member holds a section header table index link, whose interpretation
1083 depends on the section type.
1086 This member holds extra information, whose interpretation depends on the
1090 Some sections have address alignment constraints.
1091 If a section holds a
1092 doubleword, the system must ensure doubleword alignment for the entire
1094 That is, the value of
1096 must be congruent to zero, modulo the value of
1098 Only zero and positive integral powers of two are allowed.
1099 The value 0 or 1 means that the section has no alignment constraints.
1102 Some sections hold a table of fixed-sized entries, such as a symbol table.
1103 For such a section, this member gives the size in bytes for each entry.
1104 This member contains zero if the section does not hold a table of
1107 Various sections hold program and control information:
1110 This section holds uninitialized data that contributes to the program's
1112 By definition, the system initializes the data with zeros
1113 when the program begins to run.
1114 This section is of type
1116 The attribute types are
1122 This section holds version control information.
1123 This section is of type
1125 No attribute types are used.
1128 This section holds initialized pointers to the C++ constructor functions.
1129 This section is of type
1131 The attribute types are
1137 This section holds initialized data that contribute to the program's
1139 This section is of type
1141 The attribute types are
1147 This section holds initialized data that contribute to the program's
1149 This section is of type
1151 The attribute types are
1157 This section holds information for symbolic debugging.
1160 This section is of type
1162 No attribute types are used.
1165 This section holds initialized pointers to the C++ destructor functions.
1166 This section is of type
1168 The attribute types are
1174 This section holds dynamic linking information.
1175 The section's attributes
1181 bit is set is processor-specific.
1182 This section is of type
1184 See the attributes above.
1187 This section holds strings needed for dynamic linking, most commonly
1188 the strings that represent the names associated with symbol table entries.
1189 This section is of type
1191 The attribute type used is
1195 This section holds the dynamic linking symbol table.
1196 This section is of type
1198 The attribute used is
1202 This section holds executable instructions that contribute to the process
1204 When a program exits normally the system arranges to
1205 execute the code in this section.
1206 This section is of type
1208 The attributes used are
1214 This section holds the version symbol table, an array of
1217 This section is of type
1218 .BR SHT_GNU_versym .
1219 The attribute type used is
1223 This section holds the version symbol definitions, a table of
1226 This section is of type
1227 .BR SHT_GNU_verdef .
1228 The attribute type used is
1232 This section holds the version symbol needed elements, a table of
1237 .BR SHT_GNU_versym .
1238 The attribute type used is
1242 This section holds the global offset table.
1243 This section is of type
1245 The attributes are processor-specific.
1248 This section holds a symbol hash table.
1249 This section is of type
1251 The attribute used is
1255 This section holds executable instructions that contribute to the process
1256 initialization code.
1257 When a program starts to run the system arranges to execute
1258 the code in this section before calling the main program entry point.
1259 This section is of type
1261 The attributes used are
1267 This section holds the pathname of a program interpreter.
1269 a loadable segment that includes the section, the section's attributes will
1273 Otherwise, that bit will be off.
1274 This section is of type
1278 This section holds line number information for symbolic debugging,
1279 which describes the correspondence between the program source and
1281 The contents are unspecified.
1282 This section is of type
1284 No attribute types are used.
1287 This section holds various notes.
1288 This section is of type
1290 No attribute types are used.
1293 This section is used to declare the expected run-time ABI of the ELF image.
1294 It may include the operating system name and its run-time versions.
1295 This section is of type
1297 The only attribute used is
1300 .IR .note.gnu.build\-id
1301 This section is used to hold an ID that uniquely identifies
1302 the contents of the ELF image.
1303 Different files with the same build ID should contain the same executable
1307 option to the GNU linker (\fBld\fR (1)) for more details.
1308 This section is of type
1310 The only attribute used is
1313 .IR .note.GNU\-stack
1314 This section is used in Linux object files for declaring stack attributes.
1315 This section is of type
1317 The only attribute used is
1319 This indicates to the GNU linker that the object file requires an
1322 .IR .note.openbsd.ident
1323 OpenBSD native executables usually contain this section
1324 to identify themselves so the kernel can bypass any compatibility
1325 ELF binary emulation tests when loading the file.
1328 This section holds the procedure linkage table.
1329 This section is of type
1331 The attributes are processor-specific.
1334 This section holds relocation information as described below.
1336 has a loadable segment that includes relocation, the section's attributes
1340 Otherwise, the bit will be off.
1343 is supplied by the section to which the relocations apply.
1347 normally would have the name
1349 This section is of type
1353 This section holds relocation information as described below.
1355 has a loadable segment that includes relocation, the section's attributes
1359 Otherwise, the bit will be off.
1362 is supplied by the section to which the relocations apply.
1366 normally would have the name
1368 This section is of type
1372 This section holds read-only data that typically contributes to a
1373 nonwritable segment in the process image.
1374 This section is of type
1376 The attribute used is
1380 This section holds read-only data that typically contributes to a
1381 nonwritable segment in the process image.
1382 This section is of type
1384 The attribute used is
1388 This section holds section names.
1389 This section is of type
1391 No attribute types are used.
1394 This section holds strings, most commonly the strings that represent the
1395 names associated with symbol table entries.
1396 If the file has a loadable
1397 segment that includes the symbol string table, the section's attributes
1401 Otherwise, the bit will be off.
1402 This section is of type
1406 This section holds a symbol table.
1407 If the file has a loadable segment
1408 that includes the symbol table, the section's attributes will include
1412 Otherwise, the bit will be off.
1413 This section is of type
1417 This section holds the
1419 or executable instructions, of a program.
1420 This section is of type
1422 The attributes used are
1427 .SS String and symbol tables
1428 String table sections hold null-terminated character sequences, commonly
1430 The object file uses these strings to represent symbol
1432 One references a string as an index into the string
1434 The first byte, which is index zero, is defined to hold
1435 a null byte (\(aq\e0\(aq).
1436 Similarly, a string table's last byte is defined to
1437 hold a null byte, ensuring null termination for all strings.
1439 An object file's symbol table holds information needed to locate and
1440 relocate a program's symbolic definitions and references.
1442 index is a subscript into this array.
1448 Elf32_Addr st_value;
1450 unsigned char st_info;
1451 unsigned char st_other;
1461 unsigned char st_info;
1462 unsigned char st_other;
1464 Elf64_Addr st_value;
1470 The 32-bit and 64-bit versions have the same members, just in a different
1474 This member holds an index into the object file's symbol string table,
1475 which holds character representations of the symbol names.
1477 is nonzero, it represents a string table index that gives the symbol
1479 Otherwise, the symbol has no name.
1482 This member gives the value of the associated symbol.
1485 Many symbols have associated sizes.
1486 This member holds zero if the symbol
1487 has no size or an unknown size.
1490 This member specifies the symbol's type and binding attributes:
1494 The symbol's type is not defined.
1497 The symbol is associated with a data object.
1500 The symbol is associated with a function or other executable code.
1503 The symbol is associated with a section.
1504 Symbol table entries of
1505 this type exist primarily for relocation and normally have
1510 By convention, the symbol's name gives the name of the source file
1511 associated with the object file.
1514 bindings, its section index is
1516 and it precedes the other
1518 symbols of the file, if it is present.
1520 .BR STT_LOPROC ", " STT_HIPROC
1521 Values in the inclusive range
1522 .RB [ STT_LOPROC ", " STT_HIPROC ]
1523 are reserved for processor-specific semantics.
1526 Local symbols are not visible outside the object file containing their
1528 Local symbols of the same name may exist in multiple files
1529 without interfering with each other.
1532 Global symbols are visible to all object files being combined.
1534 definition of a global symbol will satisfy another file's undefined
1535 reference to the same symbol.
1538 Weak symbols resemble global symbols, but their definitions have lower
1541 .BR STB_LOPROC ", " STB_HIPROC
1542 Values in the inclusive range
1543 .RB [ STB_LOPROC ", " STB_HIPROC ]
1544 are reserved for processor-specific semantics.
1547 There are macros for packing and unpacking the binding and type fields:
1550 .BR ELF32_ST_BIND( \fIinfo\fP ) ", " ELF64_ST_BIND( \fIinfo\fP )
1551 Extract a binding from an
1555 .BR ELF32_ST_TYPE( \fIinfo ) ", " ELF64_ST_TYPE( \fIinfo\fP )
1556 Extract a type from an
1560 .BR ELF32_ST_INFO( \fIbind\fP ", " \fItype\fP ) ", " \
1561 ELF64_ST_INFO( \fIbind\fP ", " \fItype\fP )
1562 Convert a binding and a type into an
1568 This member defines the symbol visibility.
1573 Default symbol visibility rules.
1574 Global and weak symbols are available to other modules;
1575 references in the local module can be interposed
1576 by definitions in other modules.
1579 Processor-specific hidden class.
1582 Symbol is unavailable to other modules;
1583 references in the local module always resolve to the local symbol
1584 (i.e., the symbol can't be interposed by definitions in other modules).
1587 Symbol is available to other modules,
1588 but references in the local module always resolve to the local symbol.
1591 There are macros for extracting the visibility type:
1593 .BR ELF32_ST_VISIBILITY (other)
1595 .BR ELF64_ST_VISIBILITY (other)
1599 Every symbol table entry is
1601 in relation to some section.
1602 This member holds the relevant section
1605 .SS Relocation entries (Rel & Rela)
1606 Relocation is the process of connecting symbolic references with
1607 symbolic definitions.
1608 Relocatable files must have information that
1609 describes how to modify their section contents, thus allowing executable
1610 and shared object files to hold the right information for a process's
1612 Relocation entries are these data.
1614 Relocation structures that do not need an addend:
1619 Elf32_Addr r_offset;
1628 Elf64_Addr r_offset;
1634 Relocation structures that need an addend:
1639 Elf32_Addr r_offset;
1649 Elf64_Addr r_offset;
1657 This member gives the location at which to apply the relocation action.
1658 For a relocatable file, the value is the byte offset from the beginning
1659 of the section to the storage unit affected by the relocation.
1661 executable file or shared object, the value is the virtual address of
1662 the storage unit affected by the relocation.
1665 This member gives both the symbol table index with respect to which the
1666 relocation must be made and the type of relocation to apply.
1668 types are processor-specific.
1669 When the text refers to a relocation
1670 entry's relocation type or symbol table index, it means the result of
1672 .BR ELF[32|64]_R_TYPE
1674 .BR ELF[32|64]_R_SYM ,
1675 respectively, to the entry's
1680 This member specifies a constant addend used to compute the value to be
1681 stored into the relocatable field.
1683 .SS Dynamic tags (Dyn)
1686 section contains a series of structures that hold relevant
1687 dynamic linking information.
1690 member controls the interpretation
1703 extern Elf32_Dyn _DYNAMIC[];
1716 extern Elf64_Dyn _DYNAMIC[];
1721 This member may have any of the following values:
1725 Marks end of dynamic section
1728 String table offset to name of a needed library
1731 Size in bytes of PLT relocation entries
1734 Address of PLT and/or GOT
1737 Address of symbol hash table
1740 Address of string table
1743 Address of symbol table
1746 Address of Rela relocation table
1749 Size in bytes of the Rela relocation table
1752 Size in bytes of a Rela relocation table entry
1755 Size in bytes of string table
1758 Size in bytes of a symbol table entry
1761 Address of the initialization function
1764 Address of the termination function
1767 String table offset to name of shared object
1770 String table offset to library search path (deprecated)
1773 Alert linker to search this shared object before the executable for symbols
1776 Address of Rel relocation table
1779 Size in bytes of Rel relocation table
1782 Size in bytes of a Rel table entry
1785 Type of relocation entry to which the PLT refers (Rela or Rel)
1788 Undefined use for debugging
1791 Absence of this entry indicates that no relocation entries should
1792 apply to a nonwritable segment
1795 Address of relocation entries associated solely with the PLT
1798 Instruct dynamic linker to process all relocations before
1799 transferring control to the executable
1802 String table offset to library search path
1804 .BR DT_LOPROC ", " DT_HIPROC
1805 Values in the inclusive range
1806 .RB [ DT_LOPROC ", " DT_HIPROC ]
1807 are reserved for processor-specific semantics
1811 This member represents integer values with various interpretations.
1814 This member represents program virtual addresses.
1816 these addresses, the actual address should be computed based on the
1817 original file value and memory base address.
1818 Files do not contain
1819 relocation entries to fixup these addresses.
1822 Array containing all the dynamic structures in the
1825 This is automatically populated by the linker.
1826 .\" GABI ELF Reference for Note Sections:
1827 .\" http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section
1829 .\" Note that it implies the sizes and alignments of notes depend on the ELF
1830 .\" size (e.g. 32-bit ELFs have three 4-byte words and use 4-byte alignment
1831 .\" while 64-bit ELFs use 8-byte words & alignment), but that is not the case
1832 .\" in the real world. Notes always have three 4-byte words as can be seen
1833 .\" in the source links below (remember that Elf64_Word is a 32-bit quantity).
1834 .\" glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/elf.h;h=9e59b3275917549af0cebe1f2de9ded3b7b10bf2#l1173
1835 .\" binutils: https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/readelf.c;h=274ddd17266aef6e4ad1f67af8a13a21500ff2af#l15943
1836 .\" Linux: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/elf.h?h=v4.8#n422
1837 .\" Solaris: https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html
1838 .\" FreeBSD: https://svnweb.freebsd.org/base/head/sys/sys/elf_common.h?revision=303677&view=markup#l33
1839 .\" NetBSD: https://www.netbsd.org/docs/kernel/elf-notes.html
1840 .\" OpenBSD: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h#L533
1843 ELF notes allow for appending arbitrary information for the system to use.
1844 They are largely used by core files
1848 but many projects define their own set of extensions.
1850 the GNU tool chain uses ELF notes to pass information from
1851 the linker to the C library.
1853 Note sections contain a series of notes (see the
1856 Each note is followed by the name field (whose length is defined in
1857 \fIn_namesz\fR) and then by the descriptor field (whose length is defined in
1858 \fIn_descsz\fR) and whose starting address has a 4 byte alignment.
1859 Neither field is defined in the note struct due to their arbitrary lengths.
1861 An example for parsing out two consecutive notes should clarify their layout
1866 void *memory, *name, *desc;
1867 Elf64_Nhdr *note, *next_note;
1869 /* The buffer is pointing to the start of the section/segment. */
1872 /* If the name is defined, it follows the note. */
1873 name = note\->n_namesz == 0 ? NULL : memory + sizeof(*note);
1875 /* If the descriptor is defined, it follows the name
1876 (with alignment). */
1878 desc = note\->n_descsz == 0 ? NULL :
1879 memory + sizeof(*note) + ALIGN_UP(note\->n_namesz, 4);
1881 /* The next note follows both (with alignment). */
1882 next_note = memory + sizeof(*note) +
1883 ALIGN_UP(note\->n_namesz, 4) +
1884 ALIGN_UP(note\->n_descsz, 4);
1888 Keep in mind that the interpretation of
1890 depends on the namespace defined by the
1895 field is not set (e.g., is 0), then there are two sets of notes:
1896 one for core files and one for all other ELF types.
1897 If the namespace is unknown, then tools will usually fallback to these sets
1903 Elf32_Word n_namesz;
1904 Elf32_Word n_descsz;
1913 Elf64_Word n_namesz;
1914 Elf64_Word n_descsz;
1921 The length of the name field in bytes.
1922 The contents will immediately follow this note in memory.
1923 The name is null terminated.
1924 For example, if the name is "GNU", then
1929 The length of the descriptor field in bytes.
1930 The contents will immediately follow the name field in memory.
1933 Depending on the value of the name field, this member may have any of the
1937 .B Core files (e_type = ET_CORE)
1938 Notes used by all core files.
1939 These are highly operating system or architecture specific and often require
1940 close coordination with kernels, C libraries, and debuggers.
1941 These are used when the namespace is the default (i.e.,
1943 will be set to 0), or a fallback when the namespace is unknown.
1963 String from sysinfo(SI_PLATFORM)
1996 siginfo_t (size might increase over time)
1999 Contains information about mapped files
2005 PowerPC Altivec/VMX registers
2008 PowerPC SPE/EVR registers
2011 PowerPC VSX registers
2014 i386 TLS slots (struct user_desc)
2017 x86 io permission bitmap (1=deny)
2020 x86 extended state using xsave
2022 .B NT_S390_HIGH_GPRS
2023 s390 upper register halves
2029 s390 time-of-day (TOD) clock comparator register
2032 s390 time-of-day (TOD) programmable register
2035 s390 control registers
2038 s390 prefix register
2040 .B NT_S390_LAST_BREAK
2041 s390 breaking event address
2043 .B NT_S390_SYSTEM_CALL
2044 s390 system call restart data
2047 s390 transaction diagnostic block
2050 ARM VFP/NEON registers
2056 ARM hardware breakpoint registers
2059 ARM hardware watchpoint registers
2061 .B NT_ARM_SYSTEM_CALL
2062 ARM system call number
2067 Extensions used by the GNU tool chain.
2071 Operating system (OS) ABI information.
2072 The desc field will be 4 words:
2077 word 0: OS descriptor
2078 (\fBELF_NOTE_OS_LINUX\fR, \fBELF_NOTE_OS_GNU\fR, and so on)`
2080 word 1: major version of the ABI
2082 word 2: minor version of the ABI
2084 word 3: subminor version of the ABI
2089 Synthetic hwcap information.
2090 The desc field begins with two words:
2095 word 0: number of entries
2097 word 1: bit mask of enabled entries
2101 Then follow variable-length entries, one byte followed by a null-terminated
2103 The byte gives the bit number to test if enabled, (1U << bit) & bit mask.
2106 Unique build ID as generated by the GNU
2110 The desc consists of any nonzero number of bytes.
2112 .B NT_GNU_GOLD_VERSION
2113 The desc contains the GNU Gold linker version used.
2116 .B Default/unknown namespace (e_type != ET_CORE)
2117 These are used when the namespace is the default (i.e.,
2119 will be set to 0), or a fallback when the namespace is unknown.
2124 A version string of some sort.
2127 Architecture information.
2133 .\" ELF support first appeared in
2135 .\" although not all supported platforms use it as the native
2136 .\" binary file format.
2137 ELF first appeared in
2139 The ELF format is an adopted standard.
2148 Sun, BSD, and AMD64 also support them; for further information,
2149 look under SEE ALSO.
2151 .\" The original version of this manual page was written by
2152 .\" .An Jeroen Ruigrok van der Werven
2153 .\" .Aq asmodai@FreeBSD.org
2154 .\" with inspiration from BSDi's
2172 .BR dl_iterate_phdr (3),
2177 .IR "Elf-64 Object File Format" .
2179 Santa Cruz Operation,
2180 .IR "System V Application Binary Interface" .
2182 UNIX System Laboratories,
2184 .IR "Executable and Linking Format (ELF)" .
2187 .IR "Linker and Libraries Guide" .
2190 .IR "System V Application Binary Interface AMD64 Architecture Processor Supplement" .