Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual

Product codes
SW006021-1
Page of 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 422
 2012 Microchip Technology Inc.
The second cause of this message is when the total amount of memory needed by the 
psect being positioned is sufficient, but that this memory is fragmented in such a way 
that the largest contiguous block is too small to accommodate the psect. The linker is 
unable to split psects in this situation. That is, the linker cannot place part of a psect at 
one location and part somewhere else. Thus, the linker must be able to find a contigu-
ous block of memory large enough for every psect. If this is the cause of the error, then 
the psect must be split into smaller psects if possible.
To find out what memory is still available, generate and look in the map file, see 
Section 4.8.8 “-M: Generate Map File” for information on how to generate a map file. 
Search for the string UNUSED ADDRESS RANGES. Under this heading, look for the 
name of the segment specified in the error message. If the name is not present, then 
all the memory available for this psect has been allocated. If it is present, there will be 
one address range specified under this segment for each free block of memory. Deter-
mine the size of each block and compare this with the number of words specified in the 
error message.
Psects containing code can be reduced by using all the compiler’s optimizations, or 
restructuring the program. If a code psect must be split into two or more small psects, 
this requires splitting a function into two or more smaller functions (which may call each 
other). These functions may need to be placed in new modules.
Psects containing data may be reduced when invoking the compiler optimizations, but 
the effect is less dramatic. The program may need to be rewritten so that it needs less 
variables. If the default linker options must be changed, this can be done indirectly 
through the driver using the driver -L- option, see Section 4.8.7 “-L-: Adjust Linker 
Options Directly”
Section 4.8.8 “-M: Generate Map File”
 has information on inter-
preting the map file’s call graph if the compiler you are using uses a compiled stack. (If 
the string Call graph: is not present in the map file, then the compiled code uses a 
hardware stack.) If a data psect needs to be split into smaller psects, the definitions for 
variables will need to be moved to new modules or more evenly spread in the existing 
modules. Memory allocation for auto variables is entirely handled by the compiler. 
Other than reducing the number of these variables used, the programmer has little con-
trol over their operation. This applies whether the compiled code uses a hardware or 
compiled stack.
For example, after receiving the message:
Can’t find 0x34 words (0x34 withtotal) for psect text
 in segment CODE (error)
look in the map file for the ranges of unused memory.
UNUSED ADDRESS RANGES
        CODE             00000244-0000025F
                         00001000-0000102f
        RAM              00300014-00301FFB
In the CODE segment, there is 0x1c (0x25f-0x244+1) bytes of space available in one 
block and 0x30 available in another block. Neither of these are large enough to accom-
modate the psect text which is 0x34 bytes long. Notice, however, that the total amount 
of memory available is larger than 0x34 bytes.
(492) attempt to position absolute psect "*" is illegal 
(Linker)
This psect is absolute and should not have an address specified in a -P option. Either 
remove the abs psect flag, or remove the -P linker option.
(493) origin of psect "*" is defined more than once 
(Linker)
The origin of this psect is defined more than once. There is most likely more than one 
-p
 linker option specifying this psect.