This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[patch RFA] revisit MIPS warning re: global symbols as branchtargets.
- From: cgd at broadcom dot com
- To: binutils at sources dot redhat dot com
- Date: 01 Jul 2003 10:23:02 -0700
- Subject: [patch RFA] revisit MIPS warning re: global symbols as branchtargets.
So, i was just compiling some stuff, and i noticed the warning (again 8-):
Warning: Pretending global symbol used as branch target is local.
Is there ** any ** reason to issue that warning when
(mips_pic == NO_PIC)?
There may be a reason for the warning (to prevent a problem of
understanding) for people doing userland work and trying to hard-code
branches to symbols in shared libraries that they expect to be
overridden, or something.
However, if i'm writing a kernel (oh so not PIC, at least in my world
8-), i should be able to make functions global or not and i should be
able to branch to them w/o getting warning.
(Hmm, is it necessary to leave the rest of the code alone, in this
case, for proper operation? certainly, it's easiest to do so... I
suspect if you left the branch target as-is it would turn out
OK... but better to use the more well-tested code path, eh? 8-)
anyway, tested on mipsisa64sb1-elf and mips-linux w/ the
gas/etc. testsuite. (causes no change in behaviour other than the
warning, so i'm not worried about more than that. 8-)
cgd
--
[ gas/ChangeLog ]
2003-07-01 Chris Demetriou <cgd@broadcom.com>
* config/tc-mips.c (mips_validate_fix): Do not warn about branch
target being a global symbol if not compiling PIC code.
[ gas/testsuite/ChangeLog ]
2003-07-01 Chris Demetriou <cgd@broadcom.com>
* gas/testsuite/gas/mips/mips.exp: Make sure that branch-misc-2 is
run to compile non-PIC code, and add branch-misc-2pic.
* gas/mips/branch-misc-2.l: Adjust for change in non-PIC warnings.
* gas/mips/branch-misc-2pic.l: New file.
* gas/mips/branch-misc-2pic.s: New file.
Index: config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.224
diff -u -p -r1.224 tc-mips.c
--- config/tc-mips.c 30 Jun 2003 21:54:19 -0000 1.224
+++ config/tc-mips.c 1 Jul 2003 17:21:54 -0000
@@ -11059,8 +11059,9 @@ mips_validate_fix (struct fix *fixP, ase
{
symbolS *sym = fixP->fx_addsy;
- as_warn_where (fixP->fx_file, fixP->fx_line,
- _("Pretending global symbol used as branch target is local."));
+ if (mips_pic != NO_PIC)
+ as_warn_where (fixP->fx_file, fixP->fx_line,
+ _("Pretending global symbol used as branch target is local."));
fixP->fx_addsy = symbol_create (S_GET_NAME (sym),
S_GET_SEGMENT (sym),
Index: testsuite/gas/mips/branch-misc-2.l
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/branch-misc-2.l,v
retrieving revision 1.4
diff -u -p -r1.4 branch-misc-2.l
--- testsuite/gas/mips/branch-misc-2.l 12 Mar 2003 23:07:22 -0000 1.4
+++ testsuite/gas/mips/branch-misc-2.l 1 Jul 2003 17:21:55 -0000
@@ -1,10 +1,4 @@
.*: Assembler messages:
-.*:21: Warning: Pretending global symbol used as branch target is local.
-.*:22: Warning: Pretending global symbol used as branch target is local.
-.*:23: Warning: Pretending global symbol used as branch target is local.
-.*:24: Warning: Pretending global symbol used as branch target is local.
-.*:25: Warning: Pretending global symbol used as branch target is local.
-.*:26: Warning: Pretending global symbol used as branch target is local.
.*:35: Error: Cannot branch to undefined symbol.
.*:36: Error: Cannot branch to undefined symbol.
.*:37: Error: Cannot branch to symbol in another section.
Index: testsuite/gas/mips/branch-misc-2pic.l
===================================================================
RCS file: testsuite/gas/mips/branch-misc-2pic.l
diff -N testsuite/gas/mips/branch-misc-2pic.l
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gas/mips/branch-misc-2pic.l 1 Jul 2003 17:21:55 -0000
@@ -0,0 +1,10 @@
+.*: Assembler messages:
+.*:21: Warning: Pretending global symbol used as branch target is local.
+.*:22: Warning: Pretending global symbol used as branch target is local.
+.*:23: Warning: Pretending global symbol used as branch target is local.
+.*:24: Warning: Pretending global symbol used as branch target is local.
+.*:25: Warning: Pretending global symbol used as branch target is local.
+.*:26: Warning: Pretending global symbol used as branch target is local.
+.*:35: Error: Cannot branch to undefined symbol.
+.*:36: Error: Cannot branch to undefined symbol.
+.*:37: Error: Cannot branch to symbol in another section.
Index: testsuite/gas/mips/branch-misc-2pic.s
===================================================================
RCS file: testsuite/gas/mips/branch-misc-2pic.s
diff -N testsuite/gas/mips/branch-misc-2pic.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gas/mips/branch-misc-2pic.s 1 Jul 2003 17:21:55 -0000
@@ -0,0 +1,43 @@
+# Source file used to test the backward branches to globals in this file.
+
+ .globl g1 .text
+ .globl g2 .text
+ .globl g3 .text
+ .globl g4 .text
+ .globl g5 .text
+ .globl g6 .text
+
+ .globl x1 .text
+
+ .text
+g1:
+ .space 20
+g2:
+ .space 20
+g3:
+ .space 20
+
+x:
+ bal g1
+ bal g2
+ bal g3
+ bal g4
+ bal g5
+ bal g6
+
+ .space 20
+g4:
+ .space 20
+g5:
+ .space 20
+g6:
+
+ b x1
+ b x2
+ b .Ldata
+
+# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .space 8
+
+ .data
+.Ldata:
Index: testsuite/gas/mips/mips.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.75
diff -u -p -r1.75 mips.exp
--- testsuite/gas/mips/mips.exp 29 Jun 2003 19:41:33 -0000 1.75
+++ testsuite/gas/mips/mips.exp 1 Jul 2003 17:21:55 -0000
@@ -423,7 +423,8 @@ if { [istarget mips*-*-*] } then {
run_dump_test_arches "blt" [mips_arch_list_matching mips2]
run_dump_test_arches "bltu" [mips_arch_list_matching mips2]
run_dump_test_arches "branch-misc-1" [mips_arch_list_matching mips1]
- run_list_test_arches "branch-misc-2" "-32" [mips_arch_list_matching mips1]
+ run_list_test_arches "branch-misc-2" "-32 -non_shared" [mips_arch_list_matching mips1]
+ run_list_test_arches "branch-misc-2pic" "-32 -call_shared" [mips_arch_list_matching mips1]
if $ilocks {
run_dump_test "div-ilocks"