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 core dumpeille.[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 vaikutta 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) |
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.