The following names are used in the description of the file encoding.
0x signed 7 bits, 1 byte10 signed 14 bits, 2 bytes 11 signed 30 bits, 4 bytes
All integers are encoded in two's complement format, most significant byte first.
Every object file has a header followed by five sections containing code, data, and several sorts of descriptors:
Each section is described in turn below.
header: magic signatureOs runflag stack-extent code-size data-size type-size link-size entry-pc entry-type magic, runflag: operand stack-extent, code-size, data-size, type-size, link-size: operand entry-pc, entry-type: operand
The magic number is defined as 819248 (symbolically XMAGIC), for modules that have not been signed cryptographically, and 923426 (symbolically SMAGIC), for modules that contain a signature. The symbolic names XMAGIC and SMAGIC are defined by the C include file /include/isa.h and by the Limbo module dis(2).
The signature is present only if the magic number is SMAGIC. It has the form:
signature: length signature-data length: operand signature-data: byte ...
A digital signature is defined by a length, followed by an array of bytes of that length that contain the signature in some unspecified format. Data within the signature should identify the signing authority, algorithm, and data to be signed.
Runflag is a bit mask that selects various execution options for a Dis module. The flags currently defined are:
Stack-extent, if non-zero, gives the number of bytes by which the thread stack of this module should be extended in the event that procedure calls exhaust the allocated stack. While stack extension is transparent to programs, increasing this value may improve the efficiency of execution at the expense of using more memory.
Code-size, type-size and link-size give the number of entries (instructions, type descriptors, linkage directives) in the corresponding sections.
Data-size is the size in bytes of the module's global data area (not the number of items in data-section).
Entry-pc is an integer index into the instruction stream that is the default entry point for this module. It should point to the first instruction of a function. Instructions are numbered from a program counter value of zero.
Entry-type is the index of the type descriptor in the type section that corresponds to the function entry point set by entry-pc.
instruction: opcode address-mode middle-dataOs source-dataOs dest-dataOs opcode, address-mode: byte middle-data: operand source-data, dest-data: operand operandOs
The one byte opcode specifies the instruction to execute; opcodes are defined by the virtual machine specification.
The address-mode byte specifies the addressing mode of each of the three operands: middle, source and destination. The source and destination operands are encoded by three bits and the middle operand by two bits. The bits are packed as follows:
bit 7 6 5 4 3 2 1 0 m1 m0 s2 s1 s0 d2 d1 d0
The following definitions are used in the description of addressing modes:
The middle operand is encoded as follows:
The middle-data field is present only if the middle operand specifier of the address-mode is not `none'. If the field is present it is encoded as an operand.
The source and destination operands are encoded as follows:
The source-data and dest-data fields are present only when the corresponding address-mode field is not `none'. For offset indirect and immediate modes the field contains a single operand value. For double indirect modes the values are encoded as two operands: the first is the register indirect offset, and the second is the final indirect offset. The offsets for double indirect addressing cannot be larger than 16 bits.
type-descriptor: desc-number memsize mapsize map desc-number, memsize, mapsize: operand map: byte ...
The desc-number is a small integer index used to identify the descriptor to instructions such as new. Memsize is the size in bytes of the memory described by this type.
The mapsize field gives the size in bytes of the following map array. Map is an array of bytes representing a bit map where each bit corresponds to a word in memory. The most significant bit corresponds to the lowest address. For each bit in the map, the word at the corresponding offset in the type is a pointer iff the bit is set to 1.
data-item: code countOs offset data-value ... code: byte count, offset: operand
Each item contains an offset into the section, followed by one or more data values in a machine-independent encoding. As each value is placed in the data segment, the offset is incremented by the size of the datum.
The code byte has two 4-bit fields. The bottom 4 bits of code gives the number of data-values if there are between 1 and 15; if there are more than 15, the low-order field is zero, and a following operand gives the count.
The top 4 bits of code encode the type of each data-value in the item, which determines its encoding. The defined values are:
The loader maintains a current base address and a stack of addresses. Each item's value is stored at the address formed by adding the current offset to the current base address. That address initially is the base of the module's data segment. The `set base' operation immediately follows an `array' data-item. It stacks the current base address and sets the current base address to the address of the array element selected by its operand. The `restore base' operation sets the current base address to the address on the top of the stack, and pops the stack.
link-item: pc desc sig fn-name pc, desc: operand sig: word fn-name: string
Fn-name is the name of an exported function. Adt member functions appear with their full names: the member name qualified by the adt name, in the form adt-name.member-name, for instance Iobuf.gets.
Pc is the instruction number of its entry point. Desc is an index value that selects a type descriptor in the type section, which gives the type of the function's stack frame. Sig is an integer hash of the type signature of the function, used in type checking.
handler: offset pc1 pc2 desc nlab exc-tab offset, pc1, pc2, desc, nlab: operand exc-tab: exc-name pc ... exc-name pc pc exc-name: string pc: operand
Each handler specifies the frame offset of its exception structure, the range of pc values it covers (from pc1 up to but not including pc2), the type descriptor of any memory that needs destroying by the handler (or -1 if none), the number of exceptions in the handler and then the exception table itself. The latter consists of a list of exception names and the corresponding pc to jump to when this exception is raised. This is then followed by the pc to jump to in any wildcard (*) case or -1 if this is not applicable.
|DIS(6 )||Rev: Thu Feb 15 14:43:48 GMT 2007|