From 551703cfd409faca433626a0af077a43011381b7 Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Mon, 24 Sep 2018 14:05:32 -0700 Subject: RISC-V: Allow pcrel_lo addends, error on addend overflow. bfd/ * elfnn-riscv.c (riscv_resolve_pcrel_lo_relocs): Add check for reloc overflow with addend. Use reloc_dangerous instead of reloc_overflow. Add strings for the two errors handled here. (riscv_elf_relocate_section) In case R_RISCV_PCREL_LO12_I, rewrite comment. Only give error with addend when used with section symbol. In case bfd_reloc_dangerous, update error string. ld/ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run pcrel-lo-addend-2. * testsuite/ld-riscv/elf/ld-riscv-elf/pcrel-lo-addend-2.d: New. * testsuite/ld-riscv/elf/ld-riscv-elf/pcrel-lo-addend-2.s: New. * testsuite/ld-riscv/elf/ld-riscv-elf/pcrel-lo-addend.d: Update name and error string. --- ld/testsuite/ld-riscv-elf/pcrel-lo-addend-2.s | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 ld/testsuite/ld-riscv-elf/pcrel-lo-addend-2.s (limited to 'ld/testsuite/ld-riscv-elf/pcrel-lo-addend-2.s') diff --git a/ld/testsuite/ld-riscv-elf/pcrel-lo-addend-2.s b/ld/testsuite/ld-riscv-elf/pcrel-lo-addend-2.s new file mode 100644 index 0000000..b7f8212 --- /dev/null +++ b/ld/testsuite/ld-riscv-elf/pcrel-lo-addend-2.s @@ -0,0 +1,16 @@ + .text + .globl _start + .align 3 +_start: + nop + .LA0: auipc a5,%pcrel_hi(ll) + lw a0,%pcrel_lo(.LA0)(a5) + lw a0,%pcrel_lo(.LA0+4)(a5) + ret + .globl ll + .data + .align 3 + .zero 2024 +ll: + .word 0 + .word 0 -- cgit v1.1