Research V7 release
[unix-history] / usr / man / man5 / a.out.5
CommitLineData
923e9e63
KT
1.TH A.OUT 5
2.SH NAME
3a.out \- assembler and link editor output
4.SH SYNOPSIS
5.B #include <a.out.h>
6.SH DESCRIPTION
7.I A.out
8is the output file of the assembler
9.IR as (1)
10and the link editor
11.IR ld (1).
12Both programs make
13.I a.out
14executable if there were no
15errors and no unresolved external references.
16Layout information as given in the include file for the PDP11 is:
17.PP
18.nf
19.ta 8n +9n +11n
20.PP
21.so /usr/include/a.out.h
22.fi
23.PP
24The file has four sections:
25a header, the program and data text,
26relocation information, and a symbol table
27(in that order).
28The last two may be empty
29if the program was loaded
30with the `\-s' option
31of
32.I ld
33or if the symbols and relocation have been
34removed by
35.IR strip (1).
36.PP
37In the header the sizes of each section are given in bytes, but are even.
38The size of the header is not included in any of the other sizes.
39.PP
40When an
41.I a.out
42file is loaded into core for execution, three logical segments are
43set up: the text segment, the data segment
44(with uninitialized data, which starts off as all 0, following
45initialized),
46and a stack.
47The text segment begins at 0
48in the core image; the header is not loaded.
49If the magic number in the header is 0407(8), it indicates that the text
50segment is not to be write-protected and shared,
51so the data segment is immediately contiguous
52with the text segment.
53If the magic number is 0410,
54the data segment begins at the first 0 mod 8K byte
55boundary following the text segment,
56and the text segment is not writable by the program;
57if other processes are executing the same file,
58they will share the text segment.
59If the magic number is 411,
60the text segment is again pure, write-protected, and shared,
61and moreover instruction and data space are separated;
62the text and data segment both begin at location 0.
63If the magic number is 0405, the text segment
64is overlaid on an existing (0411 or 0405) text segment
65and the existing data segment is preserved.
66.PP
67The stack will occupy the highest possible locations
68in the core image: from 0177776(8) and growing downwards.
69The stack is automatically extended as required.
70The data segment is only extended as requested by
71.IR brk (2).
72.PP
73The start of the text segment in the file is 020(8);
74the start of the data segment is 020+S\s6\dt\u\s10 (the size of the text)
75the start of the relocation information is
76020+S\s6\dt\u\s10+S\s6\dd\u\s10;
77the start of the symbol table is
78020+2(S\s6\dt\u\s10+S\s6\dd\u\s10)
79if the
80relocation information is present,
81020+S\s6\dt\u\s10+S\s6\dd\u\s10
82if not.
83.PP
84The layout of a symbol table entry and the principal flag values
85that distinguish symbol types are given in the include file.
86Other flag values may occur if an assembly language program
87defines machine instructions.
88.PP
89If a symbol's type is undefined external,
90and the value field is non-zero,
91the symbol is interpreted by the loader
92.I ld
93as
94the name of a common region
95whose size is indicated by the value of the
96symbol.
97.PP
98The value of a word in the text or data portions which is not
99a reference to an undefined external symbol
100is exactly that value which will appear in core
101when the file is executed.
102If a word in the text or data portion
103involves a reference to an undefined external symbol,
104as indicated by the relocation information
105for that word,
106then the value of the word as stored in the file
107is an offset from the associated external symbol.
108When the file is processed by the
109link editor and the external symbol becomes
110defined, the value of the symbol will
111be added into the word in the file.
112.PP
113If relocation
114information is present, it amounts to one word per
115word of program text or initialized data.
116There is no relocation information if the `relocation info stripped'
117flag in the header is on.
118.PP
119Bits 3-1 of a relocation word indicate the segment referred
120to by the text or data word associated with the relocation
121word:
122.TP
123000
124absolute number
125.br
126.ns
127.TP
128002
129reference to text segment
130.br
131.ns
132.TP
133004
134reference to initialized data
135.br
136.ns
137.TP
138006
139reference to uninitialized data (bss)
140.br
141.ns
142.TP
143010
144reference to undefined external symbol
145.PP
146Bit 0 of the relocation word indicates, if 1,
147that the
148reference is relative to the pc (e.g. `clr x');
149if 0,
150that
151the reference is to the actual symbol (e.g.,
152`clr *$x').
153.PP
154The remainder of the relocation word (bits 15-4)
155contains a symbol number in the case of external
156references, and is unused otherwise.
157The first symbol is numbered 0, the second 1, etc.
158.SH "SEE ALSO"
159as(1), ld(1), nm(1)