[PATCH v2 06/10] MIPS/BFD: Standardize orphan REL HI16 relocation warning

Maciej W. Rozycki macro@orcam.me.uk
Wed Nov 5 02:46:58 GMT 2025
Use the warning callback for the orphan REL HI16 relocation warning just 
as with any other linker relocation processing warnings, standardizing 
the message format and providing source location where available.

Test cases will be added with a separate change.
---
New change in v2.
---
 bfd/elfxx-mips.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

binutils-mips-bfd-hi16-orphan-warn.diff
Index: binutils-gdb/bfd/elfxx-mips.c
===================================================================
--- binutils-gdb.orig/bfd/elfxx-mips.c
+++ binutils-gdb/bfd/elfxx-mips.c
@@ -10606,12 +10606,18 @@ _bfd_mips_elf_relocate_section (bfd *out
 			name = bfd_elf_sym_name (input_bfd, symtab_hdr,
 						 local_syms + r_symndx,
 						 sec);
-		      _bfd_error_handler
-			/* xgettext:c-format */
-			(_("%pB: can't find matching LO16 reloc against `%s'"
-			   " for %s at %#" PRIx64 " in section `%pA'"),
-			 input_bfd, name,
-			 howto->name, (uint64_t) rel->r_offset, input_section);
+		      /* xgettext:c-format */
+		      msg = bfd_asprintf (_("can't find matching LO16 reloc"
+					    " against `%s' for %s at %#" PRIx64
+					    " in section `%s'"),
+					  name, howto->name,
+					  (uint64_t) rel->r_offset,
+					  input_section->name);
+		      if (msg == NULL)
+			return false;
+		      info->callbacks->warning
+	    		(info, msg, name, input_bfd, input_section,
+			 rel->r_offset);
 		    }
 		}
 	      else


More information about the Binutils mailing list