PIC Linker trying to assign too much space to a section

I'm using Microchip's MPLAB IDE 6.20 to link several assembly routines into a control program for a system bus/memory interface. Everything would be fine, but when I run a Build All, I get the following error message:

Error - section 'GLOBALS' has a memory 'static' which can not fit the section. Section 'GLOBALS' length=0x00000028.

Meanwhile, the relevant lines from my linker command file are

DATABANK NAME=static START=0x0C END=0x0F DATABANK NAME=temp START=0x10 END=0x1F ... Other DATABANKs SECTION NAME=GLOBALS RAM=static SECTION NAME=TRANSACTION RAM=temp ... Other SECTIONS

I declare all the variables that go into these sections in a common header file that I include for each assembly module. The assembly modules declare no other variables - they're all brought in via the header. So, the key lines in the header file are:

GLOBALS idata

CMD_INT res 1 SWITCH_INT res 1 USR_INT res 1 RA_INT res 1

TRANSACTION idata

TGTADR_M1 res 1 ...Other variables

It seems to me that the GLOBALS section is as long as it needs to be - 4 byte-length values occupying addresses 0x0C - 0x0F. But somehow the linker seems to think I have 40 bytes! What's going on? How do I fix my files so that the linker does it right?

Thanks for any help.

--
Alex Rast
ad.rast.7@nwnotlink.NOSPAM.com
 Click to see the full signature
Reply to
Alex Rast
Loading thread data ...

into

--- clip clip ---

Maybe you have 10 modules with the data included?

It seems that the assembler/linker combination does not understand that the variables are common: there seems to be a separate copy in each module.

HTH

Tauno Voipio tauno voipio @ iki fi

Reply to
Tauno Voipio

...

Thanks! Your idea was exactly right. What I did, and in fact what I reasoned you have to do, is to export all my global variables in a separate assembly file (containing only the variable declaration directives) that I then make visible to the individual blocks using an extern directive. Of course you can keep all the temporary variables in the include file, declaring them as UDATA_OVR.

--
Alex Rast
ad.rast.7@nwnotlink.NOSPAM.com
 Click to see the full signature
Reply to
Alex Rast

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.