]>
Commit | Line | Data |
---|---|---|
8d5bf179 MK |
1 | .\" $OpenBSD: elf.5,v 1.12 2003/10/27 20:23:58 jmc Exp $ |
2 | .\"Copyright (c) 1999 Jeroen Ruigrok van der Werven | |
3 | .\"All rights reserved. | |
4 | .\" | |
7c576f45 | 5 | .\" %%%LICENSE_START(PERMISSIVE_MISC) |
8d5bf179 MK |
6 | .\"Redistribution and use in source and binary forms, with or without |
7 | .\"modification, are permitted provided that the following conditions | |
8 | .\"are met: | |
9 | .\"1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\"2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" | |
15 | .\"THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
16 | .\"ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
17 | .\"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
18 | .\"ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
19 | .\"FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
20 | .\"DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
21 | .\"OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
22 | .\"HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
23 | .\"LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
24 | .\"OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
25 | .\"SUCH DAMAGE. | |
8ff7380d | 26 | .\" %%%LICENSE_END |
8d5bf179 MK |
27 | .\" |
28 | .\" $FreeBSD: src/share/man/man5/elf.5,v 1.21 2001/10/01 16:09:23 ru Exp $ | |
29 | .\" | |
30 | .\" Slightly adapted - aeb, 2004-01-01 | |
31 | .\" 2005-07-15, Mike Frysinger <vapier@gentoo.org>, various fixes | |
dbdab2f4 | 32 | .\" 2007-10-11, Mike Frysinger <vapier@gentoo.org>, various fixes |
352bedee | 33 | .\" 2007-12-08, mtk, Converted from mdoc to man macros |
8d5bf179 | 34 | .\" |
b520dffc | 35 | .TH ELF 5 2010-06-19 "Linux" "Linux Programmer's Manual" |
3233d665 MK |
36 | .SH NAME |
37 | elf \- format of Executable and Linking Format (ELF) files | |
38 | .SH SYNOPSIS | |
39 | .nf | |
40 | .\" .B #include <elf_abi.h> | |
41 | .B #include <elf.h> | |
42 | .fi | |
43 | .SH DESCRIPTION | |
fea681da | 44 | The header file |
3233d665 | 45 | .I <elf.h> |
fea681da MK |
46 | defines the format of ELF executable binary files. |
47 | Amongst these files are | |
48 | normal executable files, relocatable object files, core files and shared | |
49 | libraries. | |
5ec60461 | 50 | .PP |
fea681da MK |
51 | An executable file using the ELF file format consists of an ELF header, |
52 | followed by a program header table or a section header table, or both. | |
53 | The ELF header is always at offset zero of the file. | |
54 | The program header | |
55 | table and the section header table's offset in the file are defined in the | |
56 | ELF header. | |
57 | The two tables describe the rest of the particularities of | |
58 | the file. | |
5ec60461 | 59 | .PP |
fea681da MK |
60 | .\" Applications which wish to process ELF binary files for their native |
61 | .\" architecture only should include | |
3233d665 | 62 | .\" .I <elf_abi.h> |
fea681da MK |
63 | .\" in their source code. |
64 | .\" These applications should need to refer to | |
65 | .\" all the types and structures by their generic names | |
3233d665 | 66 | .\" "Elf_xxx" |
fea681da | 67 | .\" and to the macros by |
3233d665 | 68 | .\" ELF_xxx". |
fea681da MK |
69 | .\" Applications written this way can be compiled on any architecture, |
70 | .\" regardless of whether the host is 32-bit or 64-bit. | |
3233d665 | 71 | .\" .PP |
fea681da MK |
72 | .\" Should an application need to process ELF files of an unknown |
73 | .\" architecture, then the application needs to explicitly use either | |
3233d665 | 74 | .\" "Elf32_xxx" |
fea681da | 75 | .\" or |
3233d665 | 76 | .\" "Elf64_xxx" |
fea681da MK |
77 | .\" type and structure names. |
78 | .\" Likewise, the macros need to be identified by | |
3233d665 | 79 | .\" "ELF32_xxx" |
fea681da | 80 | .\" or |
3233d665 MK |
81 | .\" "ELF64_xxx". |
82 | .\" .PP | |
fea681da MK |
83 | This header file describes the above mentioned headers as C structures |
84 | and also includes structures for dynamic sections, relocation sections and | |
85 | symbol tables. | |
5ec60461 | 86 | .PP |
fea681da | 87 | The following types are used for N-bit architectures (N=32,64, |
969c00ce MK |
88 | .I ElfN |
89 | stands for | |
90 | .I Elf32 | |
91 | or | |
92 | .IR Elf64 , | |
93 | .I uintN_t | |
94 | stands for | |
95 | .I uint32_t | |
96 | or | |
97 | .IR uint64_t ): | |
088a639b | 98 | .in +4n |
3233d665 MK |
99 | .nf |
100 | ||
101 | ElfN_Addr Unsigned program address, uintN_t | |
102 | ElfN_Off Unsigned file offset, uintN_t | |
103 | ElfN_Section Unsigned section index, uint16_t | |
104 | ElfN_Versym Unsigned version symbol information, uint16_t | |
105 | Elf_Byte unsigned char | |
106 | ElfN_Half uint16_t | |
107 | ElfN_Sword int32_t | |
108 | ElfN_Word uint32_t | |
109 | ElfN_Sxword int64_t | |
110 | ElfN_Xword uint64_t | |
fea681da | 111 | .\" Elf32_Size Unsigned object size |
3233d665 MK |
112 | .fi |
113 | .in | |
5ec60461 | 114 | .PP |
c13182ef | 115 | (Note: The *BSD terminology is a bit different. |
969c00ce MK |
116 | There |
117 | .I Elf64_Half | |
118 | is | |
119 | twice as large as | |
120 | .IR Elf32_Half , | |
121 | and | |
122 | .I Elf64Quarter | |
123 | is used for | |
124 | .IR uint16_t . | |
fea681da MK |
125 | In order to avoid confusion these types are replaced by explicit ones |
126 | in the below.) | |
5ec60461 | 127 | .PP |
fea681da | 128 | All data structures that the file format defines follow the |
3233d665 | 129 | "natural" |
fea681da MK |
130 | size and alignment guidelines for the relevant class. |
131 | If necessary, | |
132 | data structures contain explicit padding to ensure 4-byte alignment | |
133 | for 4-byte objects, to force structure sizes to a multiple of 4, etc. | |
5ec60461 | 134 | .PP |
969c00ce MK |
135 | The ELF header is described by the type |
136 | .I Elf32_Ehdr | |
137 | or | |
138 | .IR Elf64_Ehdr : | |
088a639b | 139 | .in +4n |
3233d665 MK |
140 | .nf |
141 | ||
fea681da MK |
142 | #define EI_NIDENT 16 |
143 | ||
144 | typedef struct { | |
dd0a09a5 MK |
145 | unsigned char e_ident[EI_NIDENT]; |
146 | uint16_t e_type; | |
147 | uint16_t e_machine; | |
148 | uint32_t e_version; | |
149 | ElfN_Addr e_entry; | |
150 | ElfN_Off e_phoff; | |
151 | ElfN_Off e_shoff; | |
152 | uint32_t e_flags; | |
153 | uint16_t e_ehsize; | |
154 | uint16_t e_phentsize; | |
155 | uint16_t e_phnum; | |
156 | uint16_t e_shentsize; | |
157 | uint16_t e_shnum; | |
158 | uint16_t e_shstrndx; | |
fea681da | 159 | } ElfN_Ehdr; |
3233d665 MK |
160 | .fi |
161 | .in | |
5ec60461 | 162 | .PP |
fea681da | 163 | The fields have the following meanings: |
3233d665 MK |
164 | .\" .Bl -tag -width "e_phentsize" |
165 | .TP 12 | |
166 | .IR e_ident | |
8d5bf179 MK |
167 | This array of bytes specifies to interpret the file, |
168 | independent of the processor or the file's remaining contents. | |
169 | Within this array everything is named by macros, which start with | |
170 | the prefix | |
3233d665 | 171 | .BR EI_ |
8d5bf179 | 172 | and may contain values which start with the prefix |
3233d665 | 173 | .BR ELF . |
8d5bf179 | 174 | The following macros are defined: |
3233d665 MK |
175 | .RS 12 |
176 | .\" .Bl -tag -width "EI_VERSION" \" EI_ABIVERSION | |
177 | .TP 12 | |
178 | .BR EI_MAG0 | |
8d5bf179 MK |
179 | The first byte of the magic number. |
180 | It must be filled with | |
3233d665 | 181 | .BR ELFMAG0 . |
8d5bf179 | 182 | (0: 0x7f) |
3233d665 MK |
183 | .TP |
184 | .BR EI_MAG1 | |
8d5bf179 MK |
185 | The second byte of the magic number. |
186 | It must be filled with | |
3233d665 | 187 | .BR ELFMAG1 . |
f81fb444 | 188 | (1: \(aqE\(aq) |
3233d665 MK |
189 | .TP |
190 | .BR EI_MAG2 | |
8d5bf179 MK |
191 | The third byte of the magic number. |
192 | It must be filled with | |
3233d665 | 193 | .BR ELFMAG2 . |
f81fb444 | 194 | (2: \(aqL\(aq) |
3233d665 MK |
195 | .TP |
196 | .BR EI_MAG3 | |
8d5bf179 MK |
197 | The fourth byte of the magic number. |
198 | It must be filled with | |
3233d665 | 199 | .BR ELFMAG3 . |
f81fb444 | 200 | (3: \(aqF\(aq) |
3233d665 MK |
201 | .TP |
202 | .BR EI_CLASS | |
8d5bf179 | 203 | The fifth byte identifies the architecture for this binary: |
3233d665 MK |
204 | .RS 12 |
205 | .\" .Bl -tag -width "ELFCLASSNONE" -compact | |
206 | .TP 14 | |
5ec60461 | 207 | .PD 0 |
3233d665 | 208 | .BR ELFCLASSNONE |
8d5bf179 | 209 | This class is invalid. |
3233d665 MK |
210 | .TP |
211 | .BR ELFCLASS32 | |
8d5bf179 MK |
212 | This defines the 32-bit architecture. |
213 | It supports machines with files | |
214 | and virtual address spaces up to 4 Gigabytes. | |
3233d665 MK |
215 | .TP |
216 | .BR ELFCLASS64 | |
8d5bf179 | 217 | This defines the 64-bit architecture. |
5ec60461 | 218 | .PD |
3233d665 MK |
219 | .RE |
220 | .\" .El | |
221 | .TP | |
222 | .BR EI_DATA | |
8d5bf179 MK |
223 | The sixth byte specifies the data encoding of the processor-specific |
224 | data in the file. | |
225 | Currently these encodings are supported: | |
3233d665 MK |
226 | .\" .Bl -tag -width "ELFDATA2LSB" -compact |
227 | .RS 12 | |
228 | .TP 14 | |
5ec60461 | 229 | .PD 0 |
3233d665 | 230 | .BR ELFDATANONE |
8d5bf179 | 231 | Unknown data format. |
3233d665 MK |
232 | .TP |
233 | .BR ELFDATA2LSB | |
8d5bf179 | 234 | Two's complement, little-endian. |
3233d665 MK |
235 | .TP |
236 | .BR ELFDATA2MSB | |
8d5bf179 | 237 | Two's complement, big-endian. |
5ec60461 | 238 | .PD |
3233d665 MK |
239 | .RE |
240 | .\" .El | |
241 | .TP | |
5ec60461 | 242 | .PD 0 |
3233d665 | 243 | .BR EI_VERSION |
8d5bf179 | 244 | The version number of the ELF specification: |
3233d665 MK |
245 | .\" .Bl -tag -width "EV_CURRENT" -compact |
246 | .RS 12 | |
247 | .TP 14 | |
248 | .BR EV_NONE | |
8d5bf179 | 249 | Invalid version. |
3233d665 MK |
250 | .TP |
251 | .BR EV_CURRENT | |
8d5bf179 | 252 | Current version. |
5ec60461 | 253 | .PD |
3233d665 MK |
254 | .RE |
255 | .\".El | |
256 | .TP | |
257 | .BR EI_OSABI | |
8d5bf179 MK |
258 | This byte identifies the operating system |
259 | and ABI to which the object is targeted. | |
260 | Some fields in other ELF structures have flags | |
e2badfdf | 261 | and values that have platform-specific meanings; |
8d5bf179 MK |
262 | the interpretation of those fields is determined by the value of this byte. |
263 | E.g.: | |
3233d665 MK |
264 | .\" .Bl -tag -width "ELFOSABI_STANDALONE" -compact |
265 | .RS 12 | |
266 | .TP 20 | |
5ec60461 | 267 | .PD 0 |
3233d665 | 268 | .BR ELFOSABI_NONE |
8d5bf179 MK |
269 | Same as ELFOSABI_SYSV |
270 | .\" 0 | |
3233d665 MK |
271 | .TP |
272 | .BR ELFOSABI_SYSV | |
8d5bf179 MK |
273 | UNIX System V ABI. |
274 | .\" 0 | |
275 | .\" synonym: ELFOSABI_NONE | |
3233d665 MK |
276 | .TP |
277 | .BR ELFOSABI_HPUX | |
8d5bf179 MK |
278 | HP-UX ABI. |
279 | .\" 1 | |
3233d665 MK |
280 | .TP |
281 | .BR ELFOSABI_NETBSD | |
8d5bf179 MK |
282 | NetBSD ABI. |
283 | .\" 2 | |
3233d665 MK |
284 | .TP |
285 | .BR ELFOSABI_LINUX | |
8d5bf179 MK |
286 | Linux ABI. |
287 | .\" 3 | |
3233d665 MK |
288 | .\" .TP |
289 | .\" .BR ELFOSABI_HURD | |
8d5bf179 MK |
290 | .\" Hurd ABI. |
291 | .\" 4 | |
3233d665 MK |
292 | .\" .TP |
293 | .\" .BR ELFOSABI_86OPEN | |
8d5bf179 MK |
294 | .\" 86Open Common IA32 ABI. |
295 | .\" 5 | |
3233d665 MK |
296 | .TP |
297 | .BR ELFOSABI_SOLARIS | |
8d5bf179 MK |
298 | Solaris ABI. |
299 | .\" 6 | |
3233d665 MK |
300 | .\" .TP |
301 | .\" .BR ELFOSABI_MONTEREY | |
4175f999 MK |
302 | .\" Monterey project ABI. |
303 | .\" Now replaced by | |
8d5bf179 MK |
304 | .\" ELFOSABI_AIX |
305 | .\" 7 | |
3233d665 MK |
306 | .TP |
307 | .BR ELFOSABI_IRIX | |
8d5bf179 MK |
308 | IRIX ABI. |
309 | .\" 8 | |
3233d665 MK |
310 | .TP |
311 | .BR ELFOSABI_FREEBSD | |
8d5bf179 MK |
312 | FreeBSD ABI. |
313 | .\" 9 | |
3233d665 MK |
314 | .TP |
315 | .BR ELFOSABI_TRU64 | |
8d5bf179 MK |
316 | TRU64 UNIX ABI. |
317 | .\" 10 | |
318 | .\" ELFOSABI_MODESTO | |
319 | .\" 11 | |
320 | .\" ELFOSABI_OPENBSD | |
321 | .\" 12 | |
3233d665 MK |
322 | .TP |
323 | .BR ELFOSABI_ARM | |
8d5bf179 MK |
324 | ARM architecture ABI. |
325 | .\" 97 | |
3233d665 MK |
326 | .TP |
327 | .BR ELFOSABI_STANDALONE | |
8d5bf179 MK |
328 | Stand-alone (embedded) ABI. |
329 | .\" 255 | |
3233d665 | 330 | .\" .El |
5ec60461 | 331 | .PD |
3233d665 MK |
332 | .RE |
333 | .TP | |
334 | .BR EI_ABIVERSION | |
8d5bf179 MK |
335 | This byte identifies the version of the ABI |
336 | to which the object is targeted. | |
337 | This field is used to distinguish among incompatible versions of an ABI. | |
338 | The interpretation of this version number | |
db4163b1 MK |
339 | is dependent on the ABI identified by the |
340 | .B EI_OSABI | |
341 | field. | |
8d5bf179 | 342 | Applications conforming to this specification use the value 0. |
3233d665 MK |
343 | .TP |
344 | .BR EI_PAD | |
8d5bf179 MK |
345 | Start of padding. |
346 | These bytes are reserved and set to zero. | |
347 | Programs | |
348 | which read them should ignore them. | |
db4163b1 MK |
349 | The value for |
350 | .B EI_PAD | |
351 | will change in | |
8d5bf179 | 352 | the future if currently unused bytes are given meanings. |
4e836144 | 353 | .\" As reported by Yuri Kozlov and confirmed by Mike Frysinger, EI_BRAND is |
b520dffc MK |
354 | .\" not in GABI (http://www.sco.com/developers/gabi/latest/ch4.eheader.html) |
355 | .\" It looks to be a BSDism | |
356 | .\" .TP | |
357 | .\" .BR EI_BRAND | |
358 | .\" Start of architecture identification. | |
3233d665 MK |
359 | .TP |
360 | .BR EI_NIDENT | |
db4163b1 MK |
361 | The size of the |
362 | .I e_ident | |
363 | array. | |
3233d665 MK |
364 | .\" .El |
365 | .RE | |
366 | .TP | |
367 | .IR e_type | |
8d5bf179 | 368 | This member of the structure identifies the object file type: |
3233d665 MK |
369 | .RS 12 |
370 | .\" .Bl -tag -width "ET_NONE" -compact | |
371 | .TP 12 | |
5ec60461 | 372 | .PD 0 |
3233d665 | 373 | .BR ET_NONE |
8d5bf179 | 374 | An unknown type. |
3233d665 MK |
375 | .TP |
376 | .BR ET_REL | |
8d5bf179 | 377 | A relocatable file. |
3233d665 MK |
378 | .TP |
379 | .BR ET_EXEC | |
8d5bf179 | 380 | An executable file. |
3233d665 MK |
381 | .TP |
382 | .BR ET_DYN | |
8d5bf179 | 383 | A shared object. |
3233d665 MK |
384 | .TP |
385 | .BR ET_CORE | |
8d5bf179 | 386 | A core file. |
5ec60461 | 387 | .PD |
3233d665 | 388 | .RE |
3233d665 MK |
389 | .\" .El |
390 | .TP | |
391 | .IR e_machine | |
8d5bf179 MK |
392 | This member specifies the required architecture for an individual file. |
393 | E.g.: | |
3233d665 MK |
394 | .RS 12 |
395 | .\" .Bl -tag -width "EM_MIPS_RS4_BE" -compact | |
396 | .TP 12 | |
5ec60461 | 397 | .PD 0 |
3233d665 | 398 | .BR EM_NONE |
8d5bf179 MK |
399 | An unknown machine. |
400 | .\" 0 | |
3233d665 MK |
401 | .TP |
402 | .BR EM_M32 | |
8d5bf179 MK |
403 | AT&T WE 32100. |
404 | .\" 1 | |
3233d665 MK |
405 | .TP |
406 | .BR EM_SPARC | |
8d5bf179 MK |
407 | Sun Microsystems SPARC. |
408 | .\" 2 | |
3233d665 MK |
409 | .TP |
410 | .BR EM_386 | |
8d5bf179 MK |
411 | Intel 80386. |
412 | .\" 3 | |
3233d665 MK |
413 | .TP |
414 | .BR EM_68K | |
8d5bf179 MK |
415 | Motorola 68000. |
416 | .\" 4 | |
3233d665 MK |
417 | .TP |
418 | .BR EM_88K | |
8d5bf179 MK |
419 | Motorola 88000. |
420 | .\" 5 | |
3233d665 MK |
421 | .\" .TP |
422 | .\" .BR EM_486 | |
8d5bf179 MK |
423 | .\" Intel 80486. |
424 | .\" 6 | |
3233d665 MK |
425 | .TP |
426 | .BR EM_860 | |
8d5bf179 MK |
427 | Intel 80860. |
428 | .\" 7 | |
3233d665 MK |
429 | .TP |
430 | .BR EM_MIPS | |
8d5bf179 MK |
431 | MIPS RS3000 (big-endian only). |
432 | .\" 8 | |
433 | .\" EM_S370 | |
434 | .\" 9 | |
3233d665 MK |
435 | .\" .TP |
436 | .\" .BR EM_MIPS_RS4_BE | |
8d5bf179 MK |
437 | .\" MIPS RS4000 (big-endian only). Deprecated. |
438 | .\" 10 | |
439 | .\" EM_MIPS_RS3_LE (MIPS R3000 little-endian) | |
440 | .\" 10 | |
3233d665 MK |
441 | .TP |
442 | .BR EM_PARISC | |
8d5bf179 MK |
443 | HP/PA. |
444 | .\" 15 | |
3233d665 MK |
445 | .TP |
446 | .BR EM_SPARC32PLUS | |
8d5bf179 MK |
447 | SPARC with enhanced instruction set. |
448 | .\" 18 | |
3233d665 MK |
449 | .TP |
450 | .BR EM_PPC | |
8d5bf179 MK |
451 | PowerPC. |
452 | .\" 20 | |
3233d665 MK |
453 | .TP |
454 | .BR EM_PPC64 | |
8d5bf179 MK |
455 | PowerPC 64-bit. |
456 | .\" 21 | |
3233d665 MK |
457 | .TP |
458 | .BR EM_S390 | |
8d5bf179 MK |
459 | IBM S/390 |
460 | .\" 22 | |
3233d665 MK |
461 | .TP |
462 | .BR EM_ARM | |
8d5bf179 MK |
463 | Advanced RISC Machines |
464 | .\" 40 | |
3233d665 MK |
465 | .TP |
466 | .BR EM_SH | |
8d5bf179 MK |
467 | Renesas SuperH |
468 | .\" 42 | |
3233d665 MK |
469 | .TP |
470 | .BR EM_SPARCV9 | |
8d5bf179 MK |
471 | SPARC v9 64-bit. |
472 | .\" 43 | |
3233d665 MK |
473 | .TP |
474 | .BR EM_IA_64 | |
8d5bf179 MK |
475 | Intel Itanium |
476 | .\" 50 | |
3233d665 MK |
477 | .TP |
478 | .BR EM_X86_64 | |
8d5bf179 MK |
479 | AMD x86-64 |
480 | .\" 62 | |
3233d665 MK |
481 | .TP |
482 | .BR EM_VAX | |
8d5bf179 MK |
483 | DEC Vax. |
484 | .\" 75 | |
485 | .\" EM_CRIS | |
486 | .\" 76 | |
3233d665 MK |
487 | .\" .TP |
488 | .\" .BR EM_ALPHA | |
8d5bf179 | 489 | .\" Compaq [DEC] Alpha. |
3233d665 MK |
490 | .\" .TP |
491 | .\" .BR EM_ALPHA_EXP | |
8d5bf179 | 492 | .\" Compaq [DEC] Alpha with enhanced instruction set. |
5ec60461 | 493 | .PD |
3233d665 MK |
494 | .RE |
495 | .\" .El | |
496 | .TP | |
497 | .IR e_version | |
8d5bf179 | 498 | This member identifies the file version: |
3233d665 MK |
499 | .\" .Bl -tag -width "EV_CURRENT" -compact |
500 | .RS 12 | |
501 | .TP 12 | |
5ec60461 | 502 | .PD 0 |
3233d665 | 503 | .BR EV_NONE |
8d5bf179 | 504 | Invalid version. |
3233d665 MK |
505 | .TP |
506 | .BR EV_CURRENT | |
8d5bf179 | 507 | Current version. |
3233d665 | 508 | .\" .El |
5ec60461 | 509 | .PD |
3233d665 MK |
510 | .RE |
511 | .TP | |
512 | .IR e_entry | |
8d5bf179 MK |
513 | This member gives the virtual address to which the system first transfers |
514 | control, thus starting the process. | |
515 | If the file has no associated entry | |
516 | point, this member holds zero. | |
3233d665 MK |
517 | .TP |
518 | .IR e_phoff | |
8d5bf179 MK |
519 | This member holds the program header table's file offset in bytes. |
520 | If | |
521 | the file has no program header table, this member holds zero. | |
3233d665 MK |
522 | .TP |
523 | .IR e_shoff | |
8d5bf179 MK |
524 | This member holds the section header table's file offset in bytes. |
525 | If the | |
526 | file has no section header table this member holds zero. | |
3233d665 MK |
527 | .TP |
528 | .IR e_flags | |
8d5bf179 MK |
529 | This member holds processor-specific flags associated with the file. |
530 | Flag names take the form EF_`machine_flag'. | |
531 | Currently no flags have been defined. | |
3233d665 MK |
532 | .TP |
533 | .IR e_ehsize | |
8d5bf179 | 534 | This member holds the ELF header's size in bytes. |
3233d665 MK |
535 | .TP |
536 | .IR e_phentsize | |
8d5bf179 MK |
537 | This member holds the size in bytes of one entry in the file's program header |
538 | table; all entries are the same size. | |
3233d665 MK |
539 | .TP |
540 | .IR e_phnum | |
8d5bf179 MK |
541 | This member holds the number of entries in the program header |
542 | table. | |
543 | Thus the product of | |
3233d665 | 544 | .IR e_phentsize |
8d5bf179 | 545 | and |
3233d665 | 546 | .IR e_phnum |
8d5bf179 MK |
547 | gives the table's size |
548 | in bytes. | |
549 | If a file has no program header, | |
3233d665 | 550 | .IR e_phnum |
8d5bf179 | 551 | holds the value zero. |
6866d935 DH |
552 | .IP |
553 | If the number of entries in the program header table is larger than or equal to | |
554 | .\" This is a Linux extension, added in Linux 2.6.34. | |
555 | .BR PN_XNUM | |
556 | (0xffff), this member holds | |
557 | .BR PN_XNUM | |
558 | (0xffff) and the real number of entries in the program header table is held | |
559 | in the | |
560 | .IR sh_info | |
561 | member of the initial entry in section header table. | |
562 | Otherwise, the | |
563 | .IR sh_info | |
564 | member of the initial entry contains the value zero. | |
565 | .\" .Bl -tag -width "PN_XNUM" | |
566 | .RS 12 | |
567 | .TP 9 | |
568 | .BR PN_XNUM | |
569 | This is defined as 0xffff, the largest number | |
570 | .IR e_phnum | |
571 | can have, specifying where the actual number of program headers is assigned. | |
572 | .PD | |
573 | .RE | |
574 | .\" .El | |
575 | .IP | |
3233d665 MK |
576 | .TP |
577 | .IR e_shentsize | |
8d5bf179 MK |
578 | This member holds a sections header's size in bytes. |
579 | A section header is one | |
580 | entry in the section header table; all entries are the same size. | |
3233d665 MK |
581 | .TP |
582 | .IR e_shnum | |
8d5bf179 MK |
583 | This member holds the number of entries in the section header table. |
584 | Thus | |
585 | the product of | |
3233d665 | 586 | .IR e_shentsize |
8d5bf179 | 587 | and |
3233d665 | 588 | .IR e_shnum |
8d5bf179 MK |
589 | gives the section header table's size in bytes. |
590 | If a file has no section | |
591 | header table, | |
3233d665 | 592 | .IR e_shnum |
8d5bf179 | 593 | holds the value of zero. |
6866d935 DH |
594 | .IP |
595 | If the number of entries in the section header table is larger than or equal to | |
596 | .BR SHN_LORESERVE | |
597 | (0xff00), | |
598 | .IR e_shnum | |
599 | holds the value zero and the real number of entries in the section header | |
600 | table is held in the | |
601 | .IR sh_size | |
602 | member of the initial entry in section header table. | |
603 | Otherwise, the | |
604 | .IR sh_size | |
605 | member of the initial entry in the section header table holds the value zero. | |
3233d665 MK |
606 | .TP |
607 | .IR e_shstrndx | |
8d5bf179 MK |
608 | This member holds the section header table index of the entry associated |
609 | with the section name string table. | |
610 | If the file has no section name string | |
611 | table, this member holds the value | |
3233d665 | 612 | .BR SHN_UNDEF . |
6866d935 DH |
613 | .IP |
614 | If the index of section name string table section is larger than or equal to | |
615 | .BR SHN_LORESERVE | |
616 | (0xff00), this member holds | |
617 | .BR SHN_XINDEX | |
618 | (0xffff) and the real index of the section name string table section | |
619 | is held in the | |
620 | .IR sh_link | |
4175f999 MK |
621 | member of the initial entry in section header table. |
622 | Otherwise, the | |
6866d935 DH |
623 | .IR sh_link |
624 | member of the initial entry in section header table contains the value zero. | |
3233d665 MK |
625 | .RS 12 |
626 | .\" .Bl -tag -width "SHN_LORESERVE" | |
627 | .TP 14 | |
628 | .BR SHN_UNDEF | |
8d5bf179 MK |
629 | This value marks an undefined, missing, irrelevant, or otherwise meaningless |
630 | section reference. | |
631 | For example, a symbol | |
3233d665 | 632 | "defined" |
8d5bf179 | 633 | relative to section number |
3233d665 | 634 | .BR SHN_UNDEF |
8d5bf179 | 635 | is an undefined symbol. |
3233d665 MK |
636 | .TP |
637 | .BR SHN_LORESERVE | |
8d5bf179 | 638 | This value specifies the lower bound of the range of reserved indices. |
3233d665 MK |
639 | .TP |
640 | .BR SHN_LOPROC | |
8d5bf179 | 641 | Values greater than or equal to |
3233d665 | 642 | .BR SHN_HIPROC |
8d5bf179 | 643 | are reserved for processor-specific semantics. |
3233d665 MK |
644 | .TP |
645 | .BR SHN_HIPROC | |
8d5bf179 | 646 | Values less than or equal to |
3233d665 | 647 | .BR SHN_LOPROC |
8d5bf179 | 648 | are reserved for processor-specific semantics. |
3233d665 MK |
649 | .TP |
650 | .BR SHN_ABS | |
8d5bf179 MK |
651 | This value specifies absolute values for the corresponding reference. |
652 | For | |
653 | example, symbols defined relative to section number | |
3233d665 | 654 | .BR SHN_ABS |
8d5bf179 | 655 | have absolute values and are not affected by relocation. |
3233d665 MK |
656 | .TP |
657 | .BR SHN_COMMON | |
8d5bf179 MK |
658 | Symbols defined relative to this section are common symbols, such as Fortran |
659 | COMMON or unallocated C external variables. | |
3233d665 MK |
660 | .TP |
661 | .BR SHN_HIRESERVE | |
8d5bf179 MK |
662 | This value specifies the upper bound of the range of reserved |
663 | indices between | |
3233d665 | 664 | .BR SHN_LORESERVE |
8d5bf179 | 665 | and |
3233d665 | 666 | .BR SHN_HIRESERVE , |
8d5bf179 MK |
667 | inclusive; the values do |
668 | not reference the section header table. | |
669 | That is, the section header table | |
670 | does | |
3233d665 | 671 | .I not |
8d5bf179 | 672 | contain entries for the reserved indices. |
3233d665 MK |
673 | .RE |
674 | .\" .El | |
675 | .\" .El | |
676 | .PP | |
8d5bf179 MK |
677 | An executable or shared object file's program header table is an array of |
678 | structures, each describing a segment or other information the system needs | |
679 | to prepare the program for execution. | |
680 | An object file | |
3233d665 | 681 | .IR segment |
8d5bf179 | 682 | contains one or more |
3233d665 | 683 | .IR sections . |
8d5bf179 MK |
684 | Program headers are meaningful only for executable and shared object files. |
685 | A file specifies its own program header size with the ELF header's | |
3233d665 | 686 | .IR e_phentsize |
8d5bf179 | 687 | and |
3233d665 | 688 | .IR e_phnum |
8d5bf179 | 689 | members. |
969c00ce MK |
690 | The ELF program header is described by the type |
691 | .I Elf32_Phdr | |
692 | or | |
693 | .I Elf64_Phdr | |
8d5bf179 | 694 | depending on the architecture: |
088a639b | 695 | .in +4n |
3233d665 MK |
696 | .nf |
697 | ||
8d5bf179 | 698 | typedef struct { |
dd0a09a5 MK |
699 | uint32_t p_type; |
700 | Elf32_Off p_offset; | |
701 | Elf32_Addr p_vaddr; | |
702 | Elf32_Addr p_paddr; | |
703 | uint32_t p_filesz; | |
704 | uint32_t p_memsz; | |
705 | uint32_t p_flags; | |
706 | uint32_t p_align; | |
8d5bf179 | 707 | } Elf32_Phdr; |
3233d665 MK |
708 | .fi |
709 | .in | |
088a639b | 710 | .in +4n |
3233d665 MK |
711 | .nf |
712 | ||
8d5bf179 | 713 | typedef struct { |
dd0a09a5 MK |
714 | uint32_t p_type; |
715 | uint32_t p_flags; | |
716 | Elf64_Off p_offset; | |
717 | Elf64_Addr p_vaddr; | |
718 | Elf64_Addr p_paddr; | |
719 | uint64_t p_filesz; | |
720 | uint64_t p_memsz; | |
721 | uint64_t p_align; | |
8d5bf179 | 722 | } Elf64_Phdr; |
3233d665 MK |
723 | .fi |
724 | .in | |
5ec60461 | 725 | .PP |
8d5bf179 MK |
726 | The main difference between the 32-bit and the 64-bit program header lies |
727 | in the location of the | |
3233d665 | 728 | .IR p_flags |
8d5bf179 | 729 | member in the total struct. |
3233d665 MK |
730 | .\" .Bl -tag -width "p_offset" |
731 | .TP 12 | |
732 | .IR p_type | |
8d5bf179 MK |
733 | This member of the Phdr struct tells what kind of segment this array |
734 | element describes or how to interpret the array element's information. | |
3233d665 MK |
735 | .\" .Bl -tag -width "PT_DYNAMIC" |
736 | .RS 12 | |
737 | .TP 12 | |
738 | .BR PT_NULL | |
8d5bf179 MK |
739 | The array element is unused and the other members' values are undefined. |
740 | This lets the program header have ignored entries. | |
3233d665 MK |
741 | .TP |
742 | .BR PT_LOAD | |
8d5bf179 | 743 | The array element specifies a loadable segment, described by |
3233d665 | 744 | .IR p_filesz |
8d5bf179 | 745 | and |
3233d665 | 746 | .IR p_memsz . |
8d5bf179 MK |
747 | The bytes from the file are mapped to the beginning of the memory |
748 | segment. | |
749 | If the segment's memory size | |
969c00ce | 750 | .IR p_memsz |
8d5bf179 | 751 | is larger than the file size |
969c00ce | 752 | .IR p_filesz , |
8d5bf179 | 753 | the |
3233d665 | 754 | "extra" |
8d5bf179 MK |
755 | bytes are defined to hold the value 0 and to follow the segment's |
756 | initialized area. | |
757 | The file size may not be larger than the memory size. | |
758 | Loadable segment entries in the program header table appear in ascending | |
759 | order, sorted on the | |
3233d665 | 760 | .IR p_vaddr |
8d5bf179 | 761 | member. |
3233d665 MK |
762 | .TP |
763 | .BR PT_DYNAMIC | |
8d5bf179 | 764 | The array element specifies dynamic linking information. |
3233d665 MK |
765 | .TP |
766 | .BR PT_INTERP | |
8d5bf179 | 767 | The array element specifies the location and size of a null-terminated |
2d7195b8 | 768 | pathname to invoke as an interpreter. |
8d5bf179 MK |
769 | This segment type is meaningful |
770 | only for executable files (though it may occur for shared objects). | |
771 | However it may not occur more than once in a file. | |
772 | If it is present, it must precede any loadable segment entry. | |
3233d665 MK |
773 | .TP |
774 | .BR PT_NOTE | |
8d5bf179 | 775 | The array element specifies the location and size for auxiliary information. |
3233d665 MK |
776 | .TP |
777 | .BR PT_SHLIB | |
8d5bf179 MK |
778 | This segment type is reserved but has unspecified semantics. |
779 | Programs that | |
780 | contain an array element of this type do not conform to the ABI. | |
3233d665 MK |
781 | .TP |
782 | .BR PT_PHDR | |
8d5bf179 MK |
783 | The array element, if present, specifies the location and size of the program |
784 | header table itself, both in the file and in the memory image of the program. | |
785 | This segment type may not occur more than once in a file. | |
786 | Moreover, it may | |
787 | only occur if the program header table is part of the memory image of the | |
788 | program. | |
789 | If it is present, it must precede any loadable segment entry. | |
3233d665 MK |
790 | .TP |
791 | .BR PT_LOPROC | |
8d5bf179 | 792 | Values greater than or equal to |
3233d665 | 793 | .BR PT_HIPROC |
8d5bf179 | 794 | are reserved for processor-specific semantics. |
3233d665 MK |
795 | .TP |
796 | .BR PT_HIPROC | |
8d5bf179 | 797 | Values less than or equal to |
3233d665 | 798 | .BR PT_LOPROC |
8d5bf179 | 799 | are reserved for processor-specific semantics. |
a9d82280 | 800 | .TP |
3233d665 | 801 | .BR PT_GNU_STACK |
dbdab2f4 | 802 | GNU extension which is used by the Linux kernel to control the state of the |
38f76cd2 | 803 | stack via the flags set in the |
3233d665 | 804 | .IR p_flags |
dbdab2f4 | 805 | member. |
3233d665 MK |
806 | .\" .El |
807 | .RE | |
808 | .TP | |
809 | .IR p_offset | |
8d5bf179 MK |
810 | This member holds the offset from the beginning of the file at which |
811 | the first byte of the segment resides. | |
3233d665 MK |
812 | .TP |
813 | .IR p_vaddr | |
8d5bf179 MK |
814 | This member holds the virtual address at which the first byte of the |
815 | segment resides in memory. | |
3233d665 MK |
816 | .TP |
817 | .IR p_paddr | |
8d5bf179 MK |
818 | On systems for which physical addressing is relevant, this member is |
819 | reserved for the segment's physical address. | |
820 | Under | |
3233d665 | 821 | BSD |
8d5bf179 MK |
822 | this member is |
823 | not used and must be zero. | |
3233d665 MK |
824 | .TP |
825 | .IR p_filesz | |
8d5bf179 MK |
826 | This member holds the number of bytes in the file image of the segment. |
827 | It may be zero. | |
3233d665 MK |
828 | .TP |
829 | .IR p_memsz | |
8d5bf179 MK |
830 | This member holds the number of bytes in the memory image of the segment. |
831 | It may be zero. | |
3233d665 MK |
832 | .TP |
833 | .IR p_flags | |
f3ae1918 | 834 | This member holds a bit mask of flags relevant to the segment: |
3233d665 MK |
835 | .\" .Bl -tag -width "PF_X" -compact |
836 | .RS 12 | |
837 | .TP | |
5ec60461 | 838 | .PD 0 |
3233d665 | 839 | .BR PF_X |
8d5bf179 | 840 | An executable segment. |
3233d665 MK |
841 | .TP |
842 | .BR PF_W | |
8d5bf179 | 843 | A writable segment. |
3233d665 MK |
844 | .TP |
845 | .BR PF_R | |
8d5bf179 | 846 | A readable segment. |
5ec60461 | 847 | .PD |
3233d665 MK |
848 | .RE |
849 | .\" .El | |
5ec60461 | 850 | .IP |
8d5bf179 | 851 | A text segment commonly has the flags |
3233d665 | 852 | .BR PF_X |
8d5bf179 | 853 | and |
3233d665 | 854 | .BR PF_R . |
8d5bf179 | 855 | A data segment commonly has |
3233d665 MK |
856 | .BR PF_X , |
857 | .BR PF_W | |
8d5bf179 | 858 | and |
3233d665 MK |
859 | .BR PF_R . |
860 | .TP | |
861 | .IR p_align | |
8d5bf179 MK |
862 | This member holds the value to which the segments are aligned in memory |
863 | and in the file. | |
864 | Loadable process segments must have congruent values for | |
3233d665 | 865 | .IR p_vaddr |
8d5bf179 | 866 | and |
3233d665 | 867 | .IR p_offset , |
8d5bf179 MK |
868 | modulo the page size. |
869 | Values of zero and one mean no alignment is required. | |
870 | Otherwise, | |
3233d665 | 871 | .IR p_align |
8d5bf179 | 872 | should be a positive, integral power of two, and |
3233d665 | 873 | .IR p_vaddr |
8d5bf179 | 874 | should equal |
3233d665 | 875 | .IR p_offset , |
8d5bf179 | 876 | modulo |
3233d665 MK |
877 | .IR p_align . |
878 | .\" .El | |
5ec60461 | 879 | .PP |
8d5bf179 MK |
880 | A file's section header table lets one locate all the file's sections. |
881 | The | |
969c00ce MK |
882 | section header table is an array of |
883 | .I Elf32_Shdr | |
884 | or | |
885 | .I Elf64_Shdr | |
886 | structures. | |
8d5bf179 MK |
887 | The |
888 | ELF header's | |
3233d665 | 889 | .IR e_shoff |
8d5bf179 MK |
890 | member gives the byte offset from the beginning of the file to the section |
891 | header table. | |
3233d665 | 892 | .IR e_shnum |
8d5bf179 | 893 | holds the number of entries the section header table contains. |
3233d665 | 894 | .IR e_shentsize |
8d5bf179 | 895 | holds the size in bytes of each entry. |
5ec60461 | 896 | .PP |
8d5bf179 MK |
897 | A section header table index is a subscript into this array. |
898 | Some section | |
6866d935 DH |
899 | header table indices are reserved: |
900 | the initial entry and the indices between | |
901 | .B SHN_LORESERVE | |
902 | and | |
903 | .BR SHN_HIRESERVE . | |
904 | The initial entry is used in ELF extensions for | |
905 | .IR e_phnum , | |
906 | .IR e_shnum | |
907 | and | |
908 | .IR e_strndx ; | |
909 | in other cases, each field in the initial entry is set to zero. | |
8d5bf179 MK |
910 | An object file does not have sections for |
911 | these special indices: | |
3233d665 | 912 | .\" .Bl -tag -width "SHN_LORESERVE" |
888e0048 | 913 | .RS |
3233d665 MK |
914 | .TP 14 |
915 | .BR SHN_UNDEF | |
8d5bf179 MK |
916 | This value marks an undefined, missing, irrelevant or otherwise meaningless |
917 | section reference. | |
3233d665 MK |
918 | .TP |
919 | .BR SHN_LORESERVE | |
8d5bf179 | 920 | This value specifies the lower bound of the range of reserved indices. |
3233d665 MK |
921 | .TP |
922 | .BR SHN_LOPROC | |
8d5bf179 | 923 | Values greater than or equal to |
3233d665 | 924 | .BR SHN_HIPROC |
8d5bf179 | 925 | are reserved for processor-specific semantics. |
3233d665 MK |
926 | .TP |
927 | .BR SHN_HIPROC | |
8d5bf179 | 928 | Values less than or equal to |
3233d665 | 929 | .BR SHN_LOPROC |
8d5bf179 | 930 | are reserved for processor-specific semantics. |
3233d665 MK |
931 | .TP |
932 | .BR SHN_ABS | |
8d5bf179 MK |
933 | This value specifies the absolute value for the corresponding reference. |
934 | For | |
935 | example, a symbol defined relative to section number | |
3233d665 | 936 | .BR SHN_ABS |
8d5bf179 | 937 | has an absolute value and is not affected by relocation. |
3233d665 MK |
938 | .TP |
939 | .BR SHN_COMMON | |
8d5bf179 MK |
940 | Symbols defined relative to this section are common symbols, such as FORTRAN |
941 | COMMON or unallocated C external variables. | |
3233d665 MK |
942 | .TP |
943 | .BR SHN_HIRESERVE | |
8d5bf179 MK |
944 | This value specifies the upper bound of the range of reserved indices. |
945 | The | |
946 | system reserves indices between | |
3233d665 | 947 | .BR SHN_LORESERVE |
8d5bf179 | 948 | and |
3233d665 | 949 | .BR SHN_HIRESERVE , |
8d5bf179 MK |
950 | inclusive. |
951 | The section header table does not contain entries for the | |
952 | reserved indices. | |
888e0048 | 953 | .RE |
3233d665 | 954 | .\" .El |
3233d665 | 955 | .PP |
8d5bf179 | 956 | The section header has the following structure: |
088a639b | 957 | .in +4n |
3233d665 MK |
958 | .nf |
959 | ||
8d5bf179 | 960 | typedef struct { |
dd0a09a5 MK |
961 | uint32_t sh_name; |
962 | uint32_t sh_type; | |
963 | uint32_t sh_flags; | |
964 | Elf32_Addr sh_addr; | |
965 | Elf32_Off sh_offset; | |
966 | uint32_t sh_size; | |
967 | uint32_t sh_link; | |
968 | uint32_t sh_info; | |
969 | uint32_t sh_addralign; | |
970 | uint32_t sh_entsize; | |
8d5bf179 | 971 | } Elf32_Shdr; |
3233d665 MK |
972 | .fi |
973 | .in | |
088a639b | 974 | .in +4n |
3233d665 MK |
975 | .nf |
976 | ||
8d5bf179 | 977 | typedef struct { |
dd0a09a5 MK |
978 | uint32_t sh_name; |
979 | uint32_t sh_type; | |
980 | uint64_t sh_flags; | |
981 | Elf64_Addr sh_addr; | |
982 | Elf64_Off sh_offset; | |
983 | uint64_t sh_size; | |
984 | uint32_t sh_link; | |
985 | uint32_t sh_info; | |
986 | uint64_t sh_addralign; | |
987 | uint64_t sh_entsize; | |
8d5bf179 | 988 | } Elf64_Shdr; |
3233d665 MK |
989 | .fi |
990 | .in | |
5ec60461 | 991 | .PP |
8d5bf179 | 992 | No real differences exist between the 32-bit and 64-bit section headers. |
3233d665 | 993 | .\" .Bl -tag -width "sh_addralign" |
5ec60461 | 994 | .TP 10 |
3233d665 | 995 | .IR sh_name |
8d5bf179 MK |
996 | This member specifies the name of the section. |
997 | Its value is an index | |
998 | into the section header string table section, giving the location of | |
999 | a null-terminated string. | |
3233d665 MK |
1000 | .TP |
1001 | .IR sh_type | |
8d5bf179 | 1002 | This member categorizes the section's contents and semantics. |
3233d665 | 1003 | .\" .Bl -tag -width "SHT_PROGBITS" |
5ec60461 MK |
1004 | .RS 10 |
1005 | .TP 15 | |
3233d665 | 1006 | .BR SHT_NULL |
8d5bf179 MK |
1007 | This value marks the section header as inactive. |
1008 | It does not | |
1009 | have an associated section. | |
1010 | Other members of the section header | |
1011 | have undefined values. | |
3233d665 MK |
1012 | .TP |
1013 | .BR SHT_PROGBITS | |
8d5bf179 MK |
1014 | This section holds information defined by the program, whose |
1015 | format and meaning are determined solely by the program. | |
3233d665 MK |
1016 | .TP |
1017 | .BR SHT_SYMTAB | |
8d5bf179 MK |
1018 | This section holds a symbol table. |
1019 | Typically, | |
3233d665 | 1020 | .BR SHT_SYMTAB |
8d5bf179 MK |
1021 | provides symbols for link editing, though it may also be used |
1022 | for dynamic linking. | |
1023 | As a complete symbol table, it may contain | |
1024 | many symbols unnecessary for dynamic linking. | |
1025 | An object file can | |
1026 | also contain a | |
3233d665 | 1027 | .BR SHT_DYNSYM |
8d5bf179 | 1028 | section. |
3233d665 MK |
1029 | .TP |
1030 | .BR SHT_STRTAB | |
8d5bf179 MK |
1031 | This section holds a string table. |
1032 | An object file may have multiple | |
1033 | string table sections. | |
3233d665 MK |
1034 | .TP |
1035 | .BR SHT_RELA | |
8d5bf179 MK |
1036 | This section holds relocation entries with explicit addends, such |
1037 | as type | |
969c00ce | 1038 | .IR Elf32_Rela |
8d5bf179 MK |
1039 | for the 32-bit class of object files. |
1040 | An object may have multiple | |
1041 | relocation sections. | |
3233d665 MK |
1042 | .TP |
1043 | .BR SHT_HASH | |
8d5bf179 MK |
1044 | This section holds a symbol hash table. |
1045 | An object participating in | |
1046 | dynamic linking must contain a symbol hash table. | |
1047 | An object file may | |
1048 | have only one hash table. | |
3233d665 MK |
1049 | .TP |
1050 | .BR SHT_DYNAMIC | |
8d5bf179 MK |
1051 | This section holds information for dynamic linking. |
1052 | An object file may | |
1053 | have only one dynamic section. | |
3233d665 MK |
1054 | .TP |
1055 | .BR SHT_NOTE | |
8d5bf179 | 1056 | This section holds information that marks the file in some way. |
3233d665 MK |
1057 | .TP |
1058 | .BR SHT_NOBITS | |
8d5bf179 MK |
1059 | A section of this type occupies no space in the file but otherwise |
1060 | resembles | |
3233d665 | 1061 | .BR SHT_PROGBITS . |
8d5bf179 | 1062 | Although this section contains no bytes, the |
3233d665 | 1063 | .IR sh_offset |
8d5bf179 | 1064 | member contains the conceptual file offset. |
3233d665 MK |
1065 | .TP |
1066 | .BR SHT_REL | |
8d5bf179 MK |
1067 | This section holds relocation offsets without explicit addends, such |
1068 | as type | |
969c00ce | 1069 | .IR Elf32_Rel |
8d5bf179 MK |
1070 | for the 32-bit class of object files. |
1071 | An object file may have multiple | |
1072 | relocation sections. | |
3233d665 MK |
1073 | .TP |
1074 | .BR SHT_SHLIB | |
8d5bf179 | 1075 | This section is reserved but has unspecified semantics. |
3233d665 MK |
1076 | .TP |
1077 | .BR SHT_DYNSYM | |
8d5bf179 MK |
1078 | This section holds a minimal set of dynamic linking symbols. |
1079 | An | |
1080 | object file can also contain a | |
3233d665 | 1081 | .BR SHT_SYMTAB |
8d5bf179 | 1082 | section. |
3233d665 MK |
1083 | .TP |
1084 | .BR SHT_LOPROC | |
8d5bf179 | 1085 | This value up to and including |
3233d665 | 1086 | .BR SHT_HIPROC |
8d5bf179 | 1087 | is reserved for processor-specific semantics. |
3233d665 MK |
1088 | .TP |
1089 | .BR SHT_HIPROC | |
8d5bf179 | 1090 | This value down to and including |
3233d665 | 1091 | .BR SHT_LOPROC |
8d5bf179 | 1092 | is reserved for processor-specific semantics. |
3233d665 MK |
1093 | .TP |
1094 | .BR SHT_LOUSER | |
8d5bf179 MK |
1095 | This value specifies the lower bound of the range of indices reserved for |
1096 | application programs. | |
3233d665 MK |
1097 | .TP |
1098 | .BR SHT_HIUSER | |
8d5bf179 MK |
1099 | This value specifies the upper bound of the range of indices reserved for |
1100 | application programs. | |
1101 | Section types between | |
3233d665 | 1102 | .BR SHT_LOUSER |
8d5bf179 | 1103 | and |
3233d665 | 1104 | .BR SHT_HIUSER |
8d5bf179 MK |
1105 | may be used by the application, without conflicting with current or future |
1106 | system-defined section types. | |
3233d665 MK |
1107 | .\" .El |
1108 | .RE | |
1109 | .TP | |
1110 | .IR sh_flags | |
8d5bf179 MK |
1111 | Sections support one-bit flags that describe miscellaneous attributes. |
1112 | If a flag bit is set in | |
3233d665 | 1113 | .IR sh_flags , |
8d5bf179 | 1114 | the attribute is |
3233d665 | 1115 | "on" |
8d5bf179 MK |
1116 | for the section. |
1117 | Otherwise, the attribute is | |
3233d665 | 1118 | "off" |
8d5bf179 MK |
1119 | or does not apply. |
1120 | Undefined attributes are set to zero. | |
3233d665 | 1121 | .\" .Bl -tag -width "SHF_EXECINSTR" -compact |
5ec60461 MK |
1122 | .RS 10 |
1123 | .TP 15 | |
3233d665 | 1124 | .BR SHF_WRITE |
8d5bf179 MK |
1125 | This section contains data that should be writable during process |
1126 | execution. | |
3233d665 MK |
1127 | .TP |
1128 | .BR SHF_ALLOC | |
8d5bf179 MK |
1129 | This section occupies memory during process execution. |
1130 | Some control | |
1131 | sections do not reside in the memory image of an object file. | |
1132 | This | |
1133 | attribute is off for those sections. | |
3233d665 MK |
1134 | .TP |
1135 | .BR SHF_EXECINSTR | |
8d5bf179 | 1136 | This section contains executable machine instructions. |
3233d665 MK |
1137 | .TP |
1138 | .BR SHF_MASKPROC | |
8d5bf179 MK |
1139 | All bits included in this mask are reserved for processor-specific |
1140 | semantics. | |
3233d665 MK |
1141 | .RE |
1142 | .\" .El | |
1143 | .TP | |
1144 | .IR sh_addr | |
8d5bf179 MK |
1145 | If this section appears in the memory image of a process, this member |
1146 | holds the address at which the section's first byte should reside. | |
1147 | Otherwise, the member contains zero. | |
3233d665 MK |
1148 | .TP |
1149 | .IR sh_offset | |
8d5bf179 MK |
1150 | This member's value holds the byte offset from the beginning of the file |
1151 | to the first byte in the section. | |
1152 | One section type, | |
3233d665 | 1153 | .BR SHT_NOBITS , |
8d5bf179 | 1154 | occupies no space in the file, and its |
3233d665 | 1155 | .IR sh_offset |
8d5bf179 | 1156 | member locates the conceptual placement in the file. |
3233d665 MK |
1157 | .TP |
1158 | .IR sh_size | |
8d5bf179 MK |
1159 | This member holds the section's size in bytes. |
1160 | Unless the section type | |
1161 | is | |
3233d665 | 1162 | .BR SHT_NOBITS , |
8d5bf179 | 1163 | the section occupies |
3233d665 | 1164 | .IR sh_size |
8d5bf179 MK |
1165 | bytes in the file. |
1166 | A section of type | |
3233d665 | 1167 | .BR SHT_NOBITS |
c7094399 | 1168 | may have a nonzero size, but it occupies no space in the file. |
3233d665 MK |
1169 | .TP |
1170 | .IR sh_link | |
8d5bf179 MK |
1171 | This member holds a section header table index link, whose interpretation |
1172 | depends on the section type. | |
3233d665 MK |
1173 | .TP |
1174 | .IR sh_info | |
8d5bf179 MK |
1175 | This member holds extra information, whose interpretation depends on the |
1176 | section type. | |
3233d665 MK |
1177 | .TP |
1178 | .IR sh_addralign | |
8d5bf179 MK |
1179 | Some sections have address alignment constraints. |
1180 | If a section holds a | |
1181 | doubleword, the system must ensure doubleword alignment for the entire | |
1182 | section. | |
1183 | That is, the value of | |
3233d665 | 1184 | .IR sh_addr |
8d5bf179 | 1185 | must be congruent to zero, modulo the value of |
3233d665 | 1186 | .IR sh_addralign . |
8d5bf179 MK |
1187 | Only zero and positive integral powers of two are allowed. |
1188 | Values of zero | |
1189 | or one mean the section has no alignment constraints. | |
3233d665 MK |
1190 | .TP |
1191 | .IR sh_entsize | |
8d5bf179 MK |
1192 | Some sections hold a table of fixed-sized entries, such as a symbol table. |
1193 | For such a section, this member gives the size in bytes for each entry. | |
1194 | This member contains zero if the section does not hold a table of | |
1195 | fixed-size entries. | |
3233d665 MK |
1196 | .\" .El |
1197 | .PP | |
8d5bf179 | 1198 | Various sections hold program and control information: |
3233d665 | 1199 | .\" .Bl -tag -width ".shstrtab" |
5ec60461 | 1200 | .TP 10 |
3233d665 | 1201 | .IR .bss |
8d5bf179 MK |
1202 | This section holds uninitialized data that contributes to the program's |
1203 | memory image. | |
1204 | By definition, the system initializes the data with zeros | |
1205 | when the program begins to run. | |
1206 | This section is of type | |
3233d665 | 1207 | .BR SHT_NOBITS . |
8d5bf179 | 1208 | The attribute types are |
3233d665 | 1209 | .BR SHF_ALLOC |
8d5bf179 | 1210 | and |
3233d665 MK |
1211 | .BR SHF_WRITE . |
1212 | .TP | |
1213 | .IR .comment | |
8d5bf179 MK |
1214 | This section holds version control information. |
1215 | This section is of type | |
3233d665 | 1216 | .BR SHT_PROGBITS . |
8d5bf179 | 1217 | No attribute types are used. |
3233d665 MK |
1218 | .TP |
1219 | .IR .ctors | |
8d5bf179 MK |
1220 | This section holds initialized pointers to the C++ constructor functions. |
1221 | This section is of type | |
3233d665 | 1222 | .BR SHT_PROGBITS . |
8d5bf179 | 1223 | The attribute types are |
3233d665 | 1224 | .BR SHF_ALLOC |
8d5bf179 | 1225 | and |
3233d665 MK |
1226 | .BR SHF_WRITE . |
1227 | .TP | |
1228 | .IR .data | |
8d5bf179 MK |
1229 | This section holds initialized data that contribute to the program's |
1230 | memory image. | |
1231 | This section is of type | |
3233d665 | 1232 | .BR SHT_PROGBITS . |
8d5bf179 | 1233 | The attribute types are |
3233d665 | 1234 | .BR SHF_ALLOC |
8d5bf179 | 1235 | and |
3233d665 MK |
1236 | .BR SHF_WRITE . |
1237 | .TP | |
1238 | .IR .data1 | |
8d5bf179 MK |
1239 | This section holds initialized data that contribute to the program's |
1240 | memory image. | |
1241 | This section is of type | |
3233d665 | 1242 | .BR SHT_PROGBITS . |
8d5bf179 | 1243 | The attribute types are |
3233d665 | 1244 | .BR SHF_ALLOC |
8d5bf179 | 1245 | and |
3233d665 MK |
1246 | .BR SHF_WRITE . |
1247 | .TP | |
1248 | .IR .debug | |
8d5bf179 MK |
1249 | This section holds information for symbolic debugging. |
1250 | The contents | |
1251 | are unspecified. | |
1252 | This section is of type | |
3233d665 | 1253 | .BR SHT_PROGBITS . |
8d5bf179 | 1254 | No attribute types are used. |
3233d665 MK |
1255 | .TP |
1256 | .IR .dtors | |
8d5bf179 MK |
1257 | This section holds initialized pointers to the C++ destructor functions. |
1258 | This section is of type | |
3233d665 | 1259 | .BR SHT_PROGBITS . |
8d5bf179 | 1260 | The attribute types are |
3233d665 | 1261 | .BR SHF_ALLOC |
8d5bf179 | 1262 | and |
3233d665 MK |
1263 | .BR SHF_WRITE . |
1264 | .TP | |
1265 | .IR .dynamic | |
8d5bf179 MK |
1266 | This section holds dynamic linking information. |
1267 | The section's attributes | |
1268 | will include the | |
3233d665 | 1269 | .BR SHF_ALLOC |
8d5bf179 MK |
1270 | bit. |
1271 | Whether the | |
3233d665 | 1272 | .BR SHF_WRITE |
d19a206d | 1273 | bit is set is processor-specific. |
8d5bf179 | 1274 | This section is of type |
3233d665 | 1275 | .BR SHT_DYNAMIC . |
8d5bf179 | 1276 | See the attributes above. |
3233d665 MK |
1277 | .TP |
1278 | .IR .dynstr | |
8d5bf179 MK |
1279 | This section holds strings needed for dynamic linking, most commonly |
1280 | the strings that represent the names associated with symbol table entries. | |
1281 | This section is of type | |
3233d665 | 1282 | .BR SHT_STRTAB . |
8d5bf179 | 1283 | The attribute type used is |
3233d665 MK |
1284 | .BR SHF_ALLOC . |
1285 | .TP | |
1286 | .IR .dynsym | |
8d5bf179 MK |
1287 | This section holds the dynamic linking symbol table. |
1288 | This section is of type | |
3233d665 | 1289 | .BR SHT_DYNSYM . |
8d5bf179 | 1290 | The attribute used is |
3233d665 MK |
1291 | .BR SHF_ALLOC . |
1292 | .TP | |
1293 | .IR .fini | |
8d5bf179 MK |
1294 | This section holds executable instructions that contribute to the process |
1295 | termination code. | |
1296 | When a program exits normally the system arranges to | |
1297 | execute the code in this section. | |
1298 | This section is of type | |
3233d665 | 1299 | .BR SHT_PROGBITS . |
8d5bf179 | 1300 | The attributes used are |
3233d665 | 1301 | .BR SHF_ALLOC |
8d5bf179 | 1302 | and |
3233d665 MK |
1303 | .BR SHF_EXECINSTR . |
1304 | .TP | |
1305 | .IR .gnu.version | |
969c00ce MK |
1306 | This section holds the version symbol table, an array of |
1307 | .I ElfN_Half | |
1308 | elements. | |
dbdab2f4 | 1309 | This section is of type |
3233d665 | 1310 | .BR SHT_GNU_versym . |
dbdab2f4 | 1311 | The attribute type used is |
3233d665 MK |
1312 | .BR SHF_ALLOC . |
1313 | .TP | |
1314 | .IR .gnu.version_d | |
f6c0f137 | 1315 | This section holds the version symbol definitions, a table of |
969c00ce MK |
1316 | .I ElfN_Verdef |
1317 | structures. | |
1318 | This section is of type | |
3233d665 | 1319 | .BR SHT_GNU_verdef . |
dbdab2f4 | 1320 | The attribute type used is |
3233d665 MK |
1321 | .BR SHF_ALLOC . |
1322 | .TP | |
1323 | .IR .gnu.version_r | |
dbdab2f4 | 1324 | This section holds the version symbol needed elements, a table of |
969c00ce MK |
1325 | .I ElfN_Verneed |
1326 | structures. | |
1327 | This section is of | |
dbdab2f4 | 1328 | type |
3233d665 | 1329 | .BR SHT_GNU_versym . |
dbdab2f4 | 1330 | The attribute type used is |
3233d665 MK |
1331 | .BR SHF_ALLOC . |
1332 | .TP | |
1333 | .IR .got | |
8d5bf179 MK |
1334 | This section holds the global offset table. |
1335 | This section is of type | |
3233d665 | 1336 | .BR SHT_PROGBITS . |
e2badfdf | 1337 | The attributes are processor specific. |
3233d665 MK |
1338 | .TP |
1339 | .IR .hash | |
8d5bf179 MK |
1340 | This section holds a symbol hash table. |
1341 | This section is of type | |
3233d665 | 1342 | .BR SHT_HASH . |
8d5bf179 | 1343 | The attribute used is |
3233d665 MK |
1344 | .BR SHF_ALLOC . |
1345 | .TP | |
1346 | .IR .init | |
8d5bf179 MK |
1347 | This section holds executable instructions that contribute to the process |
1348 | initialization code. | |
1349 | When a program starts to run the system arranges to | |
1350 | execute the code in this section before calling the main program entry point. | |
1351 | This section is of type | |
3233d665 | 1352 | .BR SHT_PROGBITS . |
8d5bf179 | 1353 | The attributes used are |
3233d665 | 1354 | .BR SHF_ALLOC |
8d5bf179 | 1355 | and |
3233d665 MK |
1356 | .BR SHF_EXECINSTR . |
1357 | .TP | |
1358 | .IR .interp | |
8d5bf179 MK |
1359 | This section holds the pathname of a program interpreter. |
1360 | If the file has | |
1361 | a loadable segment that includes the section, the section's attributes will | |
1362 | include the | |
3233d665 | 1363 | .BR SHF_ALLOC |
8d5bf179 MK |
1364 | bit. |
1365 | Otherwise, that bit will be off. | |
1366 | This section is of type | |
3233d665 MK |
1367 | .BR SHT_PROGBITS . |
1368 | .TP | |
1369 | .IR .line | |
8d5bf179 MK |
1370 | This section holds line number information for symbolic debugging, which |
1371 | describes the correspondence between the program source and the machine code. | |
1372 | The contents are unspecified. | |
1373 | This section is of type | |
3233d665 | 1374 | .BR SHT_PROGBITS . |
8d5bf179 | 1375 | No attribute types are used. |
3233d665 MK |
1376 | .TP |
1377 | .IR .note | |
8d5bf179 | 1378 | This section holds information in the |
3233d665 | 1379 | "Note Section" |
eed79eed | 1380 | format. |
8d5bf179 | 1381 | This section is of type |
3233d665 | 1382 | .BR SHT_NOTE . |
8d5bf179 | 1383 | No attribute types are used. |
3233d665 | 1384 | OpenBSD |
8d5bf179 | 1385 | native executables usually contain a |
3233d665 | 1386 | .I .note.openbsd.ident |
8d5bf179 MK |
1387 | section to identify themselves, for the kernel to bypass any compatibility |
1388 | ELF binary emulation tests when loading the file. | |
3233d665 MK |
1389 | .TP |
1390 | .IR .note.GNU-stack | |
dbdab2f4 MK |
1391 | This section is used in Linux object files for declaring stack attributes. |
1392 | This section is of type | |
3233d665 | 1393 | .BR SHT_PROGBITS . |
dbdab2f4 | 1394 | The only attribute used is |
3233d665 | 1395 | .BR SHF_EXECINSTR . |
dbdab2f4 MK |
1396 | This indicates to the GNU linker that the object file requires an |
1397 | executable stack. | |
3233d665 MK |
1398 | .TP |
1399 | .IR .plt | |
8d5bf179 MK |
1400 | This section holds the procedure linkage table. |
1401 | This section is of type | |
3233d665 | 1402 | .BR SHT_PROGBITS . |
e2badfdf | 1403 | The attributes are processor specific. |
3233d665 MK |
1404 | .TP |
1405 | .IR .relNAME | |
8d5bf179 MK |
1406 | This section holds relocation information as described below. |
1407 | If the file | |
1408 | has a loadable segment that includes relocation, the section's attributes | |
1409 | will include the | |
3233d665 | 1410 | .BR SHF_ALLOC |
8d5bf179 MK |
1411 | bit. |
1412 | Otherwise the bit will be off. | |
1413 | By convention, | |
3233d665 | 1414 | "NAME" |
8d5bf179 MK |
1415 | is supplied by the section to which the relocations apply. |
1416 | Thus a relocation | |
1417 | section for | |
3233d665 | 1418 | .BR .text |
8d5bf179 | 1419 | normally would have the name |
3233d665 | 1420 | .BR .rel.text . |
8d5bf179 | 1421 | This section is of type |
3233d665 MK |
1422 | .BR SHT_REL . |
1423 | .TP | |
1424 | .IR .relaNAME | |
8d5bf179 MK |
1425 | This section holds relocation information as described below. |
1426 | If the file | |
1427 | has a loadable segment that includes relocation, the section's attributes | |
1428 | will include the | |
3233d665 | 1429 | .BR SHF_ALLOC |
8d5bf179 MK |
1430 | bit. |
1431 | Otherwise the bit will be off. | |
1432 | By convention, | |
3233d665 | 1433 | "NAME" |
8d5bf179 MK |
1434 | is supplied by the section to which the relocations apply. |
1435 | Thus a relocation | |
1436 | section for | |
3233d665 | 1437 | .BR .text |
8d5bf179 | 1438 | normally would have the name |
3233d665 | 1439 | .BR .rela.text . |
8d5bf179 | 1440 | This section is of type |
3233d665 MK |
1441 | .BR SHT_RELA . |
1442 | .TP | |
1443 | .IR .rodata | |
8d5bf179 | 1444 | This section holds read-only data that typically contributes to a |
24b74457 | 1445 | nonwritable segment in the process image. |
8d5bf179 | 1446 | This section is of type |
3233d665 | 1447 | .BR SHT_PROGBITS . |
8d5bf179 | 1448 | The attribute used is |
3233d665 MK |
1449 | .BR SHF_ALLOC . |
1450 | .TP | |
1451 | .IR .rodata1 | |
8d5bf179 | 1452 | This section holds read-only data that typically contributes to a |
24b74457 | 1453 | nonwritable segment in the process image. |
8d5bf179 | 1454 | This section is of type |
3233d665 | 1455 | .BR SHT_PROGBITS . |
8d5bf179 | 1456 | The attribute used is |
3233d665 MK |
1457 | .BR SHF_ALLOC . |
1458 | .TP | |
1459 | .IR .shstrtab | |
8d5bf179 MK |
1460 | This section holds section names. |
1461 | This section is of type | |
3233d665 | 1462 | .BR SHT_STRTAB . |
8d5bf179 | 1463 | No attribute types are used. |
3233d665 MK |
1464 | .TP |
1465 | .IR .strtab | |
8d5bf179 MK |
1466 | This section holds strings, most commonly the strings that represent the |
1467 | names associated with symbol table entries. | |
1468 | If the file has a loadable | |
1469 | segment that includes the symbol string table, the section's attributes | |
1470 | will include the | |
3233d665 | 1471 | .BR SHF_ALLOC |
8d5bf179 MK |
1472 | bit. |
1473 | Otherwise the bit will be off. | |
1474 | This section is of type | |
3233d665 MK |
1475 | .BR SHT_STRTAB . |
1476 | .TP | |
1477 | .IR .symtab | |
8d5bf179 MK |
1478 | This section holds a symbol table. |
1479 | If the file has a loadable segment | |
1480 | that includes the symbol table, the section's attributes will include | |
1481 | the | |
3233d665 | 1482 | .BR SHF_ALLOC |
8d5bf179 MK |
1483 | bit. |
1484 | Otherwise the bit will be off. | |
1485 | This section is of type | |
3233d665 MK |
1486 | .BR SHT_SYMTAB . |
1487 | .TP | |
1488 | .IR .text | |
8d5bf179 | 1489 | This section holds the |
3233d665 | 1490 | "text", |
8d5bf179 MK |
1491 | or executable instructions, of a program. |
1492 | This section is of type | |
3233d665 | 1493 | .BR SHT_PROGBITS . |
8d5bf179 | 1494 | The attributes used are |
3233d665 | 1495 | .BR SHF_ALLOC |
8d5bf179 | 1496 | and |
3233d665 MK |
1497 | .BR SHF_EXECINSTR . |
1498 | .\" .El | |
5ec60461 | 1499 | .PP |
fea681da MK |
1500 | String table sections hold null-terminated character sequences, commonly |
1501 | called strings. | |
1502 | The object file uses these strings to represent symbol | |
1503 | and section names. | |
1504 | One references a string as an index into the string | |
1505 | table section. | |
1506 | The first byte, which is index zero, is defined to hold | |
f81fb444 | 1507 | a null byte (\(aq\\0\(aq). |
fea681da | 1508 | Similarly, a string table's last byte is defined to |
28d88c17 | 1509 | hold a null byte, ensuring null termination for all strings. |
5ec60461 | 1510 | .PP |
fea681da MK |
1511 | An object file's symbol table holds information needed to locate and |
1512 | relocate a program's symbolic definitions and references. | |
1513 | A symbol table | |
1514 | index is a subscript into this array. | |
088a639b | 1515 | .in +4n |
3233d665 MK |
1516 | .nf |
1517 | ||
fea681da | 1518 | typedef struct { |
dd0a09a5 MK |
1519 | uint32_t st_name; |
1520 | Elf32_Addr st_value; | |
1521 | uint32_t st_size; | |
1522 | unsigned char st_info; | |
1523 | unsigned char st_other; | |
1524 | uint16_t st_shndx; | |
fea681da | 1525 | } Elf32_Sym; |
3233d665 MK |
1526 | .fi |
1527 | .in | |
088a639b | 1528 | .in +4n |
3233d665 MK |
1529 | .nf |
1530 | ||
fea681da | 1531 | typedef struct { |
dd0a09a5 MK |
1532 | uint32_t st_name; |
1533 | unsigned char st_info; | |
1534 | unsigned char st_other; | |
1535 | uint16_t st_shndx; | |
1536 | Elf64_Addr st_value; | |
1537 | uint64_t st_size; | |
fea681da | 1538 | } Elf64_Sym; |
3233d665 MK |
1539 | .fi |
1540 | .in | |
5ec60461 | 1541 | .PP |
c13182ef | 1542 | The 32-bit and 64-bit versions have the same members, just in a different |
28d979c8 | 1543 | order. |
9a23a0c0 | 1544 | .\" .Bl -tag -width "st_value" |
5ec60461 | 1545 | .TP 10 |
3233d665 | 1546 | .IR st_name |
fea681da MK |
1547 | This member holds an index into the object file's symbol string table, |
1548 | which holds character representations of the symbol names. | |
1549 | If the value | |
c7094399 | 1550 | is nonzero, it represents a string table index that gives the symbol |
fea681da MK |
1551 | name. |
1552 | Otherwise, the symbol table has no name. | |
3233d665 MK |
1553 | .TP |
1554 | .IR st_value | |
fea681da | 1555 | This member gives the value of the associated symbol. |
3233d665 MK |
1556 | .TP |
1557 | .IR st_size | |
fea681da MK |
1558 | Many symbols have associated sizes. |
1559 | This member holds zero if the symbol | |
1560 | has no size or an unknown size. | |
3233d665 MK |
1561 | .TP |
1562 | .IR st_info | |
fea681da | 1563 | This member specifies the symbol's type and binding attributes: |
3233d665 | 1564 | .\" .Bl -tag -width "STT_SECTION" |
5ec60461 | 1565 | .RS 10 |
3233d665 MK |
1566 | .TP 12 |
1567 | .BR STT_NOTYPE | |
8d5bf179 | 1568 | The symbol's type is not defined. |
3233d665 MK |
1569 | .TP |
1570 | .BR STT_OBJECT | |
8d5bf179 | 1571 | The symbol is associated with a data object. |
3233d665 MK |
1572 | .TP |
1573 | .BR STT_FUNC | |
8d5bf179 | 1574 | The symbol is associated with a function or other executable code. |
3233d665 MK |
1575 | .TP |
1576 | .BR STT_SECTION | |
8d5bf179 MK |
1577 | The symbol is associated with a section. |
1578 | Symbol table entries of | |
1579 | this type exist primarily for relocation and normally have | |
3233d665 | 1580 | .BR STB_LOCAL |
8d5bf179 | 1581 | bindings. |
3233d665 MK |
1582 | .TP |
1583 | .BR STT_FILE | |
8d5bf179 MK |
1584 | By convention, the symbol's name gives the name of the source file |
1585 | associated with the object file. | |
1586 | A file symbol has | |
3233d665 | 1587 | .BR STB_LOCAL |
8d5bf179 | 1588 | bindings, its section index is |
3233d665 | 1589 | .BR SHN_ABS , |
8d5bf179 | 1590 | and it precedes the other |
3233d665 | 1591 | .BR STB_LOCAL |
8d5bf179 | 1592 | symbols of the file, if it is present. |
3233d665 MK |
1593 | .TP |
1594 | .BR STT_LOPROC | |
8d5bf179 | 1595 | This value up to and including |
3233d665 | 1596 | .BR STT_HIPROC |
8d5bf179 | 1597 | is reserved for processor-specific semantics. |
3233d665 MK |
1598 | .TP |
1599 | .BR STT_HIPROC | |
8d5bf179 | 1600 | This value down to and including |
3233d665 | 1601 | .BR STT_LOPROC |
8d5bf179 | 1602 | is reserved for processor-specific semantics. |
3233d665 MK |
1603 | .\" .El |
1604 | .\" .Bl -tag -width "STB_GLOBAL" | |
1605 | .TP | |
1606 | .BR STB_LOCAL | |
8d5bf179 MK |
1607 | Local symbols are not visible outside the object file containing their |
1608 | definition. | |
1609 | Local symbols of the same name may exist in multiple files | |
1610 | without interfering with each other. | |
3233d665 MK |
1611 | .TP |
1612 | .BR STB_GLOBAL | |
8d5bf179 MK |
1613 | Global symbols are visible to all object files being combined. |
1614 | One file's | |
1615 | definition of a global symbol will satisfy another file's undefined | |
1616 | reference to the same symbol. | |
3233d665 MK |
1617 | .TP |
1618 | .BR STB_WEAK | |
8d5bf179 MK |
1619 | Weak symbols resemble global symbols, but their definitions have lower |
1620 | precedence. | |
3233d665 MK |
1621 | .TP |
1622 | .BR STB_LOPROC | |
8d5bf179 | 1623 | This value up to and including |
3233d665 | 1624 | .BR STB_HIPROC |
8d5bf179 | 1625 | is reserved for processor-specific semantics. |
3233d665 MK |
1626 | .TP |
1627 | .BR STB_HIPROC | |
8d5bf179 | 1628 | This value down to and including |
3233d665 | 1629 | .BR STB_LOPROC |
8d5bf179 | 1630 | is reserved for processor-specific semantics. |
5ec60461 | 1631 | .IP |
8d5bf179 | 1632 | There are macros for packing and unpacking the binding and type fields: |
5ec60461 | 1633 | .IP |
3233d665 | 1634 | .BR ELF32_ST_BIND (info) |
8d5bf179 | 1635 | or |
3233d665 | 1636 | .BR ELF64_ST_BIND (info) |
db4163b1 MK |
1637 | extract a binding from an |
1638 | .I st_info | |
1639 | value. | |
5ec60461 | 1640 | .IP |
3233d665 | 1641 | .BR ELF32_ST_TYPE (info) |
8d5bf179 | 1642 | or |
3233d665 | 1643 | .BR ELF64_ST_TYPE (info) |
8d5bf179 | 1644 | .br |
3233d665 MK |
1645 | extract a type from an |
1646 | .I st_info | |
1647 | value. | |
5ec60461 | 1648 | .IP |
3233d665 | 1649 | .BR ELF32_ST_INFO "(bind, type)" |
8d5bf179 | 1650 | or |
3233d665 | 1651 | .BR ELF64_ST_INFO "(bind, type)" |
8d5bf179 | 1652 | .br |
db4163b1 MK |
1653 | convert a binding and a type into an |
1654 | .I st_info | |
1655 | value. | |
3233d665 MK |
1656 | .RE |
1657 | .\" .El | |
1658 | .TP | |
1659 | .IR st_other | |
dbdab2f4 | 1660 | This member defines the symbol visibility. |
3233d665 | 1661 | .\" .Bl -tag -width "STV_PROTECTED" |
5ec60461 | 1662 | .RS 10 |
3233d665 | 1663 | .TP 16 |
5ec60461 | 1664 | .PD 0 |
3233d665 | 1665 | .BR STV_DEFAULT |
dbdab2f4 | 1666 | Default symbol visibility rules. |
3233d665 MK |
1667 | .TP |
1668 | .BR STV_INTERNAL | |
e2badfdf | 1669 | Processor-specific hidden class. |
3233d665 MK |
1670 | .TP |
1671 | .BR STV_HIDDEN | |
dbdab2f4 | 1672 | Symbol is unavailable in other modules. |
3233d665 MK |
1673 | .TP |
1674 | .BR STV_PROTECTED | |
dbdab2f4 | 1675 | Not preemptible, not exported. |
5ec60461 MK |
1676 | .PD |
1677 | .PP | |
dbdab2f4 | 1678 | There are macros for extracting the visibility type: |
5ec60461 | 1679 | .PP |
3233d665 | 1680 | .BR ELF32_ST_VISIBILITY (other) |
dbdab2f4 | 1681 | or |
3233d665 MK |
1682 | .BR ELF64_ST_VISIBILITY (other) |
1683 | .RE | |
1684 | .\" .El | |
1685 | .TP | |
1686 | .IR st_shndx | |
8d5bf179 | 1687 | Every symbol table entry is |
3233d665 | 1688 | "defined" |
8d5bf179 MK |
1689 | in relation to some section. |
1690 | This member holds the relevant section | |
1691 | header table index. | |
3233d665 | 1692 | .\" .El |
5ec60461 | 1693 | .PP |
fea681da MK |
1694 | Relocation is the process of connecting symbolic references with |
1695 | symbolic definitions. | |
1696 | Relocatable files must have information that | |
1697 | describes how to modify their section contents, thus allowing executable | |
ecccf7c2 | 1698 | and shared object files to hold the right information for a process's |
fea681da MK |
1699 | program image. |
1700 | Relocation entries are these data. | |
5ec60461 | 1701 | .PP |
fea681da | 1702 | Relocation structures that do not need an addend: |
088a639b | 1703 | .in +4n |
3233d665 MK |
1704 | .nf |
1705 | ||
fea681da | 1706 | typedef struct { |
dd0a09a5 MK |
1707 | Elf32_Addr r_offset; |
1708 | uint32_t r_info; | |
fea681da | 1709 | } Elf32_Rel; |
3233d665 MK |
1710 | .fi |
1711 | .in | |
088a639b | 1712 | .in +4n |
3233d665 MK |
1713 | .nf |
1714 | ||
fea681da | 1715 | typedef struct { |
dd0a09a5 MK |
1716 | Elf64_Addr r_offset; |
1717 | uint64_t r_info; | |
fea681da | 1718 | } Elf64_Rel; |
3233d665 MK |
1719 | .fi |
1720 | .in | |
5ec60461 | 1721 | .PP |
fea681da | 1722 | Relocation structures that need an addend: |
088a639b | 1723 | .in +4n |
3233d665 MK |
1724 | .nf |
1725 | ||
fea681da | 1726 | typedef struct { |
dd0a09a5 MK |
1727 | Elf32_Addr r_offset; |
1728 | uint32_t r_info; | |
1729 | int32_t r_addend; | |
fea681da | 1730 | } Elf32_Rela; |
3233d665 MK |
1731 | .fi |
1732 | .in | |
088a639b | 1733 | .in +4n |
3233d665 MK |
1734 | .nf |
1735 | ||
fea681da | 1736 | typedef struct { |
dd0a09a5 MK |
1737 | Elf64_Addr r_offset; |
1738 | uint64_t r_info; | |
1739 | int64_t r_addend; | |
fea681da | 1740 | } Elf64_Rela; |
3233d665 MK |
1741 | .fi |
1742 | .in | |
1743 | .\" .Bl -tag -width "r_offset" | |
1744 | .TP 12 | |
1745 | .IR r_offset | |
8d5bf179 MK |
1746 | This member gives the location at which to apply the relocation action. |
1747 | For a relocatable file, the value is the byte offset from the beginning | |
1748 | of the section to the storage unit affected by the relocation. | |
1749 | For an | |
1750 | executable file or shared object, the value is the virtual address of | |
1751 | the storage unit affected by the relocation. | |
3233d665 MK |
1752 | .TP |
1753 | .IR r_info | |
8d5bf179 MK |
1754 | This member gives both the symbol table index with respect to which the |
1755 | relocation must be made and the type of relocation to apply. | |
1756 | Relocation | |
e2badfdf | 1757 | types are processor specific. |
8d5bf179 MK |
1758 | When the text refers to a relocation |
1759 | entry's relocation type or symbol table index, it means the result of | |
1760 | applying | |
cab67c64 | 1761 | .BR ELF[32|64]_R_TYPE |
8d5bf179 | 1762 | or |
3233d665 | 1763 | .BR ELF[32|64]_R_SYM , |
8d5bf179 | 1764 | respectively, to the entry's |
3233d665 | 1765 | .IR r_info |
8d5bf179 | 1766 | member. |
3233d665 MK |
1767 | .TP |
1768 | .IR r_addend | |
8d5bf179 MK |
1769 | This member specifies a constant addend used to compute the value to be |
1770 | stored into the relocatable field. | |
3233d665 | 1771 | .\" .El |
5ec60461 | 1772 | .PP |
c13182ef MK |
1773 | The .dynamic section contains a series of structures that hold relevant |
1774 | dynamic linking information. | |
1775 | The d_tag member controls the interpretation | |
8d5bf179 | 1776 | of d_un. |
088a639b | 1777 | .in +4n |
3233d665 MK |
1778 | .nf |
1779 | ||
8d5bf179 | 1780 | typedef struct { |
dd0a09a5 MK |
1781 | Elf32_Sword d_tag; |
1782 | union { | |
3233d665 MK |
1783 | Elf32_Word d_val; |
1784 | Elf32_Addr d_ptr; | |
dd0a09a5 | 1785 | } d_un; |
8d5bf179 MK |
1786 | } Elf32_Dyn; |
1787 | extern Elf32_Dyn _DYNAMIC[]; | |
3233d665 MK |
1788 | .fi |
1789 | .in | |
088a639b | 1790 | .in +4n |
3233d665 MK |
1791 | .nf |
1792 | ||
8d5bf179 | 1793 | typedef struct { |
dd0a09a5 MK |
1794 | Elf64_Sxword d_tag; |
1795 | union { | |
1796 | Elf64_Xword d_val; | |
1797 | Elf64_Addr d_ptr; | |
1798 | } d_un; | |
8d5bf179 MK |
1799 | } Elf64_Dyn; |
1800 | extern Elf64_Dyn _DYNAMIC[]; | |
3233d665 MK |
1801 | .fi |
1802 | .in | |
1803 | .\" .Bl -tag -width "d_tag" | |
5ec60461 | 1804 | .TP 10 |
3233d665 | 1805 | .IR d_tag |
8d5bf179 | 1806 | This member may have any of the following values: |
3233d665 | 1807 | .\" .Bl -tag -width "DT_SYMBOLIC" |
5ec60461 | 1808 | .RS 10 |
3233d665 MK |
1809 | .TP 12 |
1810 | .BR DT_NULL | |
8d5bf179 | 1811 | Marks end of dynamic section |
3233d665 MK |
1812 | .TP |
1813 | .BR DT_NEEDED | |
8d5bf179 | 1814 | String table offset to name of a needed library |
3233d665 MK |
1815 | .TP |
1816 | .BR DT_PLTRELSZ | |
8d5bf179 | 1817 | Size in bytes of PLT relocs |
3233d665 MK |
1818 | .TP |
1819 | .BR DT_PLTGOT | |
8d5bf179 | 1820 | Address of PLT and/or GOT |
3233d665 MK |
1821 | .TP |
1822 | .BR DT_HASH | |
8d5bf179 | 1823 | Address of symbol hash table |
3233d665 MK |
1824 | .TP |
1825 | .BR DT_STRTAB | |
8d5bf179 | 1826 | Address of string table |
3233d665 MK |
1827 | .TP |
1828 | .BR DT_SYMTAB | |
8d5bf179 | 1829 | Address of symbol table |
3233d665 MK |
1830 | .TP |
1831 | .BR DT_RELA | |
8d5bf179 | 1832 | Address of Rela relocs table |
3233d665 MK |
1833 | .TP |
1834 | .BR DT_RELASZ | |
8d5bf179 | 1835 | Size in bytes of Rela table |
3233d665 MK |
1836 | .TP |
1837 | .BR DT_RELAENT | |
8d5bf179 | 1838 | Size in bytes of a Rela table entry |
3233d665 MK |
1839 | .TP |
1840 | .BR DT_STRSZ | |
8d5bf179 | 1841 | Size in bytes of string table |
3233d665 MK |
1842 | .TP |
1843 | .BR DT_SYMENT | |
8d5bf179 | 1844 | Size in bytes of a symbol table entry |
3233d665 MK |
1845 | .TP |
1846 | .BR DT_INIT | |
8d5bf179 | 1847 | Address of the initialization function |
3233d665 MK |
1848 | .TP |
1849 | .BR DT_FINI | |
8d5bf179 | 1850 | Address of the termination function |
3233d665 MK |
1851 | .TP |
1852 | .BR DT_SONAME | |
8d5bf179 | 1853 | String table offset to name of shared object |
3233d665 MK |
1854 | .TP |
1855 | .BR DT_RPATH | |
8d5bf179 | 1856 | String table offset to library search path (deprecated) |
3233d665 MK |
1857 | .TP |
1858 | .BR DT_SYMBOLIC | |
8d5bf179 | 1859 | Alert linker to search this shared object before the executable for symbols |
3233d665 MK |
1860 | .TP |
1861 | .BR DT_REL | |
8d5bf179 | 1862 | Address of Rel relocs table |
3233d665 MK |
1863 | .TP |
1864 | .BR DT_RELSZ | |
8d5bf179 | 1865 | Size in bytes of Rel table |
3233d665 MK |
1866 | .TP |
1867 | .BR DT_RELENT | |
8d5bf179 | 1868 | Size in bytes of a Rel table entry |
3233d665 MK |
1869 | .TP |
1870 | .BR DT_PLTREL | |
8d5bf179 | 1871 | Type of reloc the PLT refers (Rela or Rel) |
3233d665 MK |
1872 | .TP |
1873 | .BR DT_DEBUG | |
8d5bf179 | 1874 | Undefined use for debugging |
3233d665 MK |
1875 | .TP |
1876 | .BR DT_TEXTREL | |
24b74457 | 1877 | Absence of this indicates no relocs should apply to a nonwritable segment |
3233d665 MK |
1878 | .TP |
1879 | .BR DT_JMPREL | |
8d5bf179 | 1880 | Address of reloc entries solely for the PLT |
3233d665 MK |
1881 | .TP |
1882 | .BR DT_BIND_NOW | |
c13182ef | 1883 | Instruct dynamic linker to process all relocs before transferring control to |
8d5bf179 | 1884 | the executable |
3233d665 MK |
1885 | .TP |
1886 | .BR DT_RUNPATH | |
8d5bf179 | 1887 | String table offset to library search path |
3233d665 MK |
1888 | .TP |
1889 | .BR DT_LOPROC | |
8d5bf179 | 1890 | Start of processor-specific semantics |
3233d665 MK |
1891 | .TP |
1892 | .BR DT_HIPROC | |
8d5bf179 | 1893 | End of processor-specific semantics |
3233d665 MK |
1894 | .RE |
1895 | .\" .El | |
1896 | .TP | |
1897 | .IR d_val | |
8d5bf179 | 1898 | This member represents integer values with various interpretations. |
3233d665 MK |
1899 | .TP |
1900 | .IR d_ptr | |
c13182ef MK |
1901 | This member represents program virtual addresses. |
1902 | When interpreting | |
1903 | these addresses, the actual address should be computed based on the | |
1904 | original file value and memory base address. | |
1905 | Files do not contain | |
8d5bf179 | 1906 | relocation entries to fixup these addresses. |
3233d665 MK |
1907 | .TP |
1908 | .I _DYNAMIC | |
c13182ef | 1909 | Array containing all the dynamic structures in the .dynamic section. |
8d5bf179 | 1910 | This is automatically populated by the linker. |
3233d665 MK |
1911 | .\" .El |
1912 | .SH NOTES | |
1913 | .\" OpenBSD | |
75434268 | 1914 | .\" ELF support first appeared in |
3233d665 | 1915 | .\" OpenBSD 1.2, |
75434268 MK |
1916 | .\" although not all supported platforms use it as the native |
1917 | .\" binary file format. | |
1918 | ELF first appeared in | |
3233d665 | 1919 | System V. |
e37e3282 | 1920 | The ELF format is an adopted standard. |
6866d935 DH |
1921 | .PP |
1922 | The extensions for | |
1923 | .IR e_phnum , | |
1924 | .IR e_shnum | |
1925 | and | |
1926 | .IR e_strndx | |
1927 | respectively are | |
1928 | Linux extensions. | |
1929 | Sun, BSD and AMD64 also support them; for further information, | |
1930 | look under SEE ALSO. | |
3233d665 | 1931 | .\" .SH AUTHORS |
d2dc6294 MK |
1932 | .\" The original version of this manual page was written by |
1933 | .\" .An Jeroen Ruigrok van der Werven | |
1934 | .\" .Aq asmodai@FreeBSD.org | |
1935 | .\" with inspiration from BSDi's | |
1936 | .\" .Bsx | |
1937 | .\" .Nm elf | |
1938 | .\" man page. | |
3233d665 MK |
1939 | .SH SEE ALSO |
1940 | .BR as (1), | |
1941 | .BR gdb (1), | |
1942 | .BR ld (1), | |
1943 | .BR objdump (1), | |
1944 | .BR execve (2), | |
1945 | .BR core (5) | |
5ec60461 | 1946 | .PP |
3233d665 MK |
1947 | Hewlett-Packard, |
1948 | .IR "Elf-64 Object File Format" . | |
5ec60461 | 1949 | .PP |
3233d665 MK |
1950 | Santa Cruz Operation, |
1951 | .IR "System V Application Binary Interface" . | |
5ec60461 | 1952 | .PP |
008f1ecc | 1953 | UNIX System Laboratories, |
3233d665 MK |
1954 | "Object Files", |
1955 | .IR "Executable and Linking Format (ELF)" . | |
6866d935 DH |
1956 | .PP |
1957 | Sun Microsystems, | |
1958 | .IR "Linker and Libraries Guide" . | |
1959 | .PP | |
1960 | AMD64 ABI Draft, | |
1961 | .IR "System V Application Binary Interface AMD64 Architecture Processor Supplement" . | |
1962 | .PP |