Variants of the command were developed to address issues including: ; File name length limitation: The BSD and System V/GNU variants devised different methods of storing long file names. ; Global symbol table: Many implementations include a global symbol table (a.k.a. armap, directory or index) for fast linking without needing to scan the whole archive for a symbol. POSIX recognizes this feature, and requires implementations to have an option for updating it. Most implementations put it at the first file entry. ;
Year 2038 problem: Although the common format is not at risk of this problem, many implementations are vulnerable to failure in that year.
BSD The BSD implementation stores file names right-padded with ASCII spaces. This causes issues with spaces inside file names. The
4.4BSD implementation stores extended file names by placing the string "#1/" followed by the file name length in the file name field, and storing the real file name in front of the data section. which inserts an architecture-specific file named __.SYMDEF as first archive member. Some descendants put a space and "SORTED" after the name to indicate a sorted version. A 64-bit variant called exists on
Darwin. To conform to POSIX, newer BSD implementations support the option instead of . FreeBSD in particular ditched the SYMDEF table format and embraced the System V style table.
System V/GNU To allow spaces in file names, the System V implementation uses a slash ('/') to mark the end of the file. This limits the file name to 15 chars. Filenames longer than 15 ASCII chars are replaced by an index, represented by a slash ('/') followed by the decimal character offset in the indexfile of the start or the name. The index file is named "//" and is usually the second entry of the archive, after the symbol table which always is the first. The format of this "//" file itself is simply a list of the long file names, separated by one or more LF characters. LF characters cannot be part of a filename. The GNU version uses '/'-terminated names and no LF. The System V implementation uses the special file name "/" to denote that the following data entry contains a symbol lookup table, which is used in ar libraries to speed up access. This symbol table is built in three parts which are recorded together as contiguous data. • A 32-bit big endian integer, giving the number of entries in the table. • A set of 32-bit big endian integers. One for each symbol, recording the position within the archive of the header for the file containing this symbol. • A set of Zero-terminated strings. Each is a symbol name, and occurs in the same order as the list of positions in part 2. Some System V systems do not use this format. For operating systems such as
HP-UX 11.0, this information is stored in a data structure based on the
SOM file format. The special file "/" is not terminated with a specific sequence; the end is assumed once the last symbol name has been read. To overcome the 4 GiB file size limit some operating system like
Solaris 11.2 and GNU use a variant lookup table. Instead of 32-bit integers, 64-bit integers are used in the symbol lookup tables. The string "/SYM64/" instead "/" is used as identifier for this table
Windows The
Windows (PE/COFF) variant is based on the SysV/GNU variant. The first entry "/" has the same layout as the SysV/GNU symbol table. The second entry is another "/", a Microsoft extension that stores an extended symbol cross-reference table. This one is sorted and uses little-endian integers. The third entry is the optional "//" long name data as in SysV/GNU.
Thin archive The
GNU binutils and
Elfutils implementations have an additional "thin archive" format with the magic number !. A thin archive only contains a symbol table and references to the file. The file format is essentially a System V format archive where every file is stored without the data sections. Every file name is stored as a "long" file name and they are to be resolved as if they were
symbolic links. == Examples ==