11/3/71 A.OUT (V)
NAME a.out -- assembler and link editor output
SYNOPSIS --
DESCRIPTION a.out is the output file of the assembler as and
the link editor ld. In both cases, a.out is exe-
cutable provided there were no errors and no un-
resolved external references.
This file has four sections: a header, the pro-
gram text, a symbol table, and relocation bits.
The last two may be empty if the program was
loaded with the "-s" option of ld or if the sym-
bols and relocation have been removed by strip.
The header always contains 6 words:
1 a "br .+14" instruction (205(8))
2 The size of the program text
3 The size of the symbol table
4. The size of the relocation bits area
5. The size of a data area
6 A zero word (unused at present)
The sizes of the program, symbol table, and relo-
cation area are in bytes but are always even.
The branch instruction serves both to identify
the file and to jump to the text entry point.
The program text size includes the 6-word header.
The data area is used when the file is executed;
the exec system call sets the program break to
the sum of the text size and this data size. The
data area is generated by the assembler when the
location counter "." lies beyond the last assem-
bled data, for example when the program ends with
one or more constructions of the form ".=.+n"; it
is preserved by the loader for the last program
in a load. (Routines other than the last have
the appropriate number of 0 words inserted, since
there is no other provision for zero-suppression
in an a.out file.)
The symbol table consists of 6-word entries. The
first four contain the ASCII name of the symbol,
null-padded. (In fact, the assembler generates
symbols of at most 7 bytes.) The next word is a
flag indicating the type of symbol. The follow-
ing values are possible:
00 undefined symbol
01 absolute symbol
02 register symbol
03 relocatable symbol
40 undefined global symbol
41 absolute global symbol
43 relocatable global symbol
An undefined global corresponds to a GMAP "sym-
ref" and an absolute or relocatable global to a
"symdef" or absolute or relocatable value respec-
tively. Values other than those given above may
occur if the user has defined some of his own in-
structions.
The last word of a symbol table entry contains
the value of the symbol. Its contents are not
specified if the symbol is undefined.
If a.out contains no unresolved global refer-
ences, header and text portions are exactly as
they will appear in core when the file is exe-
cuted. If the value of a word in the text por-
tion involves a reference to an undefined global,
the word is replaced by the offset in the symbol
table of the appropriate symbol. (That is, pos-
sible offsets are 0, 12(10), 24(10), ....) Such a
word will have appropriate relocation bits.
The relocation bits portion uses a variable-
length encoding. There is a string of bits for
each word in the text portion. The scheme has at
least two bits for each word, plus possibly two
more to extend the codes available; in either
case the bits may be followed by a 16-bit string
to represent an offset to an external symbol.
The bits are packed together without regard to
word boundaries. The last word is filled out
with 0's on the right.
The possible relocation bit configurations are:
00
word is absolute
01
word is relocatable
10
word is a relative reference to an undefined
global symbol with no offset. Currently, the
word contains the offset in the symbol table
of the symbol. When the symbol becomes de-
fined, say with value x, this location will
contain x-.-2, where "." is the location of
the word.
1100xxxxxxxxxxxxxxxx
word is relative reference to an external
symbol with an offset. It is the same as the
previous relocation type, except that the
16-bit offset is added in when the symbol be-
comes defined.
1101
word is a reference to an undefined external
symbol with no offset. At present the word
contains the symbol table offset of the sym-
bol. When the symbol becomes defined, the
word will contain the value of the symbol.
1110xxxxxxxxxxxxxxxx
word is a reference to an undefined external
symbol with an offset. At present, the word
contains the symbol table offset of the sym-
bol. When the symbol becomes defined, the
word will contain the value of the symbol
plus the given 16-bit offset.
FILES --
SEE ALSO as, ld, strip, nm, un
DIAGNOSTICS --
BUGS Soon, there will be a new type of symbol: the
data area symbol. In the text, it will appear as
an ordinary external reference. However, it need
not be defined; this will be done by the loader.
Watch this space for more details.
OWNER dmr