[U-Boot-Users] Arm-linux-gcc malloc get failure while arm-elf-gcc ok

Rui.Zhou at nokia.com Rui.Zhou at nokia.com
Sat Jan 27 12:46:54 CET 2007


hi there
 
after modifing some codes(forget  what's the codes:() arm-elf-gcc also
get malloc failure,I have to think about my program has something wrong
 
actually malloc have got failure in the lib_arm/board.c:
 
a malloc will trigger *sbrk twice(why?)
test code in start_armboot()
...
void *testptr;
testptr=malloc(10);
...
 
 
in the void *sbrk (ptrdiff_t increment)
{
 ulong old = mem_malloc_brk;
 ulong new = old + increment;
 
 if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
  return (NULL);
 }
 mem_malloc_brk = new;
 
 return ((void *) old);
}
 
 
I print out the debug information:
 
1st trigger:
 
increment:                a2e2e4e?(so big?)
old:                        c6dfc00
new:                        169c2a4e
mem_malloc_start:    c6dfc00
mem_malloc_end:    c700000
 
 
 
2nd:
 
increment:                1b2
old:                        c6dfc00
new:                        c6dfdb2
mem_malloc_start:    c6dfc00
mem_malloc_end:    c700000
 
seems the 2nd is ok
but testptr still =0
 
*****************
in the cpu/s3c44b0/start.S I create stack like that:
 
stack_setup:
 
ldr r0,=0xc700000   /* upper 128 KiB: relocated uboot   */
sub r0, r0, #CFG_MALLOC_LEN /* malloc area  1024+128*1024 =1227204bytes
*/
sub r0, r0, #CFG_GBL_DATA_SIZE /* bdinfo   128                     */
sub sp, r0, #12  /* leave 3 words for abort-stack    */
 
i think it should be ok
******************
 
regards,
rui
 

________________________________

From: u-boot-users-bounces at lists.sourceforge.net
[mailto:u-boot-users-bounces at lists.sourceforge.net] 
Sent: Saturday, January 27, 2007 12:11 PM
To: u-boot-users at lists.sourceforge.net
Subject: [U-Boot-Users] Arm-linux-gcc malloc get failure while
arm-elf-gcc ok



 hi there 

I wonder if I am the first one to get this problem 

In common\lists.c 

Handle NewHandle (unsigned int numBytes) 
{ 
        void *memPtr; 
        HandleRecord *hanPtr; 

        memPtr = calloc (numBytes, 1); 
        hanPtr = (HandleRecord *) calloc (sizeof (HandleRecord), 1); 

Debug("memPtr:%d hanPtr:%d\n",memPtr ,hanPtr ); //arm-linux-gcc get 0
for both of the Ptr while arm-elf-gcc can malloc successfully

        if (hanPtr && (memPtr || numBytes == 0)) { 
                hanPtr->ptr = memPtr; 
                hanPtr->size = numBytes; 
                return (Handle) hanPtr; 
        } else { 
                free (memPtr); 
                free (hanPtr); 
                return NULL; 
        } 

} 

Arm-elf-gcc is 3.4.0 
Arm-linux-gcc is 3.3.2 (heard there are most problems in this version??)


Regards 
Zhou rui 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.denx.de/pipermail/u-boot/attachments/20070127/fa7de896/attachment.htm 


More information about the U-Boot mailing list