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: Getting linker script memory info from the code


David Brown wrote:

Is there any way I can obtain info from the linker script's MEMORY spec
from within my code? Are the parameters made available as symbols by the
linker or anything?

- Toralf




You can certainly do it if you have your own linker script. For example, you might have something like this in your linker file:

.bss (NOLOAD) :
{
 . = ALIGN(0x4);
 __bss_start = .;
 *(.shbss)
 *(.bss)
 *(COMMON)
 _end =  ALIGN (0x8);   /* Used by sbrk() as start of heap */
 __bss_end = _end;
} > IRam


You can then have C code like:


extern unsigned long int __bss_start, __bss_end;


[ snip ]
Wouldn't that just give me the end of size of the program and/or end of memory area occupied by it? Not what I'm looking for. What I want is parameters like the *total* memory size end-of-RAM etc.


I could PROVIDE() them explicitly, the question was really: Do I have to? Or are symbols for e.g. the start and end point of IRam (in your example) provided automatically?

If it is still not clear what I mean, consider the following MEMORY setup, which might be used with the above example:

MEMORY
{
 IRam (rwx) : ORIGIN = 0x001000, LENGTH = 1M
}

the following PROVIDE would then give me symbols with addresses corresponding the start and end point of IRam:

PROVIDE (__ram_start = 0x001000);
PROVIDE (__ram_end = 0x001000+1M);

I'm looking for implicitly defined symbols with the same address as __ram_start and __ram_end. Do they exist?

- Toralf





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