Executable and Linkable Format
Tämä artikkeli tai sen osa on tuotu vieraskielisestä lähteestä ja käännös on keskeneräinen. Voit auttaa Wikipediaa tekemällä käännöksen loppuun. |

Executable and Linkable Format lyhyesti ELF on yleinen tiedostomuoto suoritettaville ohjelmille, objektitiedostoille, jaetuille kirjastoille ja coredump-tiedostoille.[1] Rakenteeltaan ELF on joustava, laajennettavissa oleva ja alustariippumaton tiedostomuoto.
Tiedoston rakenne
ELF-tiedosto sisältää ELF-ylätunnisteen (eng. header), joka muun muassa määrittää onko ohjelma 32 vai 64-bittinen. ELF-ylätunnisteen jälkeen tiedostossa on ohjelman ylätunnistetaulukko (eng. Program header table), itse ohjelma ja viimeiseksi ohjelman osuuksien ylätunnistetaulukko (eng. Section header table).[1]
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@.....| Esimerkki ELF-ylätunnisteen hexdumpista[2]
|
ELF-ylätunniste
ELF-ylätunniste määrittää onko ohjelma 32- vai 64-bittinen. Bittisyys vaikuttaa tietueiden offsettiin.
Offset | Koko (tavuja) | Nimi | Kuvaus | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
32-bittinen | 64-bittinen | 32-bittinen | 64-bittinen | ||||||||||||||||||||||||||||||||||||||
0x00 | 4 | e_ident[EI_MAG0] e_ident[EI_MAG3] | 0x7F ja 45 4c 46 (ELF) muodostavat maagisen numeron.
| ||||||||||||||||||||||||||||||||||||||
0x04 | 1 | e_ident[EI_CLASS] | Tämä tavu on 1 jos kysessä on 32-bittinen ohjelma tai jos 2 niin ohjelma on 64-bittinen. | ||||||||||||||||||||||||||||||||||||||
0x05 | 1 | e_ident[EI_DATA] | Määrittää ohjelman tavujärjestyksen. | ||||||||||||||||||||||||||||||||||||||
0x06 | 1 | e_ident[EI_VERSION] | Määrittää ELF-version. 1 tarkoittaa alkuperäistä. | ||||||||||||||||||||||||||||||||||||||
0x07 | 1 | e_ident[EI_OSABI] | Määrittää ohjelman ABI:n.
Usein määritetty nollaan riippumatta alustasta. | ||||||||||||||||||||||||||||||||||||||
0x08 | 1 | e_ident[EI_ABIVERSION] | Tarkempi määritys ABI:n versiosta. | ||||||||||||||||||||||||||||||||||||||
0x09 | 7 | e_ident[EI_PAD] | Toistaiseksi ei käytössä. | ||||||||||||||||||||||||||||||||||||||
0x10 | 2 | e_type | Määrittää objektin tyypin. | ||||||||||||||||||||||||||||||||||||||
0x12 | 2 | e_machine | Määrittää prosessoriarkkitehtuurin
| ||||||||||||||||||||||||||||||||||||||
0x14 | 4 | e_version | Määrittää ELF-version. 1 tarkoittaa alkuperäistä. | ||||||||||||||||||||||||||||||||||||||
0x18 | 4 | 8 | e_entry | Määrittää osoitteen muistista, mistä ohjelman suoritus alkaa. Voi olla 32- tai 64-bittinen. | |||||||||||||||||||||||||||||||||||||
0x1C | 0x20 | 4 | 8 | e_phoff | Osoittaa ohjelman ylätunnistetaulukon alkuun. | ||||||||||||||||||||||||||||||||||||
0x20 | 0x28 | 4 | 8 | e_shoff | Osoittaa osuuksien ylätunnistetaulukon alkuun. | ||||||||||||||||||||||||||||||||||||
0x24 | 0x30 | 4 | e_flags | Interpretation of this field depends on the target architecture. | |||||||||||||||||||||||||||||||||||||
0x28 | 0x34 | 2 | e_ehsize | Sisältää ELF-ylätunnisteen koon. | |||||||||||||||||||||||||||||||||||||
0x2A | 0x36 | 2 | e_phentsize | Contains the size of a program header table entry. | |||||||||||||||||||||||||||||||||||||
0x2C | 0x38 | 2 | e_phnum | Sisältää osuuksien määrän ohjelman ylätunnistetaulukosta. | |||||||||||||||||||||||||||||||||||||
0x2E | 0x3A | 2 | e_shentsize | Contains the size of a section header table entry. | |||||||||||||||||||||||||||||||||||||
0x30 | 0x3C | 2 | e_shnum | Sisältää osuuksen määrän osuuksien ylätunnistetaulukosta. | |||||||||||||||||||||||||||||||||||||
0x32 | 0x3E | 2 | e_shstrndx | Contains index of the section header table entry that contains the section names. |
Ohjelman ylätunniste
Ohjelman ylätunnistetaulukko kertoo, kuinka ohjelma tulee ladata muistiin.
Offset | Koko (tavuja) | Nimi | Kuvaus | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
32-bittinen | 64-bittinen | 32-bittinen | 64-bittinen | ||||||||||||||||||||||||||
0x00 | 4 | p_type | Määrittää segmentin tyypin.
PT_LOOS to PT_HIOS (PT_LOPROC to PT_HIPROC) is an inclusive reserved ranges for operating system (processor) specific semantics. | ||||||||||||||||||||||||||
0x04 | 4 | p_flags | Segmentti kohtainen tietue. | ||||||||||||||||||||||||||
0x04 | 0x08 | 4 | 8 | p_offset | Segmentin offsetti. | ||||||||||||||||||||||||
0x08 | 0x10 | 4 | 8 | p_vaddr | Segmentin virtuaalinen muistiosoite. | ||||||||||||||||||||||||
0x0C | 0x18 | 4 | 8 | p_paddr | Fyysinen muistiosoite | ||||||||||||||||||||||||
0x10 | 0x20 | 4 | 8 | p_filesz | Segmentin koko. | ||||||||||||||||||||||||
0x14 | 0x28 | 4 | 8 | p_memsz | Segmentin koko muistissa. | ||||||||||||||||||||||||
0x18 | 4 | p_flags | Segmentti kohtainen tietue. | ||||||||||||||||||||||||||
0x1C | 0x30 | 4 | 8 | p_align | 0 and 1 specify no alignment. Otherwise should be a positive, integral power of 2, with p_vaddr equating p_offset modulus p_align.
| ||||||||||||||||||||||||
0x20 | 0x38 | Ohjelman ylätunnisteen loppu (koko). |
Osion ylätunniste
Offset | Koko (Tavuja) | Nimi | Kuvaus | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
32-bittinen | 64-bittinen | 32-bittinen | 64-bittinen | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x00 | 4 | sh_name | An offset to a string in the .shstrtab section that represents the name of this section | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x04 | 4 | sh_type | Identifies the type of this header.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x08 | 4 | 8 | sh_flags | Identifies the attributes of the section.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x0C | 0x10 | 4 | 8 | sh_addr | Virtual address of the section in memory, for sections that are loaded. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x10 | 0x18 | 4 | 8 | sh_offset | Offset of the section in the file image. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x14 | 0x20 | 4 | 8 | sh_size | Size in bytes of the section in the file image. May be 0. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x18 | 0x28 | 4 | sh_link | Contains the section index of an associated section. This field is used for several purposes, depending on the type of section. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x1C | 0x2C | 4 | sh_info | Contains extra information about the section. This field is used for several purposes, depending on the type of section. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x20 | 0x30 | 4 | 8 | sh_addralign | Contains the required alignment of the section. This field must be a power of two. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x24 | 0x38 | 4 | 8 | sh_entsize | Contains the size, in bytes, of each entry, for sections that contain fixed-size entries. Otherwise, this field contains zero. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0x28 | 0x40 | End of Section Header (size) |
Käyttökohteet
Unixin kaltaiset alustat
ELF-muoto on korvannut vanhempia muotoja useilla alustoilla kuten a.out ja COFF-muodot Unixin kaltaisissa käyttöjärjestelmissä:
- Linux
- Solaris / Illumos
- IRIX
- FreeBSD[5]
- NetBSD
- OpenBSD
- Redox
- DragonFly BSD
- Syllable
- HP-UX (poislukien 32-bitttiset PA-RISC-ohjelmat jotka jatkavat SOM-muodon käyttämistä)
- QNX Neutrino
- MINIX[6]
Ei-Unix -alustat
ELF on myös käytössä eräillä ei-Unix alustoilla kuten:
- OpenVMS, Itanium ja x86-64 versiot[7][8]
- 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[9]
- Stratus VOS, in PA-RISC and x86 versions
- Windows 10 Anniversary Update using the Windows Subsystem for Linux.[10][11]
- SkyOS
- Fuchsia OS
- Z/TPF
- HPE NonStop OS[12]
Pelikonsolit
Eräät pelikonsolit käyttävät ELF-muotoa:
- PlayStation Portable,[13] PlayStation Vita, PlayStation 2, PlayStation 3, PlayStation 4
- GP2X
- Dreamcast
- Wii
PowerPC
Muut alustat PowerPC-suorittimilla jotka käyttävät ELF-muotoa:
- AmigaOS 4, ELF on korvannut aiemman Extended Hunk Format (EHF) muodon, jota käytettiin PPC-suorittimella varustettujen laajennuskorttien kanssa
- MorphOS
- AROS
Mobiililaitteet
Eräät käyttöjärjestelmät matkapuhelimille ja muille mobiililaitteille käyttävät ELF-muotoa:
- Symbian OS v9 uses E32Image[14] 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 .so (shared object[15]) libraries for the Java Native Interface. With Android Runtime (ART), the default since Android 5.0 "Lollipop", all applications are compiled into native ELF binaries on installation.
Ohjelmia
readelf
ohjelma joka näyttää tietoa elf-tiedostoista.elfutils
vaihtoehtoinen ohjelmapaketti GNU Binutilsin tilalle, joka on tehty erityisesti Linuxia varten.[16]elfdump
ohjelma joka näyttää tietoa elf-tiedostosta.objdump
ohjelma jolla voidaan tarkastella monipuolisesti eri tietoja elf-tiedostoista ja muista binääriformaateista.file
ohjelma joka näyttää tietoa elf-tiedostoista.
Lähteet
- ↑ a b 0xax.gitbooks.io 0xax.gitbooks.io. Viitattu 25.2.2018. (englanniksi)
- ↑ Available lexers — Pygments pygments.org.
- ↑ ELF Header July 2000. Sco.com. Viitattu 7.2.2014.
- ↑ Program Header July 2000. Sco.com. Viitattu 5.4.2017.
- ↑ Binary Formats docs.freebsd.org.
- ↑ MinixReleases – Minix Wiki Wiki.minix3.org. Arkistoitu 30.3.2013. Viitattu 19.1.2014.
- ↑ https://vmssoftware.com/pdfs/State_of_Port_20160906.pdf
- ↑ HP OpenVMS Linker Utility Manual h30266.www3.hpe.com. Viitattu 14.7.2018.
- ↑ GCCSDK – RISC OS 22.4.2012. Riscos.info. Viitattu 19.1.2014.
- ↑ Announcing Windows 10 Insider Preview Build 14316 blogs.windows.com. 6.4.2016. Viitattu 10.4.2016. (englanniksi)
- ↑ Foley, Mary Jo: Under the hood of Microsoft's Windows Subsystem for Linux | ZDNet zdnet.com. Viitattu 19.8.2016.
- ↑ Guardian Programmer's Guide Hewlett Packard Enterprise. Arkistoitu 30.5.2018. Viitattu 30.5.2018. p. 44 archived from the original on 2018-5-30
- ↑ PlayStation Portable use encrypted & relocated ELF : PSP
- ↑ Symbian OS executable file format
- ↑ Rosen, Kenneth; Host, Douglas; Klee, Rachel; Rosinski, Richard: UNIX: The Complete Reference, s. 707. 2 painos. McGraw Hill Professional, 2007. ”Dynamically linked libraries are also called shared objects (.so).” ISBN 9780071706988 Teoksen verkkoversio.
- ↑ elfutils sourceware.org. Viitattu 30 April 2017.