Using ASSERT() in Linker Control Files
Daniel McLean
daniel.mclean at optusnet.com.au
Mon Feb 25 23:32:25 UTC 2008
Hi,
I'm having some problems getting ASSERT() to work properly in the linker
control file using Code Sourcery Lite.
I'm using version "freescale-coldfire-4.2-47-m68k-elf" of the Code Sourcery
tools.
I've got this ASSERT() function in my linker control file:
(snippet of Linker control file)
.bss :
{
. = ALIGN (4);
__BSS_START = .;
*(.shbss)
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN (8);
__BSS_END = .;
__HEAP_START = .;
__HEAP_END = . + HEAPSIZE;
__SP_END = __HEAP_END;
__SP_INIT = __SP_END + STACKSIZE;
ASSERT(((ORIGIN(ram) + LENGTH(ram)) > (__SP_INIT)), "Ram has
overflown. Not enough room for heap/stack");
} >ram AT>rom
Which generates this in the MAP file:
0x200038b8 . = ALIGN (0x8)
*fill* 0x200038b4 0x4 00
0x200038b8 __BSS_END = .
0x200038b8 __HEAP_START = .
0x200078b8 __HEAP_END = (. + HEAPSIZE)
0x200078b8 __SP_END = __HEAP_END
0x200079b8 __SP_INIT = (__SP_END + STACKSIZE)
0x20001709 ASSERT ((0x20008000 > __SP_INIT),
Ram has overflown. Not enough room for heap/stack)
This seems as expected. Now if I increase the start of the heap just to
test whether the ASSERT will work like so:
.bss :
{
. = ALIGN (4);
__BSS_START = .;
*(.shbss)
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN (8);
__BSS_END = .;
. += 0x1000;
__HEAP_START = .;
__HEAP_END = . + HEAPSIZE;
__SP_END = __HEAP_END;
__SP_INIT = __SP_END + STACKSIZE;
ASSERT(((ORIGIN(ram) + LENGTH(ram)) > (__SP_INIT)), "Ram has
overflown. Not enough room for heap/stack");
} >ram AT>rom
I now get this in the map file:
0x200038b8 . = ALIGN (0x8)
*fill* 0x200038b4 0x4 00
0x200038b8 __BSS_END = .
0x200048b8 . = (. + 0x1000)
*fill* 0x200038b8 0x1000 00
0x200048b8 __HEAP_START = .
0x200088b8 __HEAP_END = (. + HEAPSIZE)
0x200088b8 __SP_END = __HEAP_END
0x200089b8 __SP_INIT = (__SP_END + STACKSIZE)
0x20001709 ASSERT ((0x20008000 > __SP_INIT),
Ram has overflown. Not enough room for heap/stack)
Now shouldn't the assertion fail since __SP_INIT is larger than 0x20008000??
The linker does not generate any errors..
Am I overlooking something???
Thanks
Daniel
_____________________________________
Daniel McLean
Email: daniel.mclean at optusnet.com.au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/coldfire-gnu-discuss/attachments/20080226/47a22471/attachment.html>
More information about the coldfire-gnu-discuss
mailing list