This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Generating code to execute from ROM?


Jeff:

Check out the AT command in the linker manual.

Basically, it tells ld to load data at a different address than the one located
to, which is exactly what you want.

Here's an example, culled from one of my scripts:

SECTIONS
{
  /* code and constants */
  .text :
  {
    __text_start = .;
    *(.text)
    *(.strings)
     __text_end = .;
  }  > rom

  /* initialized data section
     ld will load this at __text_end in the output file,
     but will actually locate it in ram.  By doing a
     memcpy( &_data_start, &_text_end, (&_data_end - &_data_start);
     during startup, we initialize our nonzero globals . */
  .init : AT (__text_end)
  {
    __data_start = .;
    *(.data)
    __data_end = .;
  } > ram


Cheers!

b.g.


Jeff Mock wrote:

> How do you generate code suitable for execution out of ROM with GCC?  The
> main thing
> is that I need a way to link the addresses for initialized data at one location
> and put the actual initialization data in another location in such a way that
> crt0 can figure out how to copy the initialized data from ROM to RAM.
>
> I suppose there are a lot of ways to do this.  I've seen embedded C compilers
> generate code this way or it can be done by a clever linker, etc.  I can't
> figure out how to do it with GCC...
>
> thanks,
> jeff
>
> ------
> Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
> Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com

--
William A. Gatliff
Senior Design Engineer
Komatsu Mining Systems
To teach is to learn.




------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]