From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Mack Date: Fri, 28 Nov 2008 22:04:15 +0100 Subject: [U-Boot] gd_t/bd_t on ARM Message-ID: <20081128210415.GD14044@buzzloop.caiaq.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, I'm hunting weird behaviours with the gd_t global data pointer on my PXA300 board board. The pointer gets set up fine in lib_arm/boot.c and gd->bd is filled in my board specific code. However, after the tftp download is finished, the content of these structures have been destroyed and overwritten with garbage. I suspect a stack corruption to be the culprit, an overflow or overlap, as it seems to happen randomly, after a while and some function calls. Any hints about that? Also, I wonder why the pointer to this struct is not placed *after* U-Boot's own code as shown in the patch below. This works fine for me now. Any oppinion on that? Thanks and best regards, Daniel diff --git a/lib_arm/board.c b/lib_arm/board.c index 4ba1f5e..90ad5f7 100644 --- a/lib_arm/board.c +++ b/lib_arm/board.c @@ -282,12 +282,12 @@ void start_armboot (void) #endif /* Pointer is writable since we allocated a register for it */ - gd = (gd_t*)(_armboot_start - CONFIG_SYS_MALLOC_LEN - sizeof(gd_t)); + gd = (gd_t*) _bss_end; /* compiler optimization barrier needed for GCC >= 3.4 */ __asm__ __volatile__("": : :"memory"); memset ((void*)gd, 0, sizeof (gd_t)); - gd->bd = (bd_t*)((char*)gd - sizeof(bd_t)); + gd->bd = (bd_t*)((char*)gd + sizeof(gd_t)); memset (gd->bd, 0, sizeof (bd_t)); gd->flags |= GD_FLG_RELOC;