-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecfmt.html
13288 lines (13286 loc) · 502 KB
/
execfmt.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- This file is automatically generated from execfmt.dat -->
<html>
<head>
<title>Old computer executable file formats</title>
</head>
<body>
<h1>Table of contents</h1>
<ul>
<li>1971 — <a href="#aout">UNIX a.out file format</a> (for <u>a</u>ssembly <u>out</u>put)</li>
<li>1987 — <a href="#aout_minix">MINIX a.out file format</a></li>
<li>1983 — <a href="#coff">COFF format</a> (Common Object File Format) for UNIX</li>
<li>1984 — <a href="#xout">XENIX x.out file format</a></li>
<li>1988 — <a href="#macho">Mach-O format</a> (for Mach object) for UNIX</li>
<li>1988 — <a href="#elf">ELF format</a> (Executable and Linkable Format) for UNIX</li>
<li>1974 — <a href="#cpm">flat binary</a> CP/M</li>
<li>1976 — <a href="#cmd_flex">FLEX executable</a> (.CMD)</li>
<li>1979 — <a href="#prl">Page relocatable</a> for CP/M</li>
<li>1983 — <a href="#cpm3">CP/M-80 Plus executable</a> (.COM) for CP/M</li>
<li>1981 — <a href="#cmd">CP/M-86 executable</a> (.CMD) for PC</li>
<li>1982 — <a href="#68k">CP/M-68K executable</a> (.68K) for Atari etc.</li>
<li>1982 — <a href="#z8k">CP/M-8000 executable</a> (.Z8K)</li>
<li>1987 — <a href="#hu">Human68k executable</a> (HU) for X68000</li>
<li>1981 — <a href="#mz">MZ executable</a> (named after Mark Zbikowski) for PC</li>
<li>1985 — <a href="#ne">New executable</a> (NE) for PC</li>
<li>1990 — <a href="#le">Linear executable</a> (LE, LX) for PC</li>
<li>1993 — <a href="#pe">Portable executable</a> (PE) for PC</li>
<li>1986 — <a href="#mp">MP/MQ executable</a> for Phar Lap DOS extenders</li>
<li>1987 — <a href="#bw">BW executable</a> for Rational Systems DOS/16M DOS extender</li>
<li>1988 — <a href="#xp">XP executable</a> for A. I. Architects/Ergo OS/286 DOS extender</li>
<li>1991 — <a href="#p3">P2/P3 executable</a> for Phar Lap DOS extenders</li>
<li>1984 — <a href="#rsrc">Macintosh resource</a> for Apple</li>
<li>1986 — <a href="#gsos_omf">Object Module Format</a> for Apple computers</li>
<li>1994 — <a href="#pef">Preferred Executable Format</a> (PEF) for Macintosh</li>
<li>1978 — <a href="#hunk">Hunk executable</a> for Amiga</li>
<li>1994 — <a href="#adam">Adam Seychell's DOS32 executable</a></li>
</ul>
<hr/>
<h1 id="aout">UNIX a.out file format (for <u>a</u>ssembly <u>out</u>put)</h1>
<dl>
<dt>File extensions</td>
<dd>—</dd>
<dl>
<dt>Magic code</td>
<dd>various: <tt><sub>x</sub>0107</tt>, <tt><sub>x</sub>0108</tt>, <tt><sub>x</sub>010B</tt>, <tt><sub>x</sub>0105</tt>, <tt><sub>x</sub>00CC</tt>, <tt><sub>x</sub>0101</tt>, <tt><sub>x</sub>0109</tt>, <tt><sub>x</sub>010C</tt>, <tt><sub>x</sub>010D</tt>, <tt><sub>x</sub>010E</tt>, <tt><sub>x</sub>0111</tt>, <tt><sub>x</sub>0118</tt>, <tt><sub>x</sub>0119</tt>, <tt><sub>x</sub>011F</tt></dd>
<dl>
<dt>Architecture</td>
<dd>DEC PDP-11, DEC VAX, Motorola 68000, Intel 386 and others (Interdata 7/32, IBM 370, MIPS, SPARC)</dd>
<dl>
<dt>Operating systems</td>
<dd><ul>
<li>between 1969 and 1971-11-03: PDP-11 UNIX version 1 (old format)</li>
<li>1972-06-12: PDP-11 UNIX version 2</li>
<li>1979-06: UNIX/32V before System V</li>
<li>1983-11: SunOS 1.0</li>
<li>1989: DJGPP DOS extender before version 1.11</li>
<li>1991-09-17: Linux before version 1.2</li>
<li>1993-04-19: NetBSD before version 1.5</li>
<li>1993-11-01: FreeBSD up to 2.2 until version 2.2</li>
<li>1997-05-18: <a href="http://pdos.sourceforge.net/">PDOS32</a> 0.10</li>
</ul></dd>
</dl>
<dl>
<dt>Influences</td>
<dd>DEC PDP-11, DEC VAX, Motorola 68000, Intel 386 and others (Interdata 7/32, IBM 370, MIPS, SPARC)</dd>
<a id="_contents"/>
<h2>Contents</h1>
<ol>
<li><a href="#_contents">Contents</a>
</li>
<li><a href="#">a.out header</a>
<ol>
<li><a href="#">Magic numbers</a>
</li>
<li><a href="#">UNIX v1 PDP-11 a.out header</a>
</li>
<li><a href="#">UNIX 16-bit PDP-11 a.out header</a>
</li>
<li><a href="#">UNIX 32-bit a.out header</a>
<ol>
<li><a href="#">UNIX/32V for VAX</a>
</li>
<li><a href="#">System III format</a>
</li>
<li><a href="#">Ultrix</a>
</li>
<li><a href="#">SunOS</a>
</li>
<li><a href="#">Linux</a>
</li>
<li><a href="#">The BSDs</a>
</li>
</ol></li>
<li><a href="#">UNIX 32-bit Interdata 7/32 a.out header</a>
</li>
<li><a href="#">UNIX 32-bit IBM 370 a.out header</a>
</li>
<li><a href="#">UNIX 32-bit NS16032 a.out header</a>
</li>
<li><a href="#">Xenix b.out header</a>
</li>
<li><a href="#">HP-UX a.out header</a>
</li>
</ol></li>
<li><a href="#">Runtime memory layout</a>
</li><li><a href="#_references">References</a></li>
</ol>
<h2>a.out header</h1>
<h3>Magic numbers</h2>
<p>The first word in an a.out file contains a 16-bit magic number, which specifies how the file should be processed, linked and loaded. The types and values have evolved through the various branches of UNIX-like systems.</p>
<p>The first versions of UNIX were produced by AT&T for the 16-bit PDP-11. Later these were ported to various 32-bit architectures, most notably the VAX, Motorola 68000 and Intel 80386. The AT&T versions progressed from version 1 to 7, after which UNIX was commercialized and sold as System III and then System V.</p>
<p>The other important branch are the BSD distributions. In this table we see mentions of versions 2.11BSD, which supported all Version 7 formats, then 3BSD, 4.1cBSD, after which the sources were reused by FreeBSD and NetBSD, OpenBSD. Linux is currently the most widely used UNIX-like system.</p>
<table border='1' align='center'>
<tr>
<td>Magic</td>
<td>Systems</td>
<td>Introduced</td>
<td>Dropped</td>
<td>Description</td></tr>
<tr>
<td><tt><sub>x</sub>00CC</tt></td>
<td>32</td>
<td>NetBSD 0.9<br>FreeBSD 2.0<br>Linux 0.99.13</td>
<td></td>
<td>(QMAGIC) compact demand load format</td></tr>
<tr>
<td><tt><sub>x</sub>0101</tt></td>
<td>16, 32</td>
<td>System III</td>
<td></td>
<td>UNIX/RT "lpd"</td></tr>
<tr>
<td><tt><sub>x</sub>0105</tt></td>
<td>16</td>
<td>Version 1</td>
<td>Version 2</td>
<td>Version 1 format</td></tr>
<tr>
<td><tt><sub>x</sub>0105</tt></td>
<td>16, 32</td>
<td>Version 7</td>
<td>4.1cBSD</td>
<td>overlay</td></tr>
<tr>
<td><tt><sub>x</sub>0107</tt></td>
<td>16, 32</td>
<td>Version 2</td>
<td></td>
<td>(OMAGIC) normal</td></tr>
<tr>
<td><tt><sub>x</sub>0108</tt></td>
<td>16, 32</td>
<td>Version 4</td>
<td></td>
<td>(NMAGIC) read-only text</td></tr>
<tr>
<td><tt><sub>x</sub>0109</tt></td>
<td>16, 32</td>
<td>Version 6</td>
<td>4.1cBSD</td>
<td>separated instruction and data</td></tr>
<tr>
<td><tt><sub>x</sub>010B</tt></td>
<td>16, 32</td>
<td>3BSD</td>
<td></td>
<td>(ZMAGIC) demand paged</td></tr>
<tr>
<td><tt><sub>x</sub>010C</tt></td>
<td>32</td>
<td>NetBSD</td>
<td></td>
<td>demand paged pure</td></tr>
<tr>
<td><tt><sub>x</sub>010C</tt></td>
<td>32</td>
<td>?</td>
<td></td>
<td>(SPRITE_ZMAGIC)</td></tr>
<tr>
<td><tt><sub>x</sub>010C</tt></td>
<td>32</td>
<td>NS16032</td>
<td></td>
<td>(XMAGIC) demand load (like ZMAGIC), locations 0-1023 unmapped</td></tr>
<tr>
<td><tt><sub>x</sub>010D</tt></td>
<td>32</td>
<td>?</td>
<td></td>
<td>(UNIX_ZMAGIC)</td></tr>
<tr>
<td><tt><sub>x</sub>010E</tt></td>
<td>32</td>
<td>NetBSD</td>
<td></td>
<td>readable demand paged pure</td></tr>
<tr>
<td><tt><sub>x</sub>0111</tt></td>
<td>32</td>
<td>Linux 0.96c</td>
<td></td>
<td>(CMAGIC) Linux core dump</td></tr>
<tr>
<td><tt><sub>x</sub>0118</tt></td>
<td>16</td>
<td>2.11</td>
<td>3BSD</td>
<td>overlay, non-separate</td></tr>
<tr>
<td><tt><sub>x</sub>0119</tt></td>
<td>16</td>
<td>2.11</td>
<td>3BSD</td>
<td>overlay, separate</td></tr>
<tr>
<td><tt><sub>x</sub>011F</tt></td>
<td>16, 32</td>
<td>System V</td>
<td></td>
<td>system overlay, separated instruction and data</td></tr>
</table>
<p>The following sections will discuss the layout of the headers of the various versions.</p>
<h3>UNIX v1 PDP-11 a.out header</h2>
<p>Version 1 had a different header format from later versions.</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i16le</td>
<td><tt><sub>x</sub>0105</tt></td></tr>
<tr>
<td><tt><sub>x</sub>02</tt></td> <td>i16le</td>
<td>Size of the combined program text (code) and initialized data segment</td></tr>
<tr>
<td><tt><sub>x</sub>04</tt></td> <td>i16le</td>
<td>Size of the symbol table</td></tr>
<tr>
<td><tt><sub>x</sub>06</tt></td> <td>i16le</td>
<td>Relocation bits</td></tr>
<tr>
<td><tt><sub>x</sub>08</tt></td> <td>i16le</td>
<td>Size of uninitialized data (bss), not stored in binary</td></tr>
<tr>
<td><tt><sub>x</sub>0A</tt></td> <td>i16le</td>
<td>unused</td></tr>
</table>
<h3>UNIX 16-bit PDP-11 a.out header</h2>
<p>This format was introduced in Version 2 and targetted the PDP-11 architecture.</p>
<p>The 16-bit header format evolved through various branches. Version 6 and 7 is the last common version, then it evolved separately at BSD (from 2.11BSD on) and AT&T. Version 7 was followed by System III then System V. Internally, Version 7 evolved to Version 8, 9, 10, separately from the commercial branch. These were allegedly based on the 4.1cBSD codebase and later, but the 16-bit a.out format is more similar to the commercial versions.</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i16le</td>
<td>Magic number
<table border='1'>
<tr>
<td>0x0101</td>
<td>UNIX/RT "lpd"<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a> (System III)</td></tr>
<tr>
<td>0x0105</td>
<td>overlay<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a> (around Version 7, dropped support in 4.1cBSD<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a>)</td></tr>
<tr>
<td>0x0107</td>
<td>(OMAGIC) normal</td></tr>
<tr>
<td>0x0108</td>
<td>(NMAGIC) read-only text</td></tr>
<tr>
<td>0x0109</td>
<td>Separated instruction and data (dropped support in 4.1cBSD<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a>)</td></tr>
<tr>
<td>0x010B</td>
<td>(ZMAGIC) demand paged separated instruction and data (since 3BSD<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a>)</td></tr>
<tr>
<td>0x0118</td>
<td>2.11BSD overlay, non-separate (dropped support in 3BSD<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a>)</td></tr>
<tr>
<td>0x0119</td>
<td>2.11BSD overlay, separate (dropped support in 3BSD<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a>)</td></tr>
<tr>
<td>0x011F</td>
<td>system overlay, separated I&D (since System V)</td></tr>
</table>
</td></tr>
<tr>
<td><tt><sub>x</sub>02</tt></td> <td>i16le</td>
<td>Size of program text (code)</td></tr>
<tr>
<td><tt><sub>x</sub>04</tt></td> <td>i16le</td>
<td>Size of initialized data</td></tr>
<tr>
<td><tt><sub>x</sub>06</tt></td> <td>i16le</td>
<td>Size of uninitialized data (bss), not stored in binary</td></tr>
<tr>
<td><tt><sub>x</sub>08</tt></td> <td>i16le</td>
<td>Size of symbol table</td></tr>
<tr>
<td><tt><sub>x</sub>0A</tt></td> <td>i16le</td>
<td>Entry location<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a>, always 0 before version 4<a href="#UNIX2"><sup title="UNIX Programmer's Manual, Second Edition - K. Thompson, D. M. Ritchie, June 12, 1972">[2]</sup></a></td></tr>
<tr>
<td><tt><sub>x</sub>0C</tt></td> <td>i16le</td>
<td>reserved (stack required in version 2 and 3<a href="#UNIX2"><sup title="UNIX Programmer's Manual, Second Edition - K. Thompson, D. M. Ritchie, June 12, 1972">[2]</sup></a>)<br>(System III) environment stamp<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a></td></tr>
<tr>
<td><tt><sub>x</sub>0E</tt></td> <td>i16le</td>
<td>Non-zero if relocations have been suppressed<br>Xinu uses the least significant byte to mark Version 6 compatibility, and the most significant byte for its own flag<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a></td></tr>
</table>
<p>Xenix also uses the System 7 format.<a href="#XENIX"><sup title="XENIX System V man page">[5]</sup></a></p>
<p>Overlays in 2.9BSD have an extended header with the following fields:</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>10</tt></td> <td>i16le</td>
<td>Maximum size of overlays</td></tr>
<tr>
<td><tt><sub>x</sub>12</tt></td> <td>i16le[7]</td>
<td>Size of each overlay</td></tr>
</table>
<p>They are extended in 2.11BSD to 15 overlays:</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>10</tt></td> <td>i16le</td>
<td>Maximum size of overlays</td></tr>
<tr>
<td><tt><sub>x</sub>12</tt></td> <td>i16le[15]</td>
<td>Size of each overlay</td></tr>
</table>
<p>Since System V, the final fields are slightly altered:<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a></p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>0C</tt></td> <td>i8</td>
<td>reserved</td></tr>
<tr>
<td><tt><sub>x</sub>0D</tt></td> <td>i8</td>
<td>High bits of size of program text</td></tr>
<tr>
<td><tt><sub>x</sub>0E</tt></td> <td>i8</td>
<td>Non-zero if relocations have been suppressed</td></tr>
<tr>
<td><tt><sub>x</sub>0F</tt></td> <td>i8</td>
<td>Environment stamp</td></tr>
<tr>
<td><tt><sub>x</sub>10</tt></td> <td>i32le</td>
<td>filler (only Version 8 and later)</td></tr>
</table>
<h3>UNIX 32-bit a.out header</h2>
<p>The first version was created for UNIX/32V for the VAX (little endian). It was later extended to other 32-bit targets as well. By System V, all 32-bit versions switched to COFF except for the IBM 370 (the Interdata 7/32 port was apparently not maintained). However, competitors to AT&T such as SunOS and the BSD variants still kept using the format.</p>
<p>While most formats had a similar layout, the first word was often subdivided into various fields for machine type and flags. Most variants use the native byte order to store the values, which further complicates determination of the file type.</p>
<h4>UNIX/32V for VAX</h3>
<p>The entries were extended from the 16-bit version to full 32 bits. Also the last two fields were replaced with the size of the relocation section for text and initialized data, respectively.</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32</td>
<td>Magic number
<table border='1'>
<tr>
<td>0x00CC</td>
<td>(QMAGIC) compact demand load format (Linux, FreeBSD<a href="https://github.com/freebsd/freebsd-legacy/commit/2469c867a164210ce96143517059f21db7f1fd17" target="_blank"><sup title='since 1994-05-25'>*</sup></a>, NetBSD<a href="http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/exec.h?rev=1.2&content-type=text/x-cvsweb-markup" target="_blank"><sup title='since 1993-04-15'>*</sup></a>, OpenBSD)<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a></td></tr>
<tr>
<td>0x0101</td>
<td>UNIX/RT "lpd" (System III)</td></tr>
<tr>
<td>0x0105</td>
<td>overlay (dropped support in 4.1cBSD)</td></tr>
<tr>
<td>0x0107</td>
<td>(OMAGIC) normal (used by PDOS32 before switching to PE)</td></tr>
<tr>
<td>0x0108</td>
<td>(NMAGIC) read-only text</td></tr>
<tr>
<td>0x0109</td>
<td>separated instruction and data (dropped support in 4.1cBSD)</td></tr>
<tr>
<td>0x010B</td>
<td>(ZMAGIC) demand paged separated instruction and data (since 3BSD<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a>, used by early DJGPP)</td></tr>
<tr>
<td>0x010C</td>
<td>demand paged pure for NetBSD<a href="#MAGIC"><sup title="UNIX file magic numbers">[13]</sup></a></td></tr>
<tr>
<td>0x010C</td>
<td>(XMAGIC) demand load (like ZMAGIC), locations 0-1023 unmapped (NS16032)</td></tr>
<tr>
<td>0x010C</td>
<td>(SPRITE_ZMAGIC) ?</td></tr>
<tr>
<td>0x010D</td>
<td>(UNIX_ZMAGIC) UNIX binary compatible</td></tr>
<tr>
<td>0x010E</td>
<td>readable demand paged pure for NetBSD<a href="#MAGIC"><sup title="UNIX file magic numbers">[13]</sup></a></td></tr>
<tr>
<td>0x0111</td>
<td>(CMAGIC) core dump (Linux)<a href="#LINUX1"><sup title="a.out.h - Early Linux sources">[6]</sup></a></td></tr>
<tr>
<td>0x011F</td>
<td>system overlay, separated I&D (since System V and 3BSD)</td></tr>
</table>
</td></tr>
<tr>
<td><tt><sub>x</sub>04</tt></td> <td>i32</td>
<td>Size of program text (code)</td></tr>
<tr>
<td><tt><sub>x</sub>08</tt></td> <td>i32</td>
<td>Size of initialized data</td></tr>
<tr>
<td><tt><sub>x</sub>0C</tt></td> <td>i32</td>
<td>Size of uninitialized data (bss), not stored in binary</td></tr>
<tr>
<td><tt><sub>x</sub>10</tt></td> <td>i32</td>
<td>Size of symbol table</td></tr>
<tr>
<td><tt><sub>x</sub>14</tt></td> <td>i32</td>
<td>Entry location</td></tr>
<tr>
<td><tt><sub>x</sub>18</tt></td> <td>i32</td>
<td>Size of relocations for program text</td></tr>
<tr>
<td><tt><sub>x</sub>1C</tt></td> <td>i32</td>
<td>Size of relocations for initialized data</td></tr>
</table>
<h4>System III format</h3>
<p>Since System III, subfields of the extended magic number field got reused for additional information. The ways this was extended was sometimes incompatible between systems. System III VAX introduced an environment stamp, similarly to System III PDP-11 (albeit at a different position). 4.3BSD-Reno also switched over to this format for non-VAX targets, possibly to stay compatible with SunOS, and early NetBSD kept this format.</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32</td>
<td>
<table border='1'>
<tr>
<td>Bits 0:15</td>
<td>Magic number</td></tr>
<tr>
<td>Bits 16:31</td>
<td>Environment stamp (System III VAX)<br>Machine type (4.3BSD-Reno)</td></tr>
</table>
</td></tr>
</table>
<h4>Ultrix</h3>
<p>Ultrix had a different use for the new field:</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32</td>
<td>
<table border='1'>
<tr>
<td>Bits 0:15</td>
<td>Magic number</td></tr>
<tr>
<td>Bits 16:31</td>
<td>Mode (Ultrix)
<table border='1'>
<tr>
<td>0x0000</td>
<td>BSD executable</td></tr>
<tr>
<td>0x0001</td>
<td>System V compatible executable</td></tr>
<tr>
<td>0x0002</td>
<td>POSIX compatible executable</td></tr>
</table>
</td></tr>
</table>
</td></tr>
</table>
<h4>SunOS</h3>
<p>SunOS versions had a different format for the first word:</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32</td>
<td>
<table border='1'>
<tr>
<td>Bits 0:15</td>
<td>Magic number</td></tr>
<tr>
<td>Bits 16:23</td>
<td>Machine type</td></tr>
<tr>
<td>Bits 24:30</td>
<td>Tool version</td></tr>
<tr>
<td>Bit 31</td>
<td>Dynamic</td></tr>
</table>
</td></tr>
</table>
<p>Sun 4 also offered a few additional fields:</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>20</tt></td> <td>i32</td>
<td>Size of string segment</td></tr>
<tr>
<td><tt><sub>x</sub>24</tt></td> <td>i32</td>
<td>Size of sdata segment</td></tr>
<tr>
<td><tt><sub>x</sub>28</tt></td> <td>i32</td>
<td>Size of sdata relocations</td></tr>
<tr>
<td><tt><sub>x</sub>2C</tt></td> <td>i32</td>
<td>0 (spare segment)</td></tr>
<tr>
<td><tt><sub>x</sub>30</tt></td> <td>i32</td>
<td>0 (spare segment)</td></tr>
<tr>
<td><tt><sub>x</sub>34</tt></td> <td>i32</td>
<td>0 (spare segment)</td></tr>
<tr>
<td><tt><sub>x</sub>38</tt></td> <td>i32</td>
<td>0 (spare segment)</td></tr>
<tr>
<td><tt><sub>x</sub>3C</tt></td> <td>i32</td>
<td>0 (spare segment)</td></tr>
</table>
<h4>Linux</h3>
<p>Linux used the following format:</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32</td>
<td>
<table border='1'>
<tr>
<td>Bits 0:15</td>
<td>Magic number</td></tr>
<tr>
<td>Bits 16:23</td>
<td>Machine type</td></tr>
<tr>
<td>Bits 24:31</td>
<td>Flags (Linux)</td></tr>
</table>
</td></tr>
</table>
<h4>The BSDs</h3>
<p>4.4BSD-Lite2<a href="#44BSDLite2"><sup title="https://github.com/sergev/4.4BSD-Lite2">[14]</sup></a> used different versions for different targets: it used the UNIX/32V VAX version for VAX and Intel 386, the SunOS version (without additional fields) for SPARC, the System III format with machine type for HP300 and MIPS, and COFF for other systems.</p>
<p>Since FreeBSD 2.0 and NetBSD 0.9, the following layout is used for the magic number field. FreeBSD prior to 2.0 for all ports and NetBSD prior to 0.9 on VAX and 386 used the UNIX/32V VAX format.</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32</td>
<td>
<table border='1'>
<tr>
<td>Bits 0:15</td>
<td>Magic number</td></tr>
<tr>
<td>Bits 16:25</td>
<td>Machine type
<table border='1'>
<tr>
<td>0x0000</td>
<td>unknown, old Sun-2</td></tr>
<tr>
<td>0x0001</td>
<td>SunOS, 68010+</td></tr>
<tr>
<td>0x0002</td>
<td>SunOS, 68020</td></tr>
<tr>
<td>0x0003</td>
<td>SunOS, SPARC (likely 4.0.3)</td></tr>
<tr>
<td>0x0064</td>
<td>Intel 80386 for PC (4.4BSD, Linux, FreeBSD, NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x0065</td>
<td>AMD 29000 (4.4BSD)</td></tr>
<tr>
<td>0x0068</td>
<td>old IBM RT (OpenBSD)</td></tr>
<tr>
<td>0x0086</td>
<td>Intel 80386 BSD (FreeBSD, NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x0087</td>
<td>Motorola 68K BSD with 8K pages (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x0088</td>
<td>Motorola 68K BSD with 4K pages (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x0089</td>
<td>National Semiconductor NS32532 (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x008A</td>
<td>Intel SPARC BSD (FreeBSD<a href="https://github.com/freebsd/freebsd-legacy/commit/9391975ae6f63570cc6e176352c93a0d4ddadf52" target="_blank"><sup title='since at least 1994-09-24'>*</sup></a>, NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x008B</td>
<td>PMAX (MIPS R2000 based DECstation) (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x008C</td>
<td>VAX with 1K pages (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x008D</td>
<td>MIPS big endian (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x008D</td>
<td>Alpha code (NetBSD)<a href="#MAGIC"><sup title="UNIX file magic numbers">[13]</sup></a></td></tr>
<tr>
<td>0x008E</td>
<td>MIPS (NetBSD)<a href="#MAGIC"><sup title="UNIX file magic numbers">[13]</sup></a></td></tr>
<tr>
<td>0x008F</td>
<td>ARM6 (FreeBSD<a href="https://github.com/freebsd/freebsd-legacy/commit/7806cc81b8b8e21bbf283fba04d3b4c941741bef" target="_blank"><sup title='since 2004-05-05, note ARM specific definitions were present since 2001-01-04'>*</sup></a>, NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x0090</td>
<td>Motorola 68K with 2K pages (NetBSD)</td></tr>
<tr>
<td>0x0091</td>
<td>SH3 (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x0094</td>
<td>PowerPC 64-bit big endian (NetBSD)</td></tr>
<tr>
<td>0x0095</td>
<td>PowerPC big endian (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x0096</td>
<td>VAX (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x0097</td>
<td>MIPS I R2000/R3000 (4.4BSD, NetBSD, Linux 1.3.48)</td></tr>
<tr>
<td>0x0097</td>
<td>SPARC 64-bit (OpenBSD)</td></tr>
<tr>
<td>0x0098</td>
<td>MIPS II (4.4BSD, NetBSD, OpenBSD)<br>(<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a> claims R4000 but actually that was MIPS III, this should be R6000)</td></tr>
<tr>
<td>0x0099</td>
<td>Motorola 88K BSD (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x009A</td>
<td>HP PA-RISC (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x009B</td>
<td>SH5 with LP64 model (NetBSD)</td></tr>
<tr>
<td>0x009C</td>
<td>SPARC with LP64 model (NetBSD)</td></tr>
<tr>
<td>0x009D</td>
<td>AMD64/x86-64 (NetBSD, OpenBSD)</td></tr>
<tr>
<td>0x009E</td>
<td>SH5 with ILP32 model (NetBSD)</td></tr>
<tr>
<td>0x009E</td>
<td>MIPS 64-bit big endian (OpenBSD)</td></tr>
<tr>
<td>0x009F</td>
<td>Intel Itanium (NetBSD)</td></tr>
<tr>
<td>0x009F</td>
<td>AArch64/ARM64 (OpenBSD)</td></tr>
<tr>
<td>0x00A0</td>
<td>PowerPC 64-bit big endian (OpenBSD)</td></tr>
<tr>
<td>0x00A1</td>
<td>RISC-V 64-bit little endian (OpenBSD)</td></tr>
<tr>
<td>0x00B7</td>
<td>AArch64/ARM64 (NetBSD)</td></tr>
<tr>
<td>0x00B8</td>
<td>OpenRISC 1000 (NetBSD)</td></tr>
<tr>
<td>0x00B9</td>
<td>RISC-V (NetBSD)</td></tr>
<tr>
<td>0x00C8</td>
<td>HP200 68010 (4.3BSD, FreeBSD, NetBSD)</td></tr>
<tr>
<td>0x012C</td>
<td>HP300 68020+68881 (4.3BSD, FreeBSD, NetBSD)</td></tr>
<tr>
<td>0x0208</td>
<td>HP s500<a href="#MAGIC"><sup title="UNIX file magic numbers">[13]</sup></a></td></tr>
<tr>
<td>0x020A</td>
<td>HP s200 2.x<a href="#MAGIC"><sup title="UNIX file magic numbers">[13]</sup></a></td></tr>
<tr>
<td>0x020B</td>
<td>HP/UX HP800 (4.3BSD, FreeBSD, NetBSD), PA-RISC1.0<a href="#MAGIC"><sup title="UNIX file magic numbers">[13]</sup></a></td></tr>
<tr>
<td>0x020C</td>
<td>HP/UX HP200 or HP300 (4.3BSD, NetBSD), PA-RISC1.0 (OpenBSD), HP s200<a href="#MAGIC"><sup title="UNIX file magic numbers">[13]</sup></a></td></tr>
<tr>
<td>0x0210</td>
<td>HP700 HP-UX PA-RISC1.1 (OpenBSD)<a href="#MAGIC"><sup title="UNIX file magic numbers">[13]</sup></a></td></tr>
<tr>
<td>0x0214</td>
<td>HP700 HP-UX PA-RISC2.0 (OpenBSD)<a href="#MAGIC"><sup title="UNIX file magic numbers">[13]</sup></a></td></tr>
</table>
</td></tr>
<tr>
<td>Bits 26:31</td>
<td>Flags (FreeBSD)<a href="#TUHS"><sup title="The Unix Tree">[3]</sup></a></td></tr>
<tr>
<td>Bit 30</td>
<td>Position independent code (FreeBSD, NetBSD)</td></tr>
<tr>
<td>Bit 31</td>
<td>Dynamic (SunOS, unknown version?, FreeBSD, NetBSD, OpenBSD)</td></tr>
</table>
</td></tr>
</table>
<p>In NetBSD and OpenBSD, the fields are in the native byte order, except for the magic number which is in the big endian ("network") format (most significant byte first, like the Motorola 68000). As an exception, on little endian machines, little endian order is allowed if the machine type field and flags are 0.</p>
<p>In FreeBSD since <a href="https://github.com/freebsd/freebsd-legacy/commit/8abf9484aa165999b93d86ff28183b14db4f75ab" target="_blank">2004-06-22</a>, entries are always stored in the little endian format (least significant byte first, like the VAX and Intel 80386). However since <a href="https://github.com/freebsd/freebsd-legacy/commit/2469c867a164210ce96143517059f21db7f1fd17" target="_blank">1994-05-25</a> it recognizes big endian entries for the magic number (the other entries are still read in the little endian order).</p>
<h3>UNIX 32-bit Interdata 7/32 a.out header</h2>
<p>This version was introduced in Version 7 for the Interdata 7/32 (big endian). It is identical to the PDP-11 version, except that the word sizes are 32-bit and the byte order is big endian.</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32be</td>
<td>Magic number</td></tr>
<tr>
<td><tt><sub>x</sub>04</tt></td> <td>i32be</td>
<td>Size of program text (code)</td></tr>
<tr>
<td><tt><sub>x</sub>08</tt></td> <td>i32be</td>
<td>Size of initialized data</td></tr>
<tr>
<td><tt><sub>x</sub>0C</tt></td> <td>i32be</td>
<td>Size of uninitialized data (bss), not stored in binary</td></tr>
<tr>
<td><tt><sub>x</sub>10</tt></td> <td>i32be</td>
<td>Size of symbol table</td></tr>
<tr>
<td><tt><sub>x</sub>14</tt></td> <td>i32be</td>
<td>Entry location</td></tr>
<tr>
<td><tt><sub>x</sub>18</tt></td> <td>i32be</td>
<td>reserved</td></tr>
<tr>
<td><tt><sub>x</sub>1C</tt></td> <td>i32be</td>
<td>Non-zero if relocations have been suppressed</td></tr>
</table>
<h3>UNIX 32-bit IBM 370 a.out header</h2>
<p>This version was introduced in System V for the IBM 370 (big endian). It is a variant of the VAX format.</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32be</td>
<td>Magic number</td></tr>
<tr>
<td><tt><sub>x</sub>04</tt></td> <td>i32be</td>
<td>Stamp</td></tr>
<tr>
<td><tt><sub>x</sub>08</tt></td> <td>i32be</td>
<td>Size of program text (code)</td></tr>
<tr>
<td><tt><sub>x</sub>0C</tt></td> <td>i32be</td>
<td>Size of initialized data</td></tr>
<tr>
<td><tt><sub>x</sub>10</tt></td> <td>i32be</td>
<td>Size of uninitialized data (bss), not stored in binary</td></tr>
<tr>
<td><tt><sub>x</sub>14</tt></td> <td>i32be</td>
<td>Size of symbol table</td></tr>
<tr>
<td><tt><sub>x</sub>18</tt></td> <td>i32be</td>
<td>Entry location</td></tr>
<tr>
<td><tt><sub>x</sub>1C</tt></td> <td>i32be</td>
<td>Size of relocations for program text</td></tr>
<tr>
<td><tt><sub>x</sub>20</tt></td> <td>i32be</td>
<td>Size of relocations for initialized data</td></tr>
<tr>
<td><tt><sub>x</sub>24</tt></td> <td>i32be</td>
<td>Starting address of binary image</td></tr>
<tr>
<td><tt><sub>x</sub>28</tt></td> <td>i32be</td>
<td>Size of program text without padding to page boundary</td></tr>
<tr>
<td><tt><sub>x</sub>2C</tt></td> <td>i32be</td>
<td>Size of initialized data without padding to page boundary</td></tr>
</table>
<h3>UNIX 32-bit NS16032 a.out header</h2>
<p>There was a different version for National Semiconductor NS32K executables (little endian).</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32le</td>
<td>Magic number</td></tr>
<tr>
<td><tt><sub>x</sub>04</tt></td> <td>i32le</td>
<td>Size of program text (code)</td></tr>
<tr>
<td><tt><sub>x</sub>08</tt></td> <td>i32le</td>
<td>Size of initialized data</td></tr>
<tr>
<td><tt><sub>x</sub>0C</tt></td> <td>i32le</td>
<td>Size of uninitialized data (bss), not stored in binary</td></tr>
<tr>
<td><tt><sub>x</sub>10</tt></td> <td>i32le</td>
<td>Size of symbol table</td></tr>
<tr>
<td><tt><sub>x</sub>14</tt></td> <td>i32le</td>
<td>Entry location</td></tr>
<tr>
<td><tt><sub>x</sub>18</tt></td> <td>i32le</td>
<td>Entry mod</td></tr>
<tr>
<td><tt><sub>x</sub>1C</tt></td> <td>i32le</td>
<td>Size of relocations for program text</td></tr>
<tr>
<td><tt><sub>x</sub>20</tt></td> <td>i32le</td>
<td>Size of relocations for initialized data</td></tr>
<tr>
<td><tt><sub>x</sub>24</tt></td> <td>i32le</td>
<td>Size of mod table, part of program text</td></tr>
<tr>
<td><tt><sub>x</sub>28</tt></td> <td>i32le</td>
<td>Size of link table, part of program text</td></tr>
<tr>
<td><tt><sub>x</sub>2C</tt></td> <td>i32le</td>
<td>Size of string table</td></tr>
</table>
<h3>Xenix b.out header</h2>
<p>The Xenix b.out header is very similar to the 32-bit VAX a.out header, with the field order slightly changed:</p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32</td>
<td>Magic number</td></tr>
<tr>
<td><tt><sub>x</sub>04</tt></td> <td>i32</td>
<td>Size of program text (code)</td></tr>
<tr>
<td><tt><sub>x</sub>08</tt></td> <td>i32</td>
<td>Size of initialized data</td></tr>
<tr>
<td><tt><sub>x</sub>0C</tt></td> <td>i32</td>
<td>Size of uninitialized data (bss), not stored in binary</td></tr>
<tr>
<td><tt><sub>x</sub>10</tt></td> <td>i32</td>
<td>Size of symbol table</td></tr>
<tr>
<td><tt><sub>x</sub>14</tt></td> <td>i32</td>
<td>Size of relocations for program text</td></tr>
<tr>
<td><tt><sub>x</sub>18</tt></td> <td>i32</td>
<td>Size of relocations for initialized data</td></tr>
<tr>
<td><tt><sub>x</sub>1C</tt></td> <td>i32</td>
<td>Entry location</td></tr>
</table>
<h3>HP-UX a.out header</h2>
<p>HP-UX used a different format for a.out.<a href="#44BSDLite2"><sup title="https://github.com/sergev/4.4BSD-Lite2">[14]</sup></a></p>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i32be</td>
<td>Magic number</td></tr>
<tr>
<td><tt><sub>x</sub>04</tt></td> <td>i16be</td>
<td>Version ID</td></tr>
<tr>
<td><tt><sub>x</sub>06</tt></td> <td>i16be</td>
<td>Reserved</td></tr>
<tr>
<td><tt><sub>x</sub>08</tt></td> <td>i32be</td>
<td>Miscellaneous information</td></tr>
<tr>
<td><tt><sub>x</sub>0C</tt></td> <td>i32be</td>
<td>Size of program text (code)</td></tr>
<tr>
<td><tt><sub>x</sub>10</tt></td> <td>i32be</td>
<td>Size of initialized data</td></tr>
<tr>
<td><tt><sub>x</sub>14</tt></td> <td>i32be</td>
<td>Size of uninitialized data (bss), not stored in binary</td></tr>
<tr>
<td><tt><sub>x</sub>18</tt></td> <td>i32be[5]</td>
<td>Reserved</td></tr>
<tr>
<td><tt><sub>x</sub>2C</tt></td> <td>i32be</td>
<td>Entry location</td></tr>
<tr>
<td><tt><sub>x</sub>30</tt></td> <td>i32be[4]</td>
<td>Reserved</td></tr>
</table>
<h2>Runtime memory layout</h1>
<p>This section requires further work.</p>
<a id="_references"/>
<h2>References</h1>
<ul>
<li>[1] <a href="https://github.com/DoctorWkt/Apout" target='_blank'>Warren Toomey: Apout -- Simulate PDP-11 Unix a.out binaries</a></li>
<li>[2] UNIX Programmer's Manual, Second Edition - K. Thompson, D. M. Ritchie, June 12, 1972</li>
<li>[3] <a href="https://www.tuhs.org/cgi-bin/utree.pl" target='_blank'>The Unix Tree</a></li>
<li>[4] <a href="https://github.com/386bsd/386bsd/blob/2.0/usr/src/kernel/include/sys/exec.h" target='_blank'>exec.h - 386BSD sources</a></li>
<li>[5] <a href="https://web.archive.org/web/20230410013743/http://www.polarhome.com/service/man/?qf=a.out&tf=2&of=Xenix&sf=F" target='_blank'>XENIX System V man page</a></li>
<li>[6] <a href="https://elixir.bootlin.com/linux/1.0/source/include/linux/a.out.h" target='_blank'>a.out.h - Early Linux sources</a></li>
<li>[7] <a href="https://elixir.bootlin.com/linux/v6.7-rc1/source/include/uapi/linux/a.out.h" target='_blank'>a.out.h - Linux 6.7 RC1 sources</a></li>
<li>[8] <a href="https://github.com/FreeBSDDesktop/freebsd-base/blob/master/sys/sys/imgact_aout.h" target='_blank'>imgact_aout.h - FreeBSD sources</a></li>
<li>[9] <a href="https://github.com/freebsd/freebsd-legacy/tree/master" target='_blank'>https://github.com/freebsd/freebsd-legacy/tree/master</a></li>
<li>[10] <a href="http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/exec_aout.h?rev=1.41&content-type=text/x-cvsweb-markup&only_with_tag=netbsd-9-3-RELEASE" target='_blank'>exec_aout.h - NetBSD sources</a></li>
<li>[11] <a href="http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/aout_mids.h?rev=1.7&content-type=text/x-cvsweb-markup&only_with_tag=netbsd-9-3-RELEASE" target='_blank'>aout_mids.h - NetBSD sources</a></li>
<li>[12] <a href="https://github.com/openbsd/src/blob/master/sys/sys/exec.h" target='_blank'>exec.h - OpenBSD sources</a></li>
<li>[13] UNIX file magic numbers</li>
<li>[14] <a href="https://github.com/sergev/4.4BSD-Lite2" target='_blank'>https://github.com/sergev/4.4BSD-Lite2</a></li>
</ul>
<hr/>
<h1 id="aout_minix">MINIX a.out file format</h1>
<dl>
<dt>File extensions</td>
<dd>—</dd>
<dl>
<dt>Magic code</td>
<dd><tt><sub>x</sub>01<sub>x</sub>03</tt></dd>
<dl>
<dt>Architecture</td>
<dd>various, typically Intel 8086/80286, Intel 80386, Motorola 68000, SPARC</dd>
<dl>
<dt>Operating systems</td>
<dd><ul>
<li>1987: MINIX 1.0 before version 3.2</li>
<li>1999-05-20: ELKS (Linux-8086)</li>
</ul></dd>
</dl>
<dl>
<dt>Influences</td>
<dd>various, typically Intel 8086/80286, Intel 80386, Motorola 68000, SPARC</dd>
<a id="_contents"/>
<h2>Contents</h1>
<ol>
<li><a href="#_contents">Contents</a>
</li>
<li><a href="#header">Header</a>
</li><li><a href="#_references">References</a></li>
</ol>
<a id="header"/>
<h2>Header</h1>
<table border='1' align='center'>
<tr>
<td><tt><sub>x</sub>00</tt></td> <td>i8[2]</td>
<td><tt><sub>x</sub>01</tt>, <tt><sub>x</sub>03</tt></td></tr>
<tr>
<td><tt><sub>x</sub>02</tt></td> <td>i8</td>
<td>Flags (<tt><sub>x</sub>10</tt> for combined text/data executables, <tt><sub>x</sub>20</tt> for split text/data executables)
<table border='1'>
<tr>
<td>Bit 0</td>
<td>Unmapped zero page</td></tr>
<tr>
<td>Bit 1</td>
<td>Page aligned</td></tr>
<tr>
<td>Bit 2</td>
<td>New style symbol table</td></tr>
<tr>
<td>Bit 4</td>
<td>Executable</td></tr>
<tr>
<td>Bit 5</td>
<td>Separate instruction/data space</td></tr>
<tr>
<td>Bit 6</td>
<td>Pure text (not used)</td></tr>
<tr>
<td>Bit 7</td>
<td>Text overlay (not used)</td></tr>
</table>
</td></tr>
<tr>
<td><tt><sub>x</sub>03</tt></td> <td>i8</td>
<td>CPU<br>Bit 0 encodes byte order in 16-bit word: 0 for little endian, 1 for big endian<br>Bit 1 encodes 16-bit word order in 32-bit longword: 0 for little endian, 1 for big endian
<table border='1'>
<tr>
<td>0x00</td>
<td>Unknown</td></tr>
<tr>
<td>0x04</td>
<td>Intel 8086</td></tr>
<tr>
<td>0x0B</td>
<td>Motorola 68000</td></tr>
<tr>
<td>0x0C</td>
<td>National Semiconductor 16032 (32016)</td></tr>
<tr>
<td>0x10</td>
<td>Intel 80368</td></tr>
<tr>
<td>0x17</td>
<td>Sun SPARC</td></tr>
</table>
</td></tr>
<tr>
<td><tt><sub>x</sub>04</tt></td> <td>i8</td>
<td>Length of header, should be <tt><sub>x</sub>20</tt> or <tt><sub>x</sub>30</tt></td></tr>
<tr>
<td><tt><sub>x</sub>05</tt></td> <td>i8</td>
<td>Reserved</td></tr>
<tr>
<td><tt><sub>x</sub>06</tt></td> <td>i16</td>
<td>Version stamp (unused)</td></tr>
<tr>
<td><tt><sub>x</sub>08</tt></td> <td>i32</td>
<td>Size of text segment</td></tr>
<tr>
<td><tt><sub>x</sub>0C</tt></td> <td>i32</td>
<td>Size of data segment</td></tr>
<tr>
<td><tt><sub>x</sub>10</tt></td> <td>i32</td>
<td>Size of bss segment</td></tr>
<tr>