Specifications.
[pintos-anon] / specs / sysv-abi-update.html / ch4.eheader.html
1 <html>
2 <title>ELF Header</title>
3 <h1>ELF Header</h1>
4 <p>
5 Some object file control structures can grow, because the ELF header
6 contains their actual sizes. If the object file format changes, a program
7 may encounter control structures that are larger or smaller than expected.
8 Programs might therefore ignore ``extra'' information. The treatment of
9 ``missing'' information depends on context and will be specified when and
10 if extensions are defined. 
11 <hr>
12 <b>Figure 4-3: ELF Header</b>
13 <p>
14 <pre>
15 <code>#define EI_NIDENT 16
16
17 typedef struct {
18         unsigned char   e_ident[EI_NIDENT];
19         Elf32_Half      e_type;
20         Elf32_Half      e_machine;
21         Elf32_Word      e_version;
22         Elf32_Addr      e_entry;
23         Elf32_Off       e_phoff;
24         Elf32_Off       e_shoff;
25         Elf32_Word      e_flags;
26         Elf32_Half      e_ehsize;
27         Elf32_Half      e_phentsize;
28         Elf32_Half      e_phnum;
29         Elf32_Half      e_shentsize;
30         Elf32_Half      e_shnum;
31         Elf32_Half      e_shstrndx;
32 } Elf32_Ehdr;
33
34 typedef struct {
35         unsigned char   e_ident[EI_NIDENT];
36         Elf64_Half      e_type;
37         Elf64_Half      e_machine;
38         Elf64_Word      e_version;
39         Elf64_Addr      e_entry;
40         Elf64_Off       e_phoff;
41         Elf64_Off       e_shoff;
42         Elf64_Word      e_flags;
43         Elf64_Half      e_ehsize;
44         Elf64_Half      e_phentsize;
45         Elf64_Half      e_phnum;
46         Elf64_Half      e_shentsize;
47         Elf64_Half      e_shnum;
48         Elf64_Half      e_shstrndx;
49 } Elf64_Ehdr;</code>
50 </pre>
51 <hr>
52 <dl compact>
53 <dt><code>e_ident</code></dt>
54 <dd>The initial bytes mark the file as an object file and 
55 provide machine-independent
56 data with which to decode and interpret the file's contents. 
57 Complete descriptions
58 appear below in <a href="#elfid">``ELF Identification''</a>. </dd>
59 <dt><code>e_type</code></dt>
60 <dd>This member identifies the object file type. </dd>
61 <p>
62 <table border cellspacing=0>
63 <tr>
64 <th><b>Name</b></th>
65 <th><b>Value</b></th>
66 <th><b>Meaning</b></th>
67 </tr>
68 <tr>
69 <td><code>ET_NONE</code></td>
70 <td align=right><code>0</code></td>
71 <td>No file type</td>
72 </tr>
73 <tr>
74 <td><code>ET_REL</code></td>
75 <td align=right><code>1</code></td>
76 <td>Relocatable file</td>
77 </tr>
78 <tr>
79 <td><code>ET_EXEC</code></td>
80 <td align=right><code>2</code></td>
81 <td>Executable file</td>
82 </tr>
83 <tr>
84 <td><code>ET_DYN</code></td>
85 <td align=right><code>3</code></td>
86 <td>Shared object file</td>
87 </tr>
88 <tr>
89 <td><code>ET_CORE</code></td>
90 <td align=right><code>4</code></td>
91 <td>Core file</td>
92 </tr>
93 <tr>
94 <td><code>ET_LOOS</code></td>
95 <td align=right><code>0xfe00</code></td>
96 <td>Operating system-specific</td>
97 </tr>
98 <tr>
99 <td><code>ET_HIOS</code></td>
100 <td align=right><code>0xfeff</code></td>
101 <td>Operating system-specific</td>
102 </tr>
103 <tr>
104 <td><code>ET_LOPROC</code></td>
105 <td align=right><code>0xff00</code></td>
106 <td>Processor-specific</td>
107 </tr>
108 <tr>
109 <td><code>ET_HIPROC</code></td>
110 <td align=right><code>0xffff</code></td>
111 <td>Processor-specific</td>
112 </tr>
113 </table>
114 <p>
115 Although the core file contents are unspecified, 
116 type <code>ET_CORE</code>
117 is reserved to mark the file. 
118 Values from <code>ET_LOOS</code> 
119 through <code>ET_HIOS</code>
120 (inclusive) are reserved for operating system-specific semantics.
121 Values from <code>ET_LOPROC</code> 
122 through <code>ET_HIPROC</code>
123 (inclusive) are reserved for processor-specific semantics. If meanings
124 are specified, the processor supplement explains them. Other values are
125 reserved and will be assigned to new object file types as necessary.
126 <p><a name="e_machine"></a>
127 <dt><code>e_machine</code></dt>
128 <dd>This member's value specifies the required architecture for
129 an individual file. </dd>
130 <p>
131 <table border cellspacing=0>
132 <tr>
133 <th><b>Name</b></th>
134 <th><b>Value</b></th>
135 <th><b>Meaning</b></th>
136 </tr>
137 <tr>
138 <td><code>EM_NONE</code></td>
139 <td align=right><code>0</code></td>
140 <td>No machine</td>
141 </tr>
142 <!-- AT&T, before 1994 -->
143 <tr>
144 <td><code>EM_M32</code></td>
145 <td align=right><code>1</code></td>
146 <td>AT&amp;T WE 32100</td>
147 </tr>
148 <!-- Sun Microsystems, before 1994 -->
149 <tr>
150 <td><code>EM_SPARC</code></td>
151 <td align=right><code>2</code></td>
152 <td>SPARC</td>
153 </tr>
154 <!-- USL, before 1994 -->
155 <tr>
156 <td><code>EM_386</code></td>
157 <td align=right><code>3</code></td>
158 <td>Intel 80386</td>
159 </tr>
160 <!-- before 1994 -->
161 <tr>
162 <td><code>EM_68K</code></td>
163 <td align=right><code>4</code></td>
164 <td>Motorola 68000</td>
165 </tr>
166 <!-- before 1994 -->
167 <tr>
168 <td><code>EM_88K</code></td>
169 <td align=right><code>5</code></td>
170 <td>Motorola 88000</td>
171 </tr>
172 <!-- before 1994, was EM_486, Intel 80486 -->
173 <tr>
174 <td align=right>reserved</td>
175 <td align=right><code>6</code></td>
176 <td>Reserved for future use (was <code>EM_486</code>)</td>
177 </tr>
178 <!-- before 1994 -->
179 <tr>
180 <td><code>EM_860</code></td>
181 <td align=right><code>7</code></td>
182 <td>Intel 80860</td>
183 </tr>
184 <!-- before 1994 -->
185 <tr>
186 <td><code>EM_MIPS</code></td>
187 <td align=right><code>8</code></td>
188 <td>MIPS I Architecture</td>
189 </tr>
190 <!-- Amdahl? before 1994, then Hannaford Bros, 10/99 -->
191 <tr>
192 <td><code>EM_S370</code></td>
193 <td align=right><code>9</code></td>
194 <td>IBM System/370 Processor</td>
195 </tr>
196 <!-- before 1994 -->
197 <tr>
198 <td><code>EM_MIPS_RS3_LE</code></td>
199 <td align=right><code>10</code></td>
200 <td>MIPS RS3000 Little-endian</td>
201 </tr>
202 <!-- before 1994, 11 reserved for RS/6000 -->
203 <tr>
204 <td align=right>reserved</td>
205 <td align=right><code>11-14</code></td>
206 <td>Reserved for future use</td>
207 </tr>
208 <!-- Hewlett-Packard, before 1994 -->
209 <tr>
210 <td><code>EM_PARISC</code></td>
211 <td align=right><code>15</code></td>
212 <td>Hewlett-Packard PA-RISC</td>
213 </tr>
214 <!-- before 1994, reserved for nCUBE -->
215 <tr>
216 <td align=right>reserved</td>
217 <td align=right><code>16</code></td>
218 <td>Reserved for future use</td>
219 </tr>
220 <!-- Fujitsu, 4/94 -->
221 <tr>
222 <td><code>EM_VPP500</code></td>
223 <td align=right><code>17</code></td>
224 <td>Fujitsu VPP500</td>
225 </tr>
226 <!-- SunSoft, 7/94 -->
227 <tr>
228 <td><code>EM_SPARC32PLUS</code></td>
229 <td align=right><code>18</code></td>
230 <td>Enhanced instruction set SPARC</td>
231 </tr>
232 <!-- TIS, 10/94 -->
233 <tr>
234 <td><code>EM_960</code></td>
235 <td align=right><code>19</code></td>
236 <td>Intel 80960</td>
237 </tr>
238 <!-- TIS, 10/94 -->
239 <tr>
240 <td><code>EM_PPC</code></td>
241 <td align=right><code>20</code></td>
242 <td>PowerPC</td>
243 </tr>
244 <!-- TIS, 10/94, then IBM 10/99 -->
245 <tr>
246 <td><code>EM_PPC64</code></td>
247 <td align=right><code>21</code></td>
248 <td>64-bit PowerPC</td>
249 </tr>
250 <!-- IBM (Deutschland) by Martin Schwidefsky, 12/00 -->
251 <tr>
252 <td><code>EM_S390</code></td>
253 <td align=right><code>22</code></td>
254 <td>IBM System/390 Processor</td>
255 </tr>
256 <!-- TIS, 10/94, reserved for Power/PowerPC -->
257 <tr>
258 <td align=right>reserved</td>
259 <td align=right><code>23-35</code></td>
260 <td>Reserved for future use</td>
261 </tr>
262 <!-- Green Hills Software, 6/95 -->
263 <tr>
264 <td><code>EM_V800</code></td>
265 <td align=right><code>36</code></td>
266 <td>NEC V800</td>
267 </tr>
268 <!-- Green Hills Software, 7/95 -->
269 <tr>
270 <td><code>EM_FR20</code></td>
271 <td align=right><code>37</code></td>
272 <td>Fujitsu FR20</td>
273 </tr>
274 <!-- Green Hills Software, 9/95 -->
275 <tr> <td><code>EM_RH32</code></td>
276 <td align=right><code>38</code></td>
277 <td>TRW RH-32</td>
278 </tr>
279 <!-- Motorola, 12/95 -->
280 <tr>
281 <td><code>EM_RCE</code></td>
282 <td align=right><code>39</code></td>
283 <td>Motorola RCE</td>
284 </tr>
285 <!-- Green Hills Software, 3/96 -->
286 <tr>
287 <td><code>EM_ARM</code></td>
288 <td align=right><code>40</code></td>
289 <td>Advanced RISC Machines ARM</td>
290 </tr>
291 <!-- Digital, 5/96 -->
292 <tr>
293 <td><code>EM_ALPHA</code></td>
294 <td align=right><code>41</code></td>
295 <td>Digital Alpha</td>
296 </tr>
297 <!-- Green Hills Software, 5/96 -->
298 <tr>
299 <td><code>EM_SH</code></td>
300 <td align=right><code>42</code></td>
301 <td>Hitachi SH</td>
302 </tr>
303 <!-- Sun Microsystems, 6/96 -->
304 <tr>
305 <td><code>EM_SPARCV9</code></td>
306 <td align=right><code>43</code></td>
307 <td>SPARC Version 9</td>
308 </tr>
309 <!-- Green Hills Software, 9/96 -->
310 <tr>
311 <td><code>EM_TRICORE</code></td>
312 <td align=right><code>44</code></td>
313 <td>Siemens TriCore embedded processor</td>
314 </tr>
315 <!-- MetaWare, 12/96 -->
316 <tr>
317 <td><code>EM_ARC</code></td>
318 <td align=right><code>45</code></td>
319 <td>Argonaut RISC Core, Argonaut Technologies Inc.</td>
320 </tr>
321 <!-- Hitachi, 1/97 -->
322 <tr>
323 <td><code>EM_H8_300</code></td>
324 <td align=right><code>46</code></td>
325 <td>Hitachi H8/300</td>
326 </tr>
327 <!-- Hitachi, 1/97 -->
328 <tr>
329 <td><code>EM_H8_300H</code></td>
330 <td align=right><code>47</code></td>
331 <td>Hitachi H8/300H</td>
332 </tr>
333 <!-- Hitachi, 1/97 -->
334 <tr>
335 <td><code>EM_H8S</code></td>
336 <td align=right><code>48</code></td>
337 <td>Hitachi H8S</td>
338 </tr>
339 <!-- Hitachi, 1/97 -->
340 <tr>
341 <td><code>EM_H8_500</code></td>
342 <td align=right><code>49</code></td>
343 <td>Hitachi H8/500</td>
344 </tr>
345 <!-- Intel, 1/97 -->
346 <tr>
347 <td><code>EM_IA_64</code></td>
348 <td align=right><code>50</code></td>
349 <td>Intel IA-64 processor architecture</td>
350 </tr>
351 <!-- Green Hills Software, 2/97 -->
352 <tr>
353 <td><code>EM_MIPS_X</code></td>
354 <td align=right><code>51</code></td>
355 <td>Stanford MIPS-X</td>
356 </tr>
357 <!-- Green Hills Software, 5/97 -->
358 <tr>
359 <td><code>EM_COLDFIRE</code></td>
360 <td align=right><code>52</code></td>
361 <td>Motorola ColdFire</td>
362 </tr>
363 <!-- Motorola, 11/97 -->
364 <tr>
365 <td><code>EM_68HC12</code></td>
366 <td align=right><code>53</code></td>
367 <td>Motorola M68HC12</td>
368 </tr>
369 <!-- Green Hills Software, 5/98 -->
370 <tr>
371 <td><code>EM_MMA</code></td>
372 <td align=right><code>54</code></td>
373 <td>Fujitsu MMA Multimedia Accelerator</td>
374 </tr>
375 <!-- Green Hills Software, 5/98 -->
376 <tr>
377 <td><code>EM_PCP</code></td>
378 <td align=right><code>55</code></td>
379 <td>Siemens PCP</td>
380 </tr>
381 <!-- Green Hills Software, 5/98 -->
382 <tr>
383 <td><code>EM_NCPU</code></td>
384 <td align=right><code>56</code></td>
385 <td>Sony nCPU embedded RISC processor</td>
386 </tr>
387 <!-- Green Hills Software, 6/98 -->
388 <tr>
389 <td><code>EM_NDR1</code></td>
390 <td align=right><code>57</code></td>
391 <td>Denso NDR1 microprocessor</td>
392 </tr>
393 <!-- Green Hills Software, 10/98 -->
394 <tr>
395 <td><code>EM_STARCORE</code></td>
396 <td align=right><code>58</code></td>
397 <td>Motorola Star*Core processor</td>
398 </tr>
399 <!-- Green Hills Software, 10/98 -->
400 <tr>
401 <td><code>EM_ME16</code></td>
402 <td align=right><code>59</code></td>
403 <td>Toyota ME16 processor</td>
404 </tr>
405 <!-- Green Hills Software, 12/98 -->
406 <tr>
407 <td><code>EM_ST100</code></td>
408 <td align=right><code>60</code></td>
409 <td>STMicroelectronics ST100 processor</td>
410 </tr>
411 <!-- Advanced Logic Corp., 1/99 -->
412 <tr>
413 <td><code>EM_TINYJ</code></td>
414 <td align=right><code>61</code></td>
415 <td>Advanced Logic Corp. TinyJ embedded processor family</td>
416 </tr>
417 <!-- CodeSourcery, 2000 -->
418 <tr>
419 <td><code>EM_X86_64</code></td>
420 <td align=right><code>62</code></td>
421 <td>AMD x86-64 architecture</td>
422 </tr>
423 <!-- Green Hills, 2000 -->
424 <tr>
425 <td><code>EM_PDSP</code></td>
426 <td align=right><code>63</code></td>
427 <td>Sony DSP Processor</td>
428 </tr>
429 <!-- Lars Brinkoff, lars@nocrew.org, 30 May 2002 -->
430 <tr>
431 <td><code>EM_PDP10</code></td>
432 <td align=right><code>64</code></td>
433 <td>Digital Equipment Corp. PDP-10</td>
434 </tr>
435 <!-- Lars Brinkoff, lars@nocrew.org, 30 May 2002 -->
436 <tr>
437 <td><code>EM_PDP11</code></td>
438 <td align=right><code>65</code></td>
439 <td>Digital Equipment Corp. PDP-11</td>
440 </tr>
441 <!-- Siemens AG, 6/98 -->
442 <tr>
443 <td><code>EM_FX66</code></td>
444 <td align=right><code>66</code></td>
445 <td>Siemens FX66 microcontroller</td>
446 </tr>
447 <!-- STMicroelectronics, 6/99 -->
448 <tr>
449 <td><code>EM_ST9PLUS</code></td>
450 <td align=right><code>67</code></td>
451 <td>STMicroelectronics ST9+ 8/16 bit microcontroller</td>
452 </tr>
453 <!-- STMicroelectronics, 6/99 -->
454 <tr>
455 <td><code>EM_ST7</code></td>
456 <td align=right><code>68</code></td>
457 <td>STMicroelectronics ST7 8-bit microcontroller</td>
458 </tr>
459 <!-- Motorola, 6/99 -->
460 <tr>
461 <td><code>EM_68HC16</code></td>
462 <td align=right><code>69</code></td>
463 <td>Motorola MC68HC16 Microcontroller</td>
464 </tr>
465 <!-- Motorola, 6/99 -->
466 <tr>
467 <td><code>EM_68HC11</code></td>
468 <td align=right><code>70</code></td>
469 <td>Motorola MC68HC11 Microcontroller</td>
470 </tr>
471 <!-- Motorola, 6/99 -->
472 <tr>
473 <td><code>EM_68HC08</code></td>
474 <td align=right><code>71</code></td>
475 <td>Motorola MC68HC08 Microcontroller</td>
476 </tr>
477 <!-- Motorola, 6/99 -->
478 <tr>
479 <td><code>EM_68HC05</code></td>
480 <td align=right><code>72</code></td>
481 <td>Motorola MC68HC05 Microcontroller</td>
482 </tr>
483 <!-- Silicon Graphics, 6/99 -->
484 <tr>
485 <td><code>EM_SVX</code></td>
486 <td align=right><code>73</code></td>
487 <td>Silicon Graphics SVx</td>
488 </tr>
489 <!-- STMicroelectronics, 6/99 -->
490 <tr>
491 <td><code>EM_ST19</code></td>
492 <td align=right><code>74</code></td>
493 <td>STMicroelectronics ST19 8-bit microcontroller</td>
494 </tr>
495 <!-- 3am Software Foundry, 8/99 -->
496 <tr>
497 <td><code>EM_VAX</code></td>
498 <td align=right><code>75</code></td>
499 <td>Digital VAX</td>
500 <!-- Axis Communications AB, 10/99 -->
501 <tr>
502 <td><code>EM_CRIS</code></td>
503 <td align=right><code>76</code></td>
504 <td>Axis Communications 32-bit embedded processor</td>
505 </tr>
506 <!-- Infineon Technologies, 10/99 -->
507 <tr>
508 <td><code>EM_JAVELIN</code></td>
509 <td align=right><code>77</code></td>
510 <td>Infineon Technologies 32-bit embedded processor</td>
511 </tr>
512 <!-- Green Hills Software, 11/99 -->
513 <tr>
514 <td><code>EM_FIREPATH</code></td>
515 <td align=right><code>78</code></td>
516 <td>Element 14 64-bit DSP Processor</td>
517 </tr>
518 <!-- Green Hills Software, 11/99 -->
519 <tr>
520 <td><code>EM_ZSP</code></td>
521 <td align=right><code>79</code></td>
522 <td>LSI Logic 16-bit DSP Processor</td>
523 </tr>
524 <!-- MMIXmasters  volunteer organization, 2/00 -->
525 <tr>
526 <td><code>EM_MMIX</code></td>
527 <td align=right><code>80</code></td>
528 <td>Donald Knuth's educational 64-bit processor</td>
529 </tr>
530 <!-- Harvard University, Division of Engineering and Applied Sciences 3/00 -->
531 <tr>
532 <td><code>EM_HUANY</code></td>
533 <td align=right><code>81</code></td>
534 <td>Harvard University machine-independent object files</td>
535 </tr>
536 </tr>
537 <!-- Cygnus 4/00 -->
538 <tr>
539 <td><code>EM_PRISM</code></td>
540 <td align=right><code>82</code></td>
541 <td>SiTera Prism</td>
542 </tr>
543 <!-- RedHat, 11/2000 -->
544 <tr>
545 <td><code>EM_AVR</code></td>
546 <td align=right><code>83</code></td>
547 <td>Atmel AVR 8-bit microcontroller</td>
548 </tr>
549 <tr>
550 <td><code>EM_FR30</code></td>
551 <td align=right><code>84</code></td>
552 <td>Fujitsu FR30</td>
553 </tr>
554 <tr>
555 <td><code>EM_D10V</code></td>
556 <td align=right><code>85</code></td>
557 <td>Mitsubishi D10V</td>
558 </tr>
559 <tr>
560 <td><code>EM_D30V</code></td>
561 <td align=right><code>86</code></td>
562 <td>Mitsubishi D30V</td>
563 </tr>
564 <tr>
565 <td><code>EM_V850</code></td>
566 <td align=right><code>87</code></td>
567 <td>NEC v850</td>
568 </tr>
569 <tr>
570 <td><code>EM_M32R</code></td>
571 <td align=right><code>88</code></td>
572 <td>Mitsubishi M32R</td>
573 </tr>
574 <tr>
575 <td><code>EM_MN10300</code></td>
576 <td align=right><code>89</code></td>
577 <td>Matsushita MN10300</td>
578 </tr>
579 <tr>
580 <td><code>EM_MN10200</code></td>
581 <td align=right><code>90</code></td>
582 <td>Matsushita MN10200</td>
583 </tr>
584 <tr>
585 <td><code>EM_PJ</code></td>
586 <td align=right><code>91</code></td>
587 <td>picoJava</td>
588 </tr>
589 <tr>
590 <td><code>EM_OPENRISC</code></td>
591 <td align=right><code>92</code></td>
592 <td>OpenRISC 32-bit embedded processor</td>
593 </tr>
594 <!-- MetaWare, 3 May 2001 -->
595 <tr>
596 <td><code>EM_ARC_A5</code></td>
597 <td align=right><code>93</code></td>
598 <td>ARC Cores Tangent-A5</td>
599 </tr>
600 <!-- Tensilica, Inc. 16 May 2001 -->
601 <!-- Bob Wilson and David Heine (bwilson@ and dlheine@tensilica.com) -->
602 <tr>
603 <td><code>EM_XTENSA</code></td>
604 <td align=right><code>94</code></td>
605 <td>Tensilica Xtensa Architecture</td>
606 </tr>
607 <!-- 5 Jul 2001 for Dom Cobley (dom.cobley@camcon.co.uk) -->
608 <tr>
609 <td><code>EM_VIDEOCORE</code></td>
610 <td align=right><code>95</code></td>
611 <td>Alphamosaic VideoCore processor</td>
612 </tr>
613 <!-- 19 Jul 2001 for Harshad R. Joglekar (harshad.joglekar@wipro.com) -->
614 <tr>
615 <td><code>EM_TMM_GPP</code></td>
616 <td align=right><code>96</code></td>
617 <td>Thompson Multimedia General Purpose Processor</td>
618 </tr>
619 <!-- 29 Oct 2001 for Simon Burge (simonb@wasabisystems.com) NetBSD -->
620 <tr>
621 <td><code>EM_NS32K</code></td>
622 <td align=right><code>97</code></td>
623 <td>National Semiconductor 32000 series</td>
624 </tr>
625 <!-- 7 Jun 2002 for Alan Lehotsky (apl@alum.mit.edu) -->
626 <tr>
627 <td><code>EM_TPC</code></td>
628 <td align=right><code>98</code></td>
629 <td>Tenor Network TPC processor</td>
630 </tr>
631 <!-- 7 Jun 2002 for Alan Lehotsky (apl@alum.mit.edu) -->
632 <tr>
633 <td><code>EM_SNP1K</code></td>
634 <td align=right><code>99</code></td>
635 <td>Trebia SNP 1000 processor</td>
636 </tr>
637 <!-- 10 Jun 2002 for Christian Bertin (Christian Bertin@st.com) -->
638 <tr>
639 <td><code>EM_ST200</code></td>
640 <td align=right><code>100</code></td>
641 <td>STMicroelectronics (www.st.com) ST200 microcontroller</td>
642 </tr>
643 </table>
644 <p>
645 Other values are reserved and will be assigned to new machines 
646 as necessary.
647 Processor-specific ELF names use the machine name to distinguish them.
648 For example, the flags mentioned below use the 
649 prefix <code>EF_</code>;
650 a flag named <code>WIDGET</code> for the <code>EM_XYZ</code>
651 machine would be called <code>EF_XYZ_WIDGET</code>.
652 <dt><code>e_version</code></dt>
653 <dd>This member identifies the object file version. </dd>
654 <p>
655 <table border cellspacing=0>
656 <tr>
657 <th><b>Name</b></th>
658 <th><b>Value</b></th>
659 <th><b>Meaning</b></th>
660 </tr>
661 <tr>
662 <td><code>EV_NONE</code></td>
663 <td align=right><code>0</code></td>
664 <td>Invalid version</td>
665 </tr>
666 <tr>
667 <td><code>EV_CURRENT</code></td>
668 <td align=right><code>1</code></td>
669 <td>Current version</td>
670 </tr>
671 </table>
672 <p>
673 The value <code>1</code> signifies the original file format; 
674 extensions will create new versions with higher numbers. 
675 Although the value of <code>EV_CURRENT</code>
676 is shown as <code>1</code> in the previous table, it will 
677 change as necessary to reflect the current version number.
678 <dt><code>e_entry</code></dt>
679 <dd>This member gives the virtual address to which the 
680 system first transfers
681 control, thus starting the process. If the file has no associated entry
682 point, this member holds zero. </dd>
683 <dt><code>e_phoff</code></dt>
684 <dd>This member holds the program header table's file offset in bytes.
685 If the file has no program header table, this member holds zero. </dd>
686 <dt><code>e_shoff</code></dt>
687 <dd>This member holds the section header table's file offset in bytes.
688 If the file has no section header table, this member holds zero. </dd>
689 <dt><code>e_flags</code></dt>
690 <dd>This member holds processor-specific flags associated with the file.
691 Flag names take the form 
692 <code>EF_</code><i>machine</i><b>_</b><i>flag</i>.  </dd>
693 <dt><code>e_ehsize</code></dt>
694 <dd>This member holds the ELF header's size in bytes. </dd>
695 <dt><code>e_phentsize</code></dt>
696 <dd>This member holds the size in bytes of one entry in the file's program
697 header table; all entries are the same size. </dd>
698 <dt><code>e_phnum</code></dt>
699 <dd>This member holds the number of entries in the program header table.
700 Thus the product of 
701 <code>e_phentsize</code> and <code>e_phnum</code> gives the
702 table's size in bytes. 
703 If a file has no program header table, <code>e_phnum</code>
704 holds the value zero. </dd>
705 <dt><code>e_shentsize</code></dt>
706 <dd>This member holds a section header's size in bytes. A section header
707 is one entry in the section header table; all entries are the same size.
708 </dd>
709 <dt><code>e_shnum</code></dt>
710 <a name=many_sections></a>
711 <dd>This member holds the number of entries in the section header table.
712 Thus the product of <code>e_shentsize</code> and 
713 <code>e_shnum</code> gives the
714 section header table's size in bytes. 
715 If a file has no section header table,
716 <code>e_shnum</code> holds the value zero.
717 <p>
718 If the number of sections is greater than or equal to
719 <code>SHN_LORESERVE</code> (<code>0xff00</code>), this member
720 has the value zero and the actual number of section header table
721 entries is contained in the <code>sh_size</code> field of
722 the section header at index <code>0</code>.
723 (Otherwise, the <code>sh_size</code> member of the initial entry 
724 contains <code>0</code>.)
725 </dd>
726 <dt><code>e_shstrndx</code></dt>
727 <dd>This member holds the section header table index of the 
728 entry associated with the section name string table. 
729 If the file has no section name string
730 table, this member holds the value <code>SHN_UNDEF</code>. 
731 See <a href="ch4.sheader.html">``Sections''</a>
732 and <a href="ch4.strtab.html">``String Table''</a> below 
733 for more information.
734 <p>
735 If the section name string table section index is greater than or equal to
736 <code>SHN_LORESERVE</code> (<code>0xff00</code>), this member
737 has the value <code>SHN_XINDEX</code> (<code>0xffff</code>) and the
738 actual index of the section name string table section
739 is contained in the <code>sh_link</code> field of
740 the section header at index <code>0</code>.
741 (Otherwise, the <code>sh_link</code> member of the initial entry 
742 contains <code>0</code>.)
743 </dd>
744 </dl>
745 <p><a name="elfid"></a>
746 <h2>ELF Identification</h2>
747 <p>
748 As mentioned above, ELF provides an object file framework to support
749 multiple processors, multiple data encodings, and multiple 
750 classes of machines.  To support this object file family, 
751 the initial bytes of the file specify
752 how to interpret the file, independent of the processor on 
753 which the inquiry is made and independent of the file's 
754 remaining contents.
755 <p>
756 The initial bytes of an ELF header (and an object file) correspond to
757 the <code>e_ident</code> member.
758 <hr>
759 <b>Figure 4-4: </b><code>e_ident[]</code> <b>Identification Indexes</b>
760 <p>
761 <table border cellspacing=0>
762 <tr>
763 <th><b>Name</b></th>
764 <th><b>Value</b></th>
765 <th><b>Purpose</b></th>
766 </tr>
767 <tr>
768 <td><code>EI_MAG0</code></td>
769 <td align=right><code>0</code></td>
770 <td>File identification</td>
771 </tr>
772 <tr>
773 <td><code>EI_MAG1</code></td>
774 <td align=right><code>1</code></td>
775 <td>File identification</td>
776 </tr>
777 <tr>
778 <td><code>EI_MAG2</code></td>
779 <td align=right><code>2</code></td>
780 <td>File identification</td>
781 </tr>
782 <tr>
783 <td><code>EI_MAG3</code></td>
784 <td align=right><code>3</code></td>
785 <td>File identification</td>
786 </tr>
787 <tr>
788 <td><code>EI_CLASS</code></td>
789 <td align=right><code>4</code></td>
790 <td>File class</td>
791 </tr>
792 <tr>
793 <td><code>EI_DATA</code></td>
794 <td align=right><code>5</code></td>
795 <td>Data encoding</td>
796 </tr>
797 <tr>
798 <td><code>EI_VERSION</code></td>
799 <td align=right><code>6</code></td>
800 <td>File version</td>
801 </tr>
802 <tr>
803 <td><code>EI_OSABI</code></td>
804 <td align=right><code>7</code></td>
805 <td>Operating system/ABI identification</td>
806 </tr>
807 <tr>
808 <td><code>EI_ABIVERSION</code></td>
809 <td align=right><code>8</code></td>
810 <td>ABI version</td>
811 </tr>
812 <tr>
813 <td><code>EI_PAD</code></td>
814 <td align=right><code>9</code></td>
815 <td>Start of padding bytes</td>
816 </tr>
817 <tr>
818 <td><code>EI_NIDENT</code></td>
819 <td align=right><code>16</code></td>
820 <td>Size of <code>e_ident[]</code></td>
821 </tr>
822 </table>
823 <hr>
824 <p>
825 These indexes access bytes that hold the following values.
826 <dl compact>
827 <dt><code>EI_MAG0</code>&nbsp;to&nbsp;<code>EI_MAG3</code></dt>
828 <dd>A file's first 4 bytes hold a ``magic number,'' identifying the file
829 as an ELF object file. </dd>
830 <p>
831 <table border cellspacing=0>
832 <tr>
833 <th><b>Name</b></th>
834 <th><b>Value</b></th>
835 <th><b>Position</b></th>
836 </tr>
837 <tr>
838 <td><code>ELFMAG0</code></td>
839 <td align=right><code>0x7f</code></td>
840 <td><code>e_ident[EI_MAG0]</code></td>
841 </tr>
842 <tr>
843 <td><code>ELFMAG1</code></td>
844 <td align=right><code>'E'</code></td>
845 <td><code>e_ident[EI_MAG1]</code></td>
846 </tr>
847 <tr>
848 <td><code>ELFMAG2</code></td>
849 <td align=right><code>'L'</code></td>
850 <td><code>e_ident[EI_MAG2]</code></td>
851 </tr>
852 <tr>
853 <td><code>ELFMAG3</code></td>
854 <td align=right><code>'F'</code></td>
855 <td><code>e_ident[EI_MAG3]</code></td>
856 </tr>
857 </table>
858 <p>
859 <dt><code>EI_CLASS</code></dt>
860 <dd>The next byte, <code>e_ident[EI_CLASS]</code>, identifies the 
861 file's class, or capacity. </dd>
862 <p>
863 <table border cellspacing=0>
864 <tr>
865 <th><b>Name</b></th>
866 <th><b>Value</b></th>
867 <th><b>Meaning</b></th>
868 </tr>
869 <tr>
870 <td><code>ELFCLASSNONE</code></td>
871 <td align=right><code>0</code></td>
872 <td>Invalid class</td>
873 </tr>
874 <tr>
875 <td><code>ELFCLASS32</code></td>
876 <td align=right><code>1</code></td>
877 <td>32-bit objects</td>
878 </tr>
879 <tr>
880 <td><code>ELFCLASS64</code></td>
881 <td align=right><code>2</code></td>
882 <td>64-bit objects</td>
883 </tr>
884 </table>
885 <p>
886 The file format is designed to be portable among machines of various
887 sizes, without imposing the sizes of the largest machine on the 
888 smallest.  The class of the file defines the basic types 
889 used by the data structures
890 of the object file container itself. The data contained in object file
891 sections may follow a different programming model. If so, the processor
892 supplement describes the model used.
893 <p>
894 Class <code>ELFCLASS32</code> supports machines with 
895 32-bit architectures. It
896 uses the basic types defined in the table 
897 labeled ``32-Bit Data Types.''
898 <p>
899 Class <code>ELFCLASS64</code> supports machines with 64-bit 
900 architectures.  It uses the basic types defined in the table 
901 labeled ``64-Bit Data Types.''
902 <p>
903 Other classes will be defined as necessary, with different basic types
904 and sizes for object file data.
905 <dt><code>EI_DATA</code></dt>
906 <dd>Byte <code>e_ident[EI_DATA]</code> specifies the
907 encoding of both the data structures used by object file container
908 and data contained in object file sections.
909 The following encodings are currently defined.
910 </dd>
911 <p>
912 <table border cellspacing=0>
913 <tr>
914 <th><b>Name</b></th>
915 <th><b>Value</b></th>
916 <th><b>Meaning</b></th>
917 </tr>
918 <tr>
919 <td><code>ELFDATANONE</code></td>
920 <td align=right><code>0</code></td>
921 <td>Invalid data encoding</td>
922 </tr>
923 <tr>
924 <td><code>ELFDATA2LSB</code></td>
925 <td align=right><code>1</code></td>
926 <td>See below</td>
927 </tr>
928 <tr>
929 <td><code>ELFDATA2MSB</code></td>
930 <td align=right><code>2</code></td>
931 <td>See below</td>
932 </tr>
933 </table>
934 <p>
935 Other values are reserved and will be assigned to new 
936 encodings as necessary.
937 <p>
938 <hr><img src="warning.gif" alt="NOTE:"> 
939 Primarily for the convenience of code that looks at the ELF
940 file at runtime, the ELF data structures are intended to have the
941 same byte order as that of the running program.
942 <hr>
943 <dt><code>EI_VERSION</code></dt>
944 <dd>Byte <code>e_ident[EI_VERSION]</code> specifies the 
945 ELF header version
946 number. Currently, this value must be <code>EV_CURRENT</code>, 
947 as explained above for <code>e_version</code>. </dd>
948 <p><a name="osabi"></a>
949 <dt><code>EI_OSABI</code></dt>
950 <dd>Byte <code>e_ident[EI_OSABI]</code> identifies the
951 OS- or ABI-specific ELF extensions used by this file.
952 Some fields in other ELF structures have flags and values
953 that have operating system and/or ABI specific meanings;
954 the interpretation of those fields is determined by the value of this byte.
955 If the object file does not use any extensions,
956 it is recommended that this byte be set to <code>0</code>.
957 If the value for this byte is <code>64</code> through <code>255</code>,
958 its meaning depends on the value of the <code>e_machine</code> header member.
959 The ABI processor supplement for an architecture
960 can define its own associated set of values for this byte in this range.
961 If the processor supplement does not specify a set of values,
962 one of the following values shall be used,
963 where <code>0</code> can also be taken to mean <i>unspecified</i>.
964 <p>
965 <a name=generic_osabi_values></a>
966 <table border cellspacing=0>
967 <tr>
968 <th><b>Name</b></th>
969 <th><b>Value</b></th>
970 <th><b>Meaning</b></th>
971 </tr>
972 <tr>
973 <td><code>ELFOSABI_NONE</code></td>
974 <td align=right><code>0</code></td>
975 <td>No extensions or unspecified</td>
976 </tr>
977 <tr>
978 <td><code>ELFOSABI_HPUX</code></td>
979 <td align=right><code>1</code></td>
980 <td>Hewlett-Packard HP-UX</td>
981 </tr>
982 <tr>
983 <td><code>ELFOSABI_NETBSD</code></td>
984 <td align=right><code>2</code></td>
985 <td>NetBSD</td>
986 </tr>
987 <tr>
988 <td><code>ELFOSABI_LINUX</code></td>
989 <td align=right><code>3</code></td>
990 <td>Linux</td>
991 </tr>
992 <!-- 4 reserved for IA32 GNU Mach/Hurd -->
993 <!-- 5 reserved for 86Open common IA32 ABI -->
994 <tr>
995 <td><code>ELFOSABI_SOLARIS</code></td>
996 <td align=right><code>6</code></td>
997 <td>Sun Solaris</td>
998 </tr>
999 <tr>
1000 <td><code>ELFOSABI_AIX</code></td>
1001 <td align=right><code>7</code></td>
1002 <td>AIX</td>
1003 </tr>
1004 <tr>
1005 <td><code>ELFOSABI_IRIX</code></td>
1006 <td align=right><code>8</code></td>
1007 <td>IRIX</td>
1008 </tr>
1009 <tr>
1010 <td><code>ELFOSABI_FREEBSD</code></td>
1011 <td align=right><code>9</code></td>
1012 <td>FreeBSD</td>
1013 </tr>
1014 <tr>
1015 <td><code>ELFOSABI_TRU64</code></td>
1016 <td align=right><code>10</code></td>
1017 <td>Compaq TRU64 UNIX</td>
1018 </tr>
1019 <tr>
1020 <td><code>ELFOSABI_MODESTO</code></td>
1021 <td align=right><code>11</code></td>
1022 <td>Novell Modesto</td>
1023 </tr>
1024 <tr>
1025 <td><code>ELFOSABI_OPENBSD</code></td>
1026 <td align=right><code>12</code></td>
1027 <td>Open BSD</td>
1028 </tr>
1029 <!-- For Ron Brender (Ron.Brender@hp.com) 7 Jun 2002 -->
1030 <tr>
1031 <td><code>ELFOSABI_OPENVMS</code></td>
1032 <td align=right><code>13</code></td>
1033 <td>Open VMS</td>
1034 </tr>
1035 <!-- For Cary Coutant (cary@cup.hp.com) 7 Jun 2002 -->
1036 <tr>
1037 <td><code>ELFOSABI_NSK</code></td>
1038 <td align=right><code>14</code></td>
1039 <td>Hewlett-Packard Non-Stop Kernel</td>
1040 </tr>
1041 <tr>
1042 <td>&nbsp;</td>
1043 <td align=right><code>64-255</code></td>
1044 <td>Architecture-specific value range</td>
1045 </tr>
1046 </table>
1047 </dd>
1048 <p><a name="abiversion"></a>
1049 <dt><code>EI_ABIVERSION</code></dt>
1050 <dd>Byte <code>e_ident[EI_ABIVERSION]</code> identifies the 
1051 version of the ABI to which the object is targeted.
1052 This field is used to distinguish among incompatible versions
1053 of an ABI.  The interpretation of this version number
1054 is dependent on the ABI identified by the <code>EI_OSABI</code>
1055 field.  If no values are specified for the <code>EI_OSABI</code>
1056 field by the processor supplement or no version values are
1057 specified for the ABI determined by a particular value of the
1058 <code>EI_OSABI</code> byte, the value <code>0</code> shall
1059 be used for the <code>EI_ABIVERSION</code> byte; it
1060 indicates <i>unspecified</i>.</dd>
1061 <p>
1062 <dt><code>EI_PAD</code></dt>
1063 <dd>This value marks the beginning of the unused bytes in 
1064 <code>e_ident</code>.  These bytes are reserved and set to zero; 
1065 programs that read object files
1066 should ignore them. The value of <code>EI_PAD</code> will 
1067 change in the future if currently unused bytes are given 
1068 meanings. </dd>
1069 </dl>
1070 <p>
1071 A file's data encoding specifies how to interpret the basic objects
1072 in a file. Class <code>ELFCLASS32</code> files use objects 
1073 that occupy 1, 2, and 4 bytes. Class <code>ELFCLASS64</code> files
1074 use objects that occupy 1, 2, 4, and 8 bytes. Under the defined
1075 encodings, objects are represented as shown below.
1076 <p>
1077 Encoding <code>ELFDATA2LSB</code> specifies 2's complement values,
1078 with the least significant byte occupying the lowest address. 
1079 <hr>
1080 <b>Figure 4-5: Data Encoding</b> <code>ELFDATA2LSB</code>, byte address zero on the left 
1081 <p>
1082 <table border=1 cellspacing=0 cellpadding=0 >
1083 <tr>
1084 <td align=center valign=center width="48" height="24">01</td>
1085 </tr>
1086 <caption align=bottom>0x01</caption>
1087 </table>
1088 <p>
1089 <table border=1 cellspacing=0 cellpadding=0 >
1090 <tr>
1091 <td align=center valign=center width="48" height="24">02</td>
1092 <td align=center valign=center width="48" height="24">01</td>
1093 </tr>
1094 <caption align=bottom>0x0102</caption>
1095 </table>
1096 <p>
1097 <table border=1 cellspacing=0 cellpadding=0 >
1098 <tr>
1099 <td align=center valign=center width="48" height="24">04</td>
1100 <td align=center valign=center width="48" height="24">03</td>
1101 <td align=center valign=center width="48" height="24">02</td>
1102 <td align=center valign=center width="48" height="24">01</td>
1103 </tr>
1104 <caption align=bottom>0x01020304</caption>
1105 </table>
1106 <p>
1107 <table border=1 cellspacing=0 cellpadding=0 >
1108 <tr>
1109 <td align=center Valign=center width="48" height="24">08</td>
1110 <td align=center Valign=center width="48" height="24">07</td>
1111 <td align=center Valign=center width="48" height="24">06</td>
1112 <td align=center Valign=center width="48" height="24">05</td>
1113 <td align=center Valign=center width="48" height="24">04</td>
1114 <td align=center Valign=center width="48" height="24">03</td>
1115 <td align=center Valign=center width="48" height="24">02</td>
1116 <td align=center Valign=center width="48" height="24">01</td>
1117 </tr>
1118 <caption align=bottom>0x0102030405060708</caption>
1119 </table>
1120 <hr>
1121 <p>
1122 Encoding <code>ELFDATA2MSB</code> specifies 2's complement values,
1123 with the most significant byte occupying the lowest address. 
1124 <hr>
1125 <b>Figure 4-6: Data Encoding</b> <code>ELFDATA2MSB</code>, byte address zero on the left 
1126 <p>
1127 <table border=1 cellspacing=0 cellpadding=0 >
1128 <tr>
1129 <td align=center Valign=center width="48" height="24">01</td>
1130 </tr>
1131 <caption align=bottom>0x01</caption>
1132 </table>
1133 <p>
1134 <table border=1 cellspacing=0 cellpadding=0 >
1135 <tr>
1136 <td align=center Valign=center width="48" height="24">01</td>
1137 <td align=center Valign=center width="48" height="24">02</td>
1138 </tr>
1139 <caption align=bottom>0x0102</caption>
1140 </table>
1141 <p>
1142 <table border=1 cellspacing=0 cellpadding=0 >
1143 <tr>
1144 <td align=center Valign=center width="48" height="24">01</td>
1145 <td align=center Valign=center width="48" height="24">02</td>
1146 <td align=center Valign=center width="48" height="24">03</td>
1147 <td align=center Valign=center width="48" height="24">04</td>
1148 </tr>
1149 <caption align=bottom>0x01020304</caption>
1150 </table>
1151 <p>
1152 <table border=1 cellspacing=0 cellpadding=0 >
1153 <tr>
1154 <td align=center Valign=center width="48" height="24">01</td>
1155 <td align=center Valign=center width="48" height="24">02</td>
1156 <td align=center Valign=center width="48" height="24">03</td>
1157 <td align=center Valign=center width="48" height="24">04</td>
1158 <td align=center Valign=center width="48" height="24">05</td>
1159 <td align=center Valign=center width="48" height="24">06</td>
1160 <td align=center Valign=center width="48" height="24">07</td>
1161 <td align=center Valign=center width="48" height="24">08</td>
1162 </tr>
1163 <caption align=bottom>0x0102030405060708</caption>
1164 </table>
1165 <hr>
1166 <p>
1167 <a name="machine"></a></p>
1168 <h2>Machine Information (Processor-Specific)</h2>
1169 <p>
1170 <hr><img src="warning.gif" alt="NOTE:"> 
1171 This section requires processor-specific information.
1172 The ABI supplement for the desired processor describes the details. 
1173 <hr>
1174 <a href="ch4.intro.html"><img src="previous.gif" alt="Previous"></a>
1175 <a href="contents.html"><img src="contents.gif" alt="Contents"></a>
1176 <a href="ch4.sheader.html"><img src="next.gif" alt="Next"></a>
1177 <hr>
1178 <i>
1179 <small>
1180 &#169; 1997, 1998, 1999, 2000, 2001 The Santa Cruz Operation, Inc.  All rights reserved.
1181 &#169; 2002 Caldera International.  All rights reserved.
1182 </small>
1183 </i>
1184 </html>