96
|
1 An object file consists of a series of sections each of which contains a
|
|
2 list of exported symbols, a list of incomplete references, and a list of
|
|
3 "local" symbols which may be used in calculating incomplete references. Each
|
|
4 section will obviously also contain the object code.
|
|
5
|
|
6 Exported symbols must be completely resolved to an address within the
|
|
7 section it is exported from.
|
|
8
|
|
9 Each object file starts with a magic number and version number. The magic
|
|
10 number is the string "LWOBJ16" for this 16 bit object file format. The only
|
|
11 defined version number is currently 0. Thus, the first 8 bytes of the object
|
|
12 file are:
|
|
13
|
|
14 4C574F424A313600
|
|
15
|
|
16 Each section has the following items in order:
|
|
17
|
|
18 * section name
|
|
19 * flags
|
|
20 * list of local symbols (and addresses within the section)
|
|
21 * list of exported symbols (and addresses within the section)
|
|
22 * list of incomplete references along with the expressions to calculate them
|
|
23 * the actual object code
|
|
24
|
|
25 The section starts with the name of the section with a NUL termination
|
|
26 followed by a series of flag bytes terminated by NUL. The following flag
|
|
27 bytes are defined:
|
|
28
|
|
29 Byte Meaning
|
|
30 00 no more flags
|
|
31 01 section is BSS - no actual code is present
|
|
32
|
|
33 Either a NULL section name or end of file indicate the presence of no more
|
|
34 sections.
|
|
35
|
|
36 Each entry in the exported and local symbols table consists of the symbol
|
|
37 (NUL terminated) followed by two bytes which contain the value in big endian
|
|
38 order. The end of a symbol table is indicated by a NULL symbol name.
|
|
39
|
|
40 Each entry in the incomplete references table consists of an expression
|
|
41 followed by a 16 bit offset where the reference goes. Expressions are
|
|
42 defined as a series of terms up to an "end of expression" term. Each term
|
|
43 consists of a single byte which identifies the type of term (see below)
|
|
44 followed by any data required by the term. Then end of the list is flagged
|
|
45 by a NULL expression (only an end of expression term).
|
|
46
|
|
47 TERMTYPE Meaning
|
|
48 00 end of expression
|
|
49 01 integer (16 bit in big endian order follows)
|
|
50 02 external symbol reference (NUL term symbol)
|
|
51 03 local symbol reference (NUL term symbol)
|
|
52 04 operator (1 byte operator number - see below)
|
|
53 05 section base address reference
|
|
54
|
|
55 External references are resolved using other object files while local
|
|
56 references are resolved using the local symbol table(s) from this file. This
|
|
57 allows local symbols that are not exported to have the same names as
|
|
58 exported symbols or external references.
|
|
59
|
|
60 The operator numbers are:
|
|
61
|
|
62 NUM OP
|
|
63 01 + (plus)
|
|
64 02 - (minus)
|
|
65 03 * (times)
|
|
66 04 / (divide)
|
|
67 05 % (modulus)
|
|
68 06 \ (integer division)
|
|
69 07 bitwise and
|
|
70 08 bitwise or
|
|
71 09 bitwise xor
|
|
72 0A boolean and
|
|
73 0B boolean or
|
|
74 0C - (unary negation, 2's complement)
|
|
75 0D ^ (unary 1's complement)
|
|
76
|
|
77 An expression is represented in a postfix manner with both operands for
|
|
78 binary operators preceding the operator and the single operand for unary
|
|
79 operators preceding the operator.
|