MIPS/BFD: Report `bfd_reloc_outofrange' errors as such
authorMaciej W. Rozycki <macro@imgtec.com>
Wed, 25 May 2016 19:59:37 +0000 (20:59 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Wed, 25 May 2016 20:03:22 +0000 (21:03 +0100)
commitde341542a60f7d3a80cc339db7d341b615cfa52f
tree49433d00589276b80ebc6f63f7933623ebd5b9c8
parentf3ad76370f8c79e4ae74ca6826e23bf417d5283a
MIPS/BFD: Report `bfd_reloc_outofrange' errors as such

A `bfd_reloc_outofrange' condition from `mips_elf_calculate_relocation'
currently triggers the warning callback, which in the case of LD prints
messages like:

foo.o: In function `foo':
(.text+0x0): warning: JALX to a non-word-aligned address

or:

foo.o: In function `foo':
(.text+0x0): warning: PC-relative load from unaligned address

and nothing else, which suggests this is a benign condition and link has
otherwise successfully run to completion.  This is however not the case,
the link terminates right away with no further messages and no output
produced.

Use the general error or warning info callback then, preserving the
message format.  Also set a BFD error condition so that a failure is
unambiguously reported.  Complement the change with a set of suitable
test suite additions.

bfd/
* elfxx-mips.c (_bfd_mips_elf_relocate_section)
<bfd_reloc_outofrange>: Call `->einfo' rather than `->warning'.
Call `bfd_set_error'.

ld/
* testsuite/ld-mips-elf/unaligned-jalx-0.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-1.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-2.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-mips16-2.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-micromips-2.d: New test.
* testsuite/ld-mips-elf/unaligned-lwpc-0.d: New test.
* testsuite/ld-mips-elf/unaligned-lwpc-1.d: New test.
* testsuite/ld-mips-elf/unaligned-lwpc-2.d: New test.
* testsuite/ld-mips-elf/unaligned-lwpc-3.d: New test.
* testsuite/ld-mips-elf/unaligned-ldpc-0.d: New test.
* testsuite/ld-mips-elf/unaligned-ldpc-1.d: New test.
* testsuite/ld-mips-elf/unaligned-ldpc-2.d: New test.
* testsuite/ld-mips-elf/unaligned-ldpc-3.d: New test.
* testsuite/ld-mips-elf/unaligned-ldpc-4.d: New test.
* testsuite/ld-mips-elf/unaligned-jalx-0.s: New test source.
* testsuite/ld-mips-elf/unaligned-jalx-1.s: New test source.
* testsuite/ld-mips-elf/unaligned-jalx-2.s: New test source.
* testsuite/ld-mips-elf/unaligned-insn.s: New test source.
* testsuite/ld-mips-elf/unaligned-lwpc-0.s: New test source.
* testsuite/ld-mips-elf/unaligned-lwpc-1.s: New test source.
* testsuite/ld-mips-elf/unaligned-lwpc-2.s: New test source.
* testsuite/ld-mips-elf/unaligned-lwpc-3.s: New test source.
* testsuite/ld-mips-elf/unaligned-ldpc-0.s: New test source.
* testsuite/ld-mips-elf/unaligned-ldpc-1.s: New test source.
* testsuite/ld-mips-elf/unaligned-ldpc-2.s: New test source.
* testsuite/ld-mips-elf/unaligned-ldpc-3.s: New test source.
* testsuite/ld-mips-elf/unaligned-ldpc-4.s: New test source.
* testsuite/ld-mips-elf/unaligned-syms.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
36 files changed:
bfd/ChangeLog
bfd/elfxx-mips.c
ld/ChangeLog
ld/testsuite/ld-mips-elf/mips-elf.exp
ld/testsuite/ld-mips-elf/unaligned-insn.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-0.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-0.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-1.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-1.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-2.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-2.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-micromips-2.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-jalx-mips16-2.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-ldpc-0.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-ldpc-0.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-ldpc-1.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-ldpc-1.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-ldpc-2.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-ldpc-2.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-ldpc-3.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-ldpc-3.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-ldpc-4.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-ldpc-4.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-lwpc-0.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-lwpc-0.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-lwpc-1.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-lwpc-1.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-lwpc-2.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-lwpc-2.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-lwpc-3.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-lwpc-3.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/unaligned-syms.s [new file with mode: 0644]