summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/coff/xcoff.h56
1 files changed, 34 insertions, 22 deletions
diff --git a/include/coff/xcoff.h b/include/coff/xcoff.h
index 049ccd863ac..08afc000bf0 100644
--- a/include/coff/xcoff.h
+++ b/include/coff/xcoff.h
@@ -526,7 +526,7 @@ struct xcoff_ar_file_hdr
char freeoff[XCOFFARMAG_ELEMENT_SIZE];
};
-#define SIZEOF_AR_FILE_HDR (SXCOFFARMAG + 5 * XCOFFARMAG_ELEMENT_SIZE)
+#define SIZEOF_AR_FILE_HDR (sizeof (struct xcoff_ar_file_hdr))
/* This is the equivalent data structure for the big archive format. */
@@ -557,7 +557,7 @@ struct xcoff_ar_file_hdr_big
char freeoff[XCOFFARMAGBIG_ELEMENT_SIZE];
};
-#define SIZEOF_AR_FILE_HDR_BIG (SXCOFFARMAG + 6 * XCOFFARMAGBIG_ELEMENT_SIZE)
+#define SIZEOF_AR_FILE_HDR_BIG (sizeof (struct xcoff_ar_file_hdr_big))
/* Each XCOFF archive member starts with this (printable) structure. */
@@ -595,7 +595,7 @@ struct xcoff_ar_hdr
bytes is given in the size field. */
};
-#define SIZEOF_AR_HDR (3 * XCOFFARMAG_ELEMENT_SIZE + 4 * 12 + 4)
+#define SIZEOF_AR_HDR (sizeof (struct xcoff_ar_hdr))
/* The equivalent for the big archive format. */
@@ -633,35 +633,47 @@ struct xcoff_ar_hdr_big
bytes is given in the size field. */
};
-#define SIZEOF_AR_HDR_BIG (3 * XCOFFARMAGBIG_ELEMENT_SIZE + 4 * 12 + 4)
+#define SIZEOF_AR_HDR_BIG (sizeof (struct xcoff_ar_hdr_big))
+
+/* Track archive file offsets used by elements and the header. */
+struct ar_ranges
+{
+ ufile_ptr start, end;
+ struct ar_ranges *next;
+};
+
+/* An archive bfd has tdata pointing to a struct artdata. The xcoff
+ backend has artdata.tdata pointing to the following. */
+struct xcoff_artdata
+{
+ union
+ {
+ struct xcoff_ar_file_hdr hdr;
+ struct xcoff_ar_file_hdr_big bhdr;
+ } u;
+ struct ar_ranges ranges;
+ /* Anything less than this size can't hold an archive element. */
+ unsigned int min_elt;
+};
+
+#define x_artdata(abfd) ((struct xcoff_artdata *) bfd_ardata (abfd)->tdata)
/* We often have to distinguish between the old and big file format.
- Make it a bit cleaner. We can use `xcoff_ardata' here because the
- `hdr' member has the same size and position in both formats.
- <bigaf> is the default format, return TRUE even when xcoff_ardata is
- NULL. */
+ u.hdr.magic and u.bhdr.magic have the same size and position. */
#ifndef SMALL_ARCHIVE
/* Creates big archives by default */
#define xcoff_big_format_p(abfd) \
- ((NULL != bfd_ardata (abfd) && NULL == xcoff_ardata (abfd)) || \
- ((NULL != bfd_ardata (abfd)) && \
- (NULL != xcoff_ardata (abfd)) && \
- (xcoff_ardata (abfd)->magic[1] == 'b')))
+ (bfd_ardata (abfd) != NULL \
+ && (x_artdata (abfd) == NULL \
+ || x_artdata (abfd)->u.hdr.magic[1] == 'b'))
#else
/* Creates small archives by default. */
#define xcoff_big_format_p(abfd) \
- (((NULL != bfd_ardata (abfd)) && \
- (NULL != xcoff_ardata (abfd)) && \
- (xcoff_ardata (abfd)->magic[1] == 'b')))
+ (bfd_ardata (abfd) != NULL \
+ && x_artdata (abfd) != NULL \
+ && x_artdata (abfd)->u.hdr.magic[1] == 'b')
#endif
-/* We store a copy of the xcoff_ar_file_hdr in the tdata field of the
- artdata structure. Similar for the big archive. */
-#define xcoff_ardata(abfd) \
- ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata)
-#define xcoff_ardata_big(abfd) \
- ((struct xcoff_ar_file_hdr_big *) bfd_ardata (abfd)->tdata)
-
/* We store a copy of the xcoff_ar_hdr in the arelt_data field of an
archive element. Similar for the big archive. */
#define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))