1 .\" Copyright (c) 2010 Joseph Koshy. All rights reserved.
3 .\" Redistribution and use in source and binary forms, with or without
4 .\" modification, are permitted provided that the following conditions
6 .\" 1. Redistributions of source code must retain the above copyright
7 .\" notice, this list of conditions and the following disclaimer.
8 .\" 2. Redistributions in binary form must reproduce the above copyright
9 .\" notice, this list of conditions and the following disclaimer in the
10 .\" documentation and/or other materials provided with the distribution.
12 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 .Nd archive file format for
37 archives are created and managed by the
42 These archives are typically used during program development to
43 hold libraries of program objects.
46 archive is contained in a single operating system file.
48 This manual page documents two variants of the
50 archive format: the BSD archive format, and the SVR4/GNU archive
53 In both variants the archive file starts with an identifying byte
54 sequence of the seven ASCII characters
56 followed by a ASCII linefeed character
64 Archive members follow the initial identifying byte sequence.
65 Each archive member is prefixed by a fixed size header describing the
66 file attributes associated with the member.
68 An archive header describes the file attributes for the archive member that
72 format only supports a limited number of attributes: the file name,
73 the file creation time stamp, the uid and gid of the creator, the file
74 mode and the file size.
76 Archive headers are placed at an even byte offset in the archive file.
77 If the data for an archive member ends at an odd byte offset, then a
78 padding byte with value 0x0A is used to position the next archive
79 header on an even byte offset.
81 An archive header comprises the following fixed sized fields:
82 .Bl -tag -width "Li ar_name"
84 (16 bytes) The file name of the archive member.
85 The format of this field varies between the BSD and SVR4/GNU formats and
86 is described in more detail in the section
87 .Sx "Representing File Names"
90 (12 bytes) The file modification time for the member in seconds since the
91 epoch, encoded as a decimal number.
93 (6 bytes) The uid associated with the archive member, encoded as a
96 (6 bytes) The gid associated with the archive member, encoded as a
99 (8 bytes) The file mode for the archive member, encoded as an octal
102 (10 bytes) In the SVR4/GNU archive format this field holds the size in
103 bytes of the archive member, encoded as a decimal number.
104 In the BSD archive format, for short file names, this field
105 holds the size in bytes of the archive member, encoded as a decimal
110 .Sx "Representing File Names"
113 the field contains the combined size of the
114 archive member and its file name, encoded as a decimal number.
116 (2 bytes) This field holds 2 bytes with values 0x96 and 0x0A
117 respectively, marking the end of the header.
120 Unused bytes in the fields of an archive header are set to the value
122 .Ss "Representing File Names"
123 The BSD and SVR4/GNU variants use different schemes for encoding file
125 .Bl -tag -width "SVR4/GNU"
127 File names that are up to 16 bytes long and which do not contain
128 embedded spaces are stored directly in the
130 field of the archive header.
131 File names that are either longer than 16 bytes or which contain
132 embedded spaces are stored immediately after the archive header
135 field of the archive header is set to the string
137 followed by a decimal representation of the number of bytes needed for
141 field of the archive header is set to the decimal representation of
142 the combined sizes of the archive member and the file name.
143 The file contents of the member follows the file name without further
146 As an example, if the file name for a member was
148 and its contents was the string
152 field of the header would contain
156 field of the header would contain
158 and the bytes immediately following the header would be 0x41, 0x20,
159 0x42, 0x43, 0x20 and 0x44
165 File names that are up to 15 characters long are stored directly in the
167 field of the header, terminated by a
171 If the file name is larger than would fit in space for the
173 field, then the actual file name is kept in the archive
177 .Sx "Archive String Tables"
180 and the decimal offset of the file name in the string table is stored
187 As an example, if the real file name has been stored at offset 768 in
188 the archive string table, the
190 field of the header will contain the string
193 .Ss "Special Archive Members"
194 The following archive members are special.
195 .Bl -tag -width indent
197 In the SVR4/GNU variant of the archive format, the archive member with
200 denotes an archive symbol table.
201 If present, this member will be the very first member in the
204 In the SVR4/GNU variant of the archive format, the archive member with
207 denotes the archive string table.
208 This special member is used to hold filenames that do not fit in the
209 file name field of the header
212 .Sx "Representing File Names"
215 If present, this member immediately follows the archive symbol table
216 if an archive symbol table is present, or is the first member otherwise.
217 .It Dq Li "__.SYMDEF"
218 This special member contains the archive symbol table in the BSD
219 variant of the archive format.
220 If present, this member will be the very first member in the
223 .Ss "Archive String Tables"
224 An archive string table is used in the SVR4/GNU archive format to hold
225 file names that are too large to fit into the constraints of the
227 field of the archive header.
228 An archive string table contains a sequence of file names.
229 Each file name in the archive string table is terminated by the
230 byte sequence 0x2F, 0x0A
235 No padding is used to separate adjacent file names.
236 .Ss "Archive Symbol Tables"
237 Archive symbol tables are used to speed up link editing by providing a
238 mapping between the program symbols defined in the archive
239 and the corresponding archive members.
240 Archive symbol tables are managed by the
244 The format of archive symbol tables is as follows:
245 .Bl -tag -width "SVR4/GNU"
247 In the BSD archive format, the archive symbol table comprises
248 of two parts: a part containing an array of
250 descriptors, followed by a part containing a symbol string table.
251 The sizes and layout of the structures that make up a BSD format
252 archive symbol table are machine dependent.
256 descriptors begins with a field containing the size in bytes of the
259 descriptors encoded as a C
265 descriptors follows the size field.
268 descriptor describes one symbol.
272 descriptor comprises two fields:
273 .Bl -tag -width "Ar ran_strx" -compact
276 This field contains the zero-based offset of the symbol name in the
280 This field is the file offset to the archive header for the archive
281 member defining the symbol.
284 The part containing the symbol string table begins with a field
285 containing the size in bytes of the string table, encoded as a C
288 This string table follows the size field, and contains
289 NUL-terminated strings for the symbols in the symbol table.
291 In the SVR4/GNU archive format, the archive symbol table starts with a
292 4-byte binary value containing the number of entries contained in the
293 archive symbol table.
294 This count of entries is stored most significant byte first.
298 4-byte numbers, each stored most significant byte first.
299 Each number is a binary offset to the archive header for the member in
300 the archive file for the corresponding symbol table entry.
302 After the binary offset values, there are
304 NUL-terminated strings in sequence, holding the symbol names for
305 the corresponding symbol table entries.
307 .Sh STANDARDS COMPLIANCE
310 archive format is not currently specified by a standard.
312 This manual page documents the
314 archive formats used by the
318 operating system releases.