This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Duplicating a section in a link


Steve:


If you don't mind if the code is always copied to RAM at startup,
i.e. you have enough RAM to have the code there whether you're using
it or not, then put the contents of single.c into your initialized
data section along with all your other initdata.  Your startup code
would then copy it to RAM just like it's doing now for your
initialized globals, and the linker would resolve addresses to their
RAM locations.

See gcc's __attribute__((section())) extension, and the linker's AT
directive (which you won't need to worry about if initdata already
works in your system).  I talk about these in my gcc article at
http://billgatliff.com.

Put another way, the linker is already doing the duplication you want,
but only for your initdata because traditionally that's all we ask it
for.  So call your single.c functions initdata, and capitalize on that.

To get the section name gcc emits for initdata, create a file that
just has this in it:


  int x = 10;

... and compile it to asm.  Don't test with an initial value of zero,
however, because gcc will usually optimize that by placing x into the
.bss section, which isn't what you want.


HTH,


b.g.



On Thu, May 23, 2002 at 09:21:16AM -0600, Steve Pye wrote:
> 
> Hello,
> 
> My application runs mainly out of flash memory, but a part of 
> the code has to run out of RAM.  All 
> the code that is to run from RAM is contained in a single .c
> source file.  I'd like the linker to resolve all code addresses 
> for this module to be in RAM, however I also need the linked
> object for this module to be included in the ROM image so that
> it can be programmed into flash and then later copied into
> RAM at run-time.
> 
> I think this can be done by
> 1) assigning a section name to the code/strings contained in the .c file
> 2) telling the linker that this section should be linked in RAM
> 3) telling the linker that a copy of this section should also be placed in ROM
> 
> Do you know how I can do 1,2,3? Or whom I should ask?
> 
> BTW the target is StrongARM1110.
> 
> Thanks very much.
> 
> Best regards,
> Steve.
> 
> 
> ------
> Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
> Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
> 

-- 
Bill Gatliff
bgat@billgatliff.com

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


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