How Do I Fix a Fixup Overflow Error?

Fixup – the linker action of replacing a symbolic reference with an actual address – can overflow if the address assigned to the symbol is too large to fit in the address field of an assembly instruction. Most 8-bit PIC assembly instructions specify a file address that is an offset into the currently selected memory bank. If a full unmasked address is specified with these instructions, the linker will be unable to encode the large address value into the instruction and this error will be generated. For example, a mid-range device instruction only allows for file addresses in the range of 0 to 0x7F. However, if such a device has 4 data banks of RAM, the addresses of variables can range from 0 to 0x1FF.

For example, if the symbol of a variable that will be located at address 0x1D0 has been specified with one of these instructions, then when the symbol is replaced with its final value, this value will not fit in the address field of the instruction.

Many of the jump and call instructions also take a destination operand that is a truncated address. The PIC18 call and goto instructions work with a full address, but the branch and relative call instructions do not. If the destination label to any of these instructions is not masked, a fixup error can result.

The fixup process applies to the operands of assembler directives, as well as instructions; so if the operand to a directive overflows, a fixup error can also result. For example, if the symbol error is resolved by the linker to be the value 0x238, the directive:

DB error

which expects a byte value, will generate a fixup overflow error.

In most cases, fixup errors are caused by hand-written assembly code. When writing assembly, it is the programmer’s responsibility to add instructions to select the destination bank or page, then mask the address being used in the instruction (see Section 2.4.7.5 “What Things Must I Manage When Writing Assembly Code?”).

In some situations assembly code generated from C code can produce a fixup overflow message. Typically this will be related to jumps that are out of range. C switch statements that have become too large can trigger such a message. Changing how a compiler-generated psect is linked can also cause fixup overflow, as the new psect location may break an assumption made by the compiler.

It is important to remember that this is an issue with an assembly instruction, and that you need to find the instruction at fault before you can proceed. See the relevant error number in Error and Warning Messages for specific details about how to track down the offending instruction.