blob: 815399aca5574ed87cb9733ddfe063dbc47e3d41 [file] [log] [blame]
Daniel Dunbar3b709d52012-05-08 16:50:35 +00001llvm-ar - LLVM archiver
2=======================
3
4
5SYNOPSIS
6--------
7
8
Rafael Espindola94bc2462012-08-10 01:57:52 +00009**llvm-ar** [-]{dmpqrtx}[Rabfikou] [relpos] [count] <archive> [files...]
Daniel Dunbar3b709d52012-05-08 16:50:35 +000010
11
12DESCRIPTION
13-----------
14
15
16The **llvm-ar** command is similar to the common Unix utility, ``ar``. It
17archives several files together into a single file. The intent for this is
18to produce archive libraries by LLVM bitcode that can be linked into an
19LLVM program. However, the archive can contain any kind of file. By default,
20**llvm-ar** generates a symbol table that makes linking faster because
21only the symbol table needs to be consulted, not each individual file member
22of the archive.
23
Rafael Espindola36f5ac12013-07-24 13:13:24 +000024The **llvm-ar** command can be used to *read* SVR4, GNU and BSD style archive
25files. However, right now it can only write in the GNU format. If an
Daniel Dunbar3b709d52012-05-08 16:50:35 +000026SVR4 or BSD style archive is used with the ``r`` (replace) or ``q`` (quick
Rafael Espindola36f5ac12013-07-24 13:13:24 +000027update) operations, the archive will be reconstructed in GNU format.
Daniel Dunbar3b709d52012-05-08 16:50:35 +000028
29Here's where **llvm-ar** departs from previous ``ar`` implementations:
30
31
32*Symbol Table*
33
Rafael Espindola36f5ac12013-07-24 13:13:24 +000034 Since **llvm-ar** supports bitcode files. The symbol table it creates
35 is in GNU format and includes both native and bitcode files.
Daniel Dunbar3b709d52012-05-08 16:50:35 +000036
37
38*Long Paths*
39
Rafael Espindola36f5ac12013-07-24 13:13:24 +000040 Currently **llvm-ar** can read GNU and BSD long file names, but only writes
41 archives with the GNU format.
Daniel Dunbar3b709d52012-05-08 16:50:35 +000042
43
44
45OPTIONS
46-------
47
48
49The options to **llvm-ar** are compatible with other ``ar`` implementations.
Rafael Espindola94bc2462012-08-10 01:57:52 +000050However, there are a few modifiers (*R*) that are not found in other ``ar``
Daniel Dunbar3b709d52012-05-08 16:50:35 +000051implementations. The options to **llvm-ar** specify a single basic operation to
52perform on the archive, a variety of modifiers for that operation, the name of
53the archive file, and an optional list of file names. These options are used to
54determine how **llvm-ar** should process the archive file.
55
56The Operations and Modifiers are explained in the sections below. The minimal
57set of options is at least one operator and the name of the archive. Typically
58archive files end with a ``.a`` suffix, but this is not required. Following
59the *archive-name* comes a list of *files* that indicate the specific members
60of the archive to operate on. If the *files* option is not specified, it
61generally means either "none" or "all" members, depending on the operation.
62
63Operations
64~~~~~~~~~~
65
66
67
68d
69
70 Delete files from the archive. No modifiers are applicable to this operation.
71 The *files* options specify which members should be removed from the
72 archive. It is not an error if a specified file does not appear in the archive.
73 If no *files* are specified, the archive is not modified.
74
75
76
77m[abi]
78
79 Move files from one location in the archive to another. The *a*, *b*, and
80 *i* modifiers apply to this operation. The *files* will all be moved
81 to the location given by the modifiers. If no modifiers are used, the files
82 will be moved to the end of the archive. If no *files* are specified, the
83 archive is not modified.
84
85
86
87p[k]
88
89 Print files to the standard output. The *k* modifier applies to this
90 operation. This operation simply prints the *files* indicated to the
91 standard output. If no *files* are specified, the entire archive is printed.
92 Printing bitcode files is ill-advised as they might confuse your terminal
93 settings. The *p* operation never modifies the archive.
94
95
96
Rafael Espindola94bc2462012-08-10 01:57:52 +000097q[Rf]
Daniel Dunbar3b709d52012-05-08 16:50:35 +000098
Rafael Espindola94bc2462012-08-10 01:57:52 +000099 Quickly append files to the end of the archive. The *R*, and *f*
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000100 modifiers apply to this operation. This operation quickly adds the
101 *files* to the archive without checking for duplicates that should be
102 removed first. If no *files* are specified, the archive is not modified.
103 Because of the way that **llvm-ar** constructs the archive file, its dubious
104 whether the *q* operation is any faster than the *r* operation.
105
106
107
Rafael Espindola94bc2462012-08-10 01:57:52 +0000108r[Rabfu]
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000109
Rafael Espindola94bc2462012-08-10 01:57:52 +0000110 Replace or insert file members. The *R*, *a*, *b*, *f*, and *u*
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000111 modifiers apply to this operation. This operation will replace existing
112 *files* or insert them at the end of the archive if they do not exist. If no
113 *files* are specified, the archive is not modified.
114
115
116
117t[v]
118
119 Print the table of contents. Without any modifiers, this operation just prints
120 the names of the members to the standard output. With the *v* modifier,
Rafael Espindola94bc2462012-08-10 01:57:52 +0000121 **llvm-ar** also prints out the file type (B=bitcode, S=symbol
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000122 table, blank=regular file), the permission mode, the owner and group, the
123 size, and the date. If any *files* are specified, the listing is only for
124 those files. If no *files* are specified, the table of contents for the
125 whole archive is printed.
126
127
128
129x[oP]
130
131 Extract archive members back to files. The *o* modifier applies to this
132 operation. This operation retrieves the indicated *files* from the archive
133 and writes them back to the operating system's file system. If no
134 *files* are specified, the entire archive is extract.
135
136
137
138
139Modifiers (operation specific)
140~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141
142
143The modifiers below are specific to certain operations. See the Operations
144section (above) to determine which modifiers are applicable to which operations.
145
146
147[a]
148
149 When inserting or moving member files, this option specifies the destination of
150 the new files as being after the *relpos* member. If *relpos* is not found,
151 the files are placed at the end of the archive.
152
153
154
155[b]
156
157 When inserting or moving member files, this option specifies the destination of
158 the new files as being before the *relpos* member. If *relpos* is not
159 found, the files are placed at the end of the archive. This modifier is
Sylvestre Ledruc8e41c52012-07-23 08:51:15 +0000160 identical to the *i* modifier.
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000161
162
163
164[f]
165
166 Normally, **llvm-ar** stores the full path name to a file as presented to it on
167 the command line. With this option, truncated (15 characters max) names are
168 used. This ensures name compatibility with older versions of ``ar`` but may also
169 thwart correct extraction of the files (duplicates may overwrite). If used with
170 the *R* option, the directory recursion will be performed but the file names
171 will all be flattened to simple file names.
172
173
174
175[i]
176
177 A synonym for the *b* option.
178
179
180
181[k]
182
183 Normally, **llvm-ar** will not print the contents of bitcode files when the
184 *p* operation is used. This modifier defeats the default and allows the
185 bitcode members to be printed.
186
187
188
189[N]
190
191 This option is ignored by **llvm-ar** but provided for compatibility.
192
193
194
195[o]
196
197 When extracting files, this option will cause **llvm-ar** to preserve the
198 original modification times of the files it writes.
199
200
201
202[P]
203
204 use full path names when matching
205
206
207
208[R]
209
210 This modifier instructions the *r* option to recursively process directories.
211 Without *R*, directories are ignored and only those *files* that refer to
212 files will be added to the archive. When *R* is used, any directories specified
213 with *files* will be scanned (recursively) to find files to be added to the
214 archive. Any file whose name begins with a dot will not be added.
215
216
217
218[u]
219
220 When replacing existing files in the archive, only replace those files that have
221 a time stamp than the time stamp of the member in the archive.
222
223
224
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000225
226Modifiers (generic)
227~~~~~~~~~~~~~~~~~~~
228
229
230The modifiers below may be applied to any operation.
231
232
233[c]
234
235 For all operations, **llvm-ar** will always create the archive if it doesn't
236 exist. Normally, **llvm-ar** will print a warning message indicating that the
237 archive is being created. Using this modifier turns off that warning.
238
239
240
241[s]
242
243 This modifier requests that an archive index (or symbol table) be added to the
244 archive. This is the default mode of operation. The symbol table will contain
245 all the externally visible functions and global variables defined by all the
Rafael Espindola250bfb12013-06-14 23:25:53 +0000246 bitcode files in the archive.
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000247
248
249
250[S]
251
252 This modifier is the opposite of the *s* modifier. It instructs **llvm-ar** to
253 not build the symbol table. If both *s* and *S* are used, the last modifier to
254 occur in the options will prevail.
255
256
257
258[v]
259
260 This modifier instructs **llvm-ar** to be verbose about what it is doing. Each
261 editing operation taken against the archive will produce a line of output saying
262 what is being done.
263
264
265
266
267
268STANDARDS
269---------
270
271
272The **llvm-ar** utility is intended to provide a superset of the IEEE Std 1003.2
273(POSIX.2) functionality for ``ar``. **llvm-ar** can read both SVR4 and BSD4.4 (or
274Mac OS X) archives. If the ``f`` modifier is given to the ``x`` or ``r`` operations
275then **llvm-ar** will write SVR4 compatible archives. Without this modifier,
276**llvm-ar** will write BSD4.4 compatible archives that have long names
277immediately after the header and indicated using the "#1/ddd" notation for the
278name in the header.
279
280
281FILE FORMAT
282-----------
283
284
285The file format for LLVM Archive files is similar to that of BSD 4.4 or Mac OSX
286archive files. In fact, except for the symbol table, the ``ar`` commands on those
287operating systems should be able to read LLVM archive files. The details of the
288file format follow.
289
290Each archive begins with the archive magic number which is the eight printable
291characters "!<arch>\n" where \n represents the newline character (0x0A).
292Following the magic number, the file is composed of even length members that
293begin with an archive header and end with a \n padding character if necessary
294(to make the length even). Each file member is composed of a header (defined
295below), an optional newline-terminated "long file name" and the contents of
296the file.
297
298The fields of the header are described in the items below. All fields of the
299header contain only ASCII characters, are left justified and are right padded
300with space characters.
301
302
303name - char[16]
304
305 This field of the header provides the name of the archive member. If the name is
306 longer than 15 characters or contains a slash (/) character, then this field
307 contains ``#1/nnn`` where ``nnn`` provides the length of the name and the ``#1/``
308 is literal. In this case, the actual name of the file is provided in the ``nnn``
309 bytes immediately following the header. If the name is 15 characters or less, it
310 is contained directly in this field and terminated with a slash (/) character.
311
312
313
314date - char[12]
315
316 This field provides the date of modification of the file in the form of a
317 decimal encoded number that provides the number of seconds since the epoch
318 (since 00:00:00 Jan 1, 1970) per Posix specifications.
319
320
321
322uid - char[6]
323
324 This field provides the user id of the file encoded as a decimal ASCII string.
325 This field might not make much sense on non-Unix systems. On Unix, it is the
326 same value as the st_uid field of the stat structure returned by the stat(2)
327 operating system call.
328
329
330
331gid - char[6]
332
333 This field provides the group id of the file encoded as a decimal ASCII string.
334 This field might not make much sense on non-Unix systems. On Unix, it is the
335 same value as the st_gid field of the stat structure returned by the stat(2)
336 operating system call.
337
338
339
340mode - char[8]
341
342 This field provides the access mode of the file encoded as an octal ASCII
343 string. This field might not make much sense on non-Unix systems. On Unix, it
344 is the same value as the st_mode field of the stat structure returned by the
345 stat(2) operating system call.
346
347
348
349size - char[10]
350
351 This field provides the size of the file, in bytes, encoded as a decimal ASCII
Rafael Espindola94bc2462012-08-10 01:57:52 +0000352 string.
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000353
354
355
356fmag - char[2]
357
358 This field is the archive file member magic number. Its content is always the
359 two characters back tick (0x60) and newline (0x0A). This provides some measure
360 utility in identifying archive files that have been corrupted.
361
362
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000363offset - vbr encoded 32-bit integer
364
365 The offset item provides the offset into the archive file where the bitcode
366 member is stored that is associated with the symbol. The offset value is 0
367 based at the start of the first "normal" file member. To derive the actual
368 file offset of the member, you must add the number of bytes occupied by the file
369 signature (8 bytes) and the symbol tables. The value of this item is encoded
370 using variable bit rate encoding to reduce the size of the symbol table.
371 Variable bit rate encoding uses the high bit (0x80) of each byte to indicate
372 if there are more bytes to follow. The remaining 7 bits in each byte carry bits
373 from the value. The final byte does not have the high bit set.
374
375
376
377length - vbr encoded 32-bit integer
378
379 The length item provides the length of the symbol that follows. Like this
380 *offset* item, the length is variable bit rate encoded.
381
382
383
384symbol - character array
385
386 The symbol item provides the text of the symbol that is associated with the
387 *offset*. The symbol is not terminated by any character. Its length is provided
388 by the *length* field. Note that is allowed (but unwise) to use non-printing
389 characters (even 0x00) in the symbol. This allows for multiple encodings of
390 symbol names.
391
392
393
394
395EXIT STATUS
396-----------
397
398
399If **llvm-ar** succeeds, it will exit with 0. A usage error, results
400in an exit code of 1. A hard (file system typically) error results in an
401exit code of 2. Miscellaneous or unknown errors result in an
402exit code of 3.
403
404
405SEE ALSO
406--------
407
408
Rafael Espindola250bfb12013-06-14 23:25:53 +0000409ar(1)