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 /bfd/elfxx-mips.c | |
parent | 3b4412a0419d0faa42432df1e4faab880fe43b35 (diff) | |
download | gdb-99aefae6818be07a77739e0366121f2032916d9c.zip gdb-99aefae6818be07a77739e0366121f2032916d9c.tar.gz gdb-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 'bfd/elfxx-mips.c')
-rw-r--r-- | bfd/elfxx-mips.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index d519090..e2f4749 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -2216,6 +2216,15 @@ jal_reloc_p (int r_type) } static inline bfd_boolean +b_reloc_p (int r_type) +{ + return (r_type == R_MIPS_PC26_S2 + || r_type == R_MIPS_PC21_S2 + || r_type == R_MIPS_PC16 + || r_type == R_MIPS_GNU_REL16_S2); +} + +static inline bfd_boolean aligned_pcrel_reloc_p (int r_type) { return (r_type == R_MIPS_PC18_S3 @@ -10261,6 +10270,8 @@ _bfd_mips_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, msg = NULL; if (jal_reloc_p (howto->type)) msg = _("JALX to a non-word-aligned address"); + else if (b_reloc_p (howto->type)) + msg = _("Branch to a non-instruction-aligned address"); else if (aligned_pcrel_reloc_p (howto->type)) msg = _("PC-relative load from unaligned address"); if (msg) |