[binutils-gdb] PR 32603, more ld -w misbehaviour

Alan Modra amodra@sourceware.org
Mon Feb 17 23:16:36 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d26161914cf286171b29767916a212685f9aadf3

commit d26161914cf286171b29767916a212685f9aadf3
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Feb 16 23:34:55 2025 +1030

    PR 32603, more ld -w misbehaviour
    
    Commit 8d97c1a53f3d claimed to replace all einfo calls using %F with
    a call to fatal.  It did so only for the ld/ directory.  This patch
    adds a "fatal" to linker callbacks, and replaces those calls in bfd/
    too.

Diff:
---
 bfd/archive.c         |  4 ++--
 bfd/coff-aarch64.c    |  4 +---
 bfd/coffgen.c         |  2 +-
 bfd/elf-ifunc.c       |  4 ++--
 bfd/elf-m10300.c      |  4 ++--
 bfd/elf-properties.c  |  4 ++--
 bfd/elf.c             |  4 ++--
 bfd/elf32-arm.c       |  2 +-
 bfd/elf32-avr.c       |  4 ++--
 bfd/elf32-csky.c      |  2 +-
 bfd/elf32-frv.c       |  4 ++--
 bfd/elf32-hppa.c      |  6 ++---
 bfd/elf32-i386.c      |  4 ++--
 bfd/elf32-m68hc11.c   |  2 +-
 bfd/elf32-m68hc12.c   |  2 +-
 bfd/elf32-metag.c     |  2 +-
 bfd/elf32-spu.c       |  5 ++---
 bfd/elf64-ia64-vms.c  |  4 ++--
 bfd/elf64-ppc.c       |  4 ++--
 bfd/elf64-x86-64.c    | 18 +++++++--------
 bfd/elflink.c         | 16 ++++++-------
 bfd/elfnn-aarch64.c   |  6 ++---
 bfd/elfnn-ia64.c      |  4 ++--
 bfd/elfnn-kvx.c       |  2 +-
 bfd/elfnn-loongarch.c |  4 ++--
 bfd/elfxx-aarch64.c   |  6 ++---
 bfd/elfxx-sparc.c     |  4 ++--
 bfd/elfxx-x86.c       | 62 +++++++++++++++++++++++++--------------------------
 bfd/linker.c          |  2 +-
 bfd/reloc.c           |  4 ++--
 bfd/reloc16.c         |  4 ++--
 bfd/xcofflink.c       |  2 +-
 include/bfdlink.h     |  3 +++
 ld/ldmain.c           |  1 +
 34 files changed, 102 insertions(+), 103 deletions(-)

diff --git a/bfd/archive.c b/bfd/archive.c
index ef0109599e1..6cda73ce903 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -744,8 +744,8 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos,
 	    case bfd_error_system_call:
 	      if (info != NULL)
 		{
-		  info->callbacks->einfo
-		    (_("%F%P: %pB(%s): error opening thin archive member: %E\n"),
+		  info->callbacks->fatal
+		    (_("%P: %pB(%s): error opening thin archive member: %E\n"),
 		     archive, filename);
 		  break;
 		}
diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c
index 60cd6f88473..af4a44dede0 100644
--- a/bfd/coff-aarch64.c
+++ b/bfd/coff-aarch64.c
@@ -907,10 +907,8 @@ coff_pe_aarch64_relocate_section (bfd *output_bfd,
 	  }
 
 	default:
-	  info->callbacks->einfo (_("%F%P: Unhandled relocation type %u\n"),
+	  info->callbacks->fatal (_("%P: Unhandled relocation type %u\n"),
 				  rel->r_type);
-	  BFD_FAIL ();
-	  return false;
 	}
     }
 
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index c734f058892..5dbd6666b2b 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -2794,7 +2794,7 @@ _bfd_coff_section_already_linked (bfd *abfd,
 
   /* This is the first section with this name.  Record it.  */
   if (!bfd_section_already_linked_table_insert (already_linked_list, sec))
-    info->callbacks->einfo (_("%F%P: already_linked_table: %E\n"));
+    info->callbacks->fatal (_("%P: already_linked_table: %E\n"));
   return false;
 }
 
diff --git a/bfd/elf-ifunc.c b/bfd/elf-ifunc.c
index f9569b85e65..96b828812e9 100644
--- a/bfd/elf-ifunc.c
+++ b/bfd/elf-ifunc.c
@@ -139,9 +139,9 @@ _bfd_elf_allocate_ifunc_dyn_relocs (struct bfd_link_info *info,
 	  || info->export_dynamic)
       && h->pointer_equality_needed)
     {
-      info->callbacks->einfo
+      info->callbacks->fatal
 	/* xgettext:c-format */
-	(_("%F%P: dynamic STT_GNU_IFUNC symbol `%s' with pointer "
+	(_("%P: dynamic STT_GNU_IFUNC symbol `%s' with pointer "
 	   "equality in `%pB' can not be used when making an "
 	   "executable; recompile with -fPIE and relink with -pie\n"),
 	 h->root.root.string,
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index ed399da904c..3aeaa06e2cc 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -2646,8 +2646,8 @@ mn10300_elf_relax_section (bfd *abfd,
   bfd_vma align_gap_adjustment;
 
   if (bfd_link_relocatable (link_info))
-    (*link_info->callbacks->einfo)
-      (_("%P%F: --relax and -r may not be used together\n"));
+    link_info->callbacks->fatal
+      (_("%P: --relax and -r may not be used together\n"));
 
   /* Assume nothing changes.  */
   *again = false;
diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c
index f150ab4899f..39e0d4ec456 100644
--- a/bfd/elf-properties.c
+++ b/bfd/elf-properties.c
@@ -637,11 +637,11 @@ _bfd_elf_link_create_gnu_property_sec (struct bfd_link_info *info, bfd *elf_bfd,
 				      | SEC_HAS_CONTENTS
 				      | SEC_DATA));
   if (sec == NULL)
-    info->callbacks->einfo (_("%F%P: failed to create GNU property section\n"));
+    info->callbacks->fatal (_("%P: failed to create GNU property section\n"));
 
   if (!bfd_set_section_alignment (sec,
 				  elfclass == ELFCLASS64 ? 3 : 2))
-    info->callbacks->einfo (_("%F%pA: failed to align section\n"),
+    info->callbacks->fatal (_("%pA: failed to align section\n"),
 			    sec);
 
   elf_section_type (sec) = SHT_NOTE;
diff --git a/bfd/elf.c b/bfd/elf.c
index 129cac58382..3f8bc838bfb 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5009,8 +5009,8 @@ _bfd_elf_map_sections_to_segments (bfd *abfd,
 	  && need_layout != NULL
 	  && bed->size_relative_relocs
 	  && !bed->size_relative_relocs (info, need_layout))
-	info->callbacks->einfo
-	  (_("%F%P: failed to size relative relocations\n"));
+	info->callbacks->fatal
+	  (_("%P: failed to size relative relocations\n"));
     }
 
   if (no_user_phdrs && bfd_count_sections (abfd) != 0)
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 10c93e229b6..5a87462cb26 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -5074,7 +5074,7 @@ arm_build_one_stub (struct bfd_hash_entry *gen_entry,
      section.  The user should fix his linker script.  */
   if (stub_entry->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output section. "
+    info->callbacks->fatal (_("%P: Could not assign `%pA' to an output section. "
 			      "Retry without --enable-non-contiguous-regions.\n"),
 			    stub_entry->target_section);
 
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 0c1c07426c6..a98f18132ed 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -2479,8 +2479,8 @@ elf32_avr_relax_section (bfd *abfd,
     shrinkable = false;
 
   if (bfd_link_relocatable (link_info))
-    (*link_info->callbacks->einfo)
-      (_("%P%F: --relax and -r may not be used together\n"));
+    link_info->callbacks->fatal
+      (_("%P: --relax and -r may not be used together\n"));
 
   htab = avr_link_hash_table (link_info);
   if (htab == NULL)
diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c
index dbb603b88bc..47a63895b55 100644
--- a/bfd/elf32-csky.c
+++ b/bfd/elf32-csky.c
@@ -3726,7 +3726,7 @@ csky_build_one_stub (struct bfd_hash_entry *gen_entry,
      section.  The user should fix his linker script.  */
   if (stub_entry->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output section. "
+    info->callbacks->fatal (_("%P: Could not assign `%pA' to an output section. "
 			      "Retry without --enable-non-contiguous-regions.\n"),
 			    stub_entry->target_section);
 
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index a7e8215ff5e..b1290864366 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -5623,8 +5623,8 @@ elf32_frvfdpic_relax_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec,
   struct _frvfdpic_dynamic_got_plt_info gpinfo;
 
   if (bfd_link_relocatable (info))
-    (*info->callbacks->einfo)
-      (_("%P%F: --relax and -r may not be used together\n"));
+    info->callbacks->fatal
+      (_("%P: --relax and -r may not be used together\n"));
 
   /* If we return early, we didn't change anything.  */
   *again = false;
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index ba20bc63e5a..01c0fc4658e 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -728,7 +728,7 @@ hppa_build_one_stub (struct bfd_hash_entry *bh, void *in_arg)
 	 section.  The user should fix his linker script.  */
       if (hsh->target_section->output_section == NULL
 	  && info->non_contiguous_regions)
-	info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output "
+	info->callbacks->fatal (_("%P: Could not assign `%pA' to an output "
 				  "section. Retry without "
 				  "--enable-non-contiguous-regions.\n"),
 				hsh->target_section);
@@ -757,7 +757,7 @@ hppa_build_one_stub (struct bfd_hash_entry *bh, void *in_arg)
 	 section.  The user should fix his linker script.  */
       if (hsh->target_section->output_section == NULL
 	  && info->non_contiguous_regions)
-	info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output "
+	info->callbacks->fatal (_("%P: Could not assign `%pA' to an output "
 				  "section. Retry without "
 				  "--enable-non-contiguous-regions.\n"),
 				hsh->target_section);
@@ -838,7 +838,7 @@ hppa_build_one_stub (struct bfd_hash_entry *bh, void *in_arg)
 	 section.  The user should fix his linker script.  */
       if (hsh->target_section->output_section == NULL
 	  && info->non_contiguous_regions)
-	info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output "
+	info->callbacks->fatal (_("%P: Could not assign `%pA' to an output "
 				  "section. Retry without "
 				  "--enable-non-contiguous-regions.\n"),
 				hsh->target_section);
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 701cb6d5473..78ca74e2472 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -4111,8 +4111,8 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd,
     {
       if (bfd_is_abs_section (htab->elf.splt->output_section))
 	{
-	  info->callbacks->einfo
-	    (_("%F%P: discarded output section: `%pA'\n"),
+	  info->callbacks->fatal
+	    (_("%P: discarded output section: `%pA'\n"),
 	     htab->elf.splt);
 	  return false;
 	}
diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c
index 3b564c99aff..f70716d66a2 100644
--- a/bfd/elf32-m68hc11.c
+++ b/bfd/elf32-m68hc11.c
@@ -419,7 +419,7 @@ m68hc11_elf_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
      section.  The user should fix his linker script.  */
   if (stub_entry->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output section. "
+    info->callbacks->fatal (_("%P: Could not assign `%pA' to an output section. "
 			      "Retry without --enable-non-contiguous-regions.\n"),
 			    stub_entry->target_section);
 
diff --git a/bfd/elf32-m68hc12.c b/bfd/elf32-m68hc12.c
index 43e550c8956..f8619896978 100644
--- a/bfd/elf32-m68hc12.c
+++ b/bfd/elf32-m68hc12.c
@@ -539,7 +539,7 @@ m68hc12_elf_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
      section.  The user should fix his linker script.  */
   if (stub_entry->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output section. "
+    info->callbacks->fatal (_("%P: Could not assign `%pA' to an output section. "
 			      "Retry without --enable-non-contiguous-regions.\n"),
 			    stub_entry->target_section);
 
diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c
index 479b9f4405d..9959a1f5dd0 100644
--- a/bfd/elf32-metag.c
+++ b/bfd/elf32-metag.c
@@ -3343,7 +3343,7 @@ metag_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
      section.  The user should fix his linker script.  */
   if (hsh->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output section. "
+    info->callbacks->fatal (_("%P: Could not assign `%pA' to an output section. "
 			      "Retry without --enable-non-contiguous-regions.\n"),
 			    hsh->target_section);
 
diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index a6b486736ae..919b839671d 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -4689,8 +4689,7 @@ spu_elf_auto_overlay (struct bfd_link_info *info)
  file_err:
   bfd_set_error (bfd_error_system_call);
  err_exit:
-  info->callbacks->einfo (_("%F%P: auto overlay error: %E\n"));
-  xexit (1);
+  info->callbacks->fatal (_("%P: auto overlay error: %E\n"));
 }
 
 /* Provide an estimate of total stack required.  */
@@ -4743,7 +4742,7 @@ spu_elf_final_link (bfd *output_bfd, struct bfd_link_info *info)
     info->callbacks->einfo (_("%X%P: stack/lrlive analysis error: %E\n"));
 
   if (!spu_elf_build_stubs (info))
-    info->callbacks->einfo (_("%F%P: can not build overlay stubs: %E\n"));
+    info->callbacks->fatal (_("%P: can not build overlay stubs: %E\n"));
 
   return bfd_elf_final_link (output_bfd, info);
 }
diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
index 26710bac97e..87cc16d7148 100644
--- a/bfd/elf64-ia64-vms.c
+++ b/bfd/elf64-ia64-vms.c
@@ -361,8 +361,8 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
   *again = false;
 
   if (bfd_link_relocatable (link_info))
-    (*link_info->callbacks->einfo)
-      (_("%P%F: --relax and -r may not be used together\n"));
+    link_info->callbacks->fatal
+      (_("%P: --relax and -r may not be used together\n"));
 
   /* Don't even try to relax for non-ELF outputs.  */
   if (!is_elf_hash_table (link_info->hash))
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 65415bd39c7..c3f22f6ba98 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -12294,7 +12294,7 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
   if (stub_entry->target_section != NULL
       && stub_entry->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output section. "
+    info->callbacks->fatal (_("%P: Could not assign `%pA' to an output section. "
 			      "Retry without --enable-non-contiguous-regions.\n"),
 			    stub_entry->target_section);
 
@@ -12302,7 +12302,7 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
   if (stub_entry->group->stub_sec != NULL
       && stub_entry->group->stub_sec->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output section. "
+    info->callbacks->fatal (_("%P: Could not assign `%pA' to an output section. "
 			      "Retry without --enable-non-contiguous-regions.\n"),
 			    stub_entry->group->stub_sec);
 
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 9244f86405b..0e360771d12 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -4093,8 +4093,8 @@ elf_x86_64_relocate_section (bfd *output_bfd,
 			      || (roff - 3 + 22) > input_section->size)
 			    {
 			    corrupt_input:
-			      info->callbacks->einfo
-				(_("%F%P: corrupt input: %pB\n"),
+			      info->callbacks->fatal
+				(_("%P: corrupt input: %pB\n"),
 				 input_bfd);
 			      return false;
 			    }
@@ -5122,7 +5122,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
       /* Check PC-relative offset overflow in PLT entry.  */
       if ((plt_got_pcrel_offset + 0x80000000) > 0xffffffff)
 	/* xgettext:c-format */
-	info->callbacks->einfo (_("%F%pB: PC-relative offset overflow in PLT entry for `%s'\n"),
+	info->callbacks->fatal (_("%pB: PC-relative offset overflow in PLT entry for `%s'\n"),
 				output_bfd, h->root.root.string);
 
       bfd_put_32 (output_bfd, plt_got_pcrel_offset,
@@ -5195,7 +5195,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
 		 will overflow first.  */
 	      if (plt0_offset > 0x80000000)
 		/* xgettext:c-format */
-		info->callbacks->einfo (_("%F%pB: branch displacement overflow in PLT entry for `%s'\n"),
+		info->callbacks->fatal (_("%pB: branch displacement overflow in PLT entry for `%s'\n"),
 					output_bfd, h->root.root.string);
 	      bfd_put_32 (output_bfd, - plt0_offset,
 			  (plt->contents + h->plt.offset
@@ -5248,7 +5248,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
       if ((got_after_plt && got_pcrel_offset < 0)
 	  || (!got_after_plt && got_pcrel_offset > 0))
 	/* xgettext:c-format */
-	info->callbacks->einfo (_("%F%pB: PC-relative offset overflow in GOT PLT entry for `%s'\n"),
+	info->callbacks->fatal (_("%pB: PC-relative offset overflow in GOT PLT entry for `%s'\n"),
 				output_bfd, h->root.root.string);
 
       bfd_put_32 (output_bfd, got_pcrel_offset,
@@ -5396,8 +5396,8 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
 	     generate an error instead of a reloc.  cf PR 32638.  */
 	  if (relgot == NULL || relgot->size == 0)
 	    {
-	      info->callbacks->einfo (_("%F%pB: Unable to generate dynamic relocs because a suitable section does not exist\n"),
-					output_bfd);
+	      info->callbacks->fatal (_("%pB: Unable to generate dynamic relocs because a suitable section does not exist\n"),
+				      output_bfd);
 	      return false;
 	    }
 	  
@@ -5535,8 +5535,8 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
     {
       if (bfd_is_abs_section (htab->elf.splt->output_section))
 	{
-	  info->callbacks->einfo
-	    (_("%F%P: discarded output section: `%pA'\n"),
+	  info->callbacks->fatal
+	    (_("%P: discarded output section: `%pA'\n"),
 	     htab->elf.splt);
 	  return false;
 	}
diff --git a/bfd/elflink.c b/bfd/elflink.c
index f65b6bf0f95..70460573522 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4359,8 +4359,8 @@ elf_link_add_to_first_hash (bfd *abfd, struct bfd_link_info *info,
     = ((struct elf_link_first_hash_entry *)
        bfd_hash_lookup (htab->first_hash, name, true, copy));
   if (e == NULL)
-    info->callbacks->einfo
-      (_("%F%P: %pB: failed to add %s to first hash\n"), abfd, name);
+    info->callbacks->fatal
+      (_("%P: %pB: failed to add %s to first hash\n"), abfd, name);
 
   if (e->abfd == NULL)
     /* Store ABFD in abfd.  */
@@ -4427,8 +4427,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 	      || !bfd_hash_table_init
 		   (htab->first_hash, elf_link_first_hash_newfunc,
 		    sizeof (struct elf_link_first_hash_entry)))
-	    info->callbacks->einfo
-	      (_("%F%P: first_hash failed to create: %E\n"));
+	    info->callbacks->fatal
+	      (_("%P: first_hash failed to create: %E\n"));
 	}
     }
   else
@@ -13119,8 +13119,8 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
   if (info->enable_dt_relr
       && bed->finish_relative_relocs
       && !bed->finish_relative_relocs (info))
-    info->callbacks->einfo
-      (_("%F%P: %pB: failed to finish relative relocations\n"), abfd);
+    info->callbacks->fatal
+      (_("%P: %pB: failed to finish relative relocations\n"), abfd);
 
   /* Since ELF permits relocations to be against local symbols, we
      must have the local symbols available when we do the relocations.
@@ -14289,7 +14289,7 @@ _bfd_elf_gc_mark_extra_sections (struct bfd_link_info *info,
 	  else if (strcmp (bfd_section_name (isec),
 			   "__patchable_function_entries") == 0
 		   && elf_linked_to_section (isec) == NULL)
-	      info->callbacks->einfo (_("%F%P: %pB(%pA): error: "
+	      info->callbacks->fatal (_("%P: %pB(%pA): error: "
 					"need linked-to section "
 					"for --gc-sections\n"),
 				      isec->owner, isec);
@@ -15466,7 +15466,7 @@ _bfd_elf_section_already_linked (bfd *abfd,
 
   /* This is the first section with this name.  Record it.  */
   if (!bfd_section_already_linked_table_insert (already_linked_list, sec))
-    info->callbacks->einfo (_("%F%P: already_linked_table: %E\n"));
+    info->callbacks->fatal (_("%P: already_linked_table: %E\n"));
   return sec->output_section == bfd_abs_section_ptr;
 }
 
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 9b8b86fd5d5..968e3ee047c 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -3263,7 +3263,7 @@ aarch64_build_one_stub (struct bfd_hash_entry *gen_entry,
      section.  The user should fix his linker script.  */
   if (stub_entry->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output section. "
+    info->callbacks->fatal (_("%P: Could not assign `%pA' to an output section. "
 			      "Retry without "
 			      "--enable-non-contiguous-regions.\n"),
 			    stub_entry->target_section);
@@ -8927,9 +8927,9 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 	asection *s = p->sec->output_section;
 	if (s != NULL && (s->flags & SEC_READONLY) != 0)
 	  {
-	    info->callbacks->einfo
+	    info->callbacks->fatal
 		/* xgettext:c-format */
-		(_ ("%F%P: %pB: copy relocation against non-copyable "
+		(_ ("%P: %pB: copy relocation against non-copyable "
 		    "protected symbol `%s'\n"),
 		 p->sec->owner, h->root.root.string);
 	    return false;
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index 36ccfef0291..075b3447815 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -361,8 +361,8 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec,
   *again = false;
 
   if (bfd_link_relocatable (link_info))
-    (*link_info->callbacks->einfo)
-      (_("%P%F: --relax and -r may not be used together\n"));
+    link_info->callbacks->fatal
+      (_("%P: --relax and -r may not be used together\n"));
 
   /* Don't even try to relax for non-ELF outputs.  */
   if (!is_elf_hash_table (link_info->hash))
diff --git a/bfd/elfnn-kvx.c b/bfd/elfnn-kvx.c
index 3720c5122c4..31dd7a5eed5 100644
--- a/bfd/elfnn-kvx.c
+++ b/bfd/elfnn-kvx.c
@@ -926,7 +926,7 @@ kvx_build_one_stub (struct bfd_hash_entry *gen_entry,
      section.  The user should fix his linker script.  */
   if (stub_entry->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. "
+    info->callbacks->fatal (_("%P: Could not assign '%pA' to an output section. "
 			      "Retry without "
 			      "--enable-non-contiguous-regions.\n"),
 			    stub_entry->target_section);
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 0e3bfac67f6..faad512f339 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -1699,9 +1699,9 @@ local_allocate_ifunc_dyn_relocs (struct bfd_link_info *info,
 	  || info->export_dynamic)
       && h->pointer_equality_needed)
     {
-      info->callbacks->einfo
+      info->callbacks->fatal
 	/* xgettext:c-format.  */
-	(_("%F%P: dynamic STT_GNU_IFUNC symbol `%s' with pointer "
+	(_("%P: dynamic STT_GNU_IFUNC symbol `%s' with pointer "
 	   "equality in `%pB' can not be used when making an "
 	   "executable; recompile with -fPIE and relink with -pie\n"),
 	 h->root.root.string,
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index e3795be2c2c..04c65a01788 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -744,13 +744,11 @@ _bfd_aarch64_elf_create_gnu_property_section (struct bfd_link_info *info,
 				      | SEC_HAS_CONTENTS
 				      | SEC_DATA));
   if (sec == NULL)
-    info->callbacks->einfo (
-      _("%F%P: failed to create GNU property section\n"));
+    info->callbacks->fatal (_("%P: failed to create GNU property section\n"));
 
   unsigned align = (bfd_get_mach (ebfd) & bfd_mach_aarch64_ilp32) ? 2 : 3;
   if (!bfd_set_section_alignment (sec, align))
-    info->callbacks->einfo (_("%F%pA: failed to align section\n"),
-			    sec);
+    info->callbacks->fatal (_("%pA: failed to align section\n"), sec);
 
   elf_section_type (sec) = SHT_NOTE;
 }
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index 1cf280f050f..3d89a5f1497 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -2687,8 +2687,8 @@ _bfd_sparc_elf_relax_section (bfd *abfd ATTRIBUTE_UNUSED,
 			      bool *again)
 {
   if (bfd_link_relocatable (link_info))
-    (*link_info->callbacks->einfo)
-      (_("%P%F: --relax and -r may not be used together\n"));
+    link_info->callbacks->fatal
+      (_("%P: --relax and -r may not be used together\n"));
 
   *again = false;
   sec_do_relax (section) = 1;
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index f4bf58ec088..56514000dc4 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -529,9 +529,9 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 	  asection *s = p->sec->output_section;
 	  if (s != NULL && (s->flags & SEC_READONLY) != 0)
 	    {
-	      info->callbacks->einfo
+	      info->callbacks->fatal
 		/* xgettext:c-format */
-		(_("%F%P: %pB: copy relocation against non-copyable "
+		(_("%P: %pB: copy relocation against non-copyable "
 		   "protected symbol `%s' in %pB\n"),
 		 p->sec->owner, h->root.root.string,
 		 h->root.u.def.section->owner);
@@ -1036,9 +1036,9 @@ elf_x86_relative_reloc_record_add
 
   if (relative_reloc->data == NULL)
     {
-      info->callbacks->einfo
+      info->callbacks->fatal
 	/* xgettext:c-format */
-	(_("%F%P: %pB: failed to allocate relative reloc record\n"),
+	(_("%P: %pB: failed to allocate relative reloc record\n"),
 	 info->output_bfd);
       return false;
     }
@@ -1397,9 +1397,9 @@ elf64_dt_relr_bitmap_add
 
   if (bitmap->u.elf64 == NULL)
     {
-      info->callbacks->einfo
+      info->callbacks->fatal
 	/* xgettext:c-format */
-	(_("%F%P: %pB: failed to allocate 64-bit DT_RELR bitmap\n"),
+	(_("%P: %pB: failed to allocate 64-bit DT_RELR bitmap\n"),
 	 info->output_bfd);
     }
 
@@ -1433,9 +1433,9 @@ elf32_dt_relr_bitmap_add
 
   if (bitmap->u.elf32 == NULL)
     {
-      info->callbacks->einfo
+      info->callbacks->fatal
 	/* xgettext:c-format */
-	(_("%F%P: %pB: failed to allocate 32-bit DT_RELR bitmap\n"),
+	(_("%P: %pB: failed to allocate 32-bit DT_RELR bitmap\n"),
 	 info->output_bfd);
     }
 
@@ -1572,9 +1572,9 @@ elf_x86_size_or_finish_relative_reloc
 			  if (!_bfd_elf_mmap_section_contents (sec->owner,
 							       sec,
 							       &contents))
-			    info->callbacks->einfo
+			    info->callbacks->fatal
 			      /* xgettext:c-format */
-			      (_("%F%P: %pB: failed to allocate memory for section `%pA'\n"),
+			      (_("%P: %pB: failed to allocate memory for section `%pA'\n"),
 			       info->output_bfd, sec);
 
 			  /* Cache the section contents for
@@ -1759,9 +1759,9 @@ elf_x86_compute_dl_relr_bitmap
 	  *need_layout = true;
 	}
       else
-	info->callbacks->einfo
+	info->callbacks->fatal
 	  /* xgettext:c-format */
-	  (_("%F%P: %pB: size of compact relative reloc section is "
+	  (_("%P: %pB: size of compact relative reloc section is "
 	     "changed: new (%lu) != old (%lu)\n"),
 	   info->output_bfd, htab->dt_relr_bitmap.count,
 	   dt_relr_bitmap_count);
@@ -1781,9 +1781,9 @@ elf_x86_write_dl_relr_bitmap (struct bfd_link_info *info,
 
   contents = (unsigned char *) bfd_alloc (sec->owner, size);
   if (contents == NULL)
-    info->callbacks->einfo
+    info->callbacks->fatal
       /* xgettext:c-format */
-      (_("%F%P: %pB: failed to allocate compact relative reloc section\n"),
+      (_("%P: %pB: failed to allocate compact relative reloc section\n"),
        info->output_bfd);
 
   /* Cache the section contents for elf_link_input_bfd.  */
@@ -2252,9 +2252,9 @@ _bfd_elf_x86_valid_reloc_p (asection *input_section,
 	  else
 	    name = bfd_elf_sym_name (input_section->owner, symtab_hdr,
 				     sym, NULL);
-	  info->callbacks->einfo
+	  info->callbacks->fatal
 	    /* xgettext:c-format */
-	    (_("%F%P: %pB: relocation %s against absolute symbol "
+	    (_("%P: %pB: relocation %s against absolute symbol "
 	       "`%s' in section `%pA' is disallowed\n"),
 	     input_section->owner, internal_reloc.howto->name, name,
 	     input_section);
@@ -3594,9 +3594,9 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
 	    s = p->sec->output_section;
 	    if (s != NULL && (s->flags & SEC_READONLY) != 0)
 	      {
-		info->callbacks->einfo
+		info->callbacks->fatal
 		  /* xgettext:c-format */
-		  (_("%F%P: %pB: copy relocation against non-copyable "
+		  (_("%P: %pB: copy relocation against non-copyable "
 		     "protected symbol `%s' in %pB\n"),
 		   p->sec->owner, h->root.root.string,
 		   h->root.u.def.section->owner);
@@ -4347,12 +4347,12 @@ _bfd_x86_elf_link_setup_gnu_properties
 					      | SEC_HAS_CONTENTS
 					      | SEC_DATA));
 	  if (sec == NULL)
-	    info->callbacks->einfo (_("%F%P: failed to create GNU property section\n"));
+	    info->callbacks->fatal (_("%P: failed to create GNU property section\n"));
 
 	  if (!bfd_set_section_alignment (sec, class_align))
 	    {
 	    error_alignment:
-	      info->callbacks->einfo (_("%F%pA: failed to align section\n"),
+	      info->callbacks->fatal (_("%pA: failed to align section\n"),
 				      sec);
 	    }
 
@@ -4666,7 +4666,7 @@ _bfd_x86_elf_link_setup_gnu_properties
       && !elf_vxworks_create_dynamic_sections (dynobj, info,
 					       &htab->srelplt2))
     {
-      info->callbacks->einfo (_("%F%P: failed to create VxWorks dynamic sections\n"));
+      info->callbacks->fatal (_("%P: failed to create VxWorks dynamic sections\n"));
       return pbfd;
     }
 
@@ -4675,7 +4675,7 @@ _bfd_x86_elf_link_setup_gnu_properties
      don't need to do it in check_relocs.  */
   if (htab->elf.sgot == NULL
       && !_bfd_elf_create_got_section (dynobj, info))
-    info->callbacks->einfo (_("%F%P: failed to create GOT sections\n"));
+    info->callbacks->fatal (_("%P: failed to create GOT sections\n"));
 
   got_align = (bed->target_id == X86_64_ELF_DATA) ? 3 : 2;
 
@@ -4693,7 +4693,7 @@ _bfd_x86_elf_link_setup_gnu_properties
   /* Create the ifunc sections here so that check_relocs can be
      simplified.  */
   if (!_bfd_elf_create_ifunc_sections (dynobj, info))
-    info->callbacks->einfo (_("%F%P: failed to create ifunc sections\n"));
+    info->callbacks->fatal (_("%P: failed to create ifunc sections\n"));
 
   plt_alignment = bfd_log2 (htab->plt.plt_entry_size);
 
@@ -4731,7 +4731,7 @@ _bfd_x86_elf_link_setup_gnu_properties
 						    ".plt.got",
 						    pltflags);
 	  if (sec == NULL)
-	    info->callbacks->einfo (_("%F%P: failed to create GOT PLT section\n"));
+	    info->callbacks->fatal (_("%P: failed to create GOT PLT section\n"));
 
 	  if (!bfd_set_section_alignment (sec, non_lazy_plt_alignment))
 	    goto error_alignment;
@@ -4750,7 +4750,7 @@ _bfd_x86_elf_link_setup_gnu_properties
 							    ".plt.sec",
 							    pltflags);
 		  if (sec == NULL)
-		    info->callbacks->einfo (_("%F%P: failed to create IBT-enabled PLT section\n"));
+		    info->callbacks->fatal (_("%P: failed to create IBT-enabled PLT section\n"));
 
 		  if (!bfd_set_section_alignment (sec, plt_alignment))
 		    goto error_alignment;
@@ -4770,7 +4770,7 @@ _bfd_x86_elf_link_setup_gnu_properties
 						    ".eh_frame",
 						    flags);
 	  if (sec == NULL)
-	    info->callbacks->einfo (_("%F%P: failed to create PLT .eh_frame section\n"));
+	    info->callbacks->fatal (_("%P: failed to create PLT .eh_frame section\n"));
 
 	  if (!bfd_set_section_alignment (sec, class_align))
 	    goto error_alignment;
@@ -4783,7 +4783,7 @@ _bfd_x86_elf_link_setup_gnu_properties
 							".eh_frame",
 							flags);
 	      if (sec == NULL)
-		info->callbacks->einfo (_("%F%P: failed to create GOT PLT .eh_frame section\n"));
+		info->callbacks->fatal (_("%P: failed to create GOT PLT .eh_frame section\n"));
 
 	      if (!bfd_set_section_alignment (sec, class_align))
 		goto error_alignment;
@@ -4797,7 +4797,7 @@ _bfd_x86_elf_link_setup_gnu_properties
 							".eh_frame",
 							flags);
 	      if (sec == NULL)
-		info->callbacks->einfo (_("%F%P: failed to create the second PLT .eh_frame section\n"));
+		info->callbacks->fatal (_("%P: failed to create the second PLT .eh_frame section\n"));
 
 	      if (!bfd_set_section_alignment (sec, class_align))
 		goto error_alignment;
@@ -4817,7 +4817,7 @@ _bfd_x86_elf_link_setup_gnu_properties
 						    ".sframe",
 						    flags);
 	  if (sec == NULL)
-	    info->callbacks->einfo (_("%F%P: failed to create PLT .sframe section\n"));
+	    info->callbacks->fatal (_("%P: failed to create PLT .sframe section\n"));
 
 	  // FIXME check this
 	  // if (!bfd_set_section_alignment (sec, class_align))
@@ -4832,7 +4832,7 @@ _bfd_x86_elf_link_setup_gnu_properties
 							".sframe",
 							flags);
 	      if (sec == NULL)
-		info->callbacks->einfo (_("%F%P: failed to create second PLT .sframe section\n"));
+		info->callbacks->fatal (_("%P: failed to create second PLT .sframe section\n"));
 
 	      htab->plt_second_sframe = sec;
 	    }
@@ -4844,7 +4844,7 @@ _bfd_x86_elf_link_setup_gnu_properties
 							".sframe",
 							flags);
 	      if (sec == NULL)
-		info->callbacks->einfo (_("%F%P: failed to create PLT GOT .sframe section\n"));
+		info->callbacks->fatal (_("%P: failed to create PLT GOT .sframe section\n"));
 
 	      htab->plt_got_sframe = sec;
 	    }
diff --git a/bfd/linker.c b/bfd/linker.c
index e7f0c1ad404..3466391e19d 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -3036,7 +3036,7 @@ _bfd_generic_section_already_linked (bfd *abfd ATTRIBUTE_UNUSED,
 
   /* This is the first section with this name.  Record it.  */
   if (!bfd_section_already_linked_table_insert (already_linked_list, sec))
-    info->callbacks->einfo (_("%F%P: already_linked_table: %E\n"));
+    info->callbacks->fatal (_("%P: already_linked_table: %E\n"));
   return false;
 }
 
diff --git a/bfd/reloc.c b/bfd/reloc.c
index cbb56dd7679..d3ddafb7305 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -8366,8 +8366,8 @@ bfd_generic_relax_section (bfd *abfd ATTRIBUTE_UNUSED,
 			   bool *again)
 {
   if (bfd_link_relocatable (link_info))
-    (*link_info->callbacks->einfo)
-      (_("%P%F: --relax and -r may not be used together\n"));
+    link_info->callbacks->fatal
+      (_("%P: --relax and -r may not be used together\n"));
 
   *again = false;
   return true;
diff --git a/bfd/reloc16.c b/bfd/reloc16.c
index e77a2374f9b..2a90a1d6577 100644
--- a/bfd/reloc16.c
+++ b/bfd/reloc16.c
@@ -151,8 +151,8 @@ bfd_coff_reloc16_relax_section (bfd *abfd,
   long reloc_count;
 
   if (bfd_link_relocatable (link_info))
-    (*link_info->callbacks->einfo)
-      (_("%P%F: --relax and -r may not be used together\n"));
+    link_info->callbacks->fatal
+      (_("%P: --relax and -r may not be used together\n"));
 
   /* We only do global relaxation once.  It is not safe to do it multiple
      times (see discussion of the "shrinks" array below).  */
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 14eb008f967..446fa5a85f4 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -4677,7 +4677,7 @@ xcoff_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
   if (hstub->target_section != NULL
       && hstub->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    info->callbacks->einfo (_("%F%P: Could not assign `%pA' to an output section. "
+    info->callbacks->fatal (_("%P: Could not assign `%pA' to an output section. "
 			      "Retry without --enable-non-contiguous-regions.\n"),
 			    hstub->target_section);
 
diff --git a/include/bfdlink.h b/include/bfdlink.h
index ae451075996..3d4d71b3347 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -877,6 +877,9 @@ struct bfd_link_callbacks
     (struct bfd_link_info *, struct bfd_link_hash_entry *h,
      struct bfd_link_hash_entry *inh,
      bfd *abfd, asection *section, bfd_vma address, flagword flags);
+  /* Fatal error.  */
+  void (*fatal)
+    (const char *fmt, ...) ATTRIBUTE_NORETURN;
   /* Error or warning link info message.  */
   void (*einfo)
     (const char *fmt, ...);
diff --git a/ld/ldmain.c b/ld/ldmain.c
index cb5e58d8f36..54a834e42a6 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -148,6 +148,7 @@ static struct bfd_link_callbacks link_callbacks =
   reloc_dangerous,
   unattached_reloc,
   notice,
+  fatal,
   einfo,
   info_msg,
   minfo,


More information about the Binutils-cvs mailing list