diff options
author | Maciej W. Rozycki <macro@imgtec.com> | 2016-05-28 10:57:58 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@imgtec.com> | 2016-05-28 10:59:45 +0100 |
commit | 99aefae6818be07a77739e0366121f2032916d9c (patch) | |
tree | 9f06d7da4abc5ef64fd089f95f78a30d706f6ef1 /ld/testsuite | |
parent | 3b4412a0419d0faa42432df1e4faab880fe43b35 (diff) | |
download | binutils-99aefae6818be07a77739e0366121f2032916d9c.zip binutils-99aefae6818be07a77739e0366121f2032916d9c.tar.gz binutils-99aefae6818be07a77739e0366121f2032916d9c.tar.bz2 |
MIPS/BFD: Correctly handle `bfd_reloc_outofrange' with branches
Fix internal errors like:
ld: BFD (GNU Binutils) 2.26.51.20160526 internal error, aborting at .../bfd/elfxx-mips.c:10278 in _bfd_mips_elf_relocate_section
ld: Please report this bug.
triggered by the `bfd_reloc_outofrange' condition on branch relocations.
bfd/
* elfxx-mips.c (b_reloc_p): New function.
(_bfd_mips_elf_relocate_section) <bfd_reloc_outofrange>: Handle
branch relocations.
ld/
* testsuite/ld-mips-elf/unaligned-branch.d: New test.
* testsuite/ld-mips-elf/unaligned-branch.s: New test source.
* testsuite/ld-mips-elf/unaligned-text.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-mips-elf/mips-elf.exp | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/unaligned-branch.d | 23 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/unaligned-branch.s | 21 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/unaligned-text.s | 15 |
4 files changed, 61 insertions, 0 deletions
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index f8c8b09..61a119e 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -199,6 +199,8 @@ if $has_newabi { [list [list ld $abi_ldflags(n32)]] } +run_dump_test "unaligned-branch" [list [list ld $abi_ldflags(o32)]] + run_dump_test "unaligned-lwpc-0" [list [list ld $abi_ldflags(o32)]] run_dump_test "unaligned-lwpc-1" [list [list ld $abi_ldflags(o32)]] run_dump_test "unaligned-ldpc-0" [list [list ld $abi_ldflags(o32)]] diff --git a/ld/testsuite/ld-mips-elf/unaligned-branch.d b/ld/testsuite/ld-mips-elf/unaligned-branch.d new file mode 100644 index 0000000..54894b6 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/unaligned-branch.d @@ -0,0 +1,23 @@ +#name: MIPS branch to unaligned symbol +#source: unaligned-branch.s +#source: unaligned-text.s +#as: -EB -32 -mips32r6 +#ld: -EB -Ttext 0x10000000 -e 0x10000000 +#error: \A[^\n]*: In function `foo':\n +#error: \(\.text\+0x14\): Branch to a non-instruction-aligned address\n +#error: [^\n]*: In function `foo':\n +#error: \(\.text\+0x1c\): Branch to a non-instruction-aligned address\n +#error: [^\n]*: In function `foo':\n +#error: \(\.text\+0x24\): Branch to a non-instruction-aligned address\n +#error: [^\n]*: In function `foo':\n +#error: \(\.text\+0x28\): Branch to a non-instruction-aligned address\n +#error: [^\n]*: In function `foo':\n +#error: \(\.text\+0x30\): Branch to a non-instruction-aligned address\n +#error: [^\n]*: In function `foo':\n +#error: \(\.text\+0x38\): Branch to a non-instruction-aligned address\n +#error: [^\n]*: In function `foo':\n +#error: \(\.text\+0x3c\): Branch to a non-instruction-aligned address\n +#error: [^\n]*: In function `foo':\n +#error: \(\.text\+0x44\): Branch to a non-instruction-aligned address\n +#error: [^\n]*: In function `foo':\n +#error: \(\.text\+0x4c\): Branch to a non-instruction-aligned address\Z diff --git a/ld/testsuite/ld-mips-elf/unaligned-branch.s b/ld/testsuite/ld-mips-elf/unaligned-branch.s new file mode 100644 index 0000000..8fef3bb --- /dev/null +++ b/ld/testsuite/ld-mips-elf/unaligned-branch.s @@ -0,0 +1,21 @@ + .text + .align 4 + .globl foo + .ent foo +foo: + b bar0 + beqzc $2, bar0 + bc bar0 + b bar1 + beqzc $2, bar1 + bc bar1 + b bar2 + beqzc $2, bar2 + bc bar2 + b bar3 + beqzc $2, bar3 + bc bar3 + b bar4 + beqzc $2, bar4 + bc bar4 + .end foo diff --git a/ld/testsuite/ld-mips-elf/unaligned-text.s b/ld/testsuite/ld-mips-elf/unaligned-text.s new file mode 100644 index 0000000..4b3aa38 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/unaligned-text.s @@ -0,0 +1,15 @@ + .macro sym n:req + .if \n + .globl bar\@ + .type bar\@, @object +bar\@ : + .byte 0 + .size bar\@, . - bar\@ + sym \n - 1 + .endif + .endm + + .text + .align 4 + .space 32 + sym 16 |