]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Prepare U-Boot for gcc-4.x: fix global data pointer initialization
authorWolfgang Denk <wd@pollux.denx.de>
Tue, 30 Aug 2005 12:13:23 +0000 (14:13 +0200)
committerWolfgang Denk <wd@pollux.denx.de>
Tue, 30 Aug 2005 12:13:23 +0000 (14:13 +0200)
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

index 04aa8f9b4d2eeae40de7587b20723c80a5ca4041..d1e294f23be69ca5dbc6baf5bcf14c2c64fe6c01 100644 (file)
@@ -90,6 +90,7 @@ extern flash_info_t flash_info[];
 #endif
 
 #include <environment.h>
+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;