This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 2/3] MIPS/LD: Continue processing with refused relocations in PIC code
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: binutils at sourceware dot org
- Cc: Nick Clifton <nickc at redhat dot com>, Alan Modra <amodra at gmail dot com>
- Date: Sun, 25 Nov 2018 22:52:48 +0000 (GMT)
- Subject: [PATCH 2/3] MIPS/LD: Continue processing with refused relocations in PIC code
- References: <alpine.LFD.2.21.1811232334270.27071@eddie.linux-mips.org>
Switch from `_bfd_error_handler' to `info->callbacks->einfo' with error
reporting concerning the use of position-dependent relocations such as
R_MIPS_HI16 or R_MIPS_26 in PIC code and continue processing so that any
subsequent link errors are also shown rather than the linker terminating
right away. This can reduce user frustration where correcting one error
only reveals another one; instead all are shown together making them all
possible to investigate at once. The use of the `%X' specifier causes
the linker to terminate unsuccessfully at the end of processing.
Also fix the message to say `cannot' rather than `can not'.
bfd/
* elfxx-mips.c (_bfd_mips_elf_check_relocs) <R_MIPS16_26>
<R_MIPS_26, R_MICROMIPS_26_S1>: Use `info->callbacks->einfo'
rather than `_bfd_error_handler' to report refused relocations
in PIC code and continue processing. Fix error message: `can
not' -> `cannot'.
---
bfd/elfxx-mips.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
binutils-mips-reloc-pic-check-einfo.diff
Index: src/bfd/elfxx-mips.c
===================================================================
--- src.orig/bfd/elfxx-mips.c
+++ src/bfd/elfxx-mips.c
@@ -9077,14 +9077,13 @@ _bfd_mips_elf_check_relocs (bfd *abfd, s
case R_MIPS_26:
case R_MICROMIPS_26_S1:
howto = MIPS_ELF_RTYPE_TO_HOWTO (abfd, r_type, FALSE);
- _bfd_error_handler
+ info->callbacks->einfo
/* xgettext:c-format */
- (_("%pB: relocation %s against `%s' can not be used"
- " when making a shared object; recompile with -fPIC"),
- abfd, howto->name,
+ (_("%X%H: relocation %s against `%s' cannot be used"
+ " when making a shared object; recompile with -fPIC\n"),
+ abfd, sec, rel->r_offset, howto->name,
(h) ? h->root.root.string : "a local symbol");
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
+ break;
default:
break;
}