A fixup tells the linker to patch an address into the data. Each FIXUPP record (0x9C, 0x9D) applies to the LEDATA or LIDATA record just before it, and holds subrecords to the end of the record. There are two kinds, told apart by the top bit of the first byte.
Thread subrecord
Bit 7 is 0. A thread saves a frame or target so that the fixups after it can refer to it in one bit.
| Bits | Name | Meaning |
|---|---|---|
| 6 | D | 1 frame thread, 0 target thread |
| 5 | 0 | |
| 4–2 | Method | The frame or target method |
| 1–0 | Thred | Which of the four threads of that kind |
There are four FRAME threads and four TARGET threads (numbers 0 to 3 in the Thred field); not all need be defined, and a later THREAD subrecord, in the same or a later FIXUPP record, can redefine one. A THREAD subrecord does not require a previous LEDATA or LIDATA record, and a thread can be used by fixups in the same record and in later FIXUPP records. A record that uses threads can be smaller than one that does not.
The Index field (1 or 2 bytes) follows only when the method is 0, 1 or 2: a SEGDEF, GRPDEF or EXTDEF index (if method 3 were supported, it would hold an explicit frame number). For TARGET threads only the lower two bits of the method are stored: the high bit of the method comes from the P bit of each FIXUP subrecord that uses the thread.
Fixup subrecord
Bit 7 is 1. It has these fields, in order:
+0Locat: where and how to patch, high byte first2 bytes+2Fixdat: frame and target methods1 byte…Frame datum, an index, if F is 0 and the method needs one0 to 2 bytes…Target datum, an index, if T is 00 to 2 bytes…Target displacement, if P is 02 or 4 bytes
| Locat bits | Name | Meaning |
|---|---|---|
| 15 | 1: this is a fixup | |
| 14 | M | 1 segment-relative, 0 self-relative |
| 13–10 | Location | See Locations |
| 9–0 | Data record offset | Where in the LEDATA record before to patch |
| Fixdat bits | Name | Meaning |
|---|---|---|
| 7 | F | 1: the frame is thread number given in the Frame field |
| 6–4 | Frame | The frame method, or a thread number |
| 3 | T | 1: the target is a thread |
| 2 | P | 1: there is no target displacement |
| 1–0 | Targt | The target method, or a thread number |
Locations
| Value | Patches |
|---|---|
| 0 | The low byte of an offset |
| 1 | A 16-bit offset |
| 2 | A 16-bit segment base |
| 3 | A far pointer, 16:16 |
| 4 | The high byte of an offset (not supported by Microsoft LINK or IBM LINK386) |
| 5 | A 16-bit offset, resolved by the loader (treated as 1 by the linker). The PharLap implementation uses 5 for a 32-bit offset, where IBM and Microsoft use 9 |
| 6, 7, 8, 10, 12 | Not defined, reserved. (The PharLap implementation uses 6 for a 48-bit pointer, 16-bit base and 32-bit offset, where IBM and Microsoft use 11.) |
| 9 | A 32-bit offset |
| 11 | A 48-bit pointer, 16-bit base and 32-bit offset |
| 13 | A 32-bit offset, resolved by the loader (treated as 9 by the linker) |
Frame and target methods
| Method | Frame | Target |
|---|---|---|
| 0 | A segment’s frame (datum: SEGDEF index) | A segment (datum: SEGDEF index), with a displacement |
| 1 | A group’s frame (datum: GRPDEF index) | A group (datum: GRPDEF index), with a displacement |
| 2 | An external’s frame (datum: external index) | An external (datum: external index), with a displacement |
| 3 | An absolute frame; not supported by linkers | A frame number; not supported |
| 4 | The segment of the data before: the segment index of the previous LEDATA or LIDATA record (the segment in which the location is defined) | A segment (SEGDEF index) only; the displacement is assumed to be 0 |
| 5 | Determined by the target’s segment, group or external index (no datum) | A group (GRPDEF index) only; the displacement is assumed to be 0 |
| 6 | Invalid | An external (EXTDEF index) only; the displacement is assumed to be 0 |
| 7 | (not a frame method) | Not defined in the specification (the earlier text here, “as 3 with no displacement”, was an inference; method 3 is not supported by any current linker) |
Frame methods are F0 to F5 (F3 and F6 invalid), written in the Frame field; target methods are T0 to T6. Frame method 2 (external): Microsoft LINK and IBM LINK386 take the frame from the external name’s PUBDEF in another module, which gives a logical segment or a group. When the target comes from a thread, the thread gives the low two bits of the method and the P bit of the FIXUP gives the 4’s bit. The Frame field is 3 bits; with F = 1 it is a frame thread number (modulo 4), and there is no Frame Datum field. With T = 1 the 2-bit Targt field is a target thread number; with T = 0 the P bit and Targt form a 3-bit target method analogous to Frame. The Frame Datum is present only for frame methods 0, 1 and 2, the Target Datum for target methods that carry an index, and the Target Displacement (2 bytes in a 9C record, 4 in a 9D record) only when P = 0, for methods 0, 1 and 2.
Other rules: a FIXUP applies to the nearest previous LEDATA, LIDATA or COMDAT record, which must come before it; the Data Record Offset is 10 bits, which is why an LEDATA holds at most 1024 data bytes; in an LIDATA the offset points at a data byte of a Content field, and it is an error to reference a count field. The 9D record has the Target Displacement 32 bits wide, and the Location field of its Locat word extended to 4 bits (using the previously unused higher-order bit) to allow the new Locations 9, 11 and 13. Mode M = 1 is segment-relative and M = 0 self-relative.