Executable and Linkable Format

Wikipediasta
Siirry navigaatioon Siirry hakuun
Kuva ELF-tiedoston rakenteesta. Program headerista osoittavat nuolet osoittavat segmenttejä ja section headerista ohjelman osioita.

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.

ELF on määritelty System V ABI -määrittelyssä[2] ja Tool Interface Standards (TIS) määrittelyssä: alkuperäisen ELF-muodon kehitti ja julkaisi Unix System Laboratories (USL).[3]

Tiedoston rakenne[muokkaa | muokkaa wikitekstiä]

ELF-tiedosto sisältää ELF-ylätunnisteen (engl. header), joka muun muassa määrittää onko ohjelma 32 vai 64-bittinen. ELF-ylätunnisteen jälkeen tiedostossa on ohjelman ylätunnistetaulukko (engl. Program header table), itse ohjelma ja viimeiseksi ohjelman osuuksien ylätunnistetaulukko (engl. 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[4]


ELF-ylätunniste[muokkaa | muokkaa wikitekstiä]

ELF-ylätunniste määrittää onko ohjelma 32- vai 64-bittinen. Bittisyys vaikuttaa tietueiden offsettiin.

ELF header[5]
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 kyseessä 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.
Arvo ABI
0x00 System V
0x01 HP-UX
0x02 NetBSD
0x03 Linux
0x04 GNU Hurd
0x06 Solaris
0x07 AIX
0x08 IRIX
0x09 FreeBSD
0x0A Tru64
0x0B Novell Modesto
0x0C OpenBSD
0x0D OpenVMS
0x0E NonStop Kernel
0x0F AROS
0x10 Fenix OS
0x11 CloudABI

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
Arvo ISA
0x00 Arkkitehtuuria ei määritetty
0x02 SPARC
0x03 x86
0x08 MIPS
0x14 PowerPC
0x16 S390
0x28 ARM
0x2A SuperH
0x32 IA-64
0x3E x86-64
0xB7 AArch64
0xF3 RISC-V
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 Kentän tulkinta riippuu kohdearkkitehtuurista.
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[muokkaa | muokkaa wikitekstiä]

Ohjelman ylätunnistetaulukko kertoo, kuinka ohjelma tulee ladata muistiin.

Program header[6]
Offset Koko (tavuja) Nimi Kuvaus
32-bittinen 64-bittinen 32-bittinen 64-bittinen
0x00 4 p_type Määrittää segmentin tyypin.
Value Name
0x00000000 PT_NULL
0x00000001 PT_LOAD
0x00000002 PT_DYNAMIC
0x00000003 PT_INTERP
0x00000004 PT_NOTE
0x00000005 PT_SHLIB
0x00000006 PT_PHDR
0x60000000 PT_LOOS
0x6FFFFFFF PT_HIOS
0x70000000 PT_LOPROC
0x7FFFFFFF PT_HIPROC

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[muokkaa | muokkaa wikitekstiä]

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.
Value Name Meaning
0x0 SHT_NULL Section header table entry unused
0x1 SHT_PROGBITS Program data
0x2 SHT_SYMTAB Symbol table
0x3 SHT_STRTAB String table
0x4 SHT_RELA Relocation entries with addends
0x5 SHT_HASH Symbol hash table
0x6 SHT_DYNAMIC Dynamic linking information
0x7 SHT_NOTE Notes
0x8 SHT_NOBITS Program space with no data (bss)
0x9 SHT_REL Relocation entries, no addends
0x0A SHT_SHLIB Reserved
0x0B SHT_DYNSYM Dynamic linker symbol table
0x0E SHT_INIT_ARRAY Array of constructors
0x0F SHT_FINI_ARRAY Array of destructors
0x10 SHT_PREINIT_ARRAY Array of pre-constructors
0x11 SHT_GROUP Section group
0x12 SHT_SYMTAB_SHNDX Extended section indeces
0x13 SHT_NUM Number of defined types.
0x60000000 SHT_LOOS Start OS-specific.
... ... ...
0x08 4 8 sh_flags Identifies the attributes of the section.
Value Name Meaning
0x1 SHF_WRITE Writable
0x2 SHF_ALLOC Occupies memory during execution
0x4 SHF_EXECINSTR Executable
0x10 SHF_MERGE Might be merged
0x20 SHF_STRINGS Contains nul-terminated strings
0x40 SHF_INFO_LINK 'sh_info' contains SHT index
0x80 SHF_LINK_ORDER Preserve order after combining
0x100 SHF_OS_NONCONFORMING Non-standard OS specific handling required
0x200 SHF_GROUP Section is member of a group
0x400 SHF_TLS Section hold thread-local data
0x0ff00000 SHF_MASKOS OS-specific
0xf0000000 SHF_MASKPROC Processor-specific
0x4000000 SHF_ORDERED Special ordering requirement (Solaris)
0x8000000 SHF_EXCLUDE Section is excluded unless referenced or allocated (Solaris)
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[muokkaa | muokkaa wikitekstiä]

Unixin kaltaiset alustat[muokkaa | muokkaa wikitekstiä]

ELF-muoto on korvannut vanhempia muotoja useilla alustoilla kuten a.out ja COFF-muodot Unixin kaltaisissa käyttöjärjestelmissä:

Ei-Unix -alustat[muokkaa | muokkaa wikitekstiä]

ELF on myös käytössä eräillä ei-Unix alustoilla kuten:

Pelikonsolit[muokkaa | muokkaa wikitekstiä]

Eräät pelikonsolit käyttävät ELF-muotoa:

PowerPC[muokkaa | muokkaa wikitekstiä]

Muut alustat PowerPC-suorittimilla jotka käyttävät ELF-muotoa:

Mobiililaitteet[muokkaa | muokkaa wikitekstiä]

Eräät käyttöjärjestelmät matkapuhelimille ja muille mobiililaitteille käyttävät ELF-muotoa:

Käännös suomeksi
Käännös suomeksi
Tämä artikkeli tai sen osa on käännetty tai siihen on haettu tietoja muunkielisen Wikipedian artikkelista.
Alkuperäinen artikkeli: en:Executable and Linkable Format

Ohjelmia[muokkaa | muokkaa wikitekstiä]

  • readelf ohjelma joka näyttää tietoa elf-tiedostoista.
  • elfutils vaihtoehtoinen ohjelmapaketti GNU Binutilsin tilalle, joka on tehty erityisesti Linuxia varten.[18]
  • 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[muokkaa | muokkaa wikitekstiä]

  1. a b 0xax.gitbooks.io 0xax.gitbooks.io. Arkistoitu 25.2.2018. Viitattu 25.2.2018. (englanniksi)
  2. System V Application Binary Interface (PDF) (Edition 4.1) sco.com. 18.3.1997. Viitattu 22.11.2020. (englanniksi)
  3. Tool Interface Standard (TIS) Executable and Linking Format (ELF) Specification (PDF) (Version 1.2) refspecs.linuxbase.org. toukokuu 1995. Viitattu 22.11.2020. (englanniksi)
  4. Available lexers — Pygments pygments.org.
  5. ELF Header July 2000. Sco.com.
  6. Program Header July 2000. Sco.com.
  7. Binary Formats docs.freebsd.org. Arkistoitu 31.3.2019. Viitattu 16.8.2019.
  8. MinixReleases – Minix Wiki Wiki.minix3.org. Arkistoitu 30.3.2013.
  9. https://vmssoftware.com/pdfs/State_of_Port_20160906.pdf (Arkistoitu – Internet Archive)
  10. HP OpenVMS Linker Utility Manual h30266.www3.hpe.com. Arkistoitu 14.7.2018. Viitattu 14.7.2018.
  11. GCCSDK – RISC OS 22.4.2012. Riscos.info. Arkistoitu 19.2.2014. Viitattu 16.8.2019.
  12. Announcing Windows 10 Insider Preview Build 14316 blogs.windows.com. 6.4.2016. en-US
  13. Under the hood of Microsoft's Windows Subsystem for Linux | ZDNet zdnet.com.
  14. Guardian Programmer's Guide Hewlett Packard Enterprise. Arkistoitu 30.5.2018. Viitattu 16.8.2019. p. 44 archived from the original (Arkistoitu – Internet Archive) on 2018-5-30
  15. PlayStation Portable use encrypted & relocated ELF : PSP
  16. Symbian OS executable file format
  17. (2007) UNIX: The Complete Reference, 2, McGraw Hill Professional, 707. ISBN 9780071706988. “Dynamically linked libraries are also called shared objects (.so).” 
  18. elfutils sourceware.org.

Aiheesta muualla[muokkaa | muokkaa wikitekstiä]