This page documents the format of 68K object (.o) files under the Macintosh Programmer's Workshop. The information here is taken from the manuals that came with MPW 3.0; as far as I know, it is not included with any current MPW documentation.
The standard file type for an MPW object file is "OBJ ", and the creator code is the standard MPW one, "MPS ". The file consists of a sequence of records of various types:
Every record begins with a byte containing its type code. This is often followed by a byte of flags--unused flag bits should always be zero. Variable-length records follow this by a word containing the total length of the record in bytes, including the type and flags fields.
An ID is an unsigned 16-bit integer used to refer to a symbolic name. The full name string only appears once, in a dictionary record, which saves space and simplifies other record structures. Valid ID numbers are [1 .. 65534]; IDs 0 and 65535 are reserved. Linker versions prior to MPW 3.0 only allowed IDs in the range [1 .. 16383].
Smart linking means that modules are only included in a link if they're active.
Minimum sizes in bytes for modules may be specified in more than one place: explicitly in Size records, or implicitly in Contents records. If multiple conflicting specifications are given for the size of a module, the largest one is taken.
Following are descriptions of Pad, First, Last, Comment, Dictionary, Module, Entry Point, Size, Contents, Reference and Computed Reference records.
used to ensure that other records always begin on even offsets.
begins an object file, and indicates its version.
Flag bits are as follows:
Valid version numbers are as follows:
ends an object file.
This record type is ignored by the Linker. It may be used to include any desired comment information in the object file.
lists symbolic names, and assigns integer IDs to them.
Defined flag bits:
Each name string is preceded by its length in bytes (Pascal format). There is no padding between name strings. The first name string is assigned the number given by First ID; the next one is assigned First ID + 1, and so on. The same ID may not be assigned more than once in the same object file, though different IDs can be assigned to the same name.
An ID defined as a module name or entry point must be assigned a name before its use in this way. However, an ID can be referenced before it is assigned a name.
Names may be up to 255 characters, and are case-sensitive. Languages which are not case-sensitive (eg Pascal, or the MPW Assembler in "case off" mode) conventionally convert all external names to uppercase.
An ID which is assigned a name with a length of zero, or which is not assigned a name, is treated as "anonymous". Compilers may use anonymous IDs to represent names which are not referenced outside their defining source modules.
The first ID assigned need not be 1, and multiple dictionary records are not required to define ID numbers using consecutive ranges, though the Linker works more efficiently if both of these things are done.
defines a code or data module, and establishes it as the "current" module.
Flag bits are as follows:
For code modules, the segment ID names the segment into which the Linker will include this code by default. For data modules, the module size field defines a minimum size for the module.
The Linker guarantees that module contents always begin on at least word boundaries.
defines an entry point at the specified byte offset within the current module.
Flag bits are as follows:
defines a minimum size for the current module.
Flag bits are as follows:
Flag bits are as follows:
specifies contents for the current module. The offset field, if present, indicates the byte offset from the beginning of the module at which this block of contents should be placed. The repeat count, if present, indicates the number of times this block of contents should be repeated.
The offset past the last byte defined by this Contents record specifies a minimum size for this module.
indicates that references to the specified name are to be added at the specified offsets in the current module.
Flag bits are as follows:
| A5-relative = 0 | A5-relative = 1 | |
|---|---|---|
| Code-to-code reference | Instruction must be JMP, JSR, LEA or PEA; it is forced to use PC-relative addressing if in the same segment, othewise A5-relative addressing. | Instruction must be JMP, JSR, LEA or PEA; it is forced to use A5-relative addressing unless this link is producing a code resource without an A5 world, in which case it is forced to use PC-relative addressing. |
| Code-to-data reference | not allowed | adds the A5 offset of the data |
| Data-to-code reference | adds the A5 offset of the code jump table entry;
this is fixed up at application load time by the _DataInit routine
by the further addition of the value of A5
| adds A5 offset of code |
| Data-to-data reference | adds the A5 offset of the data; this is
fixed up at application load time by the _DataInit routine
by the further addition of the value of A5 | adds the A5 offset of the data |
indicates that references to a computation based on the values of the specified names are to be added at the specified offsets in the current module. The only computation currently supported is the difference between the values of the names. Either both symbols must be code references, or they must both be data references.
Flag bits are as follows: