#2115 Linker bug: Data initialisation in library file doesn't work

linker (61)

I defined a sdcc library module that pre-initialises some data and linked it with my program:

.module _cpc_KeyMap
.globl _cpc_KeyMap

.area DATA
db 0x0ff,0x0ff,0x0ff,0x0ff,0x0ff,0x0ff,0x0ff,0xff

The data wasn't initialised.

The rel file shows the data is present, it seems when it goes to link it, the space is allocated for it, but there is no initialisation of the data.
I understand why, CODE section is generally meant to be read-only so it can go into ROM, and DATA is read-write in RAM and may be in a different memory location to the CODE. I also understand the GSINIT is emitted Z80 data probably generated by the sdcc compiler to initialise global variables, so this kind of issue is a linker one.

I expected it would be initialised by the GSINIT?

SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/TININative/ds400/hc08/s08 3.2.1 #8221 (Nov 17 2012) (Linux)

If the section is changed to "CODE" the data appears initialised, for a ROM program then it can be modified.. So it's definitely a linker/section problem?

compiling for z80, but if it's a linker problem, it may exist for other cpus supported by sdcc.


  • Kevin Thacker

    Kevin Thacker - 2012-12-19

    Ignore this one.
    I tried to make a test case. But it worked.

  • Kevin Thacker

    Kevin Thacker - 2012-12-19
    • status: open --> closed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks