This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] RISC-V: Force linker error exit after unresolvable reloc.
- From: "Maciej W. Rozycki" <macro at wdc dot com>
- To: Jim Wilson <jimw at sifive dot com>
- Cc: binutils at sourceware dot org
- Date: Mon, 30 Sep 2019 13:39:51 +0100 (BST)
- Subject: Re: [PATCH] RISC-V: Force linker error exit after unresolvable reloc.
- Ironport-sdr: K1I5lPCJNwvKrR4fiOx4hSKumg5n3ZMbMrq6qZGJ8S/KQjuGkkjAx9qMfJhinuXb3+NfvyLurz Hj9PS4ViiFGSyKZrnXOOGPllBOeEYfmd+wkn9cyf0zNUEeKAeIl6rnTcXOvfYrhFPSSMJk5Mon 708BQYFZUhuQ+o6SPfZL/asWJkeWSMVi66VpEva1RGPzAGsZoSzrPDjo/fiCBkr3IbUVzE+WUL tCnljrptVHwOww7vPSSsjKVYsS1sWsU7YLVejk2lUYkgDk5Y6lzUYdVViM0kS/XkZumsBZMQe5 wuI=
- Ironport-sdr: pKYMoiCAGYhdeKm1mM3GEvA/FxtGB/JxAaaD/KnP3qDtpsR5ek5gSNEOqsI+sj3/hqHdxAAcT4 pcAeTE6jOZ09vSS0x/u+Ho30MGPKJ5QDFMT8C0uGz9yW8zy6fsAnU5y/3HH30Pe+5EIvAa50vj xENUpcuKEpgoda/xLeH1BCkh4f3odG6ZfWotBcOoQaIWm7qa29oSdDjr69d7iaz4hrQoqxf1J4 voeElhE0OoC0IfdASYlMtlXvHfLD/YjCHAvp7puVyix3Kc5F5jiRDNa6ZU9xBsztL6wyDW2ynO b39UP7U0bXCPKw1HgCBjQfG6
- Ironport-sdr: HjtmCtUlNk+8++wCR7EUWXi3FHibPIhKAoOLUlDMnlvdASGbc3PdAB7I4F0ncaYzfpneX81E1o SmCCLrwo8zv3Qb9Z554TzCu0tCnpsMt2DJFCQeE+6YXJ+KFBJecTDXHk58V7moSPBtERVrR2Na qpG/ABHdkWPEmoDW7LZ9LC2s5THMHxsb+8eidp7vt9TcUMFYq5IMwaaCvNMnSf/uAvUJgLOZ2M XqpUzAdDBA2qurVlOjhK0tDWQgL8+ZxX+EGtadC2GTHnq76Jl4WMGWUkGVFbhKH3vW6Y4TOYj0 N1g=
- References: <20190830221610.2559-1-jimw@sifive.com>
- Wdcironportexception: Internal
Jim,
> The patch fixes this by forcing a linker error. I now get this.
>
> ohan:2059$ sh tmp.script
> /home/jimw/FOSS/BINUTILS/X-riscv64-linux/ld/ld-new: libtmp2.o(.text+0x18): unresolvable R_RISCV_CALL relocation against symbol `sub'
> /home/jimw/FOSS/BINUTILS/X-riscv64-linux/ld/ld-new: final link failed: bad value
> rohan:2060$ echo $?
> 1
> rohan:2061$ ls -lt libtmp2.so
> ls: cannot access 'libtmp2.so': No such file or directory
[...]
> diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
> index 4729bae09a..ef2471eb99 100644
> --- a/bfd/elfnn-riscv.c
> +++ b/bfd/elfnn-riscv.c
> @@ -2297,7 +2297,10 @@ riscv_elf_relocate_section (bfd *output_bfd,
> (uint64_t) rel->r_offset,
> howto->name,
> h->root.root.string);
> - continue;
> +
> + bfd_set_error (bfd_error_bad_value);
> + ret = FALSE;
> + goto out;
FYI, it's better done with one the percent-codes to `_bfd_error_handler'
rather than aborting the link right away, so that any further link errors
are also reported and you don't have to shake them out one by one. I've
done such an improvement for several error cases in the MIPS backend.
Since none was attached to this change of yours, is there a test case (as
one obviously should) already present in the LD test suite that covers
this error? If so, then I can start from there and provide you with a
quick change to show you what I mean.
Maciej