Getting linker script memory info from the code
David Brown
david@westcontrol.com
Fri Sep 26 13:00:00 GMT 2003
> 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;
void clearBss(void)
{
unsigned long int *p;
unsigned short int n;
p = &__bss_start; // Source for clear
n = &__bss_end - &__bss_start; // Total size (in 32-bit dwords)
while (n--) {
*p++ = 0; // Clear bss
};
}
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
More information about the crossgcc
mailing list