----- Alistair Buxton wrote:
> When I use my custom crt0, in the final binary, gsinit: is pointing to
> GSFINAL instead of GSINIT.
crt0 needs to be the first module in the list of modules you link.
If it is not first, then the gsinit label will not be ahead of the stuff
the compiler puts in the GSINIT area. This is not documented
very well. I think that when you let sdcc magically add crt0, it
places it ahead of everything else you link. But when you use
the "--no-std-crto", it is up to you to put it first.
> Therefore, global variables do not get
> initialised. Also, GSINIT is placed into DATA which seems to be wrong.
This is also a symptom of crt0 not being linked first. I think
the linker puts the areas in the order it first encounters them.
That is why all the areas are mentioned in the default crt0.s,
even if crt0 does not put anything in that area.
> Finally, since my device only has RAM and not ROM, I don't think I
> need separate CODE and DATA areas - all variables can be stored in
> CODE like consts are. Is there some way to tell the compiler to do
I think if you omit the "--data-loc" from the linker options it
will put your data area right after the code.