aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog58
-rw-r--r--bfd/aout-target.h3
-rw-r--r--bfd/aout-tic30.c3
-rw-r--r--bfd/archive.c129
-rw-r--r--bfd/bfd-in2.h2
-rw-r--r--bfd/coff-alpha.c1
-rw-r--r--bfd/coff-rs6000.c2
-rw-r--r--bfd/coff64-rs6000.c2
-rw-r--r--bfd/elf64-mips.c1
-rw-r--r--bfd/ieee.c1
-rw-r--r--bfd/libbfd-in.h33
-rw-r--r--bfd/libbfd.h33
-rw-r--r--bfd/libecoff.h1
-rw-r--r--bfd/mach-o-target.c12
-rw-r--r--bfd/mach-o.c15
-rw-r--r--bfd/oasys.c1
-rw-r--r--bfd/targets.c2
17 files changed, 274 insertions, 25 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 75118cb..d882c17 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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>
diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index 39c8d34..5689641 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -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
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
index 50d153b..23e6c0f 100644
--- a/bfd/aout-tic30.c
+++ b/bfd/aout-tic30.c
@@ -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
diff --git a/bfd/archive.c b/bfd/archive.c
index 2e1c8f0..6fad826 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -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]))
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;
+}
+
+/* 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;
+}
/* 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;
}
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index df9b6e0..8d9a464 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -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);
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index ce217f5..8a8f620 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -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
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 2f13f48..37e8b8a 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -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,
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 15e636e..7668e7a 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -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,
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index 312c976..6676ee6 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -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 \
diff --git a/bfd/ieee.c b/bfd/ieee.c
index 429572b..3ceef35 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -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
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 8c6f9b6..1af47e1 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -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))
/* 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). */
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 073086c..2be8fe5 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -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))
/* 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). */
diff --git a/bfd/libecoff.h b/bfd/libecoff.h
index 75c65e7..fdf3379 100644
--- a/bfd/libecoff.h
+++ b/bfd/libecoff.h
@@ -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
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index 8edf547..674cb13 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -25,16 +25,6 @@
#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),
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index abfd7c1..20279c4 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -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
diff --git a/bfd/oasys.c b/bfd/oasys.c
index a3ef752..4987ccb 100644
--- a/bfd/oasys.c
+++ b/bfd/oasys.c
@@ -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
diff --git a/bfd/targets.c b/bfd/targets.c
index ad22a29..726fe77 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -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);