[coldfire-gnu-discuss] M52235EVB - Problem using malloc - Access Error Attempted Write to Write-Protected Space

Nathan Sidwell nathan at codesourcery.com
Mon Mar 5 11:08:28 UTC 2007


Daniel McLean wrote:

> I've disassembled the malloc_r object file from libc, and by comparing this
> output to the newlib source code (downloaded from CodeSourcery) it seems
> like malloc_r is incorrectly accessing memory quite early in the piece.
> 0x11E from the start of malloc_r (in the disassembly).  It would seem that
> this is right at the start of the bin selection logic for malloc_r.  

This suggests to me that the data segment is not being correctly initialized -- 
how have you verified that?

> Just to make sure that my C runtime init is performed correctly, I've
> written test code that checks that the .bss section is zeroed out properly
> and that the .data section is correctly copied from ROM to RAM, and this
> seems fine. 

Have you checked that this program:

static int j = 5;

int main ()
{
   return 0;
}

... has the expected value in j when you're in main?

> I guess it is worth asking exactly what libraries I should be linking
> against? There are some libraries in CodeSourcery/m68k-elf/lib and then
> there are libraries underneath certain folders: eg. m5208, m5213, etc.  As
> the 52235 isn't explicitly listed, does it matter which libraries I link
> against? I've tried the ones in CodeSourcery/m68k-elf/lib and
> CodeSourcery/m68k-elf/lib/m5213 with no success.

These different libraries are known as multilibs.  Each directory is tuned for a 
different set of coldfire cores and is selected automatically by the compiler. 
All you need to provide is the -mcpu=52235 option, and it will map it onto the 
right set.  You can use the -v option to see exactly what is passed to the linker.

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::         CodeSourcery
nathan at codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk




More information about the coldfire-gnu-discuss mailing list