This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to setup a correct linker file

Hi.

I'm working on a larger project, which is split into a subset of libraries.

As the code grew the more warnings appeared after linking (Section located outside class area), which resulted in a strange behaviour. I.e. Function pointers in structures pointed to the wrong functions, functions weren't properly executed, etc.

So I tried to modify the concerning linker file to take full advantage of the provided hardware (Infineon XC164, 256KB RAM, 128 KB Flash, 6KB On-Chip-RAM). But without any luck so far.

Are there any rules to properly setup a library file? When do I have to use which class?

Here is my current linker file:

CLASSES (ICONST(0x000200-0x003FFF),
         CCONST(0x000300-0x003FFF),
         ICODE (0x000200-0x003FFF),
         NCODE (0x000200-0x003FFF),
         NCONST(0x000200-0x003FFF),
         FCODE (0x000200-0x007FFF, 0x010000-0x02FFFF),
         FCONST(0x000200-0x007FFF, 0x010000-0x02FFFF),
         HCONST(0x000200-0x007FFF, 0x010000-0x02FFFF),
         XCONST(0x000200-0x007FFF, 0x010000-0x02FFFF),
         LCODE(0xC00000-0xC1FFFF),
         LCONST(0xC00000-0xC1FFFF),

         IDATA (0x00C000-0x00C7FF, 0x00F800-0x00FBFF),
         SDATA (0x00C000-0x00C7FF),
         BDATA (0x00FD00-0x00FDFF),

0x03FFFF)
         NDATA (0x030000-0x033FFF),
         FDATA (0x030000-0x03FFFF),
         HDATA (0x030000-0x03FFFF),
         XDATA (0x030000-0x03FFFF),

         ; unused/locked classes
         IDATA0(0xFFFFFF-0xFFFFFF),
         SDATA0(0xFFFFFF-0xFFFFFF),
         BDATA0(0xFFFFFF-0xFFFFFF),
         NDATA0(0x030000-0x033FFF),
         FDATA0(0xFFFFFF-0xFFFFFF),
         HDATA0(0x030000-0x03FFFF),
         XDATA0(0xFFFFFF-0xFFFFFF))


SECTIONS (?C_INITSEC(0x200),
          ;?C_CLRMEMSEC(0x300),
          ?C_SYSSTACK%IDATA(0xF600))

RESERVE (0x000008-0x00000B,     ; Monitor: NMI Vector
         0x008000-0x00BFFF,     ; XC164: Reserved for DSRAM
         0x00C800-0x00DFFF,     ; XC164: Reserved
         0x00E000-0x00EFFF,     ; XC164: XSFR area
         0x00F000-0x00F1FF,     ; XC164: ESFR area
         0x00F200-0x00F5FF,     ; XC164: Reserved for DPRAM
         0x00FE00-0x00FFFF,     ; XC164: SFR area
         0x03FE00-0x03FFFF)     ; Monitor: Code + Data RAM1 (CS0)

The library and application code does not care about any classes when declaring variables. I'm just using const for read-only variables. Does this probably cause these problems?

Thanks for your help in advance,
Axel.

Parents Reply Children
No data