BFD messages
[deliverable/binutils-gdb.git] / bfd / archive.c
index cb7f22647b8a00d8b287c8fe689aac98c4586764..d58f1727691698afd1519ea8bfeb6ff963201968 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for archive files (libraries).
-   Copyright (C) 1990-2017 Free Software Foundation, Inc.
+   Copyright (C) 1990-2018 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.
@@ -754,6 +754,13 @@ _bfd_generic_get_elt_at_index (bfd *abfd, symindex sym_index)
   return _bfd_get_elt_at_filepos (abfd, entry->file_offset);
 }
 
+bfd *
+_bfd_noarchive_get_elt_at_index (bfd *abfd,
+                                symindex sym_index ATTRIBUTE_UNUSED)
+{
+  return (bfd *) _bfd_ptr_bfd_null_error (abfd);
+}
+
 /*
 FUNCTION
        bfd_openr_next_archived_file
@@ -764,10 +771,11 @@ SYNOPSIS
 DESCRIPTION
        Provided a BFD, @var{archive}, containing an archive and NULL, open
        an input BFD on the first contained element and returns that.
-       Subsequent calls should pass
-       the archive and the previous return value to return a created
-       BFD to the next contained element. NULL is returned when there
-       are no more.
+       Subsequent calls should pass the archive and the previous return
+       value to return a created BFD to the next contained element.  NULL
+       is returned when there are no more.
+       Note - if you want to process the bfd returned by this call be
+       sure to call bfd_check_format() on it first.
 */
 
 bfd *
@@ -815,6 +823,13 @@ bfd_generic_openr_next_archived_file (bfd *archive, bfd *last_file)
   return _bfd_get_elt_at_filepos (archive, filestart);
 }
 
+bfd *
+_bfd_noarchive_openr_next_archived_file (bfd *archive,
+                                        bfd *last_file ATTRIBUTE_UNUSED)
+{
+  return (bfd *) _bfd_ptr_bfd_null_error (archive);
+}
+
 const bfd_target *
 bfd_generic_archive_p (bfd *abfd)
 {
@@ -834,7 +849,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);
 
@@ -1432,16 +1452,16 @@ normalize (bfd *abfd ATTRIBUTE_UNUSED, const char *file)
 
      Relative path  Reference path  Result
      -------------  --------------  ------
-     bar.o          lib.a           bar.o
-     foo/bar.o      lib.a           foo/bar.o
-     bar.o          foo/lib.a       ../bar.o
-     foo/bar.o      baz/lib.a       ../foo/bar.o
-     bar.o          ../lib.a        <parent of current dir>/bar.o
-   ; ../bar.o       ../lib.a        bar.o
-   ; ../bar.o       lib.a           ../bar.o
-     foo/bar.o      ../lib.a        <parent of current dir>/foo/bar.o
-     bar.o          ../../lib.a     <grandparent>/<parent>/bar.o
-     bar.o          foo/baz/lib.a   ../../bar.o
+     bar.o         lib.a           bar.o
+     foo/bar.o     lib.a           foo/bar.o
+     bar.o         foo/lib.a       ../bar.o
+     foo/bar.o     baz/lib.a       ../foo/bar.o
+     bar.o         ../lib.a        <parent of current dir>/bar.o
+   ; ../bar.o      ../lib.a        bar.o
+   ; ../bar.o      lib.a           ../bar.o
+     foo/bar.o     ../lib.a        <parent of current dir>/foo/bar.o
+     bar.o         ../../lib.a     <grandparent>/<parent>/bar.o
+     bar.o         foo/baz/lib.a   ../../bar.o
 
    Note - the semicolons above are there to prevent the BFD chew
    utility from interpreting those lines as prototypes to put into
@@ -1580,6 +1600,15 @@ _bfd_archive_coff_construct_extended_name_table (bfd *abfd,
   return _bfd_construct_extended_name_table (abfd, TRUE, tabloc, tablen);
 }
 
+bfd_boolean
+_bfd_noarchive_construct_extended_name_table (bfd *abfd ATTRIBUTE_UNUSED,
+                                             char **tabloc ATTRIBUTE_UNUSED,
+                                             bfd_size_type *len ATTRIBUTE_UNUSED,
+                                             const char **name ATTRIBUTE_UNUSED)
+{
+  return TRUE;
+}
+
 /* Follows archive_head and produces an extended name table if
    necessary.  Returns (in tabloc) a pointer to an extended name
    table, and in tablen the length of the table.  If it makes an entry
@@ -1878,6 +1907,12 @@ _bfd_bsd44_write_ar_hdr (bfd *archive, bfd *abfd)
     }
   return TRUE;
 }
+
+bfd_boolean
+_bfd_noarchive_write_ar_hdr (bfd *archive, bfd *abfd ATTRIBUTE_UNUSED)
+{
+  return _bfd_bool_bfd_false_error (archive);
+}
 \f
 /* A couple of functions for creating ar_hdrs.  */
 
@@ -1975,6 +2010,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);
@@ -2007,7 +2048,7 @@ bfd_generic_stat_arch_elt (bfd *abfd, struct stat *buf)
     return -1;
 #define foo(arelt, stelt, size)                                \
   buf->stelt = strtol (hdr->arelt, &aloser, size);     \
-  if (aloser == hdr->arelt)                            \
+  if (aloser == hdr->arelt)                            \
     return -1;
 
   /* Some platforms support special notations for large IDs.  */
@@ -2142,6 +2183,13 @@ bfd_gnu_truncate_arname (bfd *abfd, const char *pathname, char *arhdr)
   if (length < 16)
     (hdr->ar_name)[length] = ar_padchar (abfd);
 }
+
+void
+_bfd_noarchive_truncate_arname (bfd *abfd ATTRIBUTE_UNUSED,
+                               const char *pathname ATTRIBUTE_UNUSED,
+                               char *arhdr ATTRIBUTE_UNUSED)
+{
+}
 \f
 /* The BFD is open for write and has its format set to bfd_archive.  */
 
@@ -2290,7 +2338,7 @@ _bfd_write_archive_contents (bfd *arch)
          if (bfd_update_armap_timestamp (arch))
            break;
          _bfd_error_handler
-           (_("Warning: writing archive was slow: rewriting timestamp\n"));
+           (_("warning: writing archive was slow: rewriting timestamp"));
        }
       while (++tries < 6);
     }
@@ -2298,7 +2346,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
@@ -2400,10 +2448,14 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
                          map = new_map;
                        }
 
-                     if (strcmp (syms[src_count]->name, "__gnu_lto_slim") == 0)
+                     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
-                         (_("%s: plugin needed to handle lto object"),
-                          bfd_get_filename (current));
+                         (_("%pB: 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);
@@ -2455,11 +2507,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;
@@ -2679,11 +2731,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.  */
@@ -2818,6 +2870,17 @@ coff_write_armap (bfd *arch,
   return TRUE;
 }
 
+bfd_boolean
+_bfd_noarchive_write_armap
+    (bfd *arch ATTRIBUTE_UNUSED,
+     unsigned int elength ATTRIBUTE_UNUSED,
+     struct orl *map ATTRIBUTE_UNUSED,
+     unsigned int orl_count ATTRIBUTE_UNUSED,
+     int stridx ATTRIBUTE_UNUSED)
+{
+  return TRUE;
+}
+
 static int
 archive_close_worker (void **slot, void *inf ATTRIBUTE_UNUSED)
 {
This page took 0.032932 seconds and 4 git commands to generate.