On 05.11.2025 03:46, Maciej W. Rozycki wrote:
> A couple of targets use virtually the same code for error reporting in
> relocation processing. Merge the copies, removing small discrepancies
> such as a fallback call to `abort' for NDS32 targets as per PR 17512,
> and factor out for backends to use.
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.
Jan