From c314987d19b8736574973103eca3a3ef1d281d0c Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 14 Dec 2004 09:48:20 +0000 Subject: [PATCH] * elfxx-mips.c (mips_elf_calculate_relocation): Don't report an overflow for calls to undefined weak symbols. --- bfd/ChangeLog | 5 +++++ bfd/elfxx-mips.c | 3 ++- ld/testsuite/ChangeLog | 5 +++++ ld/testsuite/ld-mips-elf/jaloverflow-2.d | 8 ++++++++ ld/testsuite/ld-mips-elf/jaloverflow-2.s | 7 +++++++ ld/testsuite/ld-mips-elf/mips-elf.exp | 1 + 6 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 ld/testsuite/ld-mips-elf/jaloverflow-2.d create mode 100644 ld/testsuite/ld-mips-elf/jaloverflow-2.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f61fd226a2..e0d5f86e83 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2004-12-14 Richard Sandiford + + * elfxx-mips.c (mips_elf_calculate_relocation): Don't report an + overflow for calls to undefined weak symbols. + 2004-12-11 Alan Modra * elfcode.h (elf_slurp_symbol_table): Use bfd_elf_sym_name so that diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index ef4650b1eb..9ec9c86dcb 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -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; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 14a6fa1985..cbf50fcdc7 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-12-14 Richard Sandiford + + * ld-mips-elf/jal-overflow-2.[sd]: New test. + * ld-mips-elf/mips-elf.exp: Run it. + 2004-12-13 Richard Sandiford * 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 index 0000000000..b28b4edb2f --- /dev/null +++ b/ld/testsuite/ld-mips-elf/jaloverflow-2.d @@ -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 index 0000000000..71acf296ea --- /dev/null +++ b/ld/testsuite/ld-mips-elf/jaloverflow-2.s @@ -0,0 +1,7 @@ +# jal relocs against undefined weak symbols should not be treated as +# overflowing + + .globl start + .weak foo +start: + jal foo diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 36e29c5016..63fe3f0625 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -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" }