diff options
author | Jim Wilson <jimw@sifive.com> | 2018-02-15 10:53:46 -0800 |
---|---|---|
committer | Jim Wilson <jimw@sifive.com> | 2018-02-15 10:53:46 -0800 |
commit | 2a0d98534964649bc6884b7833c6c4089159a6df (patch) | |
tree | f6e5caa134ac16c4d58efa8ae98f7f67f0266b06 /bfd | |
parent | 49ded53def53ae60926433b924db9525aae1e631 (diff) | |
download | gdb-2a0d98534964649bc6884b7833c6c4089159a6df.zip gdb-2a0d98534964649bc6884b7833c6c4089159a6df.tar.gz gdb-2a0d98534964649bc6884b7833c6c4089159a6df.tar.bz2 |
RISC-V: Give error for ignored pcrel_lo addend.
bfd/
* elfnn-riscv.c (riscv_elf_relocate_section): Use bfd_reloc_dangerous
when pcrel_lo reloc has an addend. Use reloc_dangerous callback for
bfd_reloc_dangerous. Use einfo instead of warning callback for errors.
Add %X%P to error messages.
ld/
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run pcrel-lo-addend test.
* testsuite/ld-riscv-elf/pcrel-lo-addend.d: New.
* testsuite/ld-riscv-elf/pcrel-lo-addend.s: New.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elfnn-riscv.c | 24 |
2 files changed, 25 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index aa14169..cab828b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2018-02-15 Jim Wilson <jimw@sifive.com> + + * elfnn-riscv.c (riscv_elf_relocate_section): Use bfd_reloc_dangerous + when pcrel_lo reloc has an addend. Use reloc_dangerous callback for + bfd_reloc_dangerous. Use einfo instead of warning callback for errors. + Add %X%P to error messages. + 2018-02-15 Eric Botcazou <ebotcazou@adacore.com> PR ld/22832 diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index dd9c300..931bd1d 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -1993,6 +1993,16 @@ riscv_elf_relocate_section (bfd *output_bfd, case R_RISCV_PCREL_LO12_I: case R_RISCV_PCREL_LO12_S: + /* Addends are not allowed, because then riscv_relax_delete_bytes + would have to search through all relocs to update the addends. + Also, riscv_resolve_pcrel_lo_relocs does not support addends + when searching for a matching hi reloc. */ + if (rel->r_addend) + { + r = bfd_reloc_dangerous; + break; + } + if (riscv_record_pcrel_lo_reloc (&pcrel_relocs, input_section, info, howto, rel, relocation, name, contents)) @@ -2234,25 +2244,27 @@ riscv_elf_relocate_section (bfd *output_bfd, break; case bfd_reloc_outofrange: - msg = _("internal error: out of range error"); + msg = _("%X%P: internal error: out of range error\n"); break; case bfd_reloc_notsupported: - msg = _("internal error: unsupported relocation error"); + msg = _("%X%P: internal error: unsupported relocation error\n"); break; case bfd_reloc_dangerous: - msg = _("internal error: dangerous relocation"); + info->callbacks->reloc_dangerous + (info, "%pcrel_lo with addend", input_bfd, input_section, + rel->r_offset); break; default: - msg = _("internal error: unknown error"); + msg = _("%X%P: internal error: unknown error\n"); break; } if (msg) - info->callbacks->warning - (info, msg, name, input_bfd, input_section, rel->r_offset); + info->callbacks->einfo (msg); + /* We already reported the error via a callback, so don't try to report it again by returning false. That leads to spurious errors. */ ret = TRUE; |