Manual Page Result
0
Command: a.out | Section: 5 | Source: UNIX v7 | File: a.out.5
A.OUT(5) File Formats Manual A.OUT(5)
NAME
a.out - assembler and link editor output
SYNOPSIS
#include <a.out.h>
DESCRIPTION
A.out is the output file of the assembler as(1) and the link editor
ld(1). Both programs make a.out executable if there were no errors and
no unresolved external references. Layout information as given in the
include file for the x86 is:
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)a.out.h 8.1 (Berkeley) 6/2/93
*/
#ifndef _AOUT_H_
#define _AOUT_H_
#include <sys/types.h>
#include <machine/exec.h>
#include <sys/endian.h>
#include <sys/imgact_aout.h>
#include <machine/reloc.h>
#define _AOUT_INCLUDE_
#include <nlist.h>
#endif /* !_AOUT_H_ */
The file has four sections: a header, the program and data text, relo-
cation information, and a symbol table (in that order). The last two
may be empty if the program was loaded with the `-s' option of ld or if
the symbols and relocation have been removed by strip(1).
In the header the sizes of each section are given in bytes. The size
of the header is not included in any of the other sizes.
When an a.out file is loaded into core for execution, three logical
segments are set up: the text segment, the data segment (with unini-
tialized data, which starts off as all 0, following initialized), and a
stack. The text segment begins at 0 in the core image; the header is
not loaded. If the magic number in the header is 0407(8), it indicates
that the text segment is not to be write-protected and shared. If the
magic number is 0410, the text segment is not writable by the program;
and, if other processes are executing the same file, they will share
the text segment.
The stack will occupy the highest allocated locations in the core im-
age: from 017777774(8) and growing downwards. The stack is automati-
cally extended as required. The data segment is only extended as re-
quested by brk(2).
The start of the text segment in the file is 020(8); the start of the
data segment is 020+St0 (the size of the text) the start of the reloca-
tion information is 020+St0+Sd0; the start of the symbol table is
020+2(St0+Sd0) if the relocation information is present, 020+St0+Sd0 if
not.
The layout of a symbol table entry and the principal flag values that
distinguish symbol types are given in the include file.
If a symbol's type is undefined external, and the value field is non-
zero, the symbol is interpreted by the loader ld as the name of a com-
mon region whose size is indicated by the value of the symbol.
The value of a word in the text or data portions which is not a refer-
ence to an undefined external symbol is exactly that value which will
appear in core when the file is executed. If a word in the text or
data portion involves a reference to an undefined external symbol, as
indicated by the relocation information for that word, then the value
of the word as stored in the file is an offset from the associated ex-
ternal symbol. When the file is processed by the link editor and the
external symbol becomes defined, the value of the symbol will be added
into the word in the file.
Each relocation item occupies eight bytes. The first 32 bits indicate
the offset within the segment of the field to which a fixup must be ap-
plied. The next 16 bits indicate, if the external flag (see below) is
not set, the segment associated with the relocation item
002 absolute number
004 reference to text segment
006 reference to initialized data
010 reference to uninitialized data (bss)
otherwise a (zero-based) symbol number. The next 8 bits are reserved.
And the final 8 bits contain flags as follows:
001 pc-relative flag
006 length bits (000 = 1; 002 = 2; 004 = 4)
010 external flag
SEE ALSO
as(1), ld(1), nm(1)
A.OUT(5)