This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: malloc() never returns
- From: Torsten Mohr <tmohr at s dot netic dot de>
- To: newlib at sourceware dot org, gdb at sourceware dot org
- Cc: Jeff Johnston <jjohnstn at redhat dot com>
- Date: Thu, 8 Jun 2006 23:41:12 +0200
- Subject: Re: malloc() never returns
- References: <200606081246.20231.tmohr@s.netic.de> <44886BBF.1030404@redhat.com>
Hi,
> It appears your static av_ array has been cleared. Perhaps you have
> gone too far when clearing the .bss. Track the static av_ array and see
> where it ends up after linking as well as what is in it. That array
> should be initialized and non-zero by the time you get to main. I don't
> have any experience with the v850 platform to give you any other direct
> suggestions.
thanks for your hint, it looks like you're right.
The array ___malloc_av_ is located in .data at 0x3ffe40c.
Or more precisely this is its VMA.
In my linker script i use the common way to place data into
ROM:
.data :
{
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
CONSTRUCTORS
} > ram AT > rom
When i verify it with v850e-unknown-elf-objdump -h | grep .data
7 .data 00000828 03ffe000 000071a8 00009000 2**2
Also, in hw2.srec at the expected offset of 0x040c (address of
___malloc_av_ - VMA(.data)) i see the expected data (at LMA(.data)
+ 0x40c):
S315000075A800000000FFFFFFFF0000020000000000CF
S315000075B8000000000CE4FF030CE4FF0314E4FF03DF
S315000075C814E4FF031CE4FF031CE4FF0324E4FF03A5
...
So all fits fine, except:
When i load the ELF file in "insight", i see the array ___malloc_av_
filled correctly, but after .data gets copied its all filled with 0x00.
So is it possible that GDB loads the sections in the ELF file to the
VMA and not to the LMA?
It looks to me like this, but this means that no program that uses
"> RAM AT > ROM" can run correctly in GDB, right?
Is there a standard solution to this standard problem?
Or do i misunderstand something here?
Best regards,
Torsten.