xref: /openbmc/linux/Documentation/userspace-api/ELF.rst (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1*5c2c34a4SAlexey Dobriyan.. SPDX-License-Identifier: GPL-2.0
2*5c2c34a4SAlexey Dobriyan
3*5c2c34a4SAlexey Dobriyan=================================
4*5c2c34a4SAlexey DobriyanLinux-specific ELF idiosyncrasies
5*5c2c34a4SAlexey Dobriyan=================================
6*5c2c34a4SAlexey Dobriyan
7*5c2c34a4SAlexey DobriyanDefinitions
8*5c2c34a4SAlexey Dobriyan===========
9*5c2c34a4SAlexey Dobriyan
10*5c2c34a4SAlexey Dobriyan"First" program header is the one with the smallest offset in the file:
11*5c2c34a4SAlexey Dobriyane_phoff.
12*5c2c34a4SAlexey Dobriyan
13*5c2c34a4SAlexey Dobriyan"Last" program header is the one with the biggest offset in the file:
14*5c2c34a4SAlexey Dobriyane_phoff + (e_phnum - 1) * sizeof(Elf_Phdr).
15*5c2c34a4SAlexey Dobriyan
16*5c2c34a4SAlexey DobriyanPT_INTERP
17*5c2c34a4SAlexey Dobriyan=========
18*5c2c34a4SAlexey Dobriyan
19*5c2c34a4SAlexey DobriyanFirst PT_INTERP program header is used to locate the filename of ELF
20*5c2c34a4SAlexey Dobriyaninterpreter. Other PT_INTERP headers are ignored (since Linux 2.4.11).
21*5c2c34a4SAlexey Dobriyan
22*5c2c34a4SAlexey DobriyanPT_GNU_STACK
23*5c2c34a4SAlexey Dobriyan============
24*5c2c34a4SAlexey Dobriyan
25*5c2c34a4SAlexey DobriyanLast PT_GNU_STACK program header defines userspace stack executability
26*5c2c34a4SAlexey Dobriyan(since Linux 2.6.6). Other PT_GNU_STACK headers are ignored.
27*5c2c34a4SAlexey Dobriyan
28*5c2c34a4SAlexey DobriyanPT_GNU_PROPERTY
29*5c2c34a4SAlexey Dobriyan===============
30*5c2c34a4SAlexey Dobriyan
31*5c2c34a4SAlexey DobriyanELF interpreter's last PT_GNU_PROPERTY program header is used (since
32*5c2c34a4SAlexey DobriyanLinux 5.8). If interpreter doesn't have one, then the last PT_GNU_PROPERTY
33*5c2c34a4SAlexey Dobriyanprogram header of an executable is used. Other PT_GNU_PROPERTY headers
34*5c2c34a4SAlexey Dobriyanare ignored.
35