[U-Boot-Users] MIPS build environment

Thomas Sailer sailer at scs.ch
Sat Jan 29 11:36:30 CET 2005


On Fri, 2005-01-28 at 18:13 -0800, Dan Malek wrote:

> to assist with the alternative :-)  I'd like it if
> we can just find a way to invoke 'mipseb-*'
> or 'mipsel-*' based upon the configuration
> chosen and let it go at that.

That would be great!

> Unless I'm doing something wrong, I also have
> to use binutils with the 'allow_branch_to_undefined'
> patch.

It looks to me that the code uses bal in an attempt to be position
independent. It also uses a rather complicated got loading sequence.
This is IMO futile, as the rest of u-boot (especially the copy to RAM
routine) isn't position independent. So you can as well just load the
full address of the called routines into a temporary register and jump
through the register. See the patch below.

Tom


--- start.S.jnx	2005-01-20 21:51:00.000000000 +0100
+++ start.S	2005-01-20 22:01:39.000000000 +0100
@@ -28,6 +28,35 @@
 #include <asm/regdef.h>
 #include <asm/mipsregs.h>
 
+#define NEWASM
+
+#ifdef NEWASM
+
+#define BAL(x) \
+	lui	t0, %hi(x) ;		\
+	ori	t0, t0, %lo(x) ;	\
+	jalr	t0
+
+#define LOADGOT \
+	lui	gp, %hi(_GLOBAL_OFFSET_TABLE_) ;	\
+	ori	gp, gp, %lo(_GLOBAL_OFFSET_TABLE_)
+
+#else
+
+#define BAL(x) \
+	bal	x
+	
+#define LOADGOT \
+	bal	1f ;					\
+	nop ;						\
+	.word	_GLOBAL_OFFSET_TABLE_ - 1f + 4 ;	\
+1: ;							\
+	move	gp, ra ;				\
+	lw	t1, 0(ra) ;				\
+	add	gp, t1	
+	
+#endif
+
 
 #define RVECENT(f,n) \
    b f; nop
@@ -237,18 +266,18 @@
 #ifdef CONFIG_INCA_IP
 	/* Disable INCA-IP Watchdog.
 	 */
-	bal	disable_incaip_wdt
+	BAL(disable_incaip_wdt)
 	nop
 #endif
 
 	/* Initialize any external memory.
 	 */
-	bal	memsetup
+	BAL(memsetup)
 	nop
 
 	/* Initialize caches...
 	 */
-	bal	mips_cache_reset
+	BAL(mips_cache_reset)
 	nop
 
 	/* ... and enable them.
@@ -260,7 +289,7 @@
 	/* Set up temporary stack.
 	 */
 	li	a0, CFG_INIT_SP_OFFSET
-	bal	mips_cache_lock
+	BAL(mips_cache_lock)
 	nop
 
 	li	t0, CFG_SDRAM_BASE + CFG_INIT_SP_OFFSET
@@ -268,13 +297,8 @@
 
 	/* Initialize GOT pointer.
 	 */
-	bal	1f
-	nop
-	.word	_GLOBAL_OFFSET_TABLE_ - 1f + 4
-1:
-	move	gp, ra
-	lw	t1, 0(ra)
-	add	gp, t1
+	LOADGOT
+
 	la	t9, board_init_f
 	j	t9
 	nop






More information about the U-Boot mailing list