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: 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 ?

        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


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