Wednesday, August 20, 2008

Remove allow_branch_to_undefined from U-boot

Old U-boot (v1.1.3 in my example, too old hum?) needs a option -mips_allow_branch_to_undefined for ELDK AS to assemble. We have to modify cpu/mips/start.S so that AS of other toolchains could assemble it without an error - Error: can't resolve `_GLOBAL_OFFSET_TABLE_' {*UND* section} - `L16' {.text section}

original start.S:

/* Initialize GOT pointer.
bal     1f
.word   _GLOBAL_OFFSET_TABLE_ - 1f + 4
move    gp, ra
lw      t1, 0(ra)
add     gp, t1

It counts an offset first, and gets the gp later from the return address and the offset. Let us do it with different method.

new start.S:
bal     1f
lw      gp, 0(ra)

Second, remove -Wa,-mips_allow_branch_to_undefined from cpu/mips/ Then we can make Uboot successfully with the toolchain built from buildroot.

1 comment:

滑嘟嘟 said...

Good solution U-boot-1.1.4 using the same method to fix this problem.
/* Initialize GOT pointer. */

bal 1f

move gp, ra
lw t1, 0(ra)
move gp, t1

_GLOBAL_OFFSET_TABLE_ will be determined at link time. So compiler can't compile _GLOBAL_OFFSET_TABLE_ - 1f + 4