1 .\" Copyright (c) 1990, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)ar.5.5 8.1 (Berkeley) 6/9/93
33 .\" $FreeBSD: src/usr.bin/ar/ar.5,v 1.5.2.2 2001/12/14 15:53:29 ru Exp $
34 .\" $DragonFly: src/usr.bin/ar/Attic/ar.5,v 1.3 2006/02/17 19:38:54 swildner Exp $
41 .Nd archive (library) file format
47 combines several files into one.
48 Archives are mainly used as libraries of object files intended to be
49 loaded using the link-editor
54 begins with the ``magic'' string "!<arch>\en".
55 The rest of the archive is made up of objects, each of which is composed
56 of a header for a file, a possible file name, and the file contents.
57 The header is portable between machine architectures, and, if the file
58 contents are printable, the archive is itself printable.
60 The header is made up of six variable length
63 two character trailer.
64 The fields are the object name (16 characters), the file last modification
65 time (12 characters), the user and group id's (each 6 characters), the file
66 mode (8 characters) and the file size (10 characters).
67 All numeric fields are in decimal, except for the file mode which is in
70 The modification time is the file
76 The user and group id's are the file
81 The file mode is the file
84 The file size is the file
87 The two-byte trailer is the string "\`\en".
89 Only the name field has any provision for overflow.
90 If any file name is more than 16 characters in length or contains an
91 embedded space, the string "#1/" followed by the
94 name is written in the name field.
95 The file size (stored in the archive header) is incremented by the length
97 The name is then written immediately following the archive header.
99 Any unused characters in any of these fields are written as space
101 If any fields are their particular maximum number of characters in
102 length, there will be no separation between the fields.
104 Objects in the archive are always an even number of bytes long; files
105 which are an odd number of bytes long are padded with a newline (``\en'')
106 character, although the size in the header does not reflect this.
108 No archive format is currently specified by any standard.
110 has historically distributed archives in a different format from
116 There have been at least four
119 The first was denoted by the leading ``magic'' number 0177555 (stored as
121 These archives were almost certainly created on a 16-bit machine, and
122 contain headers made up of five fields.
123 The fields are the object name (8 characters), the file last modification
124 time (type long), the user id (type char), the file mode (type char) and
125 the file size (type unsigned int).
126 Files were padded to an even number of bytes.
128 The second was denoted by the leading ``magic'' number 0177545 (stored as
130 These archives may have been created on either 16 or 32-bit machines, and
131 contain headers made up of six fields.
132 The fields are the object name (14 characters), the file last modification
133 time (type long), the user and group id's (each type char), the file mode
134 (type int) and the file size (type long).
135 Files were padded to an even number of bytes.
136 .\" For more information on converting from this format see
139 The current archive format (without support for long character names and
140 names with embedded spaces) was introduced in
142 The headers were the same as the current format, with the exception that
143 names longer than 16 characters were truncated, and names with embedded
144 spaces (and often trailing spaces) were not supported.
145 It has been extended for these reasons,
147 This format first appeared in