Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / archive.c
index 6fc5f1d80f9ef8be456c45b35bcea42ff3436086..0b98df34430503fe9ef6a729e18ae919e43b8ada 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for archive files (libraries).
-   Copyright (C) 1990-2016 Free Software Foundation, Inc.
+   Copyright (C) 1990-2017 Free Software Foundation, Inc.
    Written by Cygnus Support.  Mostly Gumby Henkel-Wallace's fault.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -392,6 +392,7 @@ open_nested_file (const char *filename, bfd *archive)
     {
       n_bfd->lto_output = archive->lto_output;
       n_bfd->no_export = archive->no_export;
+      n_bfd->my_archive = archive;
     }
   return n_bfd;
 }
@@ -833,7 +834,12 @@ bfd_generic_archive_p (bfd *abfd)
   if (strncmp (armag, ARMAG, SARMAG) != 0
       && strncmp (armag, ARMAGB, SARMAG) != 0
       && ! bfd_is_thin_archive (abfd))
-    return NULL;
+    {
+      bfd_set_error (bfd_error_wrong_format);
+      if (abfd->format == bfd_archive)
+       abfd->format = bfd_unknown;
+      return NULL;
+    }
 
   tdata_hold = bfd_ardata (abfd);
 
@@ -1974,6 +1980,12 @@ bfd_ar_hdr_from_filesystem (bfd *abfd, const char *filename, bfd *member)
                      status.st_gid);
   _bfd_ar_spacepad (hdr->ar_mode, sizeof (hdr->ar_mode), "%-8lo",
                    status.st_mode);
+  if (status.st_size - (bfd_size_type) status.st_size != 0)
+    {
+      bfd_set_error (bfd_error_file_too_big);
+      free (ared);
+      return NULL;
+    }
   if (!_bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size), status.st_size))
     {
       free (ared);
@@ -2288,7 +2300,7 @@ _bfd_write_archive_contents (bfd *arch)
        {
          if (bfd_update_armap_timestamp (arch))
            break;
-         (*_bfd_error_handler)
+         _bfd_error_handler
            (_("Warning: writing archive was slow: rewriting timestamp\n"));
        }
       while (++tries < 6);
@@ -2297,7 +2309,7 @@ _bfd_write_archive_contents (bfd *arch)
   return TRUE;
 
  input_err:
-  bfd_set_error (bfd_error_on_input, current, bfd_get_error ());
+  bfd_set_input_error (current, bfd_get_error ());
   return FALSE;
 }
 \f
@@ -2399,10 +2411,14 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
                          map = new_map;
                        }
 
-                     if (strcmp (syms[src_count]->name, "__gnu_lto_slim") == 0)
-                       (*_bfd_error_handler)
-                         (_("%s: plugin needed to handle lto object"),
-                          bfd_get_filename (current));
+                     if (syms[src_count]->name[0] == '_'
+                         && syms[src_count]->name[1] == '_'
+                         && strcmp (syms[src_count]->name
+                                    + (syms[src_count]->name[2] == '_'),
+                                    "__gnu_lto_slim") == 0)
+                       _bfd_error_handler
+                         (_("%B: plugin needed to handle lto object"),
+                          current);
                      namelen = strlen (syms[src_count]->name);
                      amt = sizeof (char *);
                      map[orl_count].name = (char **) bfd_alloc (arch, amt);
@@ -2454,11 +2470,11 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
 }
 
 bfd_boolean
-bsd_write_armap (bfd *arch,
-                unsigned int elength,
-                struct orl *map,
-                unsigned int orl_count,
-                int stridx)
+_bfd_bsd_write_armap (bfd *arch,
+                     unsigned int elength,
+                     struct orl *map,
+                     unsigned int orl_count,
+                     int stridx)
 {
   int padit = stridx & 1;
   unsigned int ranlibsize = orl_count * BSD_SYMDEF_SIZE;
@@ -2678,11 +2694,11 @@ _bfd_archive_bsd_update_armap_timestamp (bfd *arch)
    symbol name n-1  */
 
 bfd_boolean
-coff_write_armap (bfd *arch,
-                 unsigned int elength,
-                 struct orl *map,
-                 unsigned int symbol_count,
-                 int stridx)
+_bfd_coff_write_armap (bfd *arch,
+                      unsigned int elength,
+                      struct orl *map,
+                      unsigned int symbol_count,
+                      int stridx)
 {
   /* The size of the ranlib is the number of exported symbols in the
      archive * the number of bytes in an int, + an int for the count.  */
This page took 0.0777 seconds and 4 git commands to generate.