Fix memory access violations triggered by running strip on fuzzed binaries.
authorNick Clifton <nickc@redhat.com>
Wed, 21 Jan 2015 17:37:23 +0000 (17:37 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 21 Jan 2015 17:37:23 +0000 (17:37 +0000)
PR binutils/17512
* coffcode.h (coff_set_arch_mach_hook): Check return value from
bfd_malloc.
(coff_slurp_line_table): Return FALSE if the line number
information was corrupt.
(coff_slurp_symbol_table): Return FALSE if the symbol information
was corrupt.
* mach-o.c (bfd_mach_o_bfd_copy_private_header_data): Always
initialise the fields of the dyld_info structure.
(bfd_mach_o_build_exec_seg_command): Replace assertion with an
error message and a return value.
(bfd_mach_o_layout_commands): Change the function to boolean.
Return FALSE if the function fails.
(bfd_mach_o_build_commands): Fail if bfd_mach_o_layout_commands
fails.
(bfd_mach_o_read_command): Fail if an unrecognised command is
encountered.
* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Set bfd_error if the
read fails.
(slurp_symtab): Check the return from bfd_malloc.
(_bfd_XX_bfd_copy_private_bfd_data_common): Fail if the copy
encountered an error.
(_bfd_XXi_final_link_postscript): Fail if a section could not be
copied.
* peicode.h (pe_bfd_object_p): Fail if the header could not be
swapped in.
* tekhex.c (first_phase): Fail if the section is too big.
* versados.c (struct esdid): Add content_size field.
(process_otr): Use and check the new field.
(versados_get_section_contents): Check that the section exists and
that the requested data is available.

PR binutils/17512
* addr2line.c (main): Call bfd_set_error_program_name.
* ar.c (main): Likewise.
* coffdump.c (main): Likewise.
* cxxfilt.c (main): Likewise.
* dlltool.c (main): Likewise.
* nlmconv.c (main): Likewise.
* nm.c (main): Likewise.
* objdump.c (main): Likewise.
* size.c (main): Likewise.
* srconv.c (main): Likewise.
* strings.c (main): Likewise.
* sysdump.c (main): Likewise.
* windmc.c (main): Likewise.
* windres.c (main): Likewise.
* objcopy.c (main): Likewise.
(copy_relocations_in_section): Check for relocs without associated
symbol pointers.

23 files changed:
bfd/ChangeLog
bfd/coffcode.h
bfd/mach-o.c
bfd/peXXigen.c
bfd/peicode.h
bfd/tekhex.c
bfd/versados.c
binutils/ChangeLog
binutils/addr2line.c
binutils/ar.c
binutils/coffdump.c
binutils/cxxfilt.c
binutils/dlltool.c
binutils/nlmconv.c
binutils/nm.c
binutils/objcopy.c
binutils/objdump.c
binutils/size.c
binutils/srconv.c
binutils/strings.c
binutils/sysdump.c
binutils/windmc.c
binutils/windres.c

index 3b15cef382649c63e0e3df8a2bd9ecfed8986371..ceb77ffe4efdc1284d3f8336d2c0e4967ec15061 100644 (file)
@@ -1,3 +1,37 @@
+2015-01-21  Nick Clifton  <nickc@redhat.com>
+
+       PR binutils/17512
+       * coffcode.h (coff_set_arch_mach_hook): Check return value from
+       bfd_malloc.
+       (coff_slurp_line_table): Return FALSE if the line number
+       information was corrupt.
+       (coff_slurp_symbol_table): Return FALSE if the symbol information
+       was corrupt.
+       * mach-o.c (bfd_mach_o_bfd_copy_private_header_data): Always
+       initialise the fields of the dyld_info structure.
+       (bfd_mach_o_build_exec_seg_command): Replace assertion with an
+       error message and a return value.
+       (bfd_mach_o_layout_commands): Change the function to boolean.
+       Return FALSE if the function fails.
+       (bfd_mach_o_build_commands): Fail if bfd_mach_o_layout_commands
+       fails.
+       (bfd_mach_o_read_command): Fail if an unrecognised command is
+       encountered.
+       * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Set bfd_error if the
+       read fails.
+       (slurp_symtab): Check the return from bfd_malloc.
+       (_bfd_XX_bfd_copy_private_bfd_data_common): Fail if the copy
+       encountered an error.
+       (_bfd_XXi_final_link_postscript): Fail if a section could not be
+       copied.
+       * peicode.h (pe_bfd_object_p): Fail if the header could not be
+       swapped in.
+       * tekhex.c (first_phase): Fail if the section is too big.
+       * versados.c (struct esdid): Add content_size field.
+       (process_otr): Use and check the new field.
+       (versados_get_section_contents): Check that the section exists and
+       that the requested data is available.
+
 2015-01-20  Chung-Lin Tang  <cltang@codesourcery.com>
 
        * elf32-nios2.c (elf_backend_default_execstack): Define as 0.
index 9e1c20acf38963e4f210ed5299242d5b70b84f3c..181f9af15b47f9d42fc45aaf86d3be5102372cd9 100644 (file)
@@ -2073,10 +2073,14 @@ coff_mkobject_hook (bfd * abfd,
 #endif
 
   if ((internal_f->f_flags & F_GO32STUB) != 0)
-    coff->go32stub = (char *) bfd_alloc (abfd, (bfd_size_type) GO32_STUBSIZE);
+    {
+      coff->go32stub = (char *) bfd_alloc (abfd, (bfd_size_type) GO32_STUBSIZE);
+      if (coff->go32stub == NULL)
+       return NULL;
+    }
   if (coff->go32stub != NULL)
     memcpy (coff->go32stub, internal_f->go32stub, GO32_STUBSIZE);
-
+  
   return coff;
 }
 #endif
@@ -2278,6 +2282,8 @@ coff_set_arch_mach_hook (bfd *abfd, void * filehdr)
                bfd_size_type amt = bfd_coff_symesz (abfd);
 
                buf = bfd_malloc (amt);
+               if (buf == NULL)
+                 return FALSE;
                if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
                    || bfd_bread (buf, amt, abfd) != amt)
                  {
@@ -2666,10 +2672,16 @@ coff_write_relocs (bfd * abfd, int first_undef)
        amt = s->reloc_count;
        amt *= sizeof (arelent *);
        p = bfd_malloc (amt);
-       if (p == NULL && s->reloc_count > 0)
-         return FALSE;
-       memcpy (p, s->orelocation, (size_t) amt);
-       qsort (p, s->reloc_count, sizeof (arelent *), compare_arelent_ptr);
+       if (p == NULL)
+         {
+           if (s->reloc_count > 0)
+             return FALSE;
+         }
+       else
+         {
+           memcpy (p, s->orelocation, (size_t) amt);
+           qsort (p, s->reloc_count, sizeof (arelent *), compare_arelent_ptr);
+         }
       }
 #endif
 
@@ -4526,6 +4538,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
   unsigned int nbr_func;
   LINENO *src;
   bfd_boolean have_func;
+  bfd_boolean ret = TRUE;
 
   BFD_ASSERT (asect->lineno == NULL);
 
@@ -4575,6 +4588,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
                (_("%B: warning: illegal symbol index 0x%lx in line number entry %d"),
                 abfd, (long) symndx, counter);
              cache_ptr->line_number = -1;
+             ret = FALSE;
              continue;
            }
 
@@ -4587,6 +4601,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
                (_("%B: warning: illegal symbol index 0x%lx in line number entry %d"),
                 abfd, (long) symndx, counter);
              cache_ptr->line_number = -1;
+             ret = FALSE;
              continue;
            }
          sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
@@ -4599,6 +4614,7 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
                (_("%B: warning: illegal symbol in line number entry %d"),
                 abfd, counter);
              cache_ptr->line_number = -1;
+             ret = FALSE;
              continue;
            }
 
@@ -4678,11 +4694,15 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
 
              memcpy (lineno_cache, n_lineno_cache, amt);
            }
+         else
+           ret = FALSE;
          bfd_release (abfd, func_table);
        }
+      else
+       ret = FALSE;
     }
 
-  return TRUE;
+  return ret;
 }
 
 /* Slurp in the symbol table, converting it to generic form.  Note
@@ -4697,6 +4717,7 @@ coff_slurp_symbol_table (bfd * abfd)
   unsigned int *table_ptr;
   bfd_size_type amt;
   unsigned int number_of_symbols = 0;
+  bfd_boolean ret = TRUE;
 
   if (obj_symbols (abfd))
     return TRUE;
@@ -5017,6 +5038,7 @@ coff_slurp_symbol_table (bfd * abfd)
                (_("%B: Unrecognized storage class %d for %s symbol `%s'"),
                 abfd, src->u.syment.n_sclass,
                 dst->symbol.section->name, dst->symbol.name);
+             ret = FALSE;
            case C_EXTLAB:      /* External load time label.  */
            case C_HIDDEN:      /* Ext symbol in dmert public lib.  */
              dst->symbol.flags = BSF_DEBUGGING;
@@ -5052,7 +5074,7 @@ coff_slurp_symbol_table (bfd * abfd)
       }
   }
 
-  return TRUE;
+  return ret;
 }
 
 /* Classify a COFF symbol.  A couple of targets have globally visible
index 44b12b5047f16d803d33f003c32356d858c6208b..e136c2d3994052c9b2621e8bebd661bce29072a3 100644 (file)
@@ -690,6 +690,20 @@ bfd_mach_o_bfd_copy_private_header_data (bfd *ibfd, bfd *obfd)
                ody->export_size = idy->export_size;
                ody->export_content = idy->export_content;
              }
+           /* PR 17512L: file: 730e492d.  */
+           else
+             {
+               ody->rebase_size = 
+                 ody->bind_size = 
+                 ody->weak_bind_size = 
+                 ody->lazy_bind_size = 
+                 ody->export_size = 0;
+               ody->rebase_content = 
+                 ody->bind_content = 
+                 ody->weak_bind_content = 
+                 ody->lazy_bind_content = 
+                 ody->export_content = NULL;
+             }
          }
          break;
 
@@ -2764,7 +2778,14 @@ bfd_mach_o_build_exec_seg_command (bfd *abfd, bfd_mach_o_segment_command *seg)
 
       bfd_mach_o_append_section_to_segment (seg, s);
 
-      BFD_ASSERT (s->addr >= vma);
+      if (s->addr < vma)
+       {
+         (*_bfd_error_handler)
+           (_("section address (%lx) below start of segment (%lx)"),
+              (unsigned long) s->addr, (unsigned long) vma);
+         return FALSE;
+       }
+
       vma = s->addr + s->size;
     }
 
@@ -2839,7 +2860,7 @@ bfd_mach_o_build_exec_seg_command (bfd *abfd, bfd_mach_o_segment_command *seg)
 /* Layout the commands: set commands size and offset, set ncmds and sizeofcmds
    fields in header.  */
 
-static void
+static bfd_boolean
 bfd_mach_o_layout_commands (bfd_mach_o_data_struct *mdata)
 {
   unsigned wide = mach_o_wide_p (&mdata->header);
@@ -2847,6 +2868,7 @@ bfd_mach_o_layout_commands (bfd_mach_o_data_struct *mdata)
   ufile_ptr offset;
   bfd_mach_o_load_command *cmd;
   unsigned int align;
+  bfd_boolean ret = TRUE;
 
   hdrlen = wide ? BFD_MACH_O_HEADER_64_SIZE : BFD_MACH_O_HEADER_SIZE;
   align = wide ? 8 - 1 : 4 - 1;
@@ -2902,6 +2924,7 @@ bfd_mach_o_layout_commands (bfd_mach_o_data_struct *mdata)
          (*_bfd_error_handler)
            (_("unable to layout unknown load command 0x%lx"),
             (unsigned long) cmd->type);
+         ret = FALSE;
          break;
        }
 
@@ -2910,6 +2933,8 @@ bfd_mach_o_layout_commands (bfd_mach_o_data_struct *mdata)
     }
   mdata->header.sizeofcmds = offset - hdrlen;
   mdata->filelen = offset;
+
+  return ret;
 }
 
 /* Subroutine of bfd_mach_o_build_commands: set type, name and nsects of a
@@ -3044,8 +3069,7 @@ bfd_mach_o_build_commands (bfd *abfd)
   if (nbr_commands == 0)
     {
       /* Layout commands (well none...) and set headers command fields.  */
-      bfd_mach_o_layout_commands (mdata);
-      return TRUE;
+      return bfd_mach_o_layout_commands (mdata);
     }
 
   /* Create commands for segments (and symtabs), prepend them.  */
@@ -3128,7 +3152,8 @@ bfd_mach_o_build_commands (bfd *abfd)
     }
 
   /* Layout commands.  */
-  bfd_mach_o_layout_commands (mdata);
+  if (! bfd_mach_o_layout_commands (mdata))
+    return FALSE;
 
   /* So, now we have sized the commands and the filelen set to that.
      Now we can build the segment command and set the section file offsets.  */
@@ -4687,21 +4712,10 @@ bfd_mach_o_read_command (bfd *abfd, bfd_mach_o_load_command *command)
        return FALSE;
       break;
     default:
-      {
-       static bfd_boolean unknown_set = FALSE;
-       static unsigned long unknown_command = 0;
-
-       /* Prevent reams of error messages when parsing corrupt binaries.  */
-       if (!unknown_set)
-         unknown_set = TRUE;
-       else if (command->type == unknown_command)
-         break;
-       unknown_command = command->type;
-
-       (*_bfd_error_handler)(_("%B: unknown load command 0x%lx"),
-                             abfd, (unsigned long) command->type);
-       break;
-      }
+      command->len = 0;
+      (*_bfd_error_handler)(_("%B: unknown load command 0x%lx"),
+                           abfd, (unsigned long) command->type);
+      return FALSE;
     }
 
   return TRUE;
index 0abe609f2e83a367c0b43de087f360df175620e0..122ddf125643e1a66bfd1d396a8110791540bc97 100644 (file)
@@ -526,6 +526,8 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd,
        (*_bfd_error_handler)
          (_("%B: aout header specifies an invalid number of data-directory entries: %d"),
           abfd, a->NumberOfRvaAndSizes);
+       bfd_set_error (bfd_error_bad_value);
+
        /* Paranoia: If the number is corrupt, then assume that the
           actual entries themselves might be corrupt as well.  */
        a->NumberOfRvaAndSizes = 0;
@@ -2007,7 +2009,11 @@ slurp_symtab (bfd *abfd, sym_cache *psc)
   if (storage < 0)
     return NULL;
   if (storage)
-    sy = (asymbol **) bfd_malloc (storage);
+    {
+      sy = (asymbol **) bfd_malloc (storage);
+      if (sy == NULL)
+       return NULL;
+    }
 
   psc->symcount = bfd_canonicalize_symtab (abfd, sy);
   if (psc->symcount < 0)
@@ -2963,8 +2969,16 @@ _bfd_XX_bfd_copy_private_bfd_data_common (bfd * ibfd, bfd * obfd)
             }
 
           if (!bfd_set_section_contents (obfd, section, data, 0, section->size))
-            _bfd_error_handler (_("Failed to update file offsets in debug directory"));
+           {
+             _bfd_error_handler (_("Failed to update file offsets in debug directory"));
+             return FALSE;
+           }
         }
+      else if (section)
+       {
+         _bfd_error_handler (_("%A: Failed to read debug data section"), obfd);
+         return FALSE;
+       }
     }
 
   return TRUE;
@@ -4475,6 +4489,8 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo)
              }
            free (tmp_data);
          }
+       else
+         result = FALSE;
       }
   }
 #endif
index 92deb11895836e1d2c613da7bbb705f19dcde21b..e36568aa2070ab5fa5282c0ddcf19f934d039a2e 100644 (file)
@@ -1343,7 +1343,10 @@ pe_bfd_object_p (bfd * abfd)
          != (bfd_size_type) opt_hdr_size)
        return NULL;
 
+      bfd_set_error (bfd_error_no_error);
       bfd_coff_swap_aouthdr_in (abfd, opthdr, & internal_a);
+      if (bfd_get_error () != bfd_error_no_error)
+       return NULL;
     }
 
   return coff_real_object_p (abfd, internal_f.f_nscns, &internal_f,
index 94b47739f561675db231cb934f4b08e6c9ba9dcd..63d7d8de5e073d1a752d24330163618cf928e672 100644 (file)
@@ -407,7 +407,13 @@ first_phase (bfd *abfd, int type, char *src, char * src_end)
                return FALSE;
              if (!getvalue (&src, &val, src_end))
                return FALSE;
+             if (val < section->vma)
+               val = section->vma;
              section->size = val - section->vma;
+             /* PR 17512: file: objdump-s-endless-loop.tekhex.
+                Check for overlarge section sizes.  */
+             if (section->size & 0x80000000)
+               return FALSE;
              section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
              break;
            case '0':
index 95f5f538c877de83ef8e6fa824340366035af5b5..25403141d87ed31a3f28f3263db2e5f99e9efd8b 100644 (file)
@@ -57,6 +57,7 @@ struct esdid
 {
   asection *section;           /* Ptr to bfd version.  */
   unsigned char *contents;     /* Used to build image.  */
+  bfd_size_type content_size;  /* The size of the contents buffer.  */
   int pc;
   int relocs;                  /* Reloc count, valid end of pass 1.  */
   int donerel;                 /* Have relocs been translated.  */
@@ -406,7 +407,7 @@ process_otr (bfd *abfd, struct ext_otr *otr, int pass)
 
              if (pass == 1)
                need_contents = TRUE;
-             else if (contents && dst_idx < esdid->section->size - sizeinwords * 2)
+             else if (contents && dst_idx < esdid->content_size - sizeinwords * 2)
                for (j = 0; j < sizeinwords * 2; j++)
                  {
                    contents[dst_idx + (sizeinwords * 2) - j - 1] = val;
@@ -449,7 +450,7 @@ process_otr (bfd *abfd, struct ext_otr *otr, int pass)
        {
          need_contents = TRUE;
 
-         if (esdid->section && contents && dst_idx < esdid->section->size)
+         if (esdid->section && contents && dst_idx < esdid->content_size - 1)
            if (pass == 2)
              {
                /* Absolute code, comes in 16 bit lumps.  */
@@ -472,6 +473,7 @@ process_otr (bfd *abfd, struct ext_otr *otr, int pass)
 
          size = esdid->section->size;
          esdid->contents = bfd_alloc (abfd, size);
+         esdid->content_size = size;
        }
       else
        esdid->contents = NULL;
@@ -686,12 +688,20 @@ versados_get_section_contents (bfd *abfd,
                               file_ptr offset,
                               bfd_size_type count)
 {
+  struct esdid *esdid;
+
   if (!versados_pass_2 (abfd))
     return FALSE;
 
-  memcpy (location,
-         EDATA (abfd, section->target_index).contents + offset,
-         (size_t) count);
+  esdid = &EDATA (abfd, section->target_index);
+
+  if (esdid->contents == NULL
+      || offset < 0
+      || (bfd_size_type) offset > esdid->content_size
+      || offset + count > esdid->content_size)
+    return FALSE;
+
+  memcpy (location, esdid->contents + offset, (size_t) count);
 
   return TRUE;
 }
index 78f0a20fcf2e446b1175fb0ad23d49f5c4bc4fe7..1d1ba9d800e886993468a45ff6477c1f2e708137 100644 (file)
@@ -1,3 +1,24 @@
+2015-01-21  Nick Clifton  <nickc@redhat.com>
+
+       PR binutils/17512
+       * addr2line.c (main): Call bfd_set_error_program_name.
+       * ar.c (main): Likewise.
+       * coffdump.c (main): Likewise.
+       * cxxfilt.c (main): Likewise.
+       * dlltool.c (main): Likewise.
+       * nlmconv.c (main): Likewise.
+       * nm.c (main): Likewise.
+       * objdump.c (main): Likewise.
+       * size.c (main): Likewise.
+       * srconv.c (main): Likewise.
+       * strings.c (main): Likewise.
+       * sysdump.c (main): Likewise.
+       * windmc.c (main): Likewise.
+       * windres.c (main): Likewise.
+       * objcopy.c (main): Likewise.
+       (copy_relocations_in_section): Check for relocs without associated
+       symbol pointers.
+
 2015-01-21  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
 
        * MAINTAINERS: Add self to ARM maintainers list.
index 9d2abe6e2f575cbb9b6dcbe39b6f94ad2348a38b..d37145e9e53a39c48b2fc55631385aa9712f8bcf 100644 (file)
@@ -423,6 +423,7 @@ main (int argc, char **argv)
 
   program_name = *argv;
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&argc, &argv);
 
index 48a052c2a8cde930edb55f92d2c25747fafd9c8c..94c79e21540e2241db80b3a5291df29d06da248d 100644 (file)
@@ -691,6 +691,7 @@ main (int argc, char **argv)
 
   program_name = argv[0];
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 #if BFD_SUPPORTS_PLUGINS
   bfd_plugin_set_program_name (program_name);
 #endif
index 9883e22cffb556fddfea71098c904daf613fb36d..90ce55032e6d2e60ec871fc4428bfdf0b4077a3d 100644 (file)
@@ -500,6 +500,7 @@ main (int ac, char **av)
 
   program_name = av[0];
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&ac, &av);
 
index 2daf33bee2cf309ad34571fdbc313c7da7fc2cd7..2da511fe8d8b35f42ac5fc5abac5eec967391ff5 100644 (file)
@@ -176,6 +176,7 @@ main (int argc, char **argv)
 
   program_name = argv[0];
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&argc, &argv);
 
index 10204b08885340a2a9af958a9eb7a3f6ee2226e5..dcc46518b5321a10f0596fdf6f550a2dcfcbc427 100644 (file)
@@ -4044,6 +4044,7 @@ main (int ac, char **av)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  bfd_set_error_program_name (program_name);
   expandargv (&ac, &av);
 
   while ((c = getopt_long (ac, av,
index 8c4975df979c81cf3517706bbeed3cb73100a134..ac411993608fc49dec5108b9cad1d9e3a7fc557c 100644 (file)
@@ -211,6 +211,7 @@ main (int argc, char **argv)
 
   program_name = argv[0];
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&argc, &argv);
 
index 76013df45b0c502760bf9641a284534105b53ddb..a8f2f7059d13043b6f62a31af710f6ba10b09087 100644 (file)
@@ -1570,6 +1570,7 @@ main (int argc, char **argv)
 
   program_name = *argv;
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 #if BFD_SUPPORTS_PLUGINS
   bfd_plugin_set_program_name (program_name);
 #endif
index 9524bb85de51f531c3b9de9dfb3591c2c9b47f39..8320793bba481b83d9155582e4a4f1df80f8be4b 100644 (file)
@@ -2960,9 +2960,13 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
 
          temp_relpp = (arelent **) xmalloc (relsize);
          for (i = 0; i < relcount; i++)
-           if (is_specified_symbol (bfd_asymbol_name (*relpp[i]->sym_ptr_ptr),
-                                    keep_specific_htab))
-             temp_relpp [temp_relcount++] = relpp [i];
+           {
+             /* PR 17512: file: 9e907e0c.  */
+             if (relpp[i]->sym_ptr_ptr)
+               if (is_specified_symbol (bfd_asymbol_name (*relpp[i]->sym_ptr_ptr),
+                                        keep_specific_htab))
+                 temp_relpp [temp_relcount++] = relpp [i];
+           }
          relcount = temp_relcount;
          free (relpp);
          relpp = temp_relpp;
@@ -4411,6 +4415,9 @@ main (int argc, char *argv[])
 
   create_symbol_htabs ();
 
+  if (argv != NULL)
+    bfd_set_error_program_name (argv[0]);
+
   if (is_strip)
     strip_main (argc, argv);
   else
index 22e5ad66d880f05b44698bffd622d3a8158426b6..54fc235a5ae4381819e366b5981f62e659fb9791 100644 (file)
@@ -3495,6 +3495,7 @@ main (int argc, char **argv)
 
   program_name = *argv;
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   START_PROGRESS (program_name, 0);
 
index 465603f243dee0a1ddea3e598c0edf6fcb1fe3de..dcfd9547b25cdd58db890f9fe0dc9a3ba9228d89 100644 (file)
@@ -133,6 +133,7 @@ main (int argc, char **argv)
 
   program_name = *argv;
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&argc, &argv);
 
index c19c0ed75a8bcbada04520455dae682b945ad69a..63c6940e36cd7f8f72ff47881116f408cef9f17c 100644 (file)
@@ -1774,6 +1774,7 @@ main (int ac, char **av)
 
   program_name = av[0];
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&ac, &av);
 
index 8f215e52a4072455c9c5755134ff520aeb3efcd0..0e2c9a8b9147a228c77cb154b01770c6fdd548f1 100644 (file)
@@ -164,6 +164,7 @@ main (int argc, char **argv)
 
   program_name = argv[0];
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&argc, &argv);
 
index ac350e1513e4331d106bb5ab4543a5545ce8cf3f..177262c9b1beb872620a548b8eefd1e5ec7504c8 100644 (file)
@@ -686,6 +686,7 @@ main (int ac, char **av)
 
   program_name = av[0];
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&ac, &av);
 
index 5fd8cd5fb2c20ed11a4f671e1c4eb8f34f38d7b8..c78ae1f833a92f2aaad4b0fd391b0076c205d99e 100644 (file)
@@ -952,6 +952,7 @@ main (int argc, char **argv)
 
   program_name = argv[0];
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&argc, &argv);
 
index 00939b0d8eb1c1b0d42216227771206acd020709..2fed128df7020df113196ef610567d32fe5d9044 100644 (file)
@@ -808,6 +808,7 @@ main (int argc, char **argv)
 
   program_name = argv[0];
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&argc, &argv);