From bce84c4dab92062bc5ae7608c4a2508803b1225e Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Tue, 30 Aug 2005 14:13:23 +0200 Subject: [PATCH] Prepare U-Boot for gcc-4.x: fix global data pointer initialization The global data pointer, stored in r29 before relocation to RAM, was not initialized to a correct value. This happened because the pointer declaration was done locally in the scope of the board_init_f() function. What follows is a cite from gcc.info, 5.37, "Variables in Specified Registers": ... The compiler's data flow analysis is capable of determining where the specified registers contain live values, and where they are available for other uses. Stores into local register variables may be deleted when they appear to be dead according to dataflow analysis. References to local register variables may be deleted or moved or simplified. ... Moving the global data declaration to global scope solved the problem. --- lib_ppc/board.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib_ppc/board.c b/lib_ppc/board.c index 04aa8f9b4d..d1e294f23b 100644 --- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -90,6 +90,7 @@ extern flash_info_t flash_info[]; #endif #include +DECLARE_GLOBAL_DATA_PTR; #if defined(CFG_ENV_IS_EMBEDDED) #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN @@ -126,8 +127,6 @@ static ulong mem_malloc_brk = 0; */ static void mem_malloc_init (void) { - DECLARE_GLOBAL_DATA_PTR; - ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off; mem_malloc_end = dest_addr; @@ -187,8 +186,6 @@ typedef int (init_fnc_t) (void); static int init_baudrate (void) { - DECLARE_GLOBAL_DATA_PTR; - uchar tmp[64]; /* long enough for environment variables */ int i = getenv_r ("baudrate", tmp, sizeof (tmp)); @@ -202,8 +199,6 @@ static int init_baudrate (void) static int init_func_ram (void) { - DECLARE_GLOBAL_DATA_PTR; - #ifdef CONFIG_BOARD_TYPES int board_type = gd->board_type; #else @@ -348,8 +343,6 @@ init_fnc_t *init_sequence[] = { void board_init_f (ulong bootflag) { - DECLARE_GLOBAL_DATA_PTR; - bd_t *bd; ulong len, addr, addr_sp; ulong *s; @@ -589,7 +582,6 @@ void board_init_f (ulong bootflag) void board_init_r (gd_t *id, ulong dest_addr) { - DECLARE_GLOBAL_DATA_PTR; cmd_tbl_t *cmdtp; char *s, *e; bd_t *bd; -- 2.39.5