[coldfire-gnu-discuss] M52235EVB - Problem using malloc - Access Error Attempted Write to Write-Protected Space
Daniel McLean
daniel.mclean at optusnet.com.au
Mon Mar 5 12:51:14 UTC 2007
Hi Nathan,
Thanks for you help. You were correct in being suspicious of my data
initialisation. I had an offset problem in my linker control file that was
causing the data and BSS sections to be 1k further along in memory than they
should have been. (My mistake as I'd marked the vector RAM table as NOLOAD)
The reason I didn't pick this earlier was because my comparison routines
used the markers in the linker control file that I had exported which were
in the addresses that were 1k further along.
Again, your help was greatly appreciated.
Thanks
Daniel
-----Original Message-----
From: Nathan Sidwell [mailto:nathan at codesourcery.com]
Sent: Monday, 5 March 2007 9:08 PM
To: Daniel McLean
Cc: coldfire-gnu-discuss at codesourcery.com
Subject: Re: [coldfire-gnu-discuss] M52235EVB - Problem using malloc -
Access Error Attempted Write to Write-Protected Space
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
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.7/710 - Release Date: 4/03/2007
1:58 PM
More information about the coldfire-gnu-discuss
mailing list