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