At 12:51 PM 1/22/04 -0800, you wrote:
>--- 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
His original syntax is more or less straight out of the ld manual.
> 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.
ld should handle that transparently. All the records that are in FLASH
will already be located to run from ram. Now if you try to use them
directly from flash w/o copying them I would expect problems.
I don't see why position independent code would be needed (it is always
ending up in the same place and that place is defined at link time).
Robert
>__________________________________
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free web site building tool. Try it!
>http://webhosting.yahoo.com/ps/sb/
>
>
>
>
>Yahoo! Groups Links
>
>To visit your group on the web, go to:
> http://groups.yahoo.com/group/lpc2100/
>
>To unsubscribe from this group, send an email to:
> lpc2100-unsubscribe@yahoogroups.com
>
>Your use of Yahoo! Groups is subject to:
> http://docs.yahoo.com/info/terms/
" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "
Kelvin Throop, IIIMessage
RE: [lpc2100] More ld script questions..
2004-01-22 by Robert Adsett
Attachments
- No local attachments were found for this message.