Add compressed debug section support to binutils and ld.
[deliverable/binutils-gdb.git] / bfd / archive.c
index 15eea03629b78b78391c9d137745a4fb0bb856bf..ed4014151d1132c61509d1397c7e7e75dfc48a3b 100644 (file)
@@ -303,6 +303,15 @@ eq_file_ptr (const PTR p1, const PTR p2)
   return arc1->ptr == arc2->ptr;
 }
 
+/* The calloc function doesn't always take size_t (e.g. on VMS)
+   so wrap it to avoid a compile time warning.   */
+
+static void *
+_bfd_calloc_wrapper (size_t a, size_t b)
+{
+  return calloc (a, b);
+}
+
 /* Kind of stupid to call cons for each one, but we don't do too many.  */
 
 bfd_boolean
@@ -315,7 +324,7 @@ _bfd_add_bfd_to_archive_cache (bfd *arch_bfd, file_ptr filepos, bfd *new_elt)
   if (hash_table == NULL)
     {
       hash_table = htab_create_alloc (16, hash_file_ptr, eq_file_ptr,
-                                     NULL, calloc, free);
+                                     NULL, _bfd_calloc_wrapper, free);
       if (hash_table == NULL)
        return FALSE;
       bfd_ardata (arch_bfd)->cache = hash_table;
@@ -536,8 +545,8 @@ _bfd_generic_read_ar_hdr_mag (bfd *abfd, const char *mag)
 /* Append the relative pathname for a member of the thin archive
    to the pathname of the directory containing the archive.  */
 
-static char *
-append_relative_path (bfd *arch, char *elt_name)
+char *
+_bfd_append_relative_path (bfd *arch, char *elt_name)
 {
   const char *arch_name = arch->filename;
   const char *base_name = lbasename (arch_name);
@@ -591,7 +600,7 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
       /* This is a proxy entry for an external file.  */
       if (! IS_ABSOLUTE_PATH (filename))
         {
-          filename = append_relative_path (archive, filename);
+          filename = _bfd_append_relative_path (archive, filename);
           if (filename == NULL)
             return NULL;
         }
@@ -688,6 +697,8 @@ DESCRIPTION
 bfd *
 bfd_openr_next_archived_file (bfd *archive, bfd *last_file)
 {
+  bfd *abfd;
+
   if ((bfd_get_format (archive) != bfd_archive)
       || (archive->direction == write_direction))
     {
@@ -695,8 +706,14 @@ bfd_openr_next_archived_file (bfd *archive, bfd *last_file)
       return NULL;
     }
 
-  return BFD_SEND (archive,
+  abfd = BFD_SEND (archive,
                   openr_next_archived_file, (archive, last_file));
+
+  /* Copy BFD_COMPRESS and BFD_DECOMPRESS flags.  */
+  if (abfd)
+    abfd->flags |= archive->flags & (BFD_COMPRESS | BFD_DECOMPRESS);
+
+  return abfd;
 }
 
 bfd *
@@ -1640,7 +1657,7 @@ _bfd_archive_bsd44_construct_extended_name_table (bfd *abfd,
 
           len = (len + 3) & ~3;
           arch_eltdata (current)->extra_size = len;
-          _bfd_ar_spacepad (hdr->ar_name, maxname, "#1/%u", len);
+          _bfd_ar_spacepad (hdr->ar_name, maxname, "#1/%lu", len);
        }
     }
 
This page took 0.025718 seconds and 4 git commands to generate.