2009/7/7  <bob...@comcast.net>:
>
> ----- 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.

If I place crt0 first in the list of files for the linker, it produces
no output at all. No error messages, and no IHX file.
The linker seems to want the .o file with main() 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.

Ok, but see above.

>> 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
>> that?
>
> I think if you omit the "--data-loc" from the linker options it
> will put your data area right after the code.

I don't want to move the data area, I want to get rid of the GSINIT
section and variable initialization code, and have the variables
initialized directly in code eg ".db <value>" - that is, I want the
compiler behaviour used for allocating consts to apply to all
variables. Since all memory is writable, having a separate piece of
code to initialize variables is a waste of space.

-- 
Alistair Buxton
a.j.bux...@gmail.com

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to