[PATCH v2 01/10] BFD: Unify relocation error reporting

Maciej W. Rozycki macro@orcam.me.uk
Sat Nov 8 14:52:56 GMT 2025


On Fri, 7 Nov 2025, Jan Beulich wrote:

> This is okay as is, yet still I'd like to ask ...
> 
> > --- binutils-gdb.orig/bfd/coff-alpha.c
> > +++ binutils-gdb/bfd/coff-alpha.c
> > @@ -1154,43 +1154,10 @@ alpha_ecoff_get_relocated_section_conten
> >  
> >        if (r != bfd_reloc_ok)
> >  	{
> > -	  switch (r)
> > -	    {
> > -	    case bfd_reloc_undefined:
> > -	      (*link_info->callbacks->undefined_symbol)
> > -		(link_info, bfd_asymbol_name (*rel->sym_ptr_ptr),
> > -		 input_bfd, input_section, rel->address, true);
> > -	      break;
> > -	    case bfd_reloc_dangerous:
> > -	      (*link_info->callbacks->reloc_dangerous)
> > -		(link_info, err, input_bfd, input_section, rel->address);
> > -	      break;
> > -	    case bfd_reloc_overflow:
> > -	      (*link_info->callbacks->reloc_overflow)
> > -		(link_info, NULL, bfd_asymbol_name (*rel->sym_ptr_ptr),
> > -		 rel->howto->name, rel->addend, input_bfd,
> > -		 input_section, rel->address);
> > -	      break;
> > -	    case bfd_reloc_outofrange:
> > -	      (*link_info->callbacks->einfo)
> > -		/* xgettext:c-format */
> > -		(_("%X%P: %pB(%pA): relocation \"%pR\" goes out of range\n"),
> > -		 input_bfd, input_section, rel);
> > -	      goto error_return;
> > -	    case bfd_reloc_notsupported:
> > -	      (*link_info->callbacks->einfo)
> > -		/* xgettext:c-format */
> > -		(_("%X%P: %pB(%pA): relocation \"%pR\" is not supported\n"),
> > -		 input_bfd, input_section, rel);
> > -	      goto error_return;
> > -	    default:
> > -	      (*link_info->callbacks->einfo)
> > -		/* xgettext:c-format */
> > -		(_("%X%P: %pB(%pA): relocation \"%pR\""
> > -		   " returns an unrecognized value %x\n"),
> > -		 input_bfd, input_section, rel, r);
> > -	      break;
> > -	    }
> > +	  _bfd_link_reloc_status_error (abfd, link_info, input_section,
> > +					rel, err, r);
> > +	  if (r == bfd_reloc_outofrange || r == bfd_reloc_notsupported)
> > +	    goto error_return;
> 
> ... whether this last part (also identical everywhere) shouldn't also be
> folded, e.g. by having the new function return a boolean.

 Well, this is API consistency.  The new function is an error reporting 
facility and not a classification helper.  Adding one might be worthwhile, 
but that would be a separate change, not strictly needed for this series.  

 Conversely, this change is needed as a new call site is added for the new 
function down the series, so it's not just a random clean-up bundled with 
the series.

  Maciej


More information about the Binutils mailing list