7.1.30 Fixupoverflow Linker Option

The --fixupoverflow=action option specifies how the linker will respond should it encounter an overflow when fixing up a symbol.

Fixup is the process of replacing symbolic references in code with an actual value once psects have been located in memory and the address or value of symbols have been resolved. If the linker determines that the value of a symbol is too large to fit into the space reserved for it in the program image, then this is known as a fixup overflow. The default action of the linker when encountering a fixup overflow in C programs built with the xc8-cc driver is to trigger an error.

The --fixupoverflow option customizes the action taken by the linker when a fixup overflow situation is encountered, as described by the action arguments in the following table.
Table 7-3. Allowable actions on detection of a fixup overflow
Action Response
error Trigger an error message (the default response when used with xc8-cc).
warn Truncate the value to fit and trigger a warning message.
lstwarn Truncate the value to fit and insert a warning marker into the assembly list file where the overflow occurred.
ignore Truncate the value to fit and continue with no notification of the fact.

The warn and lstwarn actions can both be selected with this option, in which case they must be separated by a colon (:), for example --fixupoverflow=warn:lstwarn.

If an assembly list file has been requested using the -Wa,-a compiler option and the lstwarn action has been requested, a warning message will be inserted into the list file before the instruction or directive that contains the symbol being fixed up. The message will appear similar to:
13   003FF4      6F14                   movwf   _bar,b
14   003FF6
                 warning: (2090) fixup overflow storing 0x202 in 1 byte
                 5102                   movf    _foo,w,b
which shows an overflow associated with the symbol _foo. In this instance, the symbol has been resolved to the value 0x202, but there are only 7 bits in the movf instruction to hold the address offset of the file register being accessed. The linker has truncated the value 0x202 to a 7-bit quantity (0x02) and inserted this into the program image forming the opcode 0x5102.

If warning messages are inserted into a list file, a single advisory message will be issued by the compiler for each affected list file to alert you to this action. If the lstwarn action was specified, but an assembly list file was not actually requested, then an alternate warning message will be issued by the compiler.

Fixup overflows in C programs will almost certainly indicate some sort of error in how the code was written or linked. It is recommended that the (default) action of error is not change and that any fixup error is resolved. Selecting an action of ignore, warn, or lstwarn will allow the program to build, but these actions in no way address the underlying issue.