NAME
a.out – object file format |
SYNOPSIS
#include <a.out.h> |
DESCRIPTION
An executable Plan 9 binary file has up to six sections: a header,
the program text, the data, a symbol table, a PC/SP offset table
(MC68020 only), and finally a PC/line number table. The header,
given by a structure in <a.out.h>, contains 4–byte integers in big–endian
order:
typedef struct Exec { Sizes are expressed in bytes. The size of the header is not included in any of the other sizes. When a Plan 9 binary file is executed, a memory image of three segments is set up: the text segment, the data segment, and the stack. The text segment begins at a virtual address which is a multiple of the machine–dependent page size. The text segment consists of the header and the first text bytes of the binary file. The entry field gives the virtual address of the entry point of the program. The data segment starts at the first page–rounded virtual address after the text segment. It consists of the next data bytes of the binary file, followed by bss bytes initialized to zero. The stack occupies the highest possible locations in the core image, automatically growing downwards. The bss segment may be extended by brk(2).
The next syms (possibly zero) bytes of the file contain symbol
table entries, each laid out as:
The type field is one of the following characters with the high
bit set:
The Plan 9 compilers implement a virtual stack frame pointer rather than dedicating a register; moreover, on the MC680X0 architectures there is a variable offset between the stack pointer and the frame pointer. Following the symbol table, MC680X0 executable files contain a spsz–byte table encoding the offset of the stack frame pointer as a function of program location; this section is not present for other architectures. The PC/SP table is encoded as a byte stream. By setting the PC to the base of the text segment and the offset to zero and interpreting the stream, the offset can be computed for any PC. A byte value of 0 is followed by four bytes that hold, in big–endian order, a constant to be added to the offset. A byte value of 1 to 64 is multiplied by four and added, without sign extension, to the offset. A byte value of 65 to 128 is reduced by 64, multiplied by four, and subtracted from the offset. A byte value of 129 to 255 is reduced by 129, multiplied by the quantum of instruction size (e.g. two on the MC680X0), and added to the current PC without changing the offset. After any of these operations, the instruction quantum is added to the PC.
A similar table, occupying pcsz–bytes, is the next section in an
executable; it is present for all architectures. The same algorithm
may be run using this table to recover the absolute source line
number from a given program location. The absolute line number
(starting from zero) counts the newlines in the C–
preprocessed source seen by the compiler. Three symbol types in
the main symbol table facilitate conversion of the absolute number
to source file and line number:
|
SEE ALSO
db(1), acid(1), 8a(1), 8l(1), nm(1), strip(1), mach(2), symbol(2) |
BUGS
There is no type information in the symbol table; however, the
–a flags on the compilers will produce symbols for acid(1). |