2010-01-26 Tristan Gingold <gingold@adacore.com>
authorTristan Gingold <gingold@adacore.com>
Tue, 26 Jan 2010 13:42:26 +0000 (13:42 +0000)
committerTristan Gingold <gingold@adacore.com>
Tue, 26 Jan 2010 13:42:26 +0000 (13:42 +0000)
* targets.c (BFD_JUMP_TABLE_ARCHIVE): Add initializer for write_ar_hdr.
(bfd_target): Add _bfd_write_ar_hdr_fn field.
* archive.c (is_bsd44_extended_name): New macro.
(_bfd_generic_read_ar_hdr_mag): Use it.  Add extra_size.
(bfd_slurp_armap): Also check for "__.SYMDEF" as a BSD4.4 extended
name.
(_bfd_archive_bsd44_construct_extended_name_table): New function.
(_bfd_generic_write_ar_hdr): Ditto.
(_bfd_bsd44_write_ar_hdr): Ditto.
(_bfd_write_archive_contents): Call _bfd_write_ar_hdr.
(bsd_write_armap): Adjust firstreal computation.
* libbfd-in.h (struct areltdata): Add extra_size field.
(_bfd_generic_write_ar_hdr): Add prototype.
(_bfd_bsd44_write_ar_hdr): Ditto.
(_bfd_write_ar_hdr): Define.
(_bfd_noarchive_write_ar_hdr): Ditto.
(_bfd_archive_bsd_write_ar_hdr): Ditto.
(_bfd_archive_coff_write_ar_hdr): Ditto.
(_bfd_archive_bsd44_slurp_armap): Ditto.
(_bfd_archive_bsd44_slurp_extended_name_table): Ditto.
(_bfd_archive_bsd44_construct_extended_name_table): New prototype.
(_bfd_archive_bsd44_truncate_arname): Ditto.
(_bfd_archive_bsd44_write_armap): Ditto.
(_bfd_archive_bsd44_read_ar_hdr): Ditto.
(_bfd_archive_bsd44_write_ar_hdr): Ditto.
(_bfd_archive_bsd44_openr_next_archived_file): Ditto.
(_bfd_archive_bsd44_get_elt_at_index): Ditto.
(_bfd_archive_bsd44_generic_stat_arch_elt): Ditto.
(_bfd_archive_bsd44_update_armap_timestamp): Ditto.
* libbfd.h: Regenerate.
* oasys.c (oasys_write_ar_hdr): Define.
* libecoff.h (_bfd_ecoff_write_ar_hdr): Define.
* ieee.c (ieee_write_ar_hdr): Define.
* elf64-mips.c (bfd_elf64_archive_write_ar_hdr): Define.
* coff-rs6000.c (rs6000coff_vec): Adjust for write_ar_hdr field.
(bfd_pmac_xcoff_backend_data): Ditto.
* coff64-rs6000.c (rs6000coff64_vec): Ditto.
(bfd_xcoff_aix5_backend_data): Ditto.
* coff-alpha.c (alpha_ecoff_write_ar_hdr): Define.
* aout-target.h (MY_write_ar_hdr): Define it if not defined.
* aout-tic30.c (MY_write_ar_hdr): Ditto.
* mach-o-target.c (TARGET_NAME): Use _bfd_archive_bsd44 archive.
(bfd_mach_o_mkarchive, bfd_mach_o_read_ar_hdr)
(bfd_mach_o_slurp_armap, bfd_mach_o_slurp_extended_name_table)
(bfd_mach_o_construct_extended_name_table)
(bfd_mach_o_truncate_arname, bfd_mach_o_write_armap)
(bfd_mach_o_get_elt_at_index, bfd_mach_o_generic_stat_arch_elt)
(bfd_mach_o_update_armap_timestamp): Moved to mach-o.c
* mach-o.c (bfd_mach_o_mkarchive, bfd_mach_o_read_ar_hdr)
(bfd_mach_o_slurp_armap, bfd_mach_o_slurp_extended_name_table)
(bfd_mach_o_construct_extended_name_table)
(bfd_mach_o_truncate_arname, bfd_mach_o_write_armap)
(bfd_mach_o_get_elt_at_index, bfd_mach_o_generic_stat_arch_elt)
(bfd_mach_o_update_armap_timestamp): Moved from mach-o-target.c
* bfd-in2.h: Regenerate.

17 files changed:
bfd/ChangeLog
bfd/aout-target.h
bfd/aout-tic30.c
bfd/archive.c
bfd/bfd-in2.h
bfd/coff-alpha.c
bfd/coff-rs6000.c
bfd/coff64-rs6000.c
bfd/elf64-mips.c
bfd/ieee.c
bfd/libbfd-in.h
bfd/libbfd.h
bfd/libecoff.h
bfd/mach-o-target.c
bfd/mach-o.c
bfd/oasys.c
bfd/targets.c

index 75118cb68152dad2aa05dcc8b203c2a2f362e191..d882c17900944e6b621f8c7eccb7cd09c114e17a 100644 (file)
@@ -1,3 +1,61 @@
+2010-01-26  Tristan Gingold  <gingold@adacore.com>
+
+       * targets.c (BFD_JUMP_TABLE_ARCHIVE): Add initializer for write_ar_hdr.
+       (bfd_target): Add _bfd_write_ar_hdr_fn field.
+       * archive.c (is_bsd44_extended_name): New macro.
+       (_bfd_generic_read_ar_hdr_mag): Use it.  Add extra_size.
+       (bfd_slurp_armap): Also check for "__.SYMDEF" as a BSD4.4 extended
+       name.
+       (_bfd_archive_bsd44_construct_extended_name_table): New function.
+       (_bfd_generic_write_ar_hdr): Ditto.
+       (_bfd_bsd44_write_ar_hdr): Ditto.
+       (_bfd_write_archive_contents): Call _bfd_write_ar_hdr.
+       (bsd_write_armap): Adjust firstreal computation.
+       * libbfd-in.h (struct areltdata): Add extra_size field.
+       (_bfd_generic_write_ar_hdr): Add prototype.
+       (_bfd_bsd44_write_ar_hdr): Ditto.
+       (_bfd_write_ar_hdr): Define.
+       (_bfd_noarchive_write_ar_hdr): Ditto.
+       (_bfd_archive_bsd_write_ar_hdr): Ditto.
+       (_bfd_archive_coff_write_ar_hdr): Ditto.
+       (_bfd_archive_bsd44_slurp_armap): Ditto.
+       (_bfd_archive_bsd44_slurp_extended_name_table): Ditto.
+       (_bfd_archive_bsd44_construct_extended_name_table): New prototype.
+       (_bfd_archive_bsd44_truncate_arname): Ditto.
+       (_bfd_archive_bsd44_write_armap): Ditto.
+       (_bfd_archive_bsd44_read_ar_hdr): Ditto.
+       (_bfd_archive_bsd44_write_ar_hdr): Ditto.
+       (_bfd_archive_bsd44_openr_next_archived_file): Ditto.
+       (_bfd_archive_bsd44_get_elt_at_index): Ditto.
+       (_bfd_archive_bsd44_generic_stat_arch_elt): Ditto.
+       (_bfd_archive_bsd44_update_armap_timestamp): Ditto.
+       * libbfd.h: Regenerate.
+       * oasys.c (oasys_write_ar_hdr): Define.
+       * libecoff.h (_bfd_ecoff_write_ar_hdr): Define.
+       * ieee.c (ieee_write_ar_hdr): Define.
+       * elf64-mips.c (bfd_elf64_archive_write_ar_hdr): Define.
+       * coff-rs6000.c (rs6000coff_vec): Adjust for write_ar_hdr field.
+       (bfd_pmac_xcoff_backend_data): Ditto.
+       * coff64-rs6000.c (rs6000coff64_vec): Ditto.
+       (bfd_xcoff_aix5_backend_data): Ditto.
+       * coff-alpha.c (alpha_ecoff_write_ar_hdr): Define.
+       * aout-target.h (MY_write_ar_hdr): Define it if not defined.
+       * aout-tic30.c (MY_write_ar_hdr): Ditto.
+       * mach-o-target.c (TARGET_NAME): Use _bfd_archive_bsd44 archive.
+       (bfd_mach_o_mkarchive, bfd_mach_o_read_ar_hdr)
+       (bfd_mach_o_slurp_armap, bfd_mach_o_slurp_extended_name_table)
+       (bfd_mach_o_construct_extended_name_table)
+       (bfd_mach_o_truncate_arname, bfd_mach_o_write_armap)
+       (bfd_mach_o_get_elt_at_index, bfd_mach_o_generic_stat_arch_elt)
+       (bfd_mach_o_update_armap_timestamp): Moved to mach-o.c
+       * mach-o.c (bfd_mach_o_mkarchive, bfd_mach_o_read_ar_hdr)
+       (bfd_mach_o_slurp_armap, bfd_mach_o_slurp_extended_name_table)
+       (bfd_mach_o_construct_extended_name_table)
+       (bfd_mach_o_truncate_arname, bfd_mach_o_write_armap)
+       (bfd_mach_o_get_elt_at_index, bfd_mach_o_generic_stat_arch_elt)
+       (bfd_mach_o_update_armap_timestamp): Moved from mach-o-target.c
+       * bfd-in2.h: Regenerate.
+
 2010-01-26  Alan Modra  <amodra@gmail.com>
            H.J. Lu  <hongjiu.lu@intel.com>
 
index 39c8d34c1ae4669a76d94be2e427df9fb2be0284..5689641ba1657e8091f6d7a7979e2abbb761b524 100644 (file)
@@ -380,6 +380,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #ifndef MY_read_ar_hdr
 #define MY_read_ar_hdr         _bfd_generic_read_ar_hdr
 #endif
+#ifndef MY_write_ar_hdr
+#define MY_write_ar_hdr                _bfd_generic_write_ar_hdr
+#endif
 #ifndef        MY_truncate_arname
 #define        MY_truncate_arname              bfd_bsd_truncate_arname
 #endif
index 50d153b5c975819b98ff7585c95b87f058024131..23e6c0fdb13fc7fbe2236ce24a71b83d229f4f5b 100644 (file)
@@ -837,6 +837,9 @@ tic30_aout_set_arch_mach (bfd *abfd,
 #ifndef MY_read_ar_hdr
 #define MY_read_ar_hdr                 _bfd_generic_read_ar_hdr
 #endif
+#ifndef MY_write_ar_hdr
+#define MY_write_ar_hdr                        _bfd_generic_write_ar_hdr
+#endif
 #ifndef        MY_truncate_arname
 #define        MY_truncate_arname              bfd_bsd_truncate_arname
 #endif
index 2e1c8f0b1d81401a5b6d51495707037c926d2524..6fad826d9346bdc285bac646b579abe095628c6d 100644 (file)
@@ -104,7 +104,6 @@ SUBSECTION
 
    BSD 4.4 uses a third scheme:  It writes a long filename
    directly after the header.  This allows 'ar q' to work.
-   We currently can read BSD 4.4 archives, but not write them.
 */
 
 /* Summary of archive member names:
@@ -125,7 +124,6 @@ SUBSECTION
  "/18             " - SVR4 style, name at offset 18 in name table.
  "#1/23           " - Long name (or embedded spaces) 23 characters long,
                      BSD 4.4 style, full name follows header.
-                     Implemented for reading, not writing.
  " 18             " - Long name 18 characters long, extended pseudo-BSD.
  */
 
@@ -159,6 +157,11 @@ struct ar_cache {
 
 #define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))
 #define arch_hdr(bfd) ((struct ar_hdr *) arch_eltdata (bfd)->arch_header)
+
+/* True iff NAME designated a BSD 4.4 extended name.  */
+
+#define is_bsd44_extended_name(NAME) \
+  (NAME[0] == '#'  && NAME[1] == '1' && NAME[2] == '/' && ISDIGIT (NAME[3]))
 \f
 void
 _bfd_ar_spacepad (char *p, size_t n, const char *fmt, long val)
@@ -415,6 +418,7 @@ _bfd_generic_read_ar_hdr_mag (bfd *abfd, const char *mag)
   bfd_size_type allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr);
   char *allocptr = 0;
   file_ptr origin = 0;
+  unsigned int extra_size = 0;
 
   if (bfd_bread (hdrp, sizeof (struct ar_hdr), abfd) != sizeof (struct ar_hdr))
     {
@@ -450,17 +454,14 @@ _bfd_generic_read_ar_hdr_mag (bfd *abfd, const char *mag)
       if (filename == NULL)
        return NULL;
     }
-  /* BSD4.4-style long filename.
-     Only implemented for reading, so far!  */
-  else if (hdr.ar_name[0] == '#'
-          && hdr.ar_name[1] == '1'
-          && hdr.ar_name[2] == '/'
-          && ISDIGIT (hdr.ar_name[3]))
+  /* BSD4.4-style long filename.  */
+  else if (is_bsd44_extended_name (hdr.ar_name))
     {
       /* BSD-4.4 extended name */
       namelen = atoi (&hdr.ar_name[3]);
       allocsize += namelen + 1;
       parsed_size -= namelen;
+      extra_size = namelen;
 
       allocptr = (char *) bfd_zalloc (abfd, allocsize);
       if (allocptr == NULL)
@@ -515,6 +516,7 @@ _bfd_generic_read_ar_hdr_mag (bfd *abfd, const char *mag)
   ared->arch_header = allocptr + sizeof (struct areltdata);
   memcpy (ared->arch_header, &hdr, sizeof (struct ar_hdr));
   ared->parsed_size = parsed_size;
+  ared->extra_size = extra_size;
   ared->origin = origin;
 
   if (filename != NULL)
@@ -1069,7 +1071,8 @@ bfd_slurp_armap (bfd *abfd)
         return FALSE;
       if (bfd_seek (abfd, (file_ptr) -(sizeof (hdr) + 20), SEEK_CUR) != 0)
         return FALSE;
-      if (CONST_STRNEQ (extname, "__.SYMDEF SORTED"))
+      if (CONST_STRNEQ (extname, "__.SYMDEF SORTED")
+          || CONST_STRNEQ (extname, "__.SYMDEF"))
         return do_slurp_bsd_armap (abfd);
     }
 
@@ -1599,6 +1602,103 @@ _bfd_construct_extended_name_table (bfd *abfd,
 
   return TRUE;
 }
+
+/* Do not construct an extended name table but transforms name field into
+   its extended form.  */
+
+bfd_boolean
+_bfd_archive_bsd44_construct_extended_name_table (bfd *abfd,
+                                                  char **tabloc,
+                                                  bfd_size_type *tablen,
+                                                  const char **name)
+{
+  unsigned int maxname = abfd->xvec->ar_max_namelen;
+  bfd *current;
+
+  *tablen = 0;
+  *tabloc = NULL;
+  *name = NULL;
+
+  for (current = abfd->archive_head;
+       current != NULL;
+       current = current->archive_next)
+    {
+      const char *normal = normalize (current, current->filename);
+      int has_space = 0;
+      unsigned int len;
+
+      if (normal == NULL)
+       return FALSE;
+
+      for (len = 0; normal[len]; len++)
+        if (normal[len] == ' ')
+          has_space = 1;
+
+      if (len > maxname || has_space)
+       {
+          struct ar_hdr *hdr = arch_hdr (current);
+
+          len = (len + 3) & ~3;
+          arch_eltdata (current)->extra_size = len;
+          _bfd_ar_spacepad (hdr->ar_name, maxname, "#1/%u", len);
+       }
+    }
+
+  return TRUE;
+}
+\f
+/* Write an archive header.  */
+
+bfd_boolean
+_bfd_generic_write_ar_hdr (bfd *archive, bfd *abfd)
+{
+  struct ar_hdr *hdr = arch_hdr (abfd);
+
+  if (bfd_bwrite (hdr, sizeof (*hdr), archive) != sizeof (*hdr))
+    return FALSE;
+  return TRUE;
+}
+
+/* Write an archive header using BSD4.4 convention.  */
+
+bfd_boolean
+_bfd_bsd44_write_ar_hdr (bfd *archive, bfd *abfd)
+{
+  struct ar_hdr *hdr = arch_hdr (abfd);
+
+  if (is_bsd44_extended_name (hdr->ar_name))
+    {
+      /* This is a BSD 4.4 extended name.  */
+      const char *fullname = normalize (abfd, abfd->filename);
+      unsigned int len = strlen (fullname);
+      unsigned int padded_len = (len + 3) & ~3;
+
+      BFD_ASSERT (padded_len == arch_eltdata (abfd)->extra_size);
+
+      _bfd_ar_spacepad (hdr->ar_size, sizeof (hdr->ar_size), "%-10ld",
+                        arch_eltdata (abfd)->parsed_size + padded_len);
+
+      if (bfd_bwrite (hdr, sizeof (*hdr), archive) != sizeof (*hdr))
+        return FALSE;
+
+      if (bfd_bwrite (fullname, len, archive) != len)
+        return FALSE;
+      if (len & 3)
+        {
+          static const char pad[3] = { 0, 0, 0 };
+
+          len = 4 - (len & 3);
+          if (bfd_bwrite (pad, len, archive) != len)
+            return FALSE;
+        }
+    }
+  else
+    {
+      if (bfd_bwrite (hdr, sizeof (*hdr), archive) != sizeof (*hdr))
+        return FALSE;
+    }
+  return TRUE;
+}
 \f
 /* A couple of functions for creating ar_hdrs.  */
 
@@ -1957,12 +2057,10 @@ _bfd_write_archive_contents (bfd *arch)
     {
       char buffer[DEFAULT_BUFFERSIZE];
       unsigned int remaining = arelt_size (current);
-      struct ar_hdr *hdr = arch_hdr (current);
 
       /* Write ar header.  */
-      if (bfd_bwrite (hdr, sizeof (*hdr), arch)
-         != sizeof (*hdr))
-       return FALSE;
+      if (!_bfd_write_ar_hdr (arch, current))
+        return FALSE;
       if (bfd_is_thin_archive (arch))
         continue;
       if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0)
@@ -2235,7 +2333,10 @@ bsd_write_armap (bfd *arch,
        {
          do
            {
-             firstreal += arelt_size (current) + sizeof (struct ar_hdr);
+              struct areltdata *ared = arch_eltdata (current);
+
+             firstreal += (ared->parsed_size + ared->extra_size
+                            + sizeof (struct ar_hdr));
              firstreal += firstreal % 2;
              current = current->archive_next;
            }
index df9b6e04310d673b16b7cc61bcd3bfe9c078f419..8d9a464599b376a63dd7e6397d5e93cbb7cade0f 100644 (file)
@@ -5524,6 +5524,7 @@ typedef struct bfd_target
   NAME##_truncate_arname, \
   NAME##_write_armap, \
   NAME##_read_ar_hdr, \
+  NAME##_write_ar_hdr, \
   NAME##_openr_next_archived_file, \
   NAME##_get_elt_at_index, \
   NAME##_generic_stat_arch_elt, \
@@ -5537,6 +5538,7 @@ typedef struct bfd_target
   bfd_boolean (*write_armap)
     (bfd *, unsigned int, struct orl *, unsigned int, int);
   void *      (*_bfd_read_ar_hdr_fn) (bfd *);
+  bfd_boolean (*_bfd_write_ar_hdr_fn) (bfd *, bfd *);
   bfd *       (*openr_next_archived_file) (bfd *, bfd *);
 #define bfd_get_elt_at_index(b,i) BFD_SEND (b, _bfd_get_elt_at_index, (b,i))
   bfd *       (*_bfd_get_elt_at_index) (bfd *, symindex);
index ce217f549b504aa809fb324bc3116ca5ba453547..8a8f6203abb4cdf2f9916d97cbeca40a81d5e398 100644 (file)
@@ -2065,6 +2065,7 @@ alpha_adjust_headers (abfd, fhdr, ahdr)
   _bfd_ecoff_construct_extended_name_table
 #define alpha_ecoff_truncate_arname _bfd_ecoff_truncate_arname
 #define alpha_ecoff_write_armap _bfd_ecoff_write_armap
+#define alpha_ecoff_write_ar_hdr _bfd_generic_write_ar_hdr
 #define alpha_ecoff_generic_stat_arch_elt _bfd_ecoff_generic_stat_arch_elt
 #define alpha_ecoff_update_armap_timestamp _bfd_ecoff_update_armap_timestamp
 
index 2f13f489bb5a9cbc75f7dcb3ef9f0d1d76268253..37e8b8a45f68d0913db6f2043f6903bbe52987ed 100644 (file)
@@ -4193,6 +4193,7 @@ const bfd_target rs6000coff_vec =
     bfd_dont_truncate_arname,
     _bfd_xcoff_write_armap,
     _bfd_xcoff_read_ar_hdr,
+    _bfd_generic_write_ar_hdr,
     _bfd_xcoff_openr_next_archived_file,
     _bfd_generic_get_elt_at_index,
     _bfd_xcoff_stat_arch_elt,
@@ -4447,6 +4448,7 @@ const bfd_target pmac_xcoff_vec =
     bfd_dont_truncate_arname,
     _bfd_xcoff_write_armap,
     _bfd_xcoff_read_ar_hdr,
+    _bfd_generic_write_ar_hdr,
     _bfd_xcoff_openr_next_archived_file,
     _bfd_generic_get_elt_at_index,
     _bfd_xcoff_stat_arch_elt,
index 15e636e50e64a6249c4727d36b77b312aa507888..7668e7ab909df86e755944892da805702c090952 100644 (file)
@@ -2763,6 +2763,7 @@ const bfd_target rs6000coff64_vec =
     bfd_dont_truncate_arname,
     _bfd_xcoff_write_armap,
     _bfd_xcoff_read_ar_hdr,
+    _bfd_generic_write_ar_hdr,
     xcoff64_openr_next_archived_file,
     _bfd_generic_get_elt_at_index,
     _bfd_xcoff_stat_arch_elt,
@@ -3018,6 +3019,7 @@ const bfd_target aix5coff64_vec =
     bfd_dont_truncate_arname,
     _bfd_xcoff_write_armap,
     _bfd_xcoff_read_ar_hdr,
+    _bfd_generic_write_ar_hdr,
     xcoff64_openr_next_archived_file,
     _bfd_generic_get_elt_at_index,
     _bfd_xcoff_stat_arch_elt,
index 312c976db1ab8cb72ee39252e1c9ed904eb9dad0..6676ee6a9288ba386e0566d5ff40e2fa7ae8ae6d 100644 (file)
@@ -3313,6 +3313,7 @@ extern bfd_boolean bfd_elf64_archive_write_armap
 #define bfd_elf64_archive_truncate_arname \
                        _bfd_archive_coff_truncate_arname
 #define bfd_elf64_archive_read_ar_hdr  _bfd_archive_coff_read_ar_hdr
+#define bfd_elf64_archive_write_ar_hdr _bfd_archive_coff_write_ar_hdr
 #define bfd_elf64_archive_openr_next_archived_file \
                        _bfd_archive_coff_openr_next_archived_file
 #define bfd_elf64_archive_get_elt_at_index \
index 429572b12e7e240ff3f14db99fc2707ee945317d..3ceef357fc46de93f648dc8887d09085dcd56bd5 100644 (file)
@@ -3743,6 +3743,7 @@ ieee_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
     (bfd *, unsigned int, struct orl *, unsigned int, int)) \
    bfd_true)
 #define ieee_read_ar_hdr bfd_nullvoidptr
+#define ieee_write_ar_hdr ((bfd_boolean (*) (bfd *, bfd *)) bfd_false)
 #define ieee_update_armap_timestamp bfd_true
 #define ieee_get_elt_at_index _bfd_generic_get_elt_at_index
 
index 8c6f9b6321d6509e4e38b46429822c245d4517db..1af47e1a0793b2f4f6caaaaf3ae0c45c35feb85d 100644 (file)
@@ -90,6 +90,7 @@ struct artdata {
 struct areltdata {
   char * arch_header;          /* it's actually a string */
   unsigned int parsed_size;    /* octets of filesize not including ar_hdr */
+  unsigned int extra_size;     /* BSD4.4: extra bytes after the header.  */
   char *filename;              /* null-terminated */
   file_ptr origin;             /* for element of a thin archive */
 };
@@ -207,6 +208,12 @@ extern void _bfd_ar_spacepad
 extern void *_bfd_generic_read_ar_hdr_mag
   (bfd *, const char *);
 
+extern bfd_boolean _bfd_generic_write_ar_hdr
+  (bfd *, bfd *);
+
+extern bfd_boolean _bfd_bsd44_write_ar_hdr
+  (bfd *, bfd *);
+
 bfd * bfd_generic_openr_next_archived_file
   (bfd *archive, bfd *last_file);
 
@@ -215,6 +222,8 @@ int bfd_generic_stat_arch_elt
 
 #define _bfd_read_ar_hdr(abfd) \
   BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
+#define _bfd_write_ar_hdr(archive, abfd)         \
+  BFD_SEND (abfd, _bfd_write_ar_hdr_fn, (archive, abfd))
 \f
 /* Generic routines to use for BFD_JUMP_TABLE_GENERIC.  Use
    BFD_JUMP_TABLE_GENERIC (_bfd_generic).  */
@@ -273,6 +282,8 @@ extern bfd_boolean _bfd_nocore_core_file_matches_executable_p
   ((bfd_boolean (*) (bfd *, unsigned int, struct orl *, unsigned int, int)) \
    bfd_false)
 #define _bfd_noarchive_read_ar_hdr bfd_nullvoidptr
+#define _bfd_noarchive_write_ar_hdr \
+  ((bfd_boolean (*) (bfd *, bfd *)) bfd_false)
 #define _bfd_noarchive_openr_next_archived_file \
   ((bfd *(*) (bfd *, bfd *)) bfd_nullvoidptr)
 #define _bfd_noarchive_get_elt_at_index \
@@ -291,6 +302,7 @@ extern bfd_boolean _bfd_archive_bsd_construct_extended_name_table
 #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
 #define _bfd_archive_bsd_write_armap bsd_write_armap
 #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_archive_bsd_write_ar_hdr _bfd_generic_write_ar_hdr
 #define _bfd_archive_bsd_openr_next_archived_file \
   bfd_generic_openr_next_archived_file
 #define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
@@ -310,6 +322,7 @@ extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
 #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
 #define _bfd_archive_coff_write_armap coff_write_armap
 #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_archive_coff_write_ar_hdr _bfd_generic_write_ar_hdr
 #define _bfd_archive_coff_openr_next_archived_file \
   bfd_generic_openr_next_archived_file
 #define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
@@ -317,6 +330,26 @@ extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
   bfd_generic_stat_arch_elt
 #define _bfd_archive_coff_update_armap_timestamp bfd_true
 
+/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD4.4 style
+   archives.  Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44).  */
+
+#define _bfd_archive_bsd44_slurp_armap bfd_slurp_bsd_armap
+#define _bfd_archive_bsd44_slurp_extended_name_table \
+  _bfd_slurp_extended_name_table
+extern bfd_boolean _bfd_archive_bsd44_construct_extended_name_table
+  (bfd *, char **, bfd_size_type *, const char **);
+#define _bfd_archive_bsd44_truncate_arname bfd_bsd_truncate_arname
+#define _bfd_archive_bsd44_write_armap bsd_write_armap
+#define _bfd_archive_bsd44_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_archive_bsd44_write_ar_hdr _bfd_bsd44_write_ar_hdr
+#define _bfd_archive_bsd44_openr_next_archived_file \
+  bfd_generic_openr_next_archived_file
+#define _bfd_archive_bsd44_get_elt_at_index _bfd_generic_get_elt_at_index
+#define _bfd_archive_bsd44_generic_stat_arch_elt \
+  bfd_generic_stat_arch_elt
+#define _bfd_archive_bsd44_update_armap_timestamp \
+  _bfd_archive_bsd_update_armap_timestamp
+
 /* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
    support.  Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols).  */
 
index 073086ca8f85f68be81dc7227f4296cd5f4a3044..2be8fe50d062874cb4993d12aeb3a8eb61920a89 100644 (file)
@@ -95,6 +95,7 @@ struct artdata {
 struct areltdata {
   char * arch_header;          /* it's actually a string */
   unsigned int parsed_size;    /* octets of filesize not including ar_hdr */
+  unsigned int extra_size;     /* BSD4.4: extra bytes after the header.  */
   char *filename;              /* null-terminated */
   file_ptr origin;             /* for element of a thin archive */
 };
@@ -212,6 +213,12 @@ extern void _bfd_ar_spacepad
 extern void *_bfd_generic_read_ar_hdr_mag
   (bfd *, const char *);
 
+extern bfd_boolean _bfd_generic_write_ar_hdr
+  (bfd *, bfd *);
+
+extern bfd_boolean _bfd_bsd44_write_ar_hdr
+  (bfd *, bfd *);
+
 bfd * bfd_generic_openr_next_archived_file
   (bfd *archive, bfd *last_file);
 
@@ -220,6 +227,8 @@ int bfd_generic_stat_arch_elt
 
 #define _bfd_read_ar_hdr(abfd) \
   BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
+#define _bfd_write_ar_hdr(archive, abfd)         \
+  BFD_SEND (abfd, _bfd_write_ar_hdr_fn, (archive, abfd))
 \f
 /* Generic routines to use for BFD_JUMP_TABLE_GENERIC.  Use
    BFD_JUMP_TABLE_GENERIC (_bfd_generic).  */
@@ -278,6 +287,8 @@ extern bfd_boolean _bfd_nocore_core_file_matches_executable_p
   ((bfd_boolean (*) (bfd *, unsigned int, struct orl *, unsigned int, int)) \
    bfd_false)
 #define _bfd_noarchive_read_ar_hdr bfd_nullvoidptr
+#define _bfd_noarchive_write_ar_hdr \
+  ((bfd_boolean (*) (bfd *, bfd *)) bfd_false)
 #define _bfd_noarchive_openr_next_archived_file \
   ((bfd *(*) (bfd *, bfd *)) bfd_nullvoidptr)
 #define _bfd_noarchive_get_elt_at_index \
@@ -296,6 +307,7 @@ extern bfd_boolean _bfd_archive_bsd_construct_extended_name_table
 #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
 #define _bfd_archive_bsd_write_armap bsd_write_armap
 #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_archive_bsd_write_ar_hdr _bfd_generic_write_ar_hdr
 #define _bfd_archive_bsd_openr_next_archived_file \
   bfd_generic_openr_next_archived_file
 #define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
@@ -315,6 +327,7 @@ extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
 #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
 #define _bfd_archive_coff_write_armap coff_write_armap
 #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_archive_coff_write_ar_hdr _bfd_generic_write_ar_hdr
 #define _bfd_archive_coff_openr_next_archived_file \
   bfd_generic_openr_next_archived_file
 #define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
@@ -322,6 +335,26 @@ extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
   bfd_generic_stat_arch_elt
 #define _bfd_archive_coff_update_armap_timestamp bfd_true
 
+/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD4.4 style
+   archives.  Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44).  */
+
+#define _bfd_archive_bsd44_slurp_armap bfd_slurp_bsd_armap
+#define _bfd_archive_bsd44_slurp_extended_name_table \
+  _bfd_slurp_extended_name_table
+extern bfd_boolean _bfd_archive_bsd44_construct_extended_name_table
+  (bfd *, char **, bfd_size_type *, const char **);
+#define _bfd_archive_bsd44_truncate_arname bfd_bsd_truncate_arname
+#define _bfd_archive_bsd44_write_armap bsd_write_armap
+#define _bfd_archive_bsd44_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_archive_bsd44_write_ar_hdr _bfd_bsd44_write_ar_hdr
+#define _bfd_archive_bsd44_openr_next_archived_file \
+  bfd_generic_openr_next_archived_file
+#define _bfd_archive_bsd44_get_elt_at_index _bfd_generic_get_elt_at_index
+#define _bfd_archive_bsd44_generic_stat_arch_elt \
+  bfd_generic_stat_arch_elt
+#define _bfd_archive_bsd44_update_armap_timestamp \
+  _bfd_archive_bsd_update_armap_timestamp
+
 /* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
    support.  Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols).  */
 
index 75c65e7fbe0a161cb7ebb8ec8b0b0064d46fe56e..fdf337933fd0b85a337d352a0e5685f214e37b30 100644 (file)
@@ -270,6 +270,7 @@ extern bfd_boolean _bfd_ecoff_slurp_armap (bfd *);
 extern bfd_boolean _bfd_ecoff_write_armap
   (bfd *, unsigned int, struct orl *, unsigned int, int);
 #define _bfd_ecoff_read_ar_hdr _bfd_generic_read_ar_hdr
+#define _bfd_ecoff_write_ar_hdr _bfd_generic_write_ar_hdr
 #define _bfd_ecoff_openr_next_archived_file \
   bfd_generic_openr_next_archived_file
 #define _bfd_ecoff_get_elt_at_index _bfd_generic_get_elt_at_index
index 8edf547a3850e6b61f8dfdb9206515e801c1da3c..674cb1369c943bf15846ab53b42b2ab1371888cd 100644 (file)
 #ifndef MACH_O_TARGET_COMMON_DEFINED
 #define MACH_O_TARGET_COMMON_DEFINED
 
-#define bfd_mach_o_mkarchive                          _bfd_noarchive_mkarchive
-#define bfd_mach_o_read_ar_hdr                        _bfd_noarchive_read_ar_hdr
-#define bfd_mach_o_slurp_armap                        _bfd_noarchive_slurp_armap
-#define bfd_mach_o_slurp_extended_name_table          _bfd_noarchive_slurp_extended_name_table
-#define bfd_mach_o_construct_extended_name_table      _bfd_noarchive_construct_extended_name_table
-#define bfd_mach_o_truncate_arname                    _bfd_noarchive_truncate_arname
-#define bfd_mach_o_write_armap                        _bfd_noarchive_write_armap
-#define bfd_mach_o_get_elt_at_index                   _bfd_noarchive_get_elt_at_index
-#define bfd_mach_o_generic_stat_arch_elt              _bfd_noarchive_generic_stat_arch_elt
-#define bfd_mach_o_update_armap_timestamp             _bfd_noarchive_update_armap_timestamp
 #define bfd_mach_o_close_and_cleanup                  _bfd_generic_close_and_cleanup
 #define bfd_mach_o_bfd_free_cached_info               _bfd_generic_bfd_free_cached_info
 #define bfd_mach_o_new_section_hook                   _bfd_generic_new_section_hook
@@ -176,7 +166,7 @@ const bfd_target TARGET_NAME =
 #if TARGET_ARCHIVE
   BFD_JUMP_TABLE_ARCHIVE (bfd_mach_o),
 #else
-  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
+  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44),
 #endif
   BFD_JUMP_TABLE_SYMBOLS (bfd_mach_o),
   BFD_JUMP_TABLE_RELOCS (bfd_mach_o),
index abfd7c1b4d78a95e78f68ffe1fc1a57508df429d..20279c414b34754c9121e683456993ecf231c230 100644 (file)
@@ -4020,6 +4020,21 @@ bfd_mach_o_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
 #undef TARGET_BIG_ENDIAN
 #undef TARGET_ARCHIVE
 
+/* Not yet handled: creating an archive.  */
+#define bfd_mach_o_mkarchive                      _bfd_noarchive_mkarchive
+
+/* Not used.  */
+#define bfd_mach_o_read_ar_hdr                    _bfd_noarchive_read_ar_hdr
+#define bfd_mach_o_write_ar_hdr                   _bfd_noarchive_write_ar_hdr
+#define bfd_mach_o_slurp_armap                    _bfd_noarchive_slurp_armap
+#define bfd_mach_o_slurp_extended_name_table      _bfd_noarchive_slurp_extended_name_table
+#define bfd_mach_o_construct_extended_name_table  _bfd_noarchive_construct_extended_name_table
+#define bfd_mach_o_truncate_arname                _bfd_noarchive_truncate_arname
+#define bfd_mach_o_write_armap                    _bfd_noarchive_write_armap
+#define bfd_mach_o_get_elt_at_index               _bfd_noarchive_get_elt_at_index
+#define bfd_mach_o_generic_stat_arch_elt          _bfd_noarchive_generic_stat_arch_elt
+#define bfd_mach_o_update_armap_timestamp         _bfd_noarchive_update_armap_timestamp
+
 #define TARGET_NAME            mach_o_fat_vec
 #define TARGET_STRING          "mach-o-fat"
 #define TARGET_ARCHITECTURE    bfd_arch_unknown
index a3ef7526e9babc28a98261b9cff71e487a2afbd6..4987ccb170cd9f9cc53ac88d9906b6e3dcbc51a9 100644 (file)
@@ -1179,6 +1179,7 @@ oasys_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define oasys_truncate_arname                      bfd_dont_truncate_arname
 #define oasys_write_armap                          ((bfd_boolean (*) (bfd *, unsigned int, struct orl *, unsigned int, int)) bfd_true)
 #define oasys_read_ar_hdr                          bfd_nullvoidptr
+#define oasys_write_ar_hdr ((bfd_boolean (*) (bfd *, bfd *)) bfd_false)
 #define oasys_get_elt_at_index                     _bfd_generic_get_elt_at_index
 #define oasys_update_armap_timestamp               bfd_true
 #define oasys_bfd_is_local_label_name              bfd_generic_is_local_label_name
index ad22a29ded63e4e61c125fc24e1d104ce89b692b..726fe777b33c3bf2bd1eb73effc9e53fea812b3b 100644 (file)
@@ -328,6 +328,7 @@ BFD_JUMP_TABLE macros.
 .  NAME##_truncate_arname, \
 .  NAME##_write_armap, \
 .  NAME##_read_ar_hdr, \
+.  NAME##_write_ar_hdr, \
 .  NAME##_openr_next_archived_file, \
 .  NAME##_get_elt_at_index, \
 .  NAME##_generic_stat_arch_elt, \
@@ -341,6 +342,7 @@ BFD_JUMP_TABLE macros.
 .  bfd_boolean (*write_armap)
 .    (bfd *, unsigned int, struct orl *, unsigned int, int);
 .  void *      (*_bfd_read_ar_hdr_fn) (bfd *);
+.  bfd_boolean (*_bfd_write_ar_hdr_fn) (bfd *, bfd *);
 .  bfd *       (*openr_next_archived_file) (bfd *, bfd *);
 .#define bfd_get_elt_at_index(b,i) BFD_SEND (b, _bfd_get_elt_at_index, (b,i))
 .  bfd *       (*_bfd_get_elt_at_index) (bfd *, symindex);