M52235EVB - Problem using malloc - Access Error Attempted Write to Write-Protected Space

Daniel McLean daniel.mclean at optusnet.com.au
Wed Feb 28 02:13:23 UTC 2007


Hi,

 

I'm having some troubles using malloc (or more specifically malloc_r)..  I'm
running from the internal flash and in unhosted mode.  I'm using my own
startup code and interrupt vectors and am happy that everything seems to be
running ok (I can flash the LEDs on the development kit, read the switches,
print text to the serial port, etc).  I've just added the first lot of code
that makes use of malloc.  I've provided an implementation of sbrk so that
it can request sections of memory.  However it seems that malloc attempts to
access write protected space and causes an interrupt.  This is displayed via
a printf on the serial port.  It says that the program counter is at
0x000040CA when this occurs..  Below is the appropriate section of my map
file:

 

 .text          0x00003f6c       0x32 c:\program files\codesourcery\sourcery
g++\bin\../m68k-elf/lib\libc.a(malloc.o)

                0x00003f86                malloc

                0x00003f6c                free

 *fill*         0x00003f9e        0x2 00

 .text          0x00003fa0      0x76e c:\program files\codesourcery\sourcery
g++\bin\../m68k-elf/lib\libc.a(mallocr.o)

                0x00003fa0                _malloc_r

 *fill*         0x0000470e        0x2 00

 

I am using a (very slightly) modified version of the linker control file
provided: m52235evb-rom.ld

 

The only modifications I've made to this are associated with using my own
vector table and startup code (all based on the sample code from the
Freescale site).

 

Any suggestions would be appreciated.

 

I'd also be interested in knowing what compiler options the newlib libraries
were compiled with?  I am assuming that they are at least compiled with
re-entrancy support considering the inclusion of files such as _malloc_r by
the linker.

 

Thanks
Daniel 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/coldfire-gnu-discuss/attachments/20070228/06f2ac7a/attachment.html>


More information about the coldfire-gnu-discuss mailing list