Executable and Linkable Format
Filename extension |
none, .axf, .bin, .elf, .o, .out, .prx, .puff, .ko, .mod, and .so |
---|---|
Magic number | 0x7F 'E' 'L' 'F' |
Developed by | Unix System Laboratories[1]: 3 |
Type of format | Binary, executable, object, shared library, core dump |
Container for | Many executable binary formats |
In computing, the Executable and Linkable Format[2] (ELF, formerly named Extensible Linking Format), is a common standard file format for executable files, object code, shared libraries, 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),[3] and later in the Tool Interface Standard,[1] 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.
History
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.[4] 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,[5] 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.[6]
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.
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.
The program header table tells the system how to create a process image. It is found at file offset e_phoff, and consists of e_phnum entries, each with size e_phentsize. The layout is slightly different in 32-bit ELF vs 64-bit ELF, because the p_flags are in a different structure location for alignment reasons.
Tools
readelf is a Unix binary utility that displays information about one or more ELF files. A free software implementation is provided by GNU Binutils.
objdump provides a wide range of information about ELF files and other object formats. objdump
uses the Binary File Descriptor library as a back-end to structure the ELF data.
The Unix file
utility 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
The ELF format replaced a.out and COFF formats in Unix-like operating systems: including Linux, Solaris, FreeBSD[7] and MINIX.[8]
ELF has also seen some adoption in non-Unix operating systems, such as OpenVMS (in its Itanium and amd64 versions)[9], BeOS Revision 4 and later for x86 based computers (where it replaced the Portable Executable format; the PowerPC version stayed with Preferred Executable Format) and RISC OS. [10] On AmigaOS 4, the ELF executable has replaced the prior Extended Hunk Format (EHF) which was used on Amigas equipped with PPC processor expansion cards.[citation needed]
The Sony PlayStation and its successor consoles use ELF as their executable format.[citation needed]
Some operating systems for mobile phones and mobile devices use ELF. Symbian OS v9 uses E32Image[11] format that is based on the ELF file format. Android uses ELF .so libraries for the Java Native Interface.[citation needed] With Android Runtime (ART), the default since Android 5.0 "Lollipop", all applications are compiled into native ELF binaries on installation.[12] It also possible to use native Linux software from package managers like Termux, or compile them from sources via Clang or GCC, that also available in repositories.
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[13] 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.
FatELF: universal binaries for Linux
FatELF is an ELF binary-format extension that adds fat binary capabilities.[14] 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], FatELF has not been integrated into the mainline Linux kernel.[15][16][17]
See also
- Application binary interface – Binary interface between two program units
- Comparison of executable file formats
- DWARF – Standardized debugging data format
- Intel Binary Compatibility Standard – Application binary interface for Intel microprocessors
- Portable Executable – File format
- Position-independent code – Machine instruction code that executes properly regardless of where in memory it resides
- vDSO – Linux kernel mechanism
References
- ^ a b Tool Interface Standard (TIS) Executable and Linking Format (ELF) Specification Version 1.2 (May 1995)
- ^ Tool Interface Standard (TIS) Portable Formats Specification Version 1.1 (October 1993)
- ^ System V Application Binary Interface Edition 4.1 (1997-03-18)
- ^ Leibovitch, Evan (1997-12-23). "86Open Frequently-Asked Questions". Archived from the original on 2007-03-11. Retrieved 2007-06-06.
- ^ Record, Ronald (1998-05-21). "Bulletin on status of 86open at SCO". Archived from the original on 2008-12-08. Retrieved 2008-05-06.
- ^ Leibovitch, Evan (1999-07-25). "The86open Project – Final Update". Archived from the original on 2007-02-27. Retrieved 2007-05-06.
- ^ "Binary Formats". Archived from the original on 2019-03-31. Retrieved 2019-03-31.
- ^ "MinixReleases – Minix Wiki". Wiki.minix3.org. Archived from the original on 2013-03-30. Retrieved 2014-01-19.
- ^ "Archived copy" (PDF). Archived from the original (PDF) on 2020-09-15. Retrieved 2016-10-19.
{{cite web}}
: CS1 maint: archived copy as title (link) - ^ "GCCSDK – RISC OS". Riscos.info. 2012-04-22. Archived from the original on 2014-02-19. Retrieved 2014-01-19.
- ^ Symbian OS executable file format
- ^ Thomas, Romain. "Android formats". Quarks Lab. Archived from the original on 16 Feb 2023. Retrieved 17 Jan 2023.
- ^ "Chapter 4: Object Files", System V Application Binary Interface, 2009-10-26, e_machine
- ^ Gordon, Ryan. "fatelf-specification v1". icculus.org. Retrieved 2010-07-25.
- ^ Gordon, Ryan. "FatELF: Turns out I liked the uncertainty better". icculus.org. Retrieved 2010-07-13.
- ^ Holwerda, Thom (2009-11-03). "Ryan Gordon Halts FatELF Project". osnews.com. Retrieved 2010-07-05.
- ^ Brockmeier, Joe (June 23, 2010). "SELF: Anatomy of an (alleged) failure". Linux Weekly News. Retrieved 2011-02-06.
Further reading
- Levine, John R. (2000) [October 1999]. Linkers and Loaders. The Morgan Kaufmann Series in Software Engineering and Programming (1 ed.). San Francisco, USA: Morgan Kaufmann. ISBN 1-55860-496-0. OCLC 42413382. Archived from the original on 2012-12-05. Retrieved 2020-01-12. Code: [1][2] Errata: [3]
- Drepper, Ulrich (2006-08-20). "How To Write Shared Libraries" (PDF). 4.0. Retrieved 2007-06-20.
{{cite journal}}
: Cite journal requires|journal=
(help) - An unsung hero: The hardworking ELF by Peter Seebach, December 20, 2005, archived from the original on February 24, 2007
- LibElf and GElf - A Library to Manipulate ELf Files at the Wayback Machine (archived February 25, 2004)
- 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
- NetBSD ELF FAQ
- Linux elf(5) manual page
- Oracle Solaris Linker and Libraries Guide
- The ERESI project : reverse engineering on ELF-based operating systems Archived 2021-03-14 at the Wayback Machine
- Linux Today article on 86open July 26, 1999
- Announcement of 86open on Debian Announce mailing list October 10, 1997, Bruce Perens
- Declaration of Ulrich Drepper (PDF) in The SCO Group vs IBM, September 19, 2006