MobDefs.mesa (formerly BcdDefs)
Copyright Ó 1986, 1987, 1988, 1991 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) December 13, 1988 12:15:28 pm PST
DIRECTORY Table USING [Base, Selector];
MobDefs: DEFINITIONS = {
base pointer types
Base: TYPE = Table.Base;
MobBase: TYPE = LONG POINTER TO Mob;
NTHandle: TYPE = LONG POINTER TO NTRecord;
CTHandle: TYPE = LONG POINTER TO CTRecord;
MTHandle: TYPE = LONG POINTER TO MTRecord;
IMPHandle: TYPE = LONG POINTER TO IMPRecord;
EXPHandle: TYPE = LONG POINTER TO EXPRecord;
EVHandle: TYPE = LONG POINTER TO EVRecord;
SGHandle: TYPE = LONG POINTER TO SGRecord;
FTHandle: TYPE = LONG POINTER TO FTRecord;
SPHandle: TYPE = LONG POINTER TO SPRecord;
FPHandle: TYPE = LONG POINTER TO FPRecord;
TYPHandle: TYPE = LONG POINTER TO TYPRecord;
TMHandle: TYPE = LONG POINTER TO TMRecord;
NameString: TYPE = LONG POINTER TO PackedString;
allocation codes for the binder
BinderNTables: CARD16 = 20;
Selector: TYPE = Table.Selector[0..BinderNTables);
treetype: Selector = 0; -- trees
httype: Selector = 1; -- hash table
sstype: Selector = 2; -- (packed) string table
cttype: Selector = 3; -- config table
mttype: Selector = 4; -- module table
imptype: Selector = 5; -- import table
exptype: Selector = 6; -- export table
sgtype: Selector = 7; -- segment table
fttype: Selector = 8; -- file table
sttype: Selector = 9; -- semantic table
cxtype: Selector = 10; -- context table
nttype: Selector = 11; -- name table
evtype: Selector = 12; -- external variable table
sptype: Selector = 13; -- space table
fptype: Selector = 14; -- frame pack table
typtype: Selector = 15; -- type table
tmtype: Selector = 16; -- type table
lftype: Selector = 17; -- link fragment table
rftype: Selector = 18; -- ref literal and atom fragment table
tftype: Selector = 19; -- type fragment table
version identification
VersionStamp: TYPE = ARRAY [0..1] OF CARD;
NullVersion: VersionStamp = [0, 0];
Mob Header
VersionID: INT = 880328; -- defined on 28 March 1988
Mob: TYPE = MACHINE DEPENDENT RECORD [
versionIdent: INT ¬ VersionID,
format: MobFormat,
version: VersionStamp,
creator: VersionStamp,
sourceVersion: VersionStamp,
source: NameRecord,
nBytes: INT, -- # of bytes in the file
nConfigs, nModules, nImports, nExports: CARD16,
definitions, repackaged, typeExported: BOOL,
inlineFloat: BOOL,
mappingStarted: BOOL,
mappingFinished: BOOL,
versions: BOOL,
extended: BOOL ¬ TRUE,
padOptions: BYTE ¬ 0,
padDummy: [0..3] ¬ 0,
firstdummy: ModuleIndex,
nDummies: CARD16,
pad1: CARD16,
ssOffset: MobOffset, -- string table
ssLimit: MobOffset,
ctOffset: MobOffset, -- config table
ctLimit: CTIndex,
mtOffset: MobOffset, -- module table
mtLimit: MTIndex,
impOffset: MobOffset, -- import table
impLimit: IMPIndex,
expOffset: MobOffset, -- export table
expLimit: EXPIndex,
evOffset: MobOffset, -- external variable table
evLimit: EVIndex,
sgOffset: MobOffset, -- segment table
sgLimit: SGIndex,
ftOffset: MobOffset, -- file table
ftLimit: FTIndex,
spOffset: MobOffset, -- space table
spLimit: SPIndex,
ntOffset: MobOffset, -- name table
ntLimit: NTIndex,
typOffset: MobOffset, -- type table
typLimit: TYPIndex,
tmOffset: MobOffset, -- type map table
tmLimit: TMIndex,
fpOffset: MobOffset, -- frame pack table
fpLimit: FPIndex,
lfOffset: MobOffset, -- link fragment table
lfLimit: LFIndex,
rfOffset: MobOffset, -- ref literal fragment table
rfLimit: RFIndex,
tfOffset: MobOffset, -- type fragment table
tfLimit: TFIndex,
rtOffset: MobOffset, -- atom print names, type table, etc.
rtLimit: MobOffset
];
checkMobSize: BOOL [TRUE..TRUE] = (SIZE[Mob] MOD SIZE[CARD]) = 0;
MobFormat: TYPE = RECORD [
bytes: PACKED ARRAY [0..4) OF BYTE ¬ [0, 1, 2, 3],
halves: PACKED ARRAY [0..2) OF CARD16 ¬ [0, 1],
sign: INT ¬ FIRST[INT],
bitsPerWord: PACKED ARRAY [0..4) OF BYTE ¬
[BITS[WORD], BITS[WORD], BITS[WORD], BITS[WORD]],
bitsPerUnit: PACKED ARRAY [0..4) OF BYTE ¬
[BITS[UNIT], BITS[UNIT], BITS[UNIT], BITS[UNIT]]
];
This definition is sufficient to determine the characteristics of the host machine when an arbitrary machine wants to read an object file.
MobOffset: TYPE = MACHINE DEPENDENT RECORD [
SELECT OVERLAID * FROM
foreign => [xUnits: INT], -- when reader & writer differ
domestic => [units: INT] -- when reader & writer user same format
ENDCASE];
Even where not declared this way, all Limit fields in the header are also treated as MobOffset type for purposes of fixup on reading/writing. This type is here for bookeeping only.
Portable Type
Portable: TYPE = MACHINE DEPENDENT {module(0), interface(1)};
Name Table
PackedString: TYPE = MACHINE DEPENDENT RECORD [
length: CARD16,
text: PACKED SEQUENCE maxLength: CARD16 OF CHAR
];
This record occurs at ssOffset from the start of the bcd file. Every name is at most 255 characters long, the length being determined by the first byte.
NameRecord: TYPE = MACHINE DEPENDENT RECORD [INT];
NullName: NameRecord = [0];
NTRecord: TYPE = MACHINE DEPENDENT RECORD [
name: NameRecord,
item: Namee
];
checkNTRecord: [0..0] = BYTES[NTRecord] MOD 4;
Namee: TYPE = MACHINE DEPENDENT RECORD [
pad1: CARD16,
pad2: [0..CARD16.LAST/4],
cases: SELECT type: * FROM
config => [cti: CTIndex],
module => [mti: MTIndex],
import => [impi: IMPIndex],
export => [expi: EXPIndex]
ENDCASE
];
checkNamee: [0..0] = BYTES[Namee] MOD 4;
NTIndex: TYPE = Base RELATIVE LONG POINTER TO NTRecord;
NTNull: NTIndex = NTIndex.LAST;
Configuration Table
CTRecord: TYPE = MACHINE DEPENDENT RECORD [
name: NameRecord,
file: FTIndex,
config: CTIndex,
namedInstance: BOOL,
pad: NAT15,
nControls: CARD16,
controls: SEQUENCE COMPUTED NAT OF Namee
only config or module are valid
];
checkCTRecord: [0..0] = BYTES[CTRecord] MOD 4;
CTIndex: TYPE = Base RELATIVE LONG POINTER TO CTRecord;
CTNull: CTIndex = CTIndex.LAST;
Module Table
LinkLocKind: TYPE = MACHINE DEPENDENT {
framePrefix(0),
codePrefix(1),
inFrame(2),
dontcare(3)};
MTRecord: TYPE = MACHINE DEPENDENT RECORD [
name: NameRecord,
namedInstance: BOOL,
initial: BOOL,
frameRefs: BOOL, -- TRUE IFF there are REFs in this frame
spare: BOOL ¬ FALSE,
residentFrame, crossJumped, packageable: BOOL,
long, inlineFloat, boundsChecks, nilChecks: BOOL,
pad1: CARDINAL[0..31] ¬ 0,
pad2: CARD16 ¬ 0,
linkLoc: LinkLocKind, -- indicates frame or code links
modIndex: ModuleIndex, -- index of this module
entries: ProcIndex, -- # of entry points to this module
file: FTIndex,
config: CTIndex,
code: CodeDesc,
sseg: SGIndex,
links: LFIndex,
refLiterals: RFIndex,
types: TFIndex, -- the type indexes for this frame
frameType: TypeIndex, -- the type for this frame
framesize: CARD, -- # of AUs this frame occupies
variables: EVIndex -- # of external variables in this frame
];
checkMTRecordSize: BOOL [TRUE..TRUE] = (SIZE[MTRecord] MOD SIZE[CARD]) = 0;
CodeDesc: TYPE = MACHINE DEPENDENT RECORD [
sgi: SGIndex,
packed: BOOL, linkspace: BOOL,
pad1: CARDINAL[0..CARD16.LAST/4] ¬ 0,
pad2: CARD16 ¬ 0,
offset: INT,
length: INT
];
MTIndex: TYPE = Base RELATIVE LONG POINTER TO MTRecord;
MTNull: MTIndex = MTIndex.LAST;
Import Table
IMPRecord: TYPE = MACHINE DEPENDENT RECORD [
name: NameRecord ¬ NullName,
name of imported item
file: FTIndex ¬ FTNull,
file for imported item
port: Portable,
either a module import or an interface record import
namedInstance: BOOL,
TRUE if the imported item was explicitly named
modIndex: ModuleIndex ¬ 0,
index of the module receiving the import
offset: CARD16
offset in link area of the reference to the module or interface record
];
IMPIndex: TYPE = Base RELATIVE LONG POINTER TO IMPRecord;
IMPNull: IMPIndex = IMPIndex.LAST;
Export Table
EXPRecord: TYPE = MACHINE DEPENDENT RECORD [
name: NameRecord ¬ NullName,
name of exported item
file: FTIndex ¬ FTNull,
file defining exported item
pad: CARDINAL[0..CARD16.LAST/8] ¬ 0,
port: Portable,
either a module export or an interface record export
namedInstance: BOOL,
TRUE if the exported item was explicitly named
typeExported: BOOL,
TRUE if a type is exported
links: SEQUENCE nLinks: CARD16 OF EXPLink
];
EXPLink: TYPE = MACHINE DEPENDENT RECORD [
pad: CARD16 ¬ 0,
to: LinkOffset,
the destination offset (in interface record) of the exported link
from: Link
the source of the link
];
EXPIndex: TYPE = Base RELATIVE LONG POINTER TO EXPRecord;
EXPNull: EXPIndex = EXPIndex.LAST;
External Variable Table
EVRecord: TYPE = MACHINE DEPENDENT RECORD [
pad: CARD16,
length: CARD16,
offsets: PACKED SEQUENCE COMPUTED [1..CARD16.LAST) OF CARD
];
EVIndex: TYPE = Base RELATIVE LONG POINTER TO EVRecord;
EVNull: EVIndex = EVIndex.LAST;
Segment Table
SegClass: TYPE = MACHINE DEPENDENT {code (0), symbols, acMap, other (CARD16.LAST)};
SGRecord: TYPE = MACHINE DEPENDENT RECORD [
file: FTIndex,
class: SegClass,
pad: CARD16,
base: MobOffset, -- offset from file start in writer units
units: MobOffset, -- # of writer units of info
extraUnits: MobOffset -- # of writer units of extra info
];
SGIndex: TYPE = Base RELATIVE LONG POINTER TO SGRecord;
SGNull: SGIndex = SGIndex.LAST;
File Table
FTRecord: TYPE = MACHINE DEPENDENT RECORD [
name: NameRecord,
version: VersionStamp
];
FTIndex: TYPE = Base RELATIVE LONG POINTER TO FTRecord;
FTNull: FTIndex = FTIndex.LAST;
FTSelf: FTIndex = FTIndex.LAST - WORDS[WORD];
Space Table
SPRecord: TYPE = MACHINE DEPENDENT RECORD [
seg: SGIndex,
name: NameRecord,
length: CARD16,
pad: CARD16,
spaces: SEQUENCE COMPUTED NAT OF SpaceID
];
SpaceID: TYPE = MACHINE DEPENDENT RECORD [
name: NameRecord,
resident: BOOL,
offset: NAT15,
pages: [1..CARD16.LAST]
];
SPIndex: TYPE = Base RELATIVE LONG POINTER TO SPRecord;
SPNull: SPIndex = SPIndex.LAST;
Frame Pack Table
FPRecord: TYPE = MACHINE DEPENDENT RECORD [
name: NameRecord,
length: CARD16,
pad: CARD16,
modules: SEQUENCE COMPUTED NAT OF MTIndex
];
FPIndex: TYPE = Base RELATIVE LONG POINTER TO FPRecord;
FPNull: FPIndex = FPIndex.LAST;
Type Table
TYPRecord: TYPE = MACHINE DEPENDENT RECORD [
version: VersionStamp,
id: INT
];
TYPIndex: TYPE = Base RELATIVE LONG POINTER TO TYPRecord;
TYPNull: TYPIndex = TYPIndex.LAST;
Type Map Table
TMRecord: TYPE = RECORD [
version: VersionStamp,
offset: INT,
map: TYPIndex];
TMIndex: TYPE = Base RELATIVE LONG POINTER TO TMRecord;
TMNull: TMIndex = TMIndex.LAST;
Links
ModuleIndex: TYPE = CARDINAL[0..CARD16.LAST/4];
nullModule: ModuleIndex = ModuleIndex.FIRST;
ProcIndex: TYPE = LinkOffset;
procLimit: CARD16 = LinkOffset.LAST;
VarIndex: TYPE = LinkOffset;
varLimit: CARD16 = LinkOffset.LAST;
nullLink: Link = [var, 0, 0];
unboundLink: Link = [proc, 0, 0];
LinkFrag: TYPE = MACHINE DEPENDENT RECORD [
offset: CARD16 ¬ 0,
the offset in AUs to where the links are
(only useful if linkLoc = inFrame)
frag: SEQUENCE length: CARD16 OF Link
];
Link: TYPE = MACHINE DEPENDENT RECORD [
tag: LinkTag ¬ other,
modIndex: ModuleIndex ¬ 0,
offset: LinkOffset ¬ 0
];
LinkTag: TYPE = MACHINE DEPENDENT {var(0), proc(1), type(2), other(3)};
LinkOffset: TYPE = CARD16;
LFIndex: TYPE = Base RELATIVE LONG POINTER TO LinkFrag;
LFNull: LFIndex = LFIndex.LAST;
Atoms and REFs to literals
RefLitFrag: TYPE = MACHINE DEPENDENT RECORD [
offset: CARD16,
frag: SEQUENCE length: CARD16 OF RefLitIndex
];
RefLitIndex: TYPE = RECORD [INT];
RFIndex: TYPE = Base RELATIVE LONG POINTER TO RefLitFrag;
RFNull: RFIndex = RFIndex.LAST;
Types
TypeFrag: TYPE = MACHINE DEPENDENT RECORD [
offset: CARD16,
frag: PACKED SEQUENCE length: CARD16 OF TypeIndex
];
TypeIndex: TYPE = RECORD [INT];
TFIndex: TYPE = Base RELATIVE LONG POINTER TO TypeFrag;
TFNull: TFIndex = TFIndex.LAST;
}.