Introduction
The big archive is a static library format of IBM AIX, made
for archives that hold both 32-bit and 64-bit objects (IBM’s page says the format accommodates both). It starts with the eight bytes
<bigaf>\n and is not a Unix !<arch> archive: every number in it is
written as decimal text, the members are joined into a doubly linked list by offsets instead of lying one
after another, and the member table and the global symbol tables are kept at the end of the file. Its
members are usually XCOFF object files, AIX’s own object format.
This page describes the layout from IBM’s documentation of ar.h. The
AIX small archive is the older form with narrower fields.
Structure
0fixed-length header<bigaf>\nand six offsets120 bytes…members: header, name, dataeach at an offset a link gives…member tablea member with no name…global symbol table, 32-bita member with no name…global symbol table, 64-bita member with no name…free list: deleted membersspace for new ones
The members are not necessarily stored in the order of the list: the order comes from the links. A reader
starts at the first member (fl_fstmoff) and follows each member’s next-member offset until
it reaches 0. The last member (fl_lstmoff) is the start for walking back the other way.
The fixed-length header
The header is 120 bytes: the magic string and six fields of 20 bytes, each a decimal number as ASCII text
padded with spaces. In IBM’s struct fl_hdr they are:
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 8 | fl_magic | <bigaf>\n |
| 8 | 20 | fl_memoff | Offset of the member table |
| 28 | 20 | fl_gstoff | Offset of the 32-bit global symbol table |
| 48 | 20 | fl_gst64off | Offset of the 64-bit global symbol table |
| 68 | 20 | fl_fstmoff | Offset of the first member |
| 88 | 20 | fl_lstmoff | Offset of the last member |
| 108 | 20 | fl_freeoff | Offset of the first member on the free list |
IBM: a zero offset means the member is not present in the archive. An archive with only 32-bit objects has no 64-bit table, and the reverse.
The member header
Each member starts with the fixed part of struct ar_hdr, all printable ASCII, with decimal
numbers except the mode, which is octal:
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 20 | ar_size | Size of the member’s data, in bytes |
| 20 | 20 | ar_nxtmem | Offset of the next member; 0 at the end |
| 40 | 20 | ar_prvmem | Offset of the previous member; 0 at the start |
| 60 | 12 | ar_date | Modification time (decimal seconds since 1970) |
| 72 | 12 | ar_uid | User number |
| 84 | 12 | ar_gid | Group number |
| 96 | 12 | ar_mode | File mode (octal) |
| 108 | 4 | ar_namlen | Length of the name |
| 112 | ar_namlen | _ar_name | The name, up to 255 characters |
The name is followed by a zero byte if its length is odd, and then by the two bytes
`\n (ar_fmag, which IBM calls cosmetic). IBM gives the header’s length as
sizeof (struct ar_hdr) + ar_namlen, where the structure is 114 bytes by the sum of its fields;
the data starts at the first even offset after that, so the data of a member with a name of
n bytes starts 112 + n rounded up to even + 2 bytes after the header’s start. The data
runs for ar_size bytes. Headers start on even offsets, and ar pads with zero
bytes.
The member table
An indexed archive always has a member table, at fl_memoff. It is a member with a zero-length
name that ar keeps up to date and does not list. Its data is a count of members (20 bytes of
decimal text), one 20-byte decimal offset for each member header, and then the members’ names as
zero-terminated strings, in the same order as the offsets.
The global symbol tables
Two more nameless members follow the member table: the 32-bit table at fl_gstoff and the
64-bit table at fl_gst64off. A table is left out when no member of that size exists, and
strip can delete either. Each holds a symbol count (8 bytes, a big-endian binary number), one
8-byte big-endian offset for each symbol (the header of the member that defines it), and the symbol names as
zero-terminated strings in the same order.
The free list
A member that is deleted goes on the free list, which starts at fl_freeoff and runs through
the members’ next-member offsets. ar uses the space on the list before it makes the file
longer.
What llvm-ar writes
llvm-ar --format=bigarchive makes archives that the reader here follows with no problem. It puts
the file members first, then the member table, the 32-bit table and the 64-bit table in the same chain: the
last file member’s next-member offset is the member table, the table’s next is the symbol table, and so on,
while fl_lstmoff still names the last file member. The viewer accepts a chain that ends at the
last file member too, and a chain that carries the tables after it.
In the explorer
The explorer shows the fixed-length header with what each offset points at, every member with its next and previous links, the member table, both global symbol tables and the free list. It walks the chain forward from the first member and backward from the last, and reports a loop, a previous link that does not match, a walk that ends somewhere else, a table offset that points at no member, a name in the member table that differs from the member’s own, a symbol count that does not fit and a member that runs past the end of the file. Members of the kinds the explorer can open (ELF objects and nested archives) open from the Members table. XCOFF objects, the usual members, show as bytes.
Not described
Known, not yet covered
- Viewer: the members of an AIX archive are XCOFF objects, and the explorer has no XCOFF viewer, so they open as bytes. The member header, name and size are shown.
- Reference: IBM’s page says the free list holds deleted members and says nothing of how
its headers are linked or written; the explorer follows the next-member offsets from
fl_freeoff, which llvm never writes, so that part is untested on any real file. - Viewer: the layout was checked against archives built by
llvm-ar(member names withllvm-ar t, symbols withllvm-nm --print-armap) and against damaged copies of them, and not against archives written by AIX’s ownar, which was not available. Whether AIX itself chains the tables after the last file member is not known here. - Reference: IBM’s notes say the symbol-table numbers are read with
sgetlandsputl; the explorer reads them as big-endian 8-byte numbers, which is whatllvm-arwrites.
Also used for
- Assembly language source – Machine instructions as text; the syntax varies by assembler and processor.
Variants
- System V and GNU static library – the ar archive format of Linux and most Unix systems
- BSD and macOS static library – the ar archive format of macOS and the BSDs
- GNU thin archive – an archive that lists its members but leaves their data in other files
- AIX big archive – IBM AIX’s archive with linked members and 32-bit and 64-bit symbol tables
- AIX small archive – the older AIX archive with narrower fields
Links
Software
Reference
- ar File Format (Big) – IBM’s documentation of the fixed-length header, member header, member table, symbol tables and free list