Introduction
The static libraries on macOS and the BSDs use the BSD layout of the ar archive. On macOS each member is usually a Mach-O object file, and Apple’s libtool and ranlib make them. A file for several processors is a Mach-O universal file holding one archive for each.
Structure
0signature!<arch>\n8 bytes8symbol index__.SYMDEF,__.SYMDEF SORTED, or the same with_6460 bytes + size…members60 bytes + size, even offsets
A member header is laid out as shown on the member header page, and the index on the symbol index page.
Long names
A name that does not fit 16 bytes, or that holds a space, is written as #1/
followed by its length in the name field. The name itself comes straight after the
header, before the member’s data, and the header’s size field counts both. macOS pads
the name with zero bytes.
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
Links
Software
Reference
- ar(5) – the FreeBSD manual page for the archive format and its variants