I'm probably a bit out on a limb here, but I'm running the Z80 port targetting an all-RAM config (a bit like CP/M does). The gsinit code hurts me a bit, and steals some valuable space. I realise this is required for a program which will ultimately reside in ROM, but it would be nice in my case (and save me around 300 bytes) if globals could be initialised at declaration time using the relevant .db or equivalent assembler directive.
My current proposed workaround (although I've not tested it thoroughly yet) is to rearrange the linker segments in my custom crt such that I get _CODE followed by _DATA, then _GSINIT section. Thus, once the call to gsinit is completed, that code is not needed again, so this space is reclaimed by main() for use with the dynamic memory allocator (again, my own), by locating the boundary between _DATA and _GSINIT and overwriting _GSINIT as the program runs. It's a bit clumsy, but once I got my head around the linker, seems possible.
An option such as --allocate-globals-directly or equivalent would help avoid this tinkering.
Having said that, I wouldn't assign this a high priority unless somebody else thinks it's useful too. I've got my workaround which has the same run-time footprint in memory as if the gsinit section were not there (except the remaining "jp _gsinit" instruction in the crt).
Log in to post a comment.