The attached code shows the two cases I have found where const data ends up in the wrong segment. The second one is quite weird. If you have no function referencing the const data then it ends up in the right segment. If it is followed by a routine that uses it then it ends up in code.
I don't understand why the no reference case emits it at all. It's static, and unreferenced so ought to just vanish.
Causes some really weird Fuzix breakages
sdcc -mz80 --constseg _CONST /tmp/1.c
I can reproduce the problem for z80 in current SDCC 3.8.3 [r10680]. For stm8, on the other hand, this seems to work ok.
Philipp
Fixed in [r11146]. Thanks for the patch.
Philipp
I only fixex fixed the one case... the static one is still busted when I tested it ?
Reopened for the second case.
As of current [r13845], I see the string in the correct segment, but the static struct array still in the wrong one. For both stm8 and z80.
Related
Commit: [r13845]
I don't really know how to fix this in general. I'm a code generation person, and have some ideas about optimizations.
But all that segment and linker-related stuff is unfamiliar ground me. In [r13846], I fixed the second issue for z80 and related, but I have no idea about how to fix it in general. Non-z80-related ports still put some stuff that should be in the const segment into the code segment instead.
Related
Commit: [r13846]