xref: /freebsd/share/man/man5/a.out.5 (revision c4d9468ea0e627c69802bd0689c93527dc2e2a85)
1afe61c15SRodney W. Grimes.\" Copyright (c) 1991, 1993
2afe61c15SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
3afe61c15SRodney W. Grimes.\"
4afe61c15SRodney W. Grimes.\" This man page is derived from documentation contributed to Berkeley by
5afe61c15SRodney W. Grimes.\" Donn Seeley at UUNET Technologies, Inc.
6afe61c15SRodney W. Grimes.\"
7afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
8afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions
9afe61c15SRodney W. Grimes.\" are met:
10afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
11afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
12afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
13afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
14afe61c15SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
15afe61c15SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
16afe61c15SRodney W. Grimes.\"    must display the following acknowledgement:
17afe61c15SRodney W. Grimes.\"	This product includes software developed by the University of
18afe61c15SRodney W. Grimes.\"	California, Berkeley and its contributors.
19afe61c15SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
20afe61c15SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
21afe61c15SRodney W. Grimes.\"    without specific prior written permission.
22afe61c15SRodney W. Grimes.\"
23afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26afe61c15SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33afe61c15SRodney W. Grimes.\" SUCH DAMAGE.
34afe61c15SRodney W. Grimes.\"
35afe61c15SRodney W. Grimes.\"	@(#)a.out.5	8.1 (Berkeley) 6/5/93
367f3dea24SPeter Wemm.\" $FreeBSD$
37afe61c15SRodney W. Grimes.\"
38afe61c15SRodney W. Grimes.Dd June 5, 1993
39afe61c15SRodney W. Grimes.Dt A.OUT 5
40afe61c15SRodney W. Grimes.Os
41afe61c15SRodney W. Grimes.Sh NAME
42afe61c15SRodney W. Grimes.Nm a.out
43afe61c15SRodney W. Grimes.Nd format of executable binary files
44afe61c15SRodney W. Grimes.Sh SYNOPSIS
45afe61c15SRodney W. Grimes.Fd #include <a.out.h>
46afe61c15SRodney W. Grimes.Sh DESCRIPTION
47afe61c15SRodney W. GrimesThe include file
48afe61c15SRodney W. Grimes.Aq Pa a.out.h
49afe61c15SRodney W. Grimesdeclares three structures and several macros.
50afe61c15SRodney W. GrimesThe structures describe the format of
51afe61c15SRodney W. Grimesexecutable machine code files
52afe61c15SRodney W. Grimes.Pq Sq binaries
53afe61c15SRodney W. Grimeson the system.
54afe61c15SRodney W. Grimes.Pp
55afe61c15SRodney W. GrimesA binary file consists of up to 7 sections.
56afe61c15SRodney W. GrimesIn order, these sections are:
57afe61c15SRodney W. Grimes.Bl -tag -width "text relocations"
58afe61c15SRodney W. Grimes.It exec header
59afe61c15SRodney W. GrimesContains parameters used by the kernel
60afe61c15SRodney W. Grimesto load a binary file into memory and execute it,
61afe61c15SRodney W. Grimesand by the link editor
62afe61c15SRodney W. Grimes.Xr ld 1
63afe61c15SRodney W. Grimesto combine a binary file with other binary files.
64afe61c15SRodney W. GrimesThis section is the only mandatory one.
65afe61c15SRodney W. Grimes.It text segment
66afe61c15SRodney W. GrimesContains machine code and related data
67afe61c15SRodney W. Grimesthat are loaded into memory when a program executes.
68afe61c15SRodney W. GrimesMay be loaded read-only.
69afe61c15SRodney W. Grimes.It data segment
70afe61c15SRodney W. GrimesContains initialized data; always loaded into writable memory.
71afe61c15SRodney W. Grimes.It text relocations
72afe61c15SRodney W. GrimesContains records used by the link editor
73afe61c15SRodney W. Grimesto update pointers in the text segment when combining binary files.
74afe61c15SRodney W. Grimes.It data relocations
75afe61c15SRodney W. GrimesLike the text relocation section, but for data segment pointers.
76afe61c15SRodney W. Grimes.It symbol table
77afe61c15SRodney W. GrimesContains records used by the link editor
78afe61c15SRodney W. Grimesto cross reference the addresses of named variables and functions
79afe61c15SRodney W. Grimes.Pq Sq symbols
80afe61c15SRodney W. Grimesbetween binary files.
81afe61c15SRodney W. Grimes.It string table
82afe61c15SRodney W. GrimesContains the character strings corresponding to the symbol names.
83afe61c15SRodney W. Grimes.El
84afe61c15SRodney W. Grimes.Pp
85afe61c15SRodney W. GrimesEvery binary file begins with an
86afe61c15SRodney W. Grimes.Fa exec
87afe61c15SRodney W. Grimesstructure:
88afe61c15SRodney W. Grimes.Bd -literal -offset indent
89afe61c15SRodney W. Grimesstruct exec {
90b35481d4SNate Williams	unsigned long	a_midmag;
91afe61c15SRodney W. Grimes	unsigned long	a_text;
92afe61c15SRodney W. Grimes	unsigned long	a_data;
93afe61c15SRodney W. Grimes	unsigned long	a_bss;
94afe61c15SRodney W. Grimes	unsigned long	a_syms;
95afe61c15SRodney W. Grimes	unsigned long	a_entry;
96afe61c15SRodney W. Grimes	unsigned long	a_trsize;
97afe61c15SRodney W. Grimes	unsigned long	a_drsize;
98afe61c15SRodney W. Grimes};
99afe61c15SRodney W. Grimes.Ed
100afe61c15SRodney W. Grimes.Pp
101afe61c15SRodney W. GrimesThe fields have the following functions:
102afe61c15SRodney W. Grimes.Bl -tag -width a_trsize
103b35481d4SNate Williams.It Fa a_midmag
104b35481d4SNate WilliamsThis field is stored in host byte-order.
105b35481d4SNate WilliamsIt has a number of sub-components accessed by the macros
106d0353b83SRuslan Ermilov.Fn N_GETFLAG ,
107d0353b83SRuslan Ermilov.Fn N_GETMID ,
108d0353b83SRuslan Ermilovand
109d0353b83SRuslan Ermilov.Fn N_GETMAGIC ,
110b35481d4SNate Williamsand set by the macro
111d0353b83SRuslan Ermilov.Fn N_SETMAGIC .
112b35481d4SNate Williams.Pp
113b35481d4SNate WilliamsThe macro
114d0353b83SRuslan Ermilov.Fn N_GETFLAG
115b35481d4SNate Williamsreturns a few flags:
116b35481d4SNate Williams.Bl -tag -width EX_DYNAMIC
117b35481d4SNate Williams.It Dv EX_DYNAMIC
118b35481d4SNate Williamsindicates that the executable requires the services of the run-time link editor.
119b35481d4SNate Williams.It Dv EX_PIC
1201111b49cSSheldon Hearnindicates that the object contains position independent code.
1211111b49cSSheldon HearnThis flag is
122b35481d4SNate Williamsset by
123b35481d4SNate Williams.Xr as 1
124b35481d4SNate Williamswhen given the
125b35481d4SNate Williams.Sq -k
126b35481d4SNate Williamsflag and is preserved by
127b35481d4SNate Williams.Xr ld 1
128b35481d4SNate Williamsif necessary.
129b35481d4SNate Williams.El
130b35481d4SNate Williams.Pp
1314a8d0283SMike PritchardIf both EX_DYNAMIC and EX_PIC are set, the object file is a position independent
132b35481d4SNate Williamsexecutable image (eg. a shared library), which is to be loaded into the
133b35481d4SNate Williamsprocess address space by the run-time link editor.
134b35481d4SNate Williams.Pp
135b35481d4SNate WilliamsThe macro
136d0353b83SRuslan Ermilov.Fn N_GETMID
137b35481d4SNate Williamsreturns the machine-id.
138b35481d4SNate WilliamsThis indicates which machine(s) the binary is intended to run on.
139b35481d4SNate Williams.Pp
140d0353b83SRuslan Ermilov.Fn N_GETMAGIC
141b35481d4SNate Williamsspecifies the magic number, which uniquely identifies binary files
142afe61c15SRodney W. Grimesand distinguishes different loading conventions.
143afe61c15SRodney W. GrimesThe field must contain one of the following values:
144afe61c15SRodney W. Grimes.Bl -tag -width ZMAGIC
145afe61c15SRodney W. Grimes.It Dv OMAGIC
146afe61c15SRodney W. GrimesThe text and data segments immediately follow the header
147afe61c15SRodney W. Grimesand are contiguous.
148afe61c15SRodney W. GrimesThe kernel loads both text and data segments into writable memory.
149afe61c15SRodney W. Grimes.It Dv NMAGIC
150afe61c15SRodney W. GrimesAs with
151afe61c15SRodney W. Grimes.Dv OMAGIC ,
152afe61c15SRodney W. Grimestext and data segments immediately follow the header and are contiguous.
153afe61c15SRodney W. GrimesHowever, the kernel loads the text into read-only memory
154afe61c15SRodney W. Grimesand loads the data into writable memory at the next
155afe61c15SRodney W. Grimespage boundary after the text.
156afe61c15SRodney W. Grimes.It Dv ZMAGIC
157afe61c15SRodney W. GrimesThe kernel loads individual pages on demand from the binary.
158afe61c15SRodney W. GrimesThe header, text segment and data segment are all
159afe61c15SRodney W. Grimespadded by the link editor to a multiple of the page size.
160afe61c15SRodney W. GrimesPages that the kernel loads from the text segment are read-only,
161afe61c15SRodney W. Grimeswhile pages from the data segment are writable.
162afe61c15SRodney W. Grimes.El
163afe61c15SRodney W. Grimes.It Fa a_text
164afe61c15SRodney W. GrimesContains the size of the text segment in bytes.
165afe61c15SRodney W. Grimes.It Fa a_data
166afe61c15SRodney W. GrimesContains the size of the data segment in bytes.
167afe61c15SRodney W. Grimes.It Fa a_bss
168afe61c15SRodney W. GrimesContains the number of bytes in the
169afe61c15SRodney W. Grimes.Sq bss segment
170afe61c15SRodney W. Grimesand is used by the kernel to set the initial break
171afe61c15SRodney W. Grimes.Pq Xr brk 2
172afe61c15SRodney W. Grimesafter the data segment.
173afe61c15SRodney W. GrimesThe kernel loads the program so that this amount of writable memory
174afe61c15SRodney W. Grimesappears to follow the data segment and initially reads as zeroes.
175afe61c15SRodney W. Grimes.It Fa a_syms
176afe61c15SRodney W. GrimesContains the size in bytes of the symbol table section.
177afe61c15SRodney W. Grimes.It Fa a_entry
178afe61c15SRodney W. GrimesContains the address in memory of the entry point
179afe61c15SRodney W. Grimesof the program after the kernel has loaded it;
180afe61c15SRodney W. Grimesthe kernel starts the execution of the program
181afe61c15SRodney W. Grimesfrom the machine instruction at this address.
182afe61c15SRodney W. Grimes.It Fa a_trsize
183afe61c15SRodney W. GrimesContains the size in bytes of the text relocation table.
184afe61c15SRodney W. Grimes.It Fa a_drsize
185afe61c15SRodney W. GrimesContains the size in bytes of the data relocation table.
186afe61c15SRodney W. Grimes.El
187afe61c15SRodney W. Grimes.Pp
188afe61c15SRodney W. GrimesThe
189afe61c15SRodney W. Grimes.Pa a.out.h
190afe61c15SRodney W. Grimesinclude file defines several macros which use an
191afe61c15SRodney W. Grimes.Fa exec
192afe61c15SRodney W. Grimesstructure to test consistency or to locate section offsets in the binary file.
193afe61c15SRodney W. Grimes.Bl -tag -width N_BADMAG(exec)
194afe61c15SRodney W. Grimes.It Fn N_BADMAG exec
195afe61c15SRodney W. GrimesNonzero if the
196afe61c15SRodney W. Grimes.Fa a_magic
197afe61c15SRodney W. Grimesfield does not contain a recognized value.
198afe61c15SRodney W. Grimes.It Fn N_TXTOFF exec
199afe61c15SRodney W. GrimesThe byte offset in the binary file of the beginning of the text segment.
200afe61c15SRodney W. Grimes.It Fn N_SYMOFF exec
201afe61c15SRodney W. GrimesThe byte offset of the beginning of the symbol table.
202afe61c15SRodney W. Grimes.It Fn N_STROFF exec
203afe61c15SRodney W. GrimesThe byte offset of the beginning of the string table.
204afe61c15SRodney W. Grimes.El
205afe61c15SRodney W. Grimes.Pp
206afe61c15SRodney W. GrimesRelocation records have a standard format which
207afe61c15SRodney W. Grimesis described by the
208afe61c15SRodney W. Grimes.Fa relocation_info
209afe61c15SRodney W. Grimesstructure:
210afe61c15SRodney W. Grimes.Bd -literal -offset indent
211afe61c15SRodney W. Grimesstruct relocation_info {
212afe61c15SRodney W. Grimes	int		r_address;
213afe61c15SRodney W. Grimes	unsigned int	r_symbolnum : 24,
214afe61c15SRodney W. Grimes			r_pcrel : 1,
215afe61c15SRodney W. Grimes			r_length : 2,
216afe61c15SRodney W. Grimes			r_extern : 1,
217b35481d4SNate Williams			r_baserel : 1,
218b35481d4SNate Williams			r_jmptable : 1,
219b35481d4SNate Williams			r_relative : 1,
220b35481d4SNate Williams			r_copy : 1;
221afe61c15SRodney W. Grimes};
222afe61c15SRodney W. Grimes.Ed
223afe61c15SRodney W. Grimes.Pp
224afe61c15SRodney W. GrimesThe
225afe61c15SRodney W. Grimes.Fa relocation_info
226afe61c15SRodney W. Grimesfields are used as follows:
227afe61c15SRodney W. Grimes.Bl -tag -width r_symbolnum
228afe61c15SRodney W. Grimes.It Fa r_address
229afe61c15SRodney W. GrimesContains the byte offset of a pointer that needs to be link-edited.
230afe61c15SRodney W. GrimesText relocation offsets are reckoned from the start of the text segment,
231afe61c15SRodney W. Grimesand data relocation offsets from the start of the data segment.
232afe61c15SRodney W. GrimesThe link editor adds the value that is already stored at this offset
233afe61c15SRodney W. Grimesinto the new value that it computes using this relocation record.
234afe61c15SRodney W. Grimes.It Fa r_symbolnum
235afe61c15SRodney W. GrimesContains the ordinal number of a symbol structure
236afe61c15SRodney W. Grimesin the symbol table (it is
237afe61c15SRodney W. Grimes.Em not
238afe61c15SRodney W. Grimesa byte offset).
239afe61c15SRodney W. GrimesAfter the link editor resolves the absolute address for this symbol,
240afe61c15SRodney W. Grimesit adds that address to the pointer that is undergoing relocation.
241afe61c15SRodney W. Grimes(If the
242afe61c15SRodney W. Grimes.Fa r_extern
243afe61c15SRodney W. Grimesbit is clear, the situation is different; see below.)
244afe61c15SRodney W. Grimes.It Fa r_pcrel
245afe61c15SRodney W. GrimesIf this is set,
246afe61c15SRodney W. Grimesthe link editor assumes that it is updating a pointer
247afe61c15SRodney W. Grimesthat is part of a machine code instruction using pc-relative addressing.
248afe61c15SRodney W. GrimesThe address of the relocated pointer is implicitly added
249afe61c15SRodney W. Grimesto its value when the running program uses it.
250afe61c15SRodney W. Grimes.It Fa r_length
251afe61c15SRodney W. GrimesContains the log base 2 of the length of the pointer in bytes;
252afe61c15SRodney W. Grimes0 for 1-byte displacements, 1 for 2-byte displacements,
253afe61c15SRodney W. Grimes2 for 4-byte displacements.
254afe61c15SRodney W. Grimes.It Fa r_extern
255afe61c15SRodney W. GrimesSet if this relocation requires an external reference;
256afe61c15SRodney W. Grimesthe link editor must use a symbol address to update the pointer.
257afe61c15SRodney W. GrimesWhen the
258afe61c15SRodney W. Grimes.Fa r_extern
259afe61c15SRodney W. Grimesbit is clear, the relocation is
260afe61c15SRodney W. Grimes.Sq local ;
261afe61c15SRodney W. Grimesthe link editor updates the pointer to reflect
262afe61c15SRodney W. Grimeschanges in the load addresses of the various segments,
263b35481d4SNate Williamsrather than changes in the value of a symbol (except when
264b35481d4SNate Williams.Fa r_baserel
265b35481d4SNate Williamsis also set (see below).
266afe61c15SRodney W. GrimesIn this case, the content of the
267afe61c15SRodney W. Grimes.Fa r_symbolnum
268afe61c15SRodney W. Grimesfield is an
269afe61c15SRodney W. Grimes.Fa n_type
270afe61c15SRodney W. Grimesvalue (see below);
271afe61c15SRodney W. Grimesthis type field tells the link editor
272afe61c15SRodney W. Grimeswhat segment the relocated pointer points into.
273b35481d4SNate Williams.It Fa r_baserel
274b35481d4SNate WilliamsIf set, the symbol, as identified by the
275b35481d4SNate Williams.Fa r_symbolnum
276b35481d4SNate Williamsfield, is to be relocated to an offset into the Global Offset Table.
277b35481d4SNate WilliamsAt run-time, the entry in the Global Offset Table at this offset is set to
278b35481d4SNate Williamsbe the address of the symbol.
279b35481d4SNate Williams.It Fa r_jmptable
280b35481d4SNate WilliamsIf set, the symbol, as identified by the
281b35481d4SNate Williams.Fa r_symbolnum
282b35481d4SNate Williamsfield, is to be relocated to an offset into the Procedure Linkage Table.
283b35481d4SNate Williams.It Fa r_relative
284b35481d4SNate WilliamsIf set, this relocation is relative to the (run-time) load address of the
2851111b49cSSheldon Hearnimage this object file is going to be a part of.
2861111b49cSSheldon HearnThis type of relocation
287b35481d4SNate Williamsonly occurs in shared objects.
288b35481d4SNate Williams.It Fa r_copy
289b35481d4SNate WilliamsIf set, this relocation record identifies a symbol whose contents should
290b35481d4SNate Williamsbe copied to the location given in
291b35481d4SNate Williams.Fa r_address .
292b35481d4SNate WilliamsThe copying is done by the run-time link-editor from a suitable data
293b35481d4SNate Williamsitem in a shared object.
294afe61c15SRodney W. Grimes.El
295afe61c15SRodney W. Grimes.Pp
296afe61c15SRodney W. GrimesSymbols map names to addresses (or more generally, strings to values).
297afe61c15SRodney W. GrimesSince the link-editor adjusts addresses,
298afe61c15SRodney W. Grimesa symbol's name must be used to stand for its address
299afe61c15SRodney W. Grimesuntil an absolute value has been assigned.
300afe61c15SRodney W. GrimesSymbols consist of a fixed-length record in the symbol table
301afe61c15SRodney W. Grimesand a variable-length name in the string table.
302afe61c15SRodney W. GrimesThe symbol table is an array of
303afe61c15SRodney W. Grimes.Fa nlist
304afe61c15SRodney W. Grimesstructures:
305afe61c15SRodney W. Grimes.Bd -literal -offset indent
306afe61c15SRodney W. Grimesstruct nlist {
307afe61c15SRodney W. Grimes	union {
308afe61c15SRodney W. Grimes		char	*n_name;
309afe61c15SRodney W. Grimes		long	n_strx;
310afe61c15SRodney W. Grimes	} n_un;
311afe61c15SRodney W. Grimes	unsigned char	n_type;
312afe61c15SRodney W. Grimes	char		n_other;
313afe61c15SRodney W. Grimes	short		n_desc;
314afe61c15SRodney W. Grimes	unsigned long	n_value;
315afe61c15SRodney W. Grimes};
316afe61c15SRodney W. Grimes.Ed
317afe61c15SRodney W. Grimes.Pp
318afe61c15SRodney W. GrimesThe fields are used as follows:
319afe61c15SRodney W. Grimes.Bl -tag -width n_un.n_strx
320afe61c15SRodney W. Grimes.It Fa n_un.n_strx
321afe61c15SRodney W. GrimesContains a byte offset into the string table
322afe61c15SRodney W. Grimesfor the name of this symbol.
323afe61c15SRodney W. GrimesWhen a program accesses a symbol table with the
324afe61c15SRodney W. Grimes.Xr nlist 3
325afe61c15SRodney W. Grimesfunction,
326afe61c15SRodney W. Grimesthis field is replaced with the
327afe61c15SRodney W. Grimes.Fa n_un.n_name
328afe61c15SRodney W. Grimesfield, which is a pointer to the string in memory.
329afe61c15SRodney W. Grimes.It Fa n_type
330afe61c15SRodney W. GrimesUsed by the link editor to determine
331afe61c15SRodney W. Grimeshow to update the symbol's value.
332afe61c15SRodney W. GrimesThe
333afe61c15SRodney W. Grimes.Fa n_type
334afe61c15SRodney W. Grimesfield is broken down into three sub-fields using bitmasks.
335afe61c15SRodney W. GrimesThe link editor treats symbols with the
336afe61c15SRodney W. Grimes.Dv N_EXT
337afe61c15SRodney W. Grimestype bit set as
338afe61c15SRodney W. Grimes.Sq external
339afe61c15SRodney W. Grimessymbols and permits references to them from other binary files.
340afe61c15SRodney W. GrimesThe
341afe61c15SRodney W. Grimes.Dv N_TYPE
342afe61c15SRodney W. Grimesmask selects bits of interest to the link editor:
343afe61c15SRodney W. Grimes.Bl -tag -width N_TEXT
344afe61c15SRodney W. Grimes.It Dv N_UNDF
345afe61c15SRodney W. GrimesAn undefined symbol.
346afe61c15SRodney W. GrimesThe link editor must locate an external symbol with the same name
347afe61c15SRodney W. Grimesin another binary file to determine the absolute value of this symbol.
348afe61c15SRodney W. GrimesAs a special case, if the
349afe61c15SRodney W. Grimes.Fa n_value
350afe61c15SRodney W. Grimesfield is nonzero and no binary file in the link-edit defines this symbol,
351afe61c15SRodney W. Grimesthe link-editor will resolve this symbol to an address
352afe61c15SRodney W. Grimesin the bss segment,
353afe61c15SRodney W. Grimesreserving an amount of bytes equal to
354afe61c15SRodney W. Grimes.Fa n_value .
355afe61c15SRodney W. GrimesIf this symbol is undefined in more than one binary file
356afe61c15SRodney W. Grimesand the binary files do not agree on the size,
357afe61c15SRodney W. Grimesthe link editor chooses the greatest size found across all binaries.
358afe61c15SRodney W. Grimes.It Dv N_ABS
359afe61c15SRodney W. GrimesAn absolute symbol.
360afe61c15SRodney W. GrimesThe link editor does not update an absolute symbol.
361afe61c15SRodney W. Grimes.It Dv N_TEXT
362afe61c15SRodney W. GrimesA text symbol.
363afe61c15SRodney W. GrimesThis symbol's value is a text address and
364afe61c15SRodney W. Grimesthe link editor will update it when it merges binary files.
365afe61c15SRodney W. Grimes.It Dv N_DATA
366afe61c15SRodney W. GrimesA data symbol; similar to
367afe61c15SRodney W. Grimes.Dv N_TEXT
368afe61c15SRodney W. Grimesbut for data addresses.
369afe61c15SRodney W. GrimesThe values for text and data symbols are not file offsets but
370afe61c15SRodney W. Grimesaddresses; to recover the file offsets, it is necessary
371afe61c15SRodney W. Grimesto identify the loaded address of the beginning of the corresponding
372afe61c15SRodney W. Grimessection and subtract it, then add the offset of the section.
373afe61c15SRodney W. Grimes.It Dv N_BSS
374afe61c15SRodney W. GrimesA bss symbol; like text or data symbols but
375afe61c15SRodney W. Grimeshas no corresponding offset in the binary file.
376afe61c15SRodney W. Grimes.It Dv N_FN
377afe61c15SRodney W. GrimesA filename symbol.
378afe61c15SRodney W. GrimesThe link editor inserts this symbol before
379afe61c15SRodney W. Grimesthe other symbols from a binary file when
380afe61c15SRodney W. Grimesmerging binary files.
381afe61c15SRodney W. GrimesThe name of the symbol is the filename given to the link editor,
382afe61c15SRodney W. Grimesand its value is the first text address from that binary file.
383afe61c15SRodney W. GrimesFilename symbols are not needed for link-editing or loading,
384afe61c15SRodney W. Grimesbut are useful for debuggers.
385afe61c15SRodney W. Grimes.El
386afe61c15SRodney W. Grimes.Pp
387afe61c15SRodney W. GrimesThe
388afe61c15SRodney W. Grimes.Dv N_STAB
389afe61c15SRodney W. Grimesmask selects bits of interest to symbolic debuggers
390afe61c15SRodney W. Grimessuch as
391afe61c15SRodney W. Grimes.Xr gdb 1 ;
392afe61c15SRodney W. Grimesthe values are described in
393afe61c15SRodney W. Grimes.Xr stab 5 .
394afe61c15SRodney W. Grimes.It Fa n_other
395b35481d4SNate WilliamsThis field provides information on the nature of the symbol independent of
396b35481d4SNate Williamsthe symbol's location in terms of segments as determined by the
397b35481d4SNate Williams.Fa n_type
3981111b49cSSheldon Hearnfield.
3991111b49cSSheldon HearnCurrently, the lower 4 bits of the
400b35481d4SNate Williams.Fa n_other
401b35481d4SNate Williamsfield hold one of two values:
402b35481d4SNate Williams.Dv AUX_FUNC
403b35481d4SNate Williamsand
404b35481d4SNate Williams.Dv AUX_OBJECT
405c4d9468eSRuslan Ermilov(see
406b35481d4SNate Williams.Aq Pa link.h
407c4d9468eSRuslan Ermilovfor their definitions).
408b35481d4SNate Williams.Dv AUX_FUNC
409b35481d4SNate Williamsassociates the symbol with a callable function, while
410b35481d4SNate Williams.Dv AUX_OBJECT
411b35481d4SNate Williamsassociates the symbol with data, irrespective of their locations in
412b35481d4SNate Williamseither the text or the data segment.
413b35481d4SNate WilliamsThis field is intended to be used by
414b35481d4SNate Williams.Xr ld 1
415b35481d4SNate Williamsfor the construction of dynamic executables.
416afe61c15SRodney W. Grimes.It Fa n_desc
417afe61c15SRodney W. GrimesReserved for use by debuggers; passed untouched by the link editor.
418afe61c15SRodney W. GrimesDifferent debuggers use this field for different purposes.
419afe61c15SRodney W. Grimes.It Fa n_value
420afe61c15SRodney W. GrimesContains the value of the symbol.
421afe61c15SRodney W. GrimesFor text, data and bss symbols, this is an address;
422afe61c15SRodney W. Grimesfor other symbols (such as debugger symbols),
423afe61c15SRodney W. Grimesthe value may be arbitrary.
424afe61c15SRodney W. Grimes.El
425afe61c15SRodney W. Grimes.Pp
426afe61c15SRodney W. GrimesThe string table consists of an
427afe61c15SRodney W. Grimes.Em unsigned long
428afe61c15SRodney W. Grimeslength followed by null-terminated symbol strings.
429afe61c15SRodney W. GrimesThe length represents the size of the entire table in bytes,
430afe61c15SRodney W. Grimesso its minimum value (or the offset of the first string)
431afe61c15SRodney W. Grimesis always 4 on 32-bit machines.
432afe61c15SRodney W. Grimes.Sh SEE ALSO
433b35481d4SNate Williams.Xr as 1 ,
434b35481d4SNate Williams.Xr gdb 1 ,
435afe61c15SRodney W. Grimes.Xr ld 1 ,
436b35481d4SNate Williams.Xr brk 2 ,
437afe61c15SRodney W. Grimes.Xr execve 2 ,
438afe61c15SRodney W. Grimes.Xr nlist 3 ,
439afe61c15SRodney W. Grimes.Xr core 5 ,
44077a98af6SJeroen Ruigrok van der Werven.Xr elf 5 ,
441c69a537cSWolfram Schneider.Xr link 5 ,
442c69a537cSWolfram Schneider.Xr stab 5
443afe61c15SRodney W. Grimes.Sh HISTORY
444afe61c15SRodney W. GrimesThe
445afe61c15SRodney W. Grimes.Pa a.out.h
446afe61c15SRodney W. Grimesinclude file appeared in
447afe61c15SRodney W. Grimes.At v7 .
448afe61c15SRodney W. Grimes.Sh BUGS
449afe61c15SRodney W. GrimesSince not all of the supported architectures use the
450b35481d4SNate Williams.Fa a_midmag
451afe61c15SRodney W. Grimesfield,
452afe61c15SRodney W. Grimesit can be difficult to determine what
453afe61c15SRodney W. Grimesarchitecture a binary will execute on
454afe61c15SRodney W. Grimeswithout examining its actual machine code.
455afe61c15SRodney W. GrimesEven with a machine identifier,
456afe61c15SRodney W. Grimesthe byte order of the
457afe61c15SRodney W. Grimes.Fa exec
458afe61c15SRodney W. Grimesheader is machine-dependent.
459afe61c15SRodney W. Grimes.Pp
460afe61c15SRodney W. GrimesNobody seems to agree on what
461afe61c15SRodney W. Grimes.Em bss
462afe61c15SRodney W. Grimesstands for.
463