Executable and Linkable Format: Difference between revisions
Undid revision 1319841712 by 46.213.91.211 (talk) — replaced infobox with irrelevant link |
imported>Rofraja m Replaced 0 bare URLs by {{Cite web}}; Replaced "Archived copy" by actual titles |
||
| (2 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
{{Short description|Standard file format for executables, object code, shared libraries, and core dumps}} | {{Short description|Standard file format for executables, object code, shared libraries, and core dumps}} | ||
{{Infobox file format | {{Infobox file format | ||
| name = Executable and Linkable Format | | name = Executable and Linkable Format | ||
| icon = | | icon = | ||
| extension = none, {{Mono|.axf}}, {{Mono|.bin}}, {{Mono|.elf}}, {{Mono|.o}}, {{Mono|.out}}, {{Mono|.prx}}, {{Mono|.puff}}, {{Mono|.ko}}, {{Mono|.mod}}, and {{Mono|.so}} | | extension = none, {{Mono|.axf}}, {{Mono|.bin}}, {{Mono|.elf}}, {{Mono|.o}}, {{Mono|.out}}, {{Mono|.prx}}, {{Mono|.puff}}, {{Mono|.ko}}, {{Mono|.mod}}, {{Mono|.AppImage}} and {{Mono|.so}} | ||
| mime = | | mime = | ||
| magic = <code>0x7F 'E' 'L' 'F'</code> | | magic = <code>0x7F 'E' 'L' 'F'</code> | ||
| developer = [[Unix System Laboratories]]<ref name="linuxbase-elf" />{{rp|3}} | | developer = [[Unix System Laboratories]]<ref name="linuxbase-elf" />{{rp|3}} | ||
| type = [[Binary file|Binary]], [[executable]], [[object code|object]], [[Library (computing)|shared library]], [[core dump]] | | type = [[Binary file|Binary]], [[executable]], [[object code|object]], [[Library (computing)|shared library]], [[core dump]] | ||
| container_for = Many executable binary formats | | container_for = Many executable binary formats | ||
| released = {{start date and age|1998|05|14|df=yes}} | | released = {{start date and age|1998|05|14|df=yes}} | ||
| latest_release_version = 4.2 <ref>[https://gabi.xinuos.com/elf/c-history.html ELF Object File Format: Appendix C: Revision History]</ref> | | latest_release_version = 4.2 <ref>[https://gabi.xinuos.com/elf/c-history.html ELF Object File Format: Appendix C: Revision History]</ref> | ||
| latest_release_date = {{start date and age|2025|df=yes}} | | latest_release_date = {{start date and age|2025|df=yes}} | ||
}} | }} | ||
| Line 328: | Line 326: | ||
=== Example hexdump === | === Example hexdump === | ||
<syntaxhighlight lang="hexdump">00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............| | <syntaxhighlight lang="hexdump">00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............| | ||
00000010 02 00 3e 00 01 00 00 00 c5 48 40 00 00 00 00 00 |..>......H@.....|</syntaxhighlight> | 00000010 02 00 3e 00 01 00 00 00 c5 48 40 00 00 00 00 00 |..>......H@.....|</syntaxhighlight> | ||
| Line 666: | Line 665: | ||
It has replaced [[a.out]] and [[COFF]] formats in [[Unix-like]] operating systems: | It has replaced [[a.out]] and [[COFF]] formats in [[Unix-like]] operating systems: | ||
* [[Linux]] | * [[Linux]] | ||
* [[Solaris | * [[Oracle Solaris|Solaris]] / [[Illumos]] | ||
* [[IRIX]] | * [[IRIX]] | ||
* [[FreeBSD]]<ref>{{Cite web | url=https://docs.freebsd.org/doc/4.9-RELEASE/usr/share/doc/handbook/binary-formats.html | title=Binary Formats | access-date=2019-03-31 | archive-date=2019-03-31 | archive-url=https://web.archive.org/web/20190331192807/https://docs.freebsd.org/doc/4.9-RELEASE/usr/share/doc/handbook/binary-formats.html | url-status=dead }}</ref> | * [[FreeBSD]]<ref>{{Cite web | url=https://docs.freebsd.org/doc/4.9-RELEASE/usr/share/doc/handbook/binary-formats.html | title=Binary Formats | access-date=2019-03-31 | archive-date=2019-03-31 | archive-url=https://web.archive.org/web/20190331192807/https://docs.freebsd.org/doc/4.9-RELEASE/usr/share/doc/handbook/binary-formats.html | url-status=dead }}</ref> | ||
| Line 673: | Line 672: | ||
* [[Redox (operating system)|Redox]] | * [[Redox (operating system)|Redox]] | ||
* [[DragonFly BSD]] | * [[DragonFly BSD]] | ||
* [[Syllable Desktop | * [[Syllable Desktop|Syllable]] | ||
* [[HP-UX]] (except for 32-bit PA-RISC programs which continue to use [[System Object Model (file format)|SOM]]) | * [[HP-UX]] (except for 32-bit PA-RISC programs which continue to use [[System Object Model (file format)|SOM]]) | ||
* [[QNX]] Neutrino | * [[QNX]] Neutrino | ||
| Line 681: | Line 680: | ||
ELF has also seen some adoption in non-Unix operating systems, such as: | ELF has also seen some adoption in non-Unix operating systems, such as: | ||
* [[OpenVMS]], in its [[Itanium]] and [[amd64]] versions<ref>{{Cite web |url=https://vmssoftware.com/pdfs/State_of_Port_20160906.pdf |title= | * [[OpenVMS]], in its [[Itanium]] and [[amd64]] versions<ref>{{Cite web| url=https://vmssoftware.com/pdfs/State_of_Port_20160906.pdf | title=State of the Port to x86_64 | access-date=2016-10-19 | archive-date=2020-09-15 | archive-url=https://web.archive.org/web/20200915215111/https://vmssoftware.com/pdfs/State_of_Port_20160906.pdf | url-status=dead}}</ref> | ||
* [[BeOS]] Revision 4 and later for [[x86]] based computers (where it replaced the [[Portable Executable]] format; the [[PowerPC]] version stayed with [[Preferred Executable Format]]) | * [[BeOS]] Revision 4 and later for [[x86]] based computers (where it replaced the [[Portable Executable]] format; the [[PowerPC]] version stayed with [[Preferred Executable Format]]) | ||
* [[Haiku (operating system)|Haiku]], an open source reimplementation of BeOS | * [[Haiku (operating system)|Haiku]], an open source reimplementation of BeOS | ||
| Line 689: | Line 688: | ||
* [[Fuchsia OS]] | * [[Fuchsia OS]] | ||
* [[Z/TPF]] | * [[Z/TPF]] | ||
* [[NonStop (server computers)|HPE NonStop OS]]<ref>{{cite web |url=http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c02543407-12.pdf |archive-url=https://web.archive.org/web/20180530042640/http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c02543407-12.pdf |url-status=dead |archive-date=2018-05-30 |title=Guardian Programmer's Guide |publisher=Hewlett Packard Enterprise |access-date=2018-05-30 }} p. 44 archived from [http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c02543407-12.pdf the original] on 2018-5-30</ref> | * [[NonStop (server computers)|HPE NonStop OS]]<ref>{{cite web |url=http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c02543407-12.pdf |archive-url=https://web.archive.org/web/20180530042640/http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c02543407-12.pdf |url-status=dead |archive-date=2018-05-30 |title=Guardian Programmer's Guide |publisher=Hewlett Packard Enterprise |access-date=2018-05-30 }} p. 44 archived from [http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c02543407-12.pdf the original] {{Webarchive|url=https://web.archive.org/web/20180530042640/http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c02543407-12.pdf |date=2018-05-30 }} on 2018-5-30</ref> | ||
* [[DDC-I|Deos]] | * [[DDC-I|Deos]] | ||
| Line 697: | Line 696: | ||
Some game consoles also use ELF: | Some game consoles also use ELF: | ||
* PlayStation Portable,<ref>PlayStation Portable use encrypted & relocated ELF : PSP</ref> PlayStation Vita, PlayStation, PlayStation 2, PlayStation 3, PlayStation 4, PlayStation 5 | * [[PlayStation Portable]],<ref>PlayStation Portable use encrypted & relocated ELF : PSP</ref> [[PlayStation Vita]], [[PlayStation (console)|PlayStation]], PlayStation 2, PlayStation 3, PlayStation 4, PlayStation 5 | ||
* GP2X | * [[GP2X]] | ||
* Dreamcast | * [[Dreamcast]] | ||
* GameCube | * [[GameCube]] | ||
* Nintendo 64 | * [[Nintendo 64]] | ||
* Wii | * [[Wii]] | ||
* Wii U | * [[Wii U]] | ||
=== PowerPC === | === PowerPC === | ||
Other (operating) systems running on PowerPC that use ELF: | Other (operating) systems running on PowerPC that use ELF: | ||
* AmigaOS 4, the ELF executable has replaced the prior [[Extended Hunk Format]] (EHF) which was used on Amigas equipped with PPC processor expansion cards. | * [[AmigaOS 4]], the ELF executable has replaced the prior [[Extended Hunk Format]] (EHF) which was used on Amigas equipped with PPC processor expansion cards. | ||
* MorphOS | * [[MorphOS]] | ||
* AROS | * [[AROS]] | ||
* Café OS (The operating system run by the Wii U) | * [[Café OS]] (The operating system run by the Wii U) | ||
=== Mobile phones === | === Mobile phones === | ||
Some operating systems for mobile phones and mobile devices use ELF: | Some operating systems for mobile phones and mobile devices use ELF: | ||
* Symbian OS v9 uses E32Image<ref>''[https://web.archive.org/web/20091213034509/http://wiki.forum.nokia.com/index.php/E32Image Symbian OS executable file format]''</ref> format that is based on the ELF file format; | * [[Symbian OS]] v9 uses E32Image<ref>''[https://web.archive.org/web/20091213034509/http://wiki.forum.nokia.com/index.php/E32Image Symbian OS executable file format]''</ref> format that is based on the ELF file format; | ||
* Sony Ericsson, for example, the W800i, W610, W300, etc. | * [[Sony Ericsson]], for example, the [[W800i]], W610, [[W300]], etc. | ||
* Siemens, the SGOLD and SGOLD2 platforms: from Siemens C65 to S75 and BenQ-Siemens E71/EL71; | * [[Siemens]], the SGOLD and SGOLD2 platforms: from [[Siemens C65]] to S75 and [[BenQ-Siemens EL71|BenQ-Siemens E71/EL71]]; | ||
* Motorola, for example, the E398, SLVR L7, v360, v3i (and all phone LTE2 which has the patch applied). | * [[Motorola]], for example, the E398, SLVR L7, [[Motorola V360|v360]], v3i (and all phone LTE2 which has the patch applied). | ||
* Bada, for example, the Samsung Wave S8500. | * [[Bada (operating system)|Bada]], for example, the [[Samsung Wave S8500]]. | ||
* Nokia phones or tablets running the Maemo or the Meego OS, for example, the Nokia N900. | * [[Nokia]] phones or tablets running the [[Maemo]] or the [[MeeGo|Meego OS]], for example, the Nokia N900. | ||
* [[Android (operating system)|Android]] uses ELF {{mono|.so}} (shared object<ref> | * [[Android (operating system)|Android]] uses ELF {{mono|.so}} (shared object<ref> | ||
{{cite book | {{cite book | ||
| Line 758: | Line 757: | ||
=== Blockchain platforms === | === Blockchain platforms === | ||
* Solana uses ELF format for its on-chain programs (smart contracts). The platform processes ELF files compiled to BPF (Berkeley Packet Filter) byte-code, which are then deployed as shared objects and executed in Solana's runtime environment. The BPF loader validates and processes these ELF files during program deployment.<ref>{{Cite web | * [[Solana (blockchain platform)|Solana]] uses ELF format for its on-chain programs ([[smart contracts]]). The platform processes ELF files compiled to [[Berkeley Packet Filter|BPF]] (Berkeley Packet Filter) byte-code, which are then deployed as shared objects and executed in Solana's runtime environment. The BPF loader validates and processes these ELF files during program deployment.<ref>{{Cite web | ||
| url = https://solana.com/docs/core/programs | | url = https://solana.com/docs/core/programs | ||
| title = Solana Programs | | title = Solana Programs | ||
| Line 766: | Line 765: | ||
| quote = Solana leverages the LLVM compiler infrastructure to compile programs into Executable and Linkable Format (ELF) files.}} | | quote = Solana leverages the LLVM compiler infrastructure to compile programs into Executable and Linkable Format (ELF) files.}} | ||
</ref> | </ref> | ||
== Specifications == | |||
{| class="wikitable" | |||
! Architecture || Specification | |||
|- | |||
| Generic || | |||
* ''[http://www.sco.com/developers/devspecs/gabi41.pdf System V Application Binary Interface]'' Edition 4.1 (1997-03-18) | |||
* ''[http://www.sco.com/developers/gabi/latest/contents.html System V ABI Update]'' (October 2009) | |||
|- | |||
| [[AMD64]] || | |||
* ''[http://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf System V ABI, AMD64 Supplement]'' | |||
|- | |||
| [[ARM architecture family|Arm]] || | |||
* ''[https://github.com/ARM-software/abi-aa/releases/download/2022Q1/aaelf32.pdf ELF for the ARM Architecture]'' | |||
|- | |||
| [[IA-32]] || | |||
* ''[http://www.sco.com/developers/devspecs/abi386-4.pdf System V ABI, Intel386 Architecture Processor Supplement]'' | |||
|- | |||
| [[IA-64]] || | |||
* ''[http://refspecs.linux-foundation.org/IA64conventions.pdf Itanium Software Conventions and Runtime Guide]'' (September 2000) | |||
|- | |||
| [[M32R]] || | |||
* ''[http://www.linux-m32r.org/cmn/m32r/M32R-elf-abi.pdf M32R ELF ABI Supplement] {{Webarchive|url=https://web.archive.org/web/20220512145623/http://www.linux-m32r.org/cmn/m32r/M32R-elf-abi.pdf |date=2022-05-12 }}'' Version 1.2 (2004-08-26) | |||
|- | |||
| [[MIPS architecture|MIPS]] || | |||
* ''[http://www.sco.com/developers/devspecs/mipsabi.pdf System V ABI, MIPS RISC Processor Supplement]'' | |||
* ''[http://sources.redhat.com/ml/binutils/2003-06/msg00436.html MIPS EABI documentation] {{Webarchive|url=https://web.archive.org/web/20120401235051/http://sources.redhat.com/ml/binutils/2003-06/msg00436.html |date=2012-04-01 }}'' (2003-06-11) | |||
|- | |||
| [[Motorola 6800]] || | |||
* ''[http://uclibc.org/docs/psABI-m8-16.pdf Motorola 8- and 16- bit Embedded ABI]'' | |||
|- | |||
| [[PA-RISC]] || | |||
* ''[https://web.archive.org/web/20110317045038/http://refspecs.freestandards.org/elf/elf-pa.pdf ELF Supplement for PA-RISC]'' Version 1.43 (October 6, 1997) | |||
|- | |||
| [[PowerPC]] || | |||
* ''[https://web.archive.org/web/20070630123210/http://refspecs.freestandards.org/elf/elfspec_ppc.pdf System V ABI, PPC Supplement]'' | |||
* ''[https://web.archive.org/web/20110723003758/http://sources-redhat.mirrors.airband.net/binutils/ppc-docs/ppc-eabi-1995-01.pdf PowerPC Embedded Application Binary Interface] 32-Bit Implementation'' (1995-10-01) | |||
* ''[http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html 64-bit PowerPC ELF Application Binary Interface Supplement]'' Version 1.9 (2004) | |||
|- | |||
| [[RISC-V]] || | |||
* ''[https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc RISC-V ELF Specification]'' | |||
|- | |||
| [[SPARC]] || | |||
* ''[https://web.archive.org/web/20080517110249/http://www.sparc.org/standards/psABI3rd.pdf System V ABI, SPARC Supplement]'' | |||
|- | |||
| [[S/390]] || | |||
* ''[http://refspecs.linuxbase.org/ELF/zSeries/lzsabi0_s390.html S/390 32bit ELF ABI Supplement]'' | |||
|- | |||
| [[zSeries]] || | |||
* ''[http://refspecs.linuxbase.org/ELF/zSeries/lzsabi0_zSeries.html zSeries 64bit ELF ABI Supplement]'' | |||
|- | |||
| [[Symbian]] OS 9 || | |||
* ''[https://web.archive.org/web/20080518002831/http://wiki.forum.nokia.com/index.php/E32Image_file_format_on_Symbian_OS_9 E32Image file format on Symbian OS 9]'' | |||
|} | |||
The [[Linux Standard Base]] (LSB) supplements some of the above specifications for architectures in which it is specified.<ref>{{cite web|url=http://refspecs.linuxfoundation.org/lsb.shtml|title=LSB Referenced Specifications|website=linuxfoundation.org|access-date=27 April 2015}}</ref> For example, that is the case for the System V ABI, AMD64 Supplement.<ref>{{cite web|url=http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-AMD64/LSB-Core-AMD64/elf-amd64.html|title=Executable and Linking Format (ELF)|website=linuxfoundation.org|access-date=27 April 2015}}</ref><ref>{{cite web|url=http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-AMD64/LSB-Core-AMD64/elfintro.html|title=Introduction|website=linuxfoundation.org|access-date=27 April 2015}}</ref> | |||
== 86open == | == 86open == | ||
| Line 823: | Line 879: | ||
{{Div col|colwidth=30em}} | {{Div col|colwidth=30em}} | ||
* [https://maskray.me/blog/2024-05-26-evolution-of-elf-object-file-format Evolution of the ELF object file format], by Fangrui Song. | * [https://maskray.me/blog/2024-05-26-evolution-of-elf-object-file-format Evolution of the ELF object file format], by Fangrui Song. | ||
* {{cite book |author-last=Levine |author-first=John R. |author-link=John R. Levine |title=Linkers and Loaders |date=2000 |orig-year=October 1999 |edition=1 |publisher=[[Morgan Kaufmann]] |series=The Morgan Kaufmann Series in Software Engineering and Programming |location=San Francisco, USA |isbn=1-55860-496-0 |oclc=42413382 |url=https://www.iecc.com/linker/ |access-date=2020-01-12 |url-status=live |archive-url=https://archive.today/20121205032107/http://www.iecc.com/linker/ |archive-date=2012-12-05}} Code:<ref>https://archive.today/20200114225034/https://linker.iecc.com/code.html | * {{cite book |author-last=Levine |author-first=John R. |author-link=John R. Levine |title=Linkers and Loaders |date=2000 |orig-year=October 1999 |edition=1 |publisher=[[Morgan Kaufmann]] |series=The Morgan Kaufmann Series in Software Engineering and Programming |location=San Francisco, USA |isbn=1-55860-496-0 |oclc=42413382 |url=https://www.iecc.com/linker/ |access-date=2020-01-12 |url-status=live |archive-url=https://archive.today/20121205032107/http://www.iecc.com/linker/ |archive-date=2012-12-05}} Code:<ref>{{Cite web|url=https://linker.iecc.com/code.html|archive-url=https://archive.today/20200114225034/https://linker.iecc.com/code.html|title= Linkers and Loaders: Sample code |archive-date=2020-01-14|url-status=live}} </ref>[ftp://ftp.iecc.com/pub/linker/]{{dead link|date=May 2025|bot=medic}}{{cbignore|bot=medic}} Errata: [https://linker.iecc.com/<!-- https://archive.today/20200114224817/https://linker.iecc.com/ 2020-01-14 -->] | ||
* [[Ulrich Drepper]], How To Write Shared Libraries, Version 4.1.2 (2011). Published on the author's web page, https://www.akkadia.org/drepper. | * [[Ulrich Drepper]], How To Write Shared Libraries, Version 4.1.2 (2011). Published on the author's web page, https://www.akkadia.org/drepper. | ||
* ''[https://web.archive.org/web/20070224140341/http://www-128.ibm.com/developerworks/power/library/pa-spec12/ An unsung hero: The hardworking ELF]'' by Peter Seebach, December 20, 2005, archived from the original on February 24, 2007 | * ''[https://web.archive.org/web/20070224140341/http://www-128.ibm.com/developerworks/power/library/pa-spec12/ An unsung hero: The hardworking ELF]'' by Peter Seebach, December 20, 2005, archived from the original on February 24, 2007 | ||
Latest revision as of 19:08, 16 June 2026
Template:Short description Script error: No such module "Infobox".Script error: No such module "Check for unknown parameters".
In computing, the Executable and Linkable Format[1] (ELF, formerly named Extensible Linking Format) is a common standard file format for executable files, object code, shared libraries, device drivers, and core dumps. First published in the specification for the application binary interface (ABI) of the Unix operating system version named System V Release 4 (SVR4),[2] and later in the Tool Interface Standard,[3] it was quickly accepted among different vendors of Unix systems. In 1999, it was chosen as the standard binary file format for Unix and Unix-like systems on x86 processors by the 86open project.
By design, the ELF format is flexible, extensible, and cross-platform. For instance, it supports different endiannesses and address sizes so it does not exclude any particular CPU or instruction set architecture. This has allowed it to be adopted by many different operating systems on many different hardware platforms.
File layout
Each ELF file is made up of one ELF header, followed by file data. The data can include:
- Program header table, describing zero or more memory segments
- Section header table, describing zero or more sections
- Data referred to by entries in the program header table or section header table
The segments contain information that is needed for run time execution of the file, while sections contain important data for linking and relocation. Any byte in the entire file can be owned by one section at most, and orphan bytes can occur which are unowned by any section.
ELF header
The ELF header defines whether to use 32-bit or 64-bit addresses. The header contains three fields that are affected by this setting and offset other fields that follow them. The ELF header is 52 or 64 bytes long for 32-bit and 64-bit binaries, respectively.
| Offset | Size (bytes) | Field | Purpose | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 32-bit | 64-bit | 32-bit | 64-bit | ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 4 | <templatestyles src="Mono/styles.css" />e_ident[EI_MAG0] through <templatestyles src="Mono/styles.css" />e_ident[EI_MAG3] | 0x7F followed by ELF(45 4c 46) in ASCII; these four bytes constitute the magic number.
| ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 1 | <templatestyles src="Mono/styles.css" />e_ident[EI_CLASS] | This byte is set to either 1 or 2 to signify 32- or 64-bit format, respectively.
| ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 1 | <templatestyles src="Mono/styles.css" />e_ident[EI_DATA] | This byte is set to either 1 or 2 to signify little or big endianness, respectively. This affects interpretation of multi-byte fields starting with offset 0x10.
| ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 1 | <templatestyles src="Mono/styles.css" />e_ident[EI_VERSION] | Set to 1 for the original and current version of ELF.
| ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 1 | <templatestyles src="Mono/styles.css" />e_ident[EI_OSABI] | Identifies the target operating system ABI.
| ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 1 | <templatestyles src="Mono/styles.css" />e_ident[EI_ABIVERSION] | Further specifies the ABI version. Its interpretation depends on the target ABI. Linux kernel (after at least 2.6) has no definition of it,[5] so it is ignored for statically linked executables. In that case, offset and size of EI_PAD are 8.
glibc 2.12+ in case <templatestyles src="Mono/styles.css" />e_ident[EI_OSABI] == 3 treats this field as ABI version of the dynamic linker:[6] it defines a list of dynamic linker's features,[7] treats <templatestyles src="Mono/styles.css" />e_ident[EI_ABIVERSION] as a feature level requested by the shared object (executable or dynamic library) and refuses to load it if an unknown feature is requested, i.e. <templatestyles src="Mono/styles.css" />e_ident[EI_ABIVERSION] is greater than the largest known feature.[8] | ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 7 | <templatestyles src="Mono/styles.css" />e_ident[EI_PAD] | Reserved padding bytes. Currently unused. Should be filled with zeros and ignored when read. | ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 2 | <templatestyles src="Mono/styles.css" />e_type | Identifies object file type.
| ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 2 | <templatestyles src="Mono/styles.css" />e_machine | Specifies target instruction set architecture. Some examples are: | ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 4 | <templatestyles src="Mono/styles.css" />e_version | Set to 1 for the original version of ELF.
| ||||||||||||||||||||||||||||||||||||||||
| Template:Tt | 4 | 8 | <templatestyles src="Mono/styles.css" />e_entry | This is the memory address of the entry point from where the process starts executing. This field is either 32 or 64 bits long, depending on the format defined earlier (byte 0x04). If the file doesn't have an associated entry point, then this holds zero. | |||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | <templatestyles src="Mono/styles.css" />e_phoff | Points to the start of the program header table. It usually follows the file header immediately following this one, making the offset 0x34 or 0x40 for 32- and 64-bit ELF executables, respectively.
| ||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | <templatestyles src="Mono/styles.css" />e_shoff | Points to the start of the section header table. | ||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | <templatestyles src="Mono/styles.css" />e_flags | Interpretation of this field depends on the target architecture. | |||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 2 | <templatestyles src="Mono/styles.css" />e_ehsize | Contains the size of this header, normally 64 Bytes for 64-bit and 52 Bytes for 32-bit format. | |||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 2 | <templatestyles src="Mono/styles.css" />e_phentsize | Contains the size of a program header table entry. As explained below, this will typically be 0x20 (32-bit) or 0x38 (64-bit). | |||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 2 | <templatestyles src="Mono/styles.css" />e_phnum | Contains the number of entries in the program header table. | |||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 2 | <templatestyles src="Mono/styles.css" />e_shentsize | Contains the size of a section header table entry. As explained below, this will typically be 0x28 (32-bit) or 0x40 (64-bit). | |||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 2 | <templatestyles src="Mono/styles.css" />e_shnum | Contains the number of entries in the section header table. | |||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 2 | <templatestyles src="Mono/styles.css" />e_shstrndx | Contains index of the section header table entry that contains the section names. | |||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | End of ELF Header (size). | |||||||||||||||||||||||||||||||||||||||||
Example hexdump
00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010 02 00 3e 00 01 00 00 00 c5 48 40 00 00 00 00 00 |..>......H@.....|
Program header
The program header table tells the system how to create a process image. It is found at file offset <templatestyles src="Mono/styles.css" />e_phoff, and consists of <templatestyles src="Mono/styles.css" />e_phnum entries, each with size <templatestyles src="Mono/styles.css" />e_phentsize. The layout is slightly different in 32-bit ELF vs 64-bit ELF, because the <templatestyles src="Mono/styles.css" />p_flags are in a different structure location for alignment reasons. Each entry is structured as:
| Offset | Size (bytes) | Field | Purpose | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 32-bit | 64-bit | 32-bit | 64-bit | |||||||||||||||||||||||||||||||||||||||
| Template:Tt | 4 | <templatestyles src="Mono/styles.css" />p_type | Identifies the type of the segment.
| |||||||||||||||||||||||||||||||||||||||
| Template:Tt | 4 | <templatestyles src="Mono/styles.css" />p_flags | Segment-dependent flags (position for 64-bit structure).
| |||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | <templatestyles src="Mono/styles.css" />p_offset | Offset of the segment in the file image. | |||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | <templatestyles src="Mono/styles.css" />p_vaddr | Virtual address of the segment in memory. | |||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | <templatestyles src="Mono/styles.css" />p_paddr | On systems where physical address is relevant, reserved for segment's physical address. | |||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | <templatestyles src="Mono/styles.css" />p_filesz | Size in bytes of the segment in the file image. May be 0. | |||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | <templatestyles src="Mono/styles.css" />p_memsz | Size in bytes of the segment in memory. May be 0. | |||||||||||||||||||||||||||||||||||||
| Template:Tt | 4 | <templatestyles src="Mono/styles.css" />p_flags | Segment-dependent flags (position for 32-bit structure). See above p_flags field for flag definitions.
| |||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | <templatestyles src="Mono/styles.css" />p_align | 0 and 1 specify no alignment. Otherwise should be a positive, integral power of 2, with <templatestyles src="Mono/styles.css" />p_vaddr equating <templatestyles src="Mono/styles.css" />p_offset modulus <templatestyles src="Mono/styles.css" />p_align.
| |||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | End of Program Header (size). | ||||||||||||||||||||||||||||||||||||||||
Section header
| Offset | Size (bytes) | Field | Purpose | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 32-bit | 64-bit | 32-bit | 64-bit | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 0x00 | 4 | Template:Tt | An offset to a string in the .shstrtab section that represents the name of this section. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 0x04 | 4 | Template:Tt | Identifies the type of this header.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 0x08 | 4 | 8 | Template:Tt | Identifies the attributes of the section.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | Template:Tt | Virtual address of the section in memory, for sections that are loaded. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | Template:Tt | Offset of the section in the file image. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | Template:Tt | Size in bytes of the section. May be 0. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | Template:Tt | Contains the section index of an associated section. This field is used for several purposes, depending on the type of section. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | Template:Tt | Contains extra information about the section. This field is used for several purposes, depending on the type of section. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | Template:Tt | Contains the required alignment of the section. This field must be a power of two. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | 4 | 8 | Template:Tt | Contains the size, in bytes, of each entry, for sections that contain fixed-size entries. Otherwise, this field contains zero. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template:Tt | Template:Tt | End of Section Header (size). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tools
Script error: No such module "Labelled list hatnote".
readelfis a Unix binary utility that displays information about one or more ELF files. A free software implementation is provided by GNU Binutils.elfutilsprovides alternative tools to GNU Binutils purely for Linux.[11]elfdumpis a command for viewing ELF information in an ELF file, available under Solaris and FreeBSD.objdumpprovides a wide range of information about ELF files and other object formats.objdumpuses the Binary File Descriptor library as a back-end to structure the ELF data.- The Unix
fileutility can display some information about ELF files, including the instruction set architecture for which the code in a relocatable, executable, or shared object file is intended, or on which an ELF core dump was produced.
Applications
Unix-like systems
Script error: No such module "Unsubst". The ELF format has replaced older executable formats in various environments. It has replaced a.out and COFF formats in Unix-like operating systems:
- Linux
- Solaris / Illumos
- IRIX
- FreeBSD[12]
- NetBSD
- OpenBSD
- Redox
- DragonFly BSD
- Syllable
- HP-UX (except for 32-bit PA-RISC programs which continue to use SOM)
- QNX Neutrino
- MINIX[13]
Non-Unix adoption
ELF has also seen some adoption in non-Unix operating systems, such as:
- OpenVMS, in its Itanium and amd64 versions[14]
- BeOS Revision 4 and later for x86 based computers (where it replaced the Portable Executable format; the PowerPC version stayed with Preferred Executable Format)
- Haiku, an open source reimplementation of BeOS
- RISC OS[15]
- Stratus VOS, in PA-RISC and x86 versions
- SkyOS
- Fuchsia OS
- Z/TPF
- HPE NonStop OS[16]
- Deos
Microsoft Windows also uses the ELF format, but only for its Windows Subsystem for Linux compatibility system.[17]
Game consoles
Some game consoles also use ELF:
- PlayStation Portable,[18] PlayStation Vita, PlayStation, PlayStation 2, PlayStation 3, PlayStation 4, PlayStation 5
- GP2X
- Dreamcast
- GameCube
- Nintendo 64
- Wii
- Wii U
PowerPC
Other (operating) systems running on PowerPC that use ELF:
- AmigaOS 4, the ELF executable has replaced the prior Extended Hunk Format (EHF) which was used on Amigas equipped with PPC processor expansion cards.
- MorphOS
- AROS
- Café OS (The operating system run by the Wii U)
Mobile phones
Some operating systems for mobile phones and mobile devices use ELF:
- Symbian OS v9 uses E32Image[19] format that is based on the ELF file format;
- Sony Ericsson, for example, the W800i, W610, W300, etc.
- Siemens, the SGOLD and SGOLD2 platforms: from Siemens C65 to S75 and BenQ-Siemens E71/EL71;
- Motorola, for example, the E398, SLVR L7, v360, v3i (and all phone LTE2 which has the patch applied).
- Bada, for example, the Samsung Wave S8500.
- Nokia phones or tablets running the Maemo or the Meego OS, for example, the Nokia N900.
- Android uses ELF <templatestyles src="Mono/styles.css" />.so (shared object[20]) libraries for the Java Native Interface.Script error: No such module "Unsubst". With Android Runtime (ART), the default since Android 5.0 "Lollipop", all applications are compiled into native ELF binaries on installation.[21] It's also possible to use native Linux software from package managers like Termux, or compile them from sources via Clang or GCC, that are available in repositories.
Script error: No such module "anchor". Some phones can run ELF files through the use of a patch that adds assembly code to the main firmware, which is a feature known as ELFPack in the underground modding culture. The ELF file format is also used with the Atmel AVR (8-bit), AVR32[22] and with Texas Instruments MSP430 microcontroller architectures. Some implementations of Open Firmware can also load ELF files, most notably Apple's implementation used in almost all PowerPC machines the company produced.
Blockchain platforms
- Solana uses ELF format for its on-chain programs (smart contracts). The platform processes ELF files compiled to BPF (Berkeley Packet Filter) byte-code, which are then deployed as shared objects and executed in Solana's runtime environment. The BPF loader validates and processes these ELF files during program deployment.[23]
Specifications
| Architecture | Specification |
|---|---|
| Generic |
|
| AMD64 | |
| Arm | |
| IA-32 | |
| IA-64 |
|
| M32R |
|
| MIPS |
|
| Motorola 6800 | |
| PA-RISC |
|
| PowerPC |
|
| RISC-V | |
| SPARC | |
| S/390 | |
| zSeries | |
| Symbian OS 9 |
The Linux Standard Base (LSB) supplements some of the above specifications for architectures in which it is specified.[24] For example, that is the case for the System V ABI, AMD64 Supplement.[25][26]
86open
86open was a project to form consensus on a common binary file format for Unix and Unix-like operating systems on the common PC compatible x86 architecture, to encourage software developers to port to the architecture.[27] The initial idea was to standardize on a small subset of Spec 1170, a predecessor of the Single UNIX Specification, and the GNU C Library (glibc) to enable unmodified binaries to run on the x86 Unix-like operating systems. The project was originally designated "Spec 150".
The format eventually chosen was ELF, specifically the Linux implementation of ELF, after it had turned out to be a de facto standard supported by all involved vendors and operating systems.
The group began email discussions in 1997 and first met together at the Santa Cruz Operation offices on August 22, 1997.
The steering committee was Marc Ewing, Dion Johnson, Evan Leibovitch, Bruce Perens, Andrew Roach, Bryan Wayne Sparks and Linus Torvalds. Other people on the project were Keith Bostic, Chuck Cranor, Michael Davidson, Chris G. Demetriou, Ulrich Drepper, Don Dugger, Steve Ginzburg, Jon "maddog" Hall, Ron Holt, Jordan Hubbard, Dave Jensen, Kean Johnston, Andrew Josey, Robert Lipe, Bela Lubkin, Tim Marsland, Greg Page, Ronald Joe Record, Tim Ruckle, Joel Silverstein, Chia-pi Tien, and Erik Troan. Operating systems and companies represented were BeOS, BSDI, FreeBSD, Intel, Linux, NetBSD, SCO and SunSoft.
The project progressed and in mid-1998, SCO began developing lxrun, an open-source compatibility layer able to run Linux binaries on OpenServer, UnixWare, and Solaris. SCO announced official support of lxrun at LinuxWorld in March 1999. Sun Microsystems began officially supporting lxrun for Solaris in early 1999,[28] and later moved to integrated support of the Linux binary format via Solaris Containers for Linux Applications.
With the BSDs having long supported Linux binaries (through a compatibility layer) and the main x86 Unix vendors having added support for the format, the project decided that Linux ELF was the format chosen by the industry and "declare[d] itself dissolved" on July 25, 1999.[29]
FatELF: universal binaries for Linux
FatELF is an ELF binary-format extension that adds fat binary capabilities.[30] It is aimed for Linux and other Unix-like operating systems. Additionally to the CPU architecture abstraction (byte order, word size, CPU instruction set etc.), there is the potential advantage of software-platform abstraction e.g., binaries which support multiple kernel ABI versions. As of 2021[update]Script error: No such module "Check for unknown parameters"., FatELF has not been integrated into the mainline Linux kernel.[31][32][33]
See also
Script error: No such module "Portal".
- Application binary interface
- Comparison of executable file formats
- DWARFTemplate:Snd a format for debugging data
- Intel Binary Compatibility Standard
- Portable ExecutableTemplate:Snd format used by Windows
- vDSOTemplate:Snd virtual DSO
- Position-independent code
References
<templatestyles src="Reflist/styles.css" />
- ↑ Tool Interface Standard (TIS) Portable Formats Specification Version 1.1 (October 1993)
- ↑ System V Application Binary Interface Edition 4.1 (1997-03-18)
- ↑ Tool Interface Standard (TIS) Executable and Linking Format (ELF) Specification Version 1.2 (May 1995)
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1". p. 44 archived from the original Script error: No such module "webarchive". on 2018-5-30
- ↑ Script error: No such module "citation/CS1".
- ↑ PlayStation Portable use encrypted & relocated ELF : PSP
- ↑ Symbian OS executable file format
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
Script error: No such module "Check for unknown parameters".
Further reading
<templatestyles src="Div col/styles.css"/>
- Evolution of the ELF object file format, by Fangrui Song.
- Script error: No such module "citation/CS1". Code:[1][1]Script error: No such module "Unsubst".Template:Cbignore Errata: [2]
- Ulrich Drepper, How To Write Shared Libraries, Version 4.1.2 (2011). Published on the author's web page, https://www.akkadia.org/drepper.
- An unsung hero: The hardworking ELF by Peter Seebach, December 20, 2005, archived from the original on February 24, 2007
- Script error: No such module "webarchive".
- The ELF Object File Format: Introduction, The ELF Object File Format by Dissection by Eric Youngdale (1995-05-01)
- A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux by Brian Raiter
- ELF relocation into non-relocatable objects by Julien Vanegue (2003-08-13)
- Embedded ELF debugging without ptrace by the ELFsh team (2005-08-01)
- Study of ELF loading and relocs by Pat Beirne (1999-08-03)
External links
<templatestyles src="Div col/styles.css"/>
- ELF Object File Format Specification
- Template:Github
- System V Application Binary Interface and Interface Definition
- FreeBSD Handbook: Binary formats (archived version)
- FreeBSD <templatestyles src="Mono/styles.css" />elf(5) manual page
- NetBSD ELF FAQ
- Linux <templatestyles src="Mono/styles.css" />elf(5) manual page
- Oracle Solaris Linker and Libraries Guide
- The ERESI project: reverse engineering on ELF-based operating systems Script error: No such module "webarchive".
- Linux Today article on 86open Script error: No such module "webarchive". July 26, 1999
- Announcement of 86open on Debian Announce mailing list October 10, 1997, Bruce Perens
- Declaration of Ulrich Drepper (PDF)Script error: No such module "Category handler".[<span title="Script error: No such module "string".">usurped]Script error: No such module "Check for unknown parameters". in The SCO Group vs IBM, September 19, 2006
- 86open and ELF discussionScript error: No such module "Category handler".[<span title="Script error: No such module "string".">usurped]Script error: No such module "Check for unknown parameters". on Groklaw, August 13, 2006
Script error: No such module "Navbox".
- ↑ Script error: No such module "citation/CS1".