6.1.31 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 hand-written assembly programs built with the pic-as driver is to place warning markers in the assembly list file where possible.

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 6-3. Allowable actions on detection of a fixup overflow
Action Response
error Trigger an error message
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. (the default response when used with pic-as)
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 assembler 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 assembler 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 assembler.

Fixup overflows in hand-written assembly programs might indicate some sort of error in how the code was written or linked. It is commonly associated with the address of symbols in PIC programs that have not been masked to remove the banking or paging information. In this case, if you do not wish to mask addresses manually (see the Address Masking section in this guide), this option can be used to truncate the addresses and allow the program to build. It should be stressed that this option will, however, suppress the error message associated with any fixup overflow. It is recommended that an action of warn, or lstwarn be used so that you can monitor which instructions are affected. If there is some other erroneous situation in your program, using this option will in no way address the underlying issue.