Siirry sisältöön

Executable and Linkable Format

Wikipediasta
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]
OffsetKoko (tavuja)NimiKuvaus
32-bittinen64-bittinen32-bittinen64-bittinen
0x004e_ident[EI_MAG0] e_ident[EI_MAG3] 0x7F ja 45 4c 46 (ELF) muodostavat maagisen numeron.
0x041e_ident[EI_CLASS] Tämä tavu on 1 jos kyseessä on 32-bittinen ohjelma tai jos 2 niin ohjelma on 64-bittinen.
0x051e_ident[EI_DATA] Määrittää ohjelman tavujärjestyksen.
0x061e_ident[EI_VERSION] Määrittää ELF-version. 1 tarkoittaa alkuperäistä.
0x071e_ident[EI_OSABI] Määrittää ohjelman ABI:n.
ArvoABI
0x00System V
0x01HP-UX
0x02NetBSD
0x03Linux
0x04GNU Hurd
0x06Solaris
0x07AIX
0x08IRIX
0x09FreeBSD
0x0ATru64
0x0BNovell Modesto
0x0COpenBSD
0x0DOpenVMS
0x0ENonStop Kernel
0x0FAROS
0x10Fenix OS
0x11CloudABI

Usein määritetty nollaan riippumatta alustasta.

0x081e_ident[EI_ABIVERSION] Tarkempi määritys ABI:n versiosta.
0x097e_ident[EI_PAD] Toistaiseksi ei käytössä.
0x102e_type Määrittää objektin tyypin.
0x122e_machine Määrittää prosessoriarkkitehtuurin
ArvoISA
0x00Arkkitehtuuria ei määritetty
0x02SPARC
0x03x86
0x08MIPS
0x14PowerPC
0x16 S390
0x28ARM
0x2ASuperH
0x32IA-64
0x3Ex86-64
0xB7AArch64
0xF3RISC-V
0x144e_version Määrittää ELF-version. 1 tarkoittaa alkuperäistä.
0x1848e_entry Määrittää osoitteen muistista, mistä ohjelman suoritus alkaa. Voi olla 32- tai 64-bittinen.
0x1C0x2048e_phoff Osoittaa ohjelman ylätunnistetaulukon alkuun.
0x200x2848e_shoff Osoittaa osuuksien ylätunnistetaulukon alkuun.
0x240x304e_flags Kentän tulkinta riippuu kohdearkkitehtuurista.
0x280x342e_ehsize Sisältää ELF-ylätunnisteen koon.
0x2A0x362e_phentsize Contains the size of a program header table entry.
0x2C0x382e_phnum Sisältää osuuksien määrän ohjelman ylätunnistetaulukosta.
0x2E0x3A2e_shentsize Contains the size of a section header table entry.
0x300x3C2e_shnum Sisältää osuuksen määrän osuuksien ylätunnistetaulukosta.
0x320x3E2e_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]
OffsetKoko (tavuja)NimiKuvaus
32-bittinen64-bittinen32-bittinen64-bittinen
0x004p_typeMäärittää segmentin tyypin.
ValueName
0x00000000PT_NULL
0x00000001PT_LOAD
0x00000002PT_DYNAMIC
0x00000003PT_INTERP
0x00000004PT_NOTE
0x00000005PT_SHLIB
0x00000006PT_PHDR
0x60000000PT_LOOS
0x6FFFFFFFPT_HIOS
0x70000000PT_LOPROC
0x7FFFFFFFPT_HIPROC

PT_LOOS to PT_HIOS (PT_LOPROC to PT_HIPROC) is an inclusive reserved ranges for operating system (processor) specific semantics.

0x044p_flagsSegmentti kohtainen tietue.
0x040x0848p_offsetSegmentin offsetti.
0x080x1048p_vaddrSegmentin virtuaalinen muistiosoite.
0x0C0x1848p_paddrFyysinen muistiosoite
0x100x2048p_fileszSegmentin koko.
0x140x2848p_memszSegmentin koko muistissa.
0x184p_flagsSegmentti kohtainen tietue.
0x1C0x3048p_align0 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:

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

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
  • 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.
  1. 1 2 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. Viitattu 7.2.2014.
  6. ↑ Program Header July 2000. Sco.com. Viitattu 5.4.2017.
  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. Viitattu 19.1.2014.
  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 19.1.2014.
  12. ↑ Announcing Windows 10 Insider Preview Build 14316 blogs.windows.com. 6.4.2016. Viitattu 10.4.2016. (englanniksi)
  13. ↑ Foley, Mary Jo: Under the hood of Microsoft's Windows Subsystem for Linux | ZDNet zdnet.com. Viitattu 19.8.2016.
  14. ↑ Guardian Programmer's Guide Hewlett Packard Enterprise. Arkistoitu 30.5.2018. Viitattu 30.5.2018. 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. ↑ 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.
  18. ↑ elfutils sourceware.org. Viitattu 30 April 2017.

Aiheesta muualla

[muokkaa | muokkaa wikitekstiä]