Standard file format for executables, object code, shared libraries, and core dumps.
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.
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.
Program header
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. Each entry is structured as:
Section header
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.
elfutils provides alternative tools to GNU Binutils purely for Linux.[10]
elfdump is a command for viewing ELF information in an ELF file, available under Solaris and FreeBSD.
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
Unix-like systems
The ELF format has replaced older executable formats in various environments.
It has replaced a.out and COFF formats in Unix-like operating systems:
Nokia phones or tablets running the Maemo or the Meego OS, for example, the Nokia N900.
Android uses ELF .so (shared object[19]) 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.[20] 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.
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[21]and with Texas InstrumentsMSP430 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.
Specifications
Generic:
System V Application Binary Interface Edition 4.1 (1997-03-18)
The Linux Standard Base (LSB) supplements some of the above specifications for architectures in which it is specified.[22] For example, that is the case for the System V ABI, AMD64 Supplement.[23][24]
86open
86open was a project to form consensus on a common binary file format for Unix and Unix-likeoperating systems on the common PC compatible x86 architecture, to encourage software developers to port to the architecture.[25] 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.
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.[27]
FatELF: universal binaries for Linux
FatELF is an ELF binary-format extension that adds fat binary capabilities.[28] 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.[29][30][31]
^"sourceware.org Git - glibc.git/blob - sysdeps/gnu/ldsodefs.h". Archived from the original on 2021-03-07. Retrieved 2019-10-28.
^"Program Header". Sco.com. July 2000. Retrieved 2017-04-05.
^"elfutils". sourceware.org. Retrieved 30 April 2017.
^"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.
^"Guardian Programmer's Guide" (PDF). Hewlett Packard Enterprise. Archived from the original (PDF) on 2018-05-30. Retrieved 2018-05-30. p. 44 archived from the original on 2018-5-30
^Foley, Mary Jo. "Under the hood of Microsoft's Windows Subsystem for Linux". ZDNet. Retrieved 2016-08-19.
^PlayStation Portable use encrypted & relocated ELF : PSP
^Symbian OS executable file format
^Rosen, Kenneth; Host, Douglas; Klee, Rachel; Rosinski, Richard (2007). UNIX: The Complete Reference (2 ed.). McGraw Hill Professional. p. 707. ISBN 9780071706988. Retrieved 2017-06-08. Dynamically linked libraries are also called shared objects (.so).
^Thomas, Romain. "Android formats". Quarks Lab. Archived from the original on 16 February 2023. Retrieved 17 Jan 2023.
^"Chapter 4: Object Files", System V Application Binary Interface, 2009-10-26, e_machine
^"LSB Referenced Specifications". linuxfoundation.org. Retrieved 27 April 2015.
^"Executable and Linking Format (ELF)". linuxfoundation.org. Retrieved 27 April 2015.
^"Introduction". linuxfoundation.org. Retrieved 27 April 2015.
^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.
^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]
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
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)