* elfxx-mips.c (mips_elf_calculate_relocation): Don't report an
authorRichard Sandiford <rdsandiford@googlemail.com>
Tue, 14 Dec 2004 09:48:20 +0000 (09:48 +0000)
committerRichard Sandiford <rdsandiford@googlemail.com>
Tue, 14 Dec 2004 09:48:20 +0000 (09:48 +0000)
overflow for calls to undefined weak symbols.

bfd/ChangeLog
bfd/elfxx-mips.c
ld/testsuite/ChangeLog
ld/testsuite/ld-mips-elf/jaloverflow-2.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/jaloverflow-2.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-elf.exp

index f61fd226a2939643b0b15ffe044545834be7d4ad..e0d5f86e835ee95e636f35183c3222f0661c7f22 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-14  Richard Sandiford  <rsandifo@redhat.com>
+
+       * elfxx-mips.c (mips_elf_calculate_relocation): Don't report an
+       overflow for calls to undefined weak symbols.
+
 2004-12-11  Alan Modra  <amodra@bigpond.net.au>
 
        * elfcode.h (elf_slurp_symbol_table): Use bfd_elf_sym_name so that
index ef4650b1eb6c35b76c4abe7904335936ed2a84b5..9ec9c86dcb0547b1425d48546685e0dc1f4ed479 100644 (file)
@@ -3352,7 +3352,8 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
       else
        {
          value = (_bfd_mips_elf_sign_extend (addend, 28) + symbol) >> 2;
-         overflowed_p = (value >> 26) != ((p + 4) >> 28);
+         if (h->root.root.type != bfd_link_hash_undefweak)
+           overflowed_p = (value >> 26) != ((p + 4) >> 28);
        }
       value &= howto->dst_mask;
       break;
index 14a6fa1985ca15d80d4b33f1cf81bf1fc50b02ec..cbf50fcdc768e342163be9fae0a0ccec8d3b9510 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-14  Richard Sandiford  <rsandifo@redhat.com>
+
+       * ld-mips-elf/jal-overflow-2.[sd]: New test.
+       * ld-mips-elf/mips-elf.exp: Run it.
+
 2004-12-13  Richard Sandiford  <rsandifo@redhat.com>
 
        * ld-mips-elf/mips-elf.exp: Only run jalbal if n32 is supported.
diff --git a/ld/testsuite/ld-mips-elf/jaloverflow-2.d b/ld/testsuite/ld-mips-elf/jaloverflow-2.d
new file mode 100644 (file)
index 0000000..b28b4ed
--- /dev/null
@@ -0,0 +1,8 @@
+#name: JAL overflow 2
+#source: jaloverflow-2.s
+#as:
+#ld: -Ttext=0x10000000 -e start
+#objdump: -dr
+#...
+0*10000000:    0c000000.*
+#pass
diff --git a/ld/testsuite/ld-mips-elf/jaloverflow-2.s b/ld/testsuite/ld-mips-elf/jaloverflow-2.s
new file mode 100644 (file)
index 0000000..71acf29
--- /dev/null
@@ -0,0 +1,7 @@
+# jal relocs against undefined weak symbols should not be treated as
+# overflowing
+
+       .globl  start
+       .weak   foo
+start:
+       jal     foo
index 36e29c50169783ee38d29cbac02c0f04cc659a27..63fe3f06253ff32bea8c0df828f54a9620e582f8 100644 (file)
@@ -81,6 +81,7 @@ if {$has_newabi && $linux_gnu} {
 }
 
 run_dump_test "jaloverflow"
+run_dump_test "jaloverflow-2"
 if {$has_newabi} {
     run_dump_test "jalbal"
 }