--- James Dabbs <jdabbs@...> wrote:
> Another question, more conceptual. This ld uses
> named sections, using >
> to say where it will be loaded, and AT> to say where
> it is at the moment
> of reset. (I think, anyway). Let's say I also want
> to use
> __attribute__ to define some functions in RAM,
> naming this ".ramtext" in
> my C code. My guess is that this looks something
> like this:
>
> prog : {
> *(.text)
> *(.rodata)
> *(.rodata*)
> *(.glue_7)
> *(.glue_7t)
> __end_of_prog__ = . ;
> } >flash
>
> .ramtext : {
> __ramtext_beg__ = . ;
> __ramtext_beg_src__ = __end_of_prog__ ;
> *(.ramtext)
> __ramtext_end__ = .;
> } >ram AT>flash
>
I didn't see anybody using "AT" in this way. My
linker script would probably look like this instead:
.ramtext : AT( ADDR( flash ) + SIZEOF( prog ) )
{
/* the rest goes here */
} > ram
I'm not saying that your syntax is wrong, I just
never seen it in practice, nor heard of it, so if it
doesn't work you can try the above variant instead.
Another advice (this comes directly from experience):
try to always set the location counter (.) to a
multiple of 4 at the end of the section declaration,
or at least do this for data sections, or you might
have some nasty surprises.
> And then my boot.s would just copy (__ramtext_end__
> - __ramtext_beg__)
> bytes from __ramtext_beg_src__ to __ramtext_beg__.
>
> Is this right?
Almost. This will work for simple examples.
However, things will get much more interesting if you
have pointers to functions in your program. They must
be changed to reflect the new address of your code in
RAM. I'm not exactly sure how GCC handles this, but
you'll need to specify -fPIC for compilation and hope
that the rest of the story is already implemented in
the runtime.
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/Message
RE: [lpc2100] More ld script questions..
2004-01-22 by Bogdan Marinescu
Attachments
- No local attachments were found for this message.