[U-Boot] [PATCH] nios2: fix r15 issue for gcc4

Thomas Chou thomas at wytron.com.tw
Sat May 15 00:00:04 CEST 2010


The "-ffixed-r15" option doesn't work well for gcc4. Since we
don't use gp for small data with option "-G0", we can use gp
as global data pointer. This allows compiler to use r15. It
is necessary for gcc4 to work properly.

Signed-off-by: Thomas Chou <thomas at wytron.com.tw>
---
 arch/nios2/config.mk                 |    2 +-
 arch/nios2/cpu/start.S               |    7 -------
 arch/nios2/include/asm/global_data.h |    2 +-
 3 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk
index 8e5d6ef..6789038 100644
--- a/arch/nios2/config.mk
+++ b/arch/nios2/config.mk
@@ -27,6 +27,6 @@ CROSS_COMPILE ?= nios2-elf-
 STANDALONE_LOAD_ADDR = 0x02000000 -L $(gcclibdir)
 
 PLATFORM_CPPFLAGS += -DCONFIG_NIOS2 -D__NIOS2__
-PLATFORM_CPPFLAGS += -ffixed-r15 -G0
+PLATFORM_CPPFLAGS += -G0
 
 LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds
diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
index d1016ea..76d3b52 100644
--- a/arch/nios2/cpu/start.S
+++ b/arch/nios2/cpu/start.S
@@ -113,13 +113,6 @@ _cur:	movhi	r5, %hi(_cur - _start)
 	 bne	r5, r6, 4b
 5:
 
-	/* GLOBAL POINTER -- the global pointer is used to reference
-	 * "small data" (see -G switch). The linker script must
-	 * provide the gp address.
-	 */
-	 movhi	gp, %hi(_gp)
-	 ori	gp, gp, %lo(_gp)
-
 	/* JUMP TO RELOC ADDR */
 	movhi	r4, %hi(_reloc)
 	ori	r4, r4, %lo(_reloc)
diff --git a/arch/nios2/include/asm/global_data.h b/arch/nios2/include/asm/global_data.h
index 34aa962..f1b3482 100644
--- a/arch/nios2/include/asm/global_data.h
+++ b/arch/nios2/include/asm/global_data.h
@@ -48,6 +48,6 @@ typedef	struct	global_data {
 #define	GD_FLG_LOGINIT	0x00020		/* Log Buffer has been initialized	*/
 #define GD_FLG_DISABLE_CONSOLE	0x00040		/* Disable console (in & out)	 */
 
-#define DECLARE_GLOBAL_DATA_PTR     register gd_t *gd asm ("r15")
+#define DECLARE_GLOBAL_DATA_PTR     register gd_t *gd asm ("gp")
 
 #endif /* __ASM_NIOS2_GLOBALDATA_H_ */
-- 
1.5.5.6



More information about the U-Boot mailing list