u-boot/cpu/mips
Shinya Kuribayashi 49387dba91 [MIPS] cpu/mips/cache.S: Fix build warning
Some old GNU assemblers, such as v2.14 (ELDK 3.1.1), v2.16 (ELDK 4.1.0),
warns illegal global symbol references by bal (and jal also) instruction.
This does not happen with the latest binutils v2.18.

Here's an example on gth2_config:

mips_4KC-gcc  -D__ASSEMBLY__ -g  -Os   -D__KERNEL__ -DTEXT_BASE=0x90000000 -I/home/skuribay/devel/u-boot.git/include -fno-builtin -ffreestanding -nostdinc -isy
stem /opt/eldk311/usr/bin/../lib/gcc-lib/mips-linux/3.3.3/include -pipe  -DCONFIG_MIPS -D__MIPS__ -G 0 -mabicalls -fpic -pipe -msoft-float -march=4kc -mtune=4k
c -EB -c -o cache.o cache.S
cache.S: Assembler messages:
cache.S:243: Warning: Pretending global symbol used as branch target is local.
cache.S:250: Warning: Pretending global symbol used as branch target is local.

In principle, gas might be sensitive to global symbol references in PIC
code because they should be processed through GOT (global offset table).
But if `bal' instruction is used, it results in PC-based offset jump.
This is the cause of this warning.

In practice, we know it doesn't matter whether PC-based reference or GOT-
based. As for this case, both will work before/after relocation. But let's
fix the code.

This patch explicitly sets up a target address, then jump there.
Here's an example of disassembled code with/without this patch.

 90000668:       1485ffef        bne     a0,a1,90000628 <mips_cache_reset+0x20>
 9000066c:       ac80fffc        sw      zero,-4(a0)
 90000670:       01402821        move    a1,t2
-90000674:       0411ffba        bal     90000560 <mips_init_icache>
-90000678:       01803021        move    a2,t4
-9000067c:       01602821        move    a1,t3
-90000680:       0411ffcc        bal     900005b4 <mips_init_dcache>
-90000684:       01a03021        move    a2,t5
-90000688:       03000008        jr      t8
-9000068c:       00000000        nop
+90000674:       01803021        move    a2,t4
+90000678:       8f8f83ec        lw      t7,-31764(gp)
+9000067c:       01e0f809        jalr    t7
+90000680:       00000000        nop
+90000684:       01602821        move    a1,t3
+90000688:       01a03021        move    a2,t5
+9000068c:       8f8f81e0        lw      t7,-32288(gp)
+90000690:       01e0f809        jalr    t7
+90000694:       00000000        nop
+90000698:       03000008        jr      t8
+9000069c:       00000000        nop

Signed-off-by: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
2008-05-06 13:22:52 +09:00
..
asc_serial.c * Patch by Steven Scholz, 10 Oct 2003 2003-10-09 20:09:04 +00:00
asc_serial.h * Patch by Steven Scholz, 10 Oct 2003 2003-10-09 20:09:04 +00:00
au1x00_eth.c [MIPS] au1x00_eth.c: Fixed a warning on pb1000 build. 2007-11-17 18:54:16 +09:00
au1x00_serial.c Fix au1x00_serial baud rate calculation: 2005-09-25 16:50:33 +02:00
au1x00_usb_ohci.c Add support for AMD's Pb1x00 eval board; 2005-09-25 00:53:22 +02:00
au1x00_usb_ohci.h Add support for AMD's Pb1x00 eval board; 2005-09-25 00:53:22 +02:00
cache.S [MIPS] cpu/mips/cache.S: Fix build warning 2008-05-06 13:22:52 +09:00
config.mk [MIPS] cpu/mips/config.mk: Fix GNU assembler minor version picker 2008-05-03 13:51:44 +09:00
cpu.c cpu/mips/cpu.c: Fix flush_cache bug 2008-04-17 14:54:23 -07:00
incaip_clock.c Code cleanup, especially MIPS for GCC 4.x 2005-12-04 00:40:34 +01:00
incaip_wdt.S Use jr as register jump instruction 2008-04-18 00:47:29 -07:00
interrupts.c * Code cleanup: 2003-06-27 21:31:46 +00:00
Makefile Move "ar" flags to config.mk to allow for silent "make -s" 2006-10-09 01:02:05 +02:00
start.S Allow building mips versions with ELDK 3.1.1 2008-05-05 13:24:12 +02:00