Introduction
The small archive is the older IBM AIX archive format. It
starts with the eight bytes <aiaff>\n and has the same design as the
big archive, with narrower fields: offsets and sizes are decimal text of
12 bytes instead of 20, and there is one global symbol table, with 4-byte numbers, because the format has no
separate 64-bit table. Members are joined into a doubly linked list by offsets, so they need not lie in
order, and the member table and the symbol table are kept at the end of the file. This page follows IBM’s
documentation of ar.h.
Structure
0fixed-length header<aiaff>\nand five offsets68 bytes…members: header, name, dataeach at an offset a link gives…member tablea member with no name…global symbol tablea member with no name…free list: deleted membersspace for new ones
The fixed-length header
The header is 68 bytes: the magic string and five 12-byte fields, each a decimal number as ASCII text padded
with spaces (IBM’s struct fl_hdr):
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 8 | fl_magic | <aiaff>\n |
| 8 | 12 | fl_memoff | Offset of the member table |
| 20 | 12 | fl_gstoff | Offset of the global symbol table |
| 32 | 12 | fl_fstmoff | Offset of the first member |
| 44 | 12 | fl_lstmoff | Offset of the last member |
| 56 | 12 | fl_freeoff | Offset of the first member on the free list |
A zero offset means the part is not in the archive.
The member header
Each member starts with the fixed part of struct ar_hdr, 12-byte decimal fields (the mode in
octal) and a 4-byte name length:
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 12 | ar_size | Size of the member’s data, in bytes |
| 12 | 12 | ar_nxtmem | Offset of the next member; 0 at the end |
| 24 | 12 | ar_prvmem | Offset of the previous member; 0 at the start |
| 36 | 12 | ar_date | Modification time (decimal seconds since 1970) |
| 48 | 12 | ar_uid | User number |
| 60 | 12 | ar_gid | Group number |
| 72 | 12 | ar_mode | File mode (octal) |
| 84 | 4 | ar_namlen | Length of the name |
| 88 | ar_namlen | _ar_name | The name, up to 255 characters |
The structure is 90 bytes by the sum of IBM’s fields (88 and the two bytes `\n of
ar_fmag, which IBM calls cosmetic). The header is that plus the name length, and the data starts
at the first even offset after it. Headers start on even offsets, and padding is zero bytes. The explorer
reads a header as 88 bytes, the name padded to an even length, and `\n, the same arrangement
llvm-ar writes for the big archive.
The member table
A member with a zero-length name at fl_memoff. Its data is a member count (12 bytes of decimal
text), one 12-byte decimal offset for each member header, and the members’ names as zero-terminated strings
in the same order.
The global symbol table
A member with a zero-length name at fl_gstoff. Its data is a symbol count (4 bytes), one 4-byte
offset for each symbol (the header of the member that defines it), and the names as zero-terminated strings
in the same order. IBM says the numbers are read with sgetl and sputl, which are
big-endian; the explorer reads them that way.
The free list
Deleted members go on the free list, which starts at fl_freeoff and runs through the members’
next-member offsets.
In the explorer
The explorer reads the small archive as it reads the big archive: the fixed-length header, every member with its links, the member table, the symbol table and the free list. It walks the chain forward and backward and reports loops, links that do not match, tables that disagree with the members and members that run past the end of the file. Members open as files where there is a viewer; XCOFF objects show as bytes.
Not described
Known, not yet covered
- Viewer: the members are XCOFF objects, and the explorer has no XCOFF viewer, so they open as bytes.
- Reference: only IBM’s page was used.
llvm-arhas no writer for the small format (it reads and writes only the big archive), so the test file for this format was made by hand to the layout above, and no archive written by AIX’sarwas checked. Whether AIX chains the tables after the last file member, and the exact order of the name padding and the`\ntrailer, are as llvm writes them for the big archive and unconfirmed for the small one. - Reference: how the free list’s members are linked is not described by IBM and is untested here.
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
- IBM AIX – the operating system whose
arcommand makes and reads them (AIX)
Reference
- ar File Format (Small) – IBM’s documentation of the fixed-length header, member header, member table and symbol table