6.6. The .reloc Section (Image Only)

The Fix-Up Table contains entries for all fixups in the image. The Total Fix-Up Data Size in the Optional Header is the number of bytes in the fixup table. The fixup table is broken into blocks of fixups. Each block represents the fixups for a 4K page. Each block must start on a 32-bit boundary.

Fixups that are resolved by the linker do not need to be processed by the loader, unless the load image can’t be loaded at the Image Base specified in the PE Header.

6.6.1. Fixup Block

Each fixup block starts with the following structure:

Offset Size Field Description
0 4 Page RVA The image base plus the page RVA is added to each offset to create the virtual address of where the fixup needs to be applied.
4 4 Block Size Total number of bytes in the fixup block, including the Page RVA and Block Size fields, as well as the Type/Offset fields that follow.

The Block Size field is then followed by any number of Type/Offset entries. Each entry is a word (2 bytes) and has the following structure:

Offset Size Field Description
0 4 bits Type Stored in high 4 bits of word. Value indicating which type of fixup is to be applied. These fixups are described in “Fixup Types.”
0 12 bits Offset Stored in remaining 12 bits of word. Offset from starting address specified in the Page RVA field for the block. This offset specifies where the fixup is to be applied.

To apply a fixup, a delta is calculated as the difference between the preferred base address, and the base where the image is actually loaded. If the image is loaded at its preferred base, the delta would be zero, and thus the fixups would not have to be applied.

6.6.2. Fixup Types

 Constant Value Description
IMAGE_REL_BASED_ABSOLUTE 0 The fixup is skipped. This type can be used to pad a block.
IMAGE_REL_BASED_HIGH 1 The fixup adds the high 16 bits of the delta to the 16-bit field at Offset. The 16-bit field represents the high value of a 32-bit word.
IMAGE_REL_BASED_LOW 2 The fixup adds the low 16 bits of the delta to the 16-bit field at Offset. The 16-bit field represents the low half of a 32-bit word.
IMAGE_REL_BASED_HIGHLOW 3 The fixup applies the delta to the 32-bit field at Offset.
IMAGE_REL_BASED_HIGHADJ 4 The fixup adds the high 16 bits of the delta to the 16-bit field at Offset. The 16-bit field represents the high value of a 32-bit word. The low 16 bits of the 32-bit value are stored in the 16-bit word that follows this base relocation. This means that this base relocation occupies two slots.
IMAGE_REL_BASED_MIPS_JMPADDR 5 Fixup applies to a MIPS jump instruction.
IMAGE_REL_BASED_SECTION 6 Reserved for future use
IMAGE_REL_BASED_REL32 7 Reserved for future use
IMAGE_REL_BASED_MIPS_JMPADDR16 9 Fixup applies to a MIPS16 jump instruction.
IMAGE_REL_BASED_DIR64 10 This fixup applies the delta to the 64-bit field at Offset
IMAGE_REL_BASED_HIGH3ADJ 11 The fixup adds the high 16 bits of the delta to the 16-bit field at Offset. The 16-bit field represents the high value of a 48-bit word. The low 32 bits of the 48-bit value are stored in the 32-bit word that follows this base relocation. This means that this base relocation occupies three slots.