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: defining memory addresses




> -----Original Message-----
> From: David Korn [mailto:dkorn@pixelpower.com]
> Sent: Wednesday, January 09, 2002 3:42 PM
> To: 'Jan Van Belle'; CrossGCC
> Subject: RE: defining memory addresses
> 
> 
> >-----Original Message-----
> >From: Jan Van Belle [mailto:Jan.Van_Belle@alcatel.be]
> >Sent: 09 January 2002 13:35
> 
> >       Hello all,
> 
>     Hi Jan,
> 
> >       I wonder how I can tell the compiler how many memory he has on
> >the target board.
> >e.g:
> >512kb ROM
> >3MB RAM
> 
>    You don't tell the compiler, you tell the linker, by 
> writing a linker
> script.
> 
> >ROM starts at 0x0000, containing the program code 
> (boot-loader/monitor
> >program). The codesize is (much) smaller than 512kb. How does the
> >compiler know he cannot store variables in that area??
> 
>   The compiler outputs assembly files that just say how much space is 
> reserved for variables; it's the job of the linker to position all the
> code and data in memory at convenient places and fill in the cross-
> references between them.
> 
>   Read the linker manual: chapter "Command language", section "Memory
> Layout" to see how to inform the linker of the sizes and addresses of
> the ram and rom available on your target board: 
> 
> ---begin quote---
> The MEMORY command describes the location and size of blocks 
> of memory in
> the target. By using it carefully, you can describe which 
> memory regions
> may be used by the linker, and which memory regions it must avoid.
> ----end quote----
> 
>   Note that linker scripts are pretty mysterious, and it's 
> likely to be
> easiest to write one by modifying the default linker script 
> that is being
> used by your compiler (use the -v option to gcc and then look 
> at the link
> command line for the -T parameter to see the path to the 
> default ld script;
> if there isn't a -T parameter, then ld is using its built-in 
> script which
> you can view by executing 'ld --verbose'.)
> 
> >Related to this: how can I effectively use the internal RAM?
> 
>   That's a strange question, or rather, I don't understand 
> what you mean
> and why the answer isn't "put programs and variables in it, 
> same as usual."
> "Internal" ram?  Do you mean some special block of ram built 
> into the CPU
> itself ?
> 
Yes, possibly.

I'm using a 68LC302 which has an on chip memory of 576 bytes which may
be located somewhere in the address space. So I've defined 3 memory
areas: ROM, external RAM and internal RAM.

You may put variables in the internal RAM by assigning a special section
( say: .ibss) to the internal RAM and put all theses variable into the
.ibss section via __attribute__ ((section ".ibss")) (the syntax may not
be right, I don't have a gcc manual at reach now)

Wolfgang
>         DaveK
> -- 
> Burn your ID card!  http://www.optional-identity.org.uk/
> Help support the campaign, copy this into your .sig!
> 
> 
> 
> **********************************************************************
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> the system manager.
> 
> This footnote also confirms that this email message has been swept by
> MIMEsweeper for the presence of computer viruses.
> 
> www.mimesweeper.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
> 
> 

------
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]