Non-contiguous memory regions support: Avoid calls to abort
authorChristophe Lyon <christophe.lyon@linaro.org>
Tue, 17 Mar 2020 15:59:01 +0000 (15:59 +0000)
committerChristophe Lyon <christophe.lyon@linaro.org>
Wed, 18 Mar 2020 10:09:43 +0000 (10:09 +0000)
Use '%F' format when printing error messages to exit cleanly rather
than by calling abort().

2020-03-18  Christophe Lyon  <christophe.lyon@linaro.org>

bfd/
* elf32-arm.c (arm_build_one_stub): Emit a fatal error message
instead of calling abort.
* elf32-csky.c (csky_build_one_stub): Likewise.
* elf32-hppa.c (hppa_build_one_stub): Likewise.
* elf32-m68hc11.c (m68hc11_elf_build_one_stub): Likewise.
* elf32-m68hc12.c (m68hc12_elf_build_one_stub): Likewise.
* elf32-metag.c (metag_build_one_stub): Likewise.
* elf32-nios2.c (nios2_build_one_stub): Likewise.
* elf64-ppc.c (ppc_build_one_stub): Likewise.
(ppc_size_one_stub): Likewise.
* elfnn-aarch64.c (aarch64_build_one_stub): Likewise.

ld/
* emultempl/xtensaelf.em: Emit a fatal error message
instead of calling abort.
* ldlang.c: Likewise.

Change-Id: I60deaeeee59d4e7cab06b8a40a3e51837c43a8ab

13 files changed:
bfd/ChangeLog
bfd/elf32-arm.c
bfd/elf32-csky.c
bfd/elf32-hppa.c
bfd/elf32-m68hc11.c
bfd/elf32-m68hc12.c
bfd/elf32-metag.c
bfd/elf32-nios2.c
bfd/elf64-ppc.c
bfd/elfnn-aarch64.c
ld/ChangeLog
ld/emultempl/xtensaelf.em
ld/ldlang.c

index f690147280749b1f49c00d1059949cc8103aa17f..2780b76a907b503021b32d2c8c7d21cbd0f19aa0 100644 (file)
@@ -1,3 +1,17 @@
+2020-03-18  Christophe Lyon  <christophe.lyon@linaro.org>
+
+       * elf32-arm.c (arm_build_one_stub): Emit a fatal error message
+       instead of calling abort.
+       * elf32-csky.c (csky_build_one_stub): Likewise.
+       * elf32-hppa.c (hppa_build_one_stub): Likewise.
+       * elf32-m68hc11.c (m68hc11_elf_build_one_stub): Likewise.
+       * elf32-m68hc12.c (m68hc12_elf_build_one_stub): Likewise.
+       * elf32-metag.c (metag_build_one_stub): Likewise.
+       * elf32-nios2.c (nios2_build_one_stub): Likewise.
+       * elf64-ppc.c (ppc_build_one_stub): Likewise.
+       (ppc_size_one_stub): Likewise.
+       * elfnn-aarch64.c (aarch64_build_one_stub): Likewise.
+
 2020-03-17  Nick Clifton  <nickc@redhat.com>
 
        PR 25688
index e8b2ac4702ad6eec2271316461fa3d943866c088..1ccbf143e0aea0ec5c5218285ba110ee8d06b9b0 100644 (file)
@@ -5068,12 +5068,9 @@ 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)
-    {
-      _bfd_error_handler (_("Could not assign '%pA' to an output section. "
-                           "Retry without --enable-non-contiguous-regions.\n"),
-                         stub_entry->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. "
+                             "Retry without --enable-non-contiguous-regions.\n"),
+                           stub_entry->target_section);
 
   globals = elf32_arm_hash_table (info);
   if (globals == NULL)
index 8415f7c5ec875a50501eac78b52de6cd1feff6f5..06ea26632d147fc01aaf7387cb8f98417bc7d575 100644 (file)
@@ -3625,12 +3625,9 @@ 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)
-    {
-      _bfd_error_handler (_("Could not assign '%pA' to an output section. "
-                           "Retry without --enable-non-contiguous-regions.\n"),
-                         stub_entry->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. "
+                             "Retry without --enable-non-contiguous-regions.\n"),
+                           stub_entry->target_section);
 
   globals = csky_elf_hash_table (info);
   if (globals == NULL)
index 9760b751612b6dde409316e53b9d257f1e6622bd..6d5382dc26de4a0d9300f80dbebc295e410dd5ca 100644 (file)
@@ -735,12 +735,10 @@ 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)
-       {
-         _bfd_error_handler (_("Could not assign '%pA' to an output section. "
-                               "Retry without --enable-non-contiguous-regions.\n"),
-                             hsh->target_section);
-         abort();
-    }
+       info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output "
+                                 "section. Retry without "
+                                 "--enable-non-contiguous-regions.\n"),
+                               hsh->target_section);
 
       /* Create the long branch.  A long branch is formed with "ldil"
         loading the upper bits of the target address into a register,
@@ -766,12 +764,11 @@ 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)
-       {
-         _bfd_error_handler (_("Could not assign %pA to an output section. "
-                               "Retry without --enable-non-contiguous-regions.\n"),
-                             hsh->target_section);
-         abort();
-    }
+       info->callbacks->einfo (_("%F%P: Could not assign %pA to an output "
+                                 "section. Retry without "
+                                 "--enable-non-contiguous-regions.\n"),
+                               hsh->target_section);
+
       /* Branches are relative.  This is where we are going to.  */
       sym_value = (hsh->target_value
                   + hsh->target_section->output_offset
@@ -848,12 +845,11 @@ 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)
-       {
-         _bfd_error_handler (_("Could not assign %pA to an output section. "
-                               "Retry without --enable-non-contiguous-regions.\n"),
-                             hsh->target_section);
-         abort();
-    }
+       info->callbacks->einfo (_("%F%P: Could not assign %pA to an output "
+                                 "section. Retry without "
+                                 "--enable-non-contiguous-regions.\n"),
+                               hsh->target_section);
+
       /* Branches are relative.  This is where we are going to.  */
       sym_value = (hsh->target_value
                   + hsh->target_section->output_offset
index 3e12ae5e44031fd65399873574f0a406a6b4f08f..46aa43806310de287602041a33c32b52c0c2d068 100644 (file)
@@ -419,12 +419,9 @@ 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)
-    {
-      _bfd_error_handler (_("Could not assign '%pA' to an output section. "
-                           "Retry without --enable-non-contiguous-regions.\n"),
-                         stub_entry->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. "
+                             "Retry without --enable-non-contiguous-regions.\n"),
+                           stub_entry->target_section);
 
   htab = m68hc11_elf_hash_table (info);
   if (htab == NULL)
index a04efd84e0bd04cc861df1a85d92e4e11e0c5510..c74f5674db7d6db870f4be24f583fa520b9b934b 100644 (file)
@@ -539,12 +539,9 @@ 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)
-    {
-      _bfd_error_handler (_("Could not assign '%pA' to an output section. "
-                           "Retry without --enable-non-contiguous-regions.\n"),
-                         stub_entry->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. "
+                             "Retry without --enable-non-contiguous-regions.\n"),
+                           stub_entry->target_section);
 
   htab = m68hc11_elf_hash_table (info);
 
index 3f30d6dadd9e9afdef5a5b3fc55ef122384d712a..44923edc7b4fc1335eeb4cff35389306b38a6a77 100644 (file)
@@ -3477,12 +3477,9 @@ 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)
-    {
-      _bfd_error_handler (_("Could not assign '%pA' to an output section. "
-                           "Retry without --enable-non-contiguous-regions.\n"),
-                         hsh->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. "
+                             "Retry without --enable-non-contiguous-regions.\n"),
+                           hsh->target_section);
 
   stub_sec = hsh->stub_sec;
 
index 8c8bc0c8f8017d369c5c238bc69cd46230c0af67..bfb6fd16325666ed508be3dff46f009675bf6d0a 100644 (file)
@@ -2498,12 +2498,10 @@ nios2_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg ATTRIBUTE_U
      section.  The user should fix his linker script.  */
   if (hsh->target_section->output_section == NULL
       && info->non_contiguous_regions)
-    {
-      _bfd_error_handler (_("Could not assign '%pA' to an output section. "
-                           "Retry without --enable-non-contiguous-regions.\n"),
-                         hsh->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. "
+                             "Retry without --enable-non-contiguous-regions.\n"),
+                           hsh->target_section);
+
   /* Make a note of the offset within the stubs for this entry.  */
   hsh->stub_offset = stub_sec->size;
 
index 83eaadfb0d9559284d5842dcbb39357fe25f240b..7f7e190ce2b656d31ba1f163010adcccc924c645 100644 (file)
@@ -11367,25 +11367,19 @@ ppc_build_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)
-    {
-      _bfd_error_handler (_("Could not assign '%pA' to an output section. "
-                           "Retry without --enable-non-contiguous-regions.\n"),
-                         stub_entry->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. "
+                             "Retry without --enable-non-contiguous-regions.\n"),
+                           stub_entry->target_section);
 
   /* Same for the group.  */
   if (stub_entry->group->stub_sec != NULL
       && stub_entry->group->stub_sec->output_section == NULL
       && info->non_contiguous_regions)
-    {
-      _bfd_error_handler (_("Could not assign group %pA target %pA to an "
-                           "output section. Retry without "
-                           "--enable-non-contiguous-regions.\n"),
-                         stub_entry->group->stub_sec,
-                         stub_entry->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign group %pA target %pA to an "
+                             "output section. Retry without "
+                             "--enable-non-contiguous-regions.\n"),
+                           stub_entry->group->stub_sec,
+                           stub_entry->target_section);
 
   htab = ppc_hash_table (info);
   if (htab == NULL)
@@ -11917,25 +11911,19 @@ 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)
-    {
-      _bfd_error_handler (_("Could not assign %pA to an output section. "
-                           "Retry without --enable-non-contiguous-regions.\n"),
-                         stub_entry->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign %pA to an output section. "
+                             "Retry without --enable-non-contiguous-regions.\n"),
+                           stub_entry->target_section);
 
   /* Same for the group.  */
   if (stub_entry->group->stub_sec != NULL
       && stub_entry->group->stub_sec->output_section == NULL
       && info->non_contiguous_regions)
-    {
-      _bfd_error_handler (_("Could not assign group %pA target %pA to an "
-                           "output section. Retry without "
-                           "--enable-non-contiguous-regions.\n"),
-                         stub_entry->group->stub_sec,
-                         stub_entry->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign group %pA target %pA to an "
+                             "output section. Retry without "
+                             "--enable-non-contiguous-regions.\n"),
+                           stub_entry->group->stub_sec,
+                           stub_entry->target_section);
 
   /* Make a note of the offset within the stubs for this entry.  */
   stub_entry->stub_offset = stub_entry->group->stub_sec->size;
index b00b6c4818f9b2620849f5f91d2b7052bd1788b9..02688ccee10c145a5578e2ee8158d69373a8fd9b 100644 (file)
@@ -3302,12 +3302,10 @@ 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)
-    {
-      _bfd_error_handler (_("Could not assign '%pA' to an output section. "
-                           "Retry without --enable-non-contiguous-regions.\n"),
-                         stub_entry->target_section);
-      abort();
-    }
+    info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. "
+                             "Retry without "
+                             "--enable-non-contiguous-regions.\n"),
+                           stub_entry->target_section);
 
   stub_sec = stub_entry->stub_sec;
 
index 79fd3bef013090c71de744c03a311f716b509477..f8ee247ed746e447a755d1f4c4a13c74847caf17 100644 (file)
@@ -1,3 +1,9 @@
+2020-03-18  Christophe Lyon  <christophe.lyon@linaro.org>
+
+       * emultempl/xtensaelf.em: Emit a fatal error message
+       instead of calling abort.
+       * ldlang.c: Likewise.
+
 2020-03-14  Alan Modra  <amodra@gmail.com>
 
        * testsuite/ld-elf/non-contiguous.d: Don't xfail generic ELF
index 74bd11c6b00092ce08e0f626b358c5928bf60c7d..2d9f594969f54a3e6a8065e72e731fa0342a1a93 100644 (file)
@@ -1225,10 +1225,8 @@ ld_build_required_section_dependence (lang_statement_union_type *s)
       lang_statement_union_type *l = iter_stack_current (&stack);
 
       if (l == NULL && link_info.non_contiguous_regions)
-       {
-         einfo (_("Relaxation not supported with --enable-non-contiguous-regions.\n"));
-         abort();
-       }
+       einfo (_("%F%P: Relaxation not supported with "
+                "--enable-non-contiguous-regions.\n"));
 
       if (l->header.type == lang_input_section_enum)
        {
index 8e56e8678fb16f0c87ac8062d3635ca92fb9a6f6..0bb5f3c044c23f3ea3c8ddb1b9e70bc27ebf8076 100644 (file)
@@ -5220,21 +5220,15 @@ size_input_section
              if (dot + TO_ADDR (i->size) > end)
                {
                  if (i->flags & SEC_LINKER_CREATED)
-                   {
-                     einfo (_("Output section '%s' not large enough for the "
-                              "linker-created stubs section '%s'.\n"),
-                            i->output_section->name, i->name);
-                     abort();
-                   }
+                   einfo (_("%F%P: Output section '%s' not large enough for the "
+                            "linker-created stubs section '%s'.\n"),
+                          i->output_section->name, i->name);
 
                  if (i->rawsize && i->rawsize != i->size)
-                   {
-                     einfo (_("Relaxation not supported with "
-                              "--enable-non-contiguous-regions (section '%s' "
-                              "would overflow '%s' after it changed size).\n"),
-                            i->name, i->output_section->name);
-                     abort();
-                   }
+                   einfo (_("%F%P: Relaxation not supported with "
+                            "--enable-non-contiguous-regions (section '%s' "
+                            "would overflow '%s' after it changed size).\n"),
+                          i->name, i->output_section->name);
 
                  *removed = 1;
                  dot = end;