1LLVM-AR(1)                    LLVM Command Guide                    LLVM-AR(1)
2
3
4

NAME

6       llvm-ar - LLVM archiver
7

SYNOPSIS

9       llvm-ar [-]{dmpqrtx}[Rabfikouz] [relpos] [count] <archive> [files...]
10

DESCRIPTION

12       The llvm-ar command is similar to the common Unix utility, "ar". It
13       archives several files together into a single file. The intent for this
14       is to produce archive libraries by LLVM bitcode that can be linked into
15       an LLVM program. However, the archive can contain any kind of file. By
16       default, llvm-ar generates a symbol table that makes linking faster
17       because only the symbol table needs to be consulted, not each
18       individual file member of the archive.
19
20       The llvm-ar command can be used to read both SVR4 and BSD style archive
21       files. However, it cannot be used to write them.  While the llvm-ar
22       command produces files that are almost identical to the format used by
23       other "ar" implementations, it has two significant departures in order
24       to make the archive appropriate for LLVM. The first departure is that
25       llvm-ar only uses BSD4.4 style long path names (stored immediately
26       after the header) and never contains a string table for long names. The
27       second departure is that the symbol table is formated for efficient
28       construction of an in-memory data structure that permits rapid (red-
29       black tree) lookups. Consequently, archives produced with llvm-ar
30       usually won't be readable or editable with any "ar" implementation or
31       useful for linking.  Using the "f" modifier to flatten file names will
32       make the archive readable by other "ar" implementations but not for
33       linking because the symbol table format for LLVM is unique. If an SVR4
34       or BSD style archive is used with the "r" (replace) or "q" (quick
35       update) operations, the archive will be reconstructed in LLVM format.
36       This means that the string table will be dropped (in deference to BSD
37       4.4 long names) and an LLVM symbol table will be added (by default).
38       The system symbol table will be retained.
39
40       Here's where llvm-ar departs from previous "ar" implementations:
41
42       Symbol Table
43           Since llvm-ar is intended to archive bitcode files, the symbol
44           table won't make much sense to anything but LLVM. Consequently, the
45           symbol table's format has been simplified. It consists simply of a
46           sequence of pairs of a file member index number as an LSB 4byte
47           integer and a null-terminated string.
48
49       Long Paths
50           Some "ar" implementations (SVR4) use a separate file member to
51           record long path names (> 15 characters). llvm-ar takes the BSD 4.4
52           and Mac OS X approach which is to simply store the full path name
53           immediately preceding the data for the file. The path name is null
54           terminated and may contain the slash (/) character.
55
56       Compression
57           llvm-ar can compress the members of an archive to save space. The
58           compression used depends on what's available on the platform and
59           what choices the LLVM Compressor utility makes. It generally favors
60           bzip2 but will select between "no compression" or bzip2 depending
61           on what makes sense for the file's content.
62
63       Directory Recursion
64           Most "ar" implementations do not recurse through directories but
65           simply ignore directories if they are presented to the program in
66           the files option. llvm-ar, however, can recurse through directory
67           structures and add all the files under a directory, if requested.
68
69       TOC Verbose Output
70           When llvm-ar prints out the verbose table of contents ("tv"
71           option), it precedes the usual output with a character indicating
72           the basic kind of content in the file. A blank means the file is a
73           regular file. A 'Z' means the file is compressed. A 'B' means the
74           file is an LLVM bitcode file. An 'S' means the file is the symbol
75           table.
76

OPTIONS

78       The options to llvm-ar are compatible with other "ar" implementations.
79       However, there are a few modifiers (zR) that are not found in other
80       "ar"s. The options to llvm-ar specify a single basic operation to
81       perform on the archive, a variety of modifiers for that operation, the
82       name of the archive file, and an optional list of file names. These
83       options are used to determine how llvm-ar should process the archive
84       file.
85
86       The Operations and Modifiers are explained in the sections below. The
87       minimal set of options is at least one operator and the name of the
88       archive. Typically archive files end with a ".a" suffix, but this is
89       not required. Following the archive-name comes a list of files that
90       indicate the specific members of the archive to operate on. If the
91       files option is not specified, it generally means either "none" or
92       "all" members, depending on the operation.
93
94   Operations
95       d   Delete files from the archive. No modifiers are applicable to this
96           operation.  The files options specify which members should be
97           removed from the archive. It is not an error if a specified file
98           does not appear in the archive.  If no files are specified, the
99           archive is not modified.
100
101       m[abi]
102           Move files from one location in the archive to another. The a, b,
103           and i modifiers apply to this operation. The files will all be
104           moved to the location given by the modifiers. If no modifiers are
105           used, the files will be moved to the end of the archive. If no
106           files are specified, the archive is not modified.
107
108       p[k]
109           Print files to the standard output. The k modifier applies to this
110           operation. This operation simply prints the files indicated to the
111           standard output. If no files are specified, the entire archive is
112           printed.  Printing bitcode files is ill-advised as they might
113           confuse your terminal settings. The p operation never modifies the
114           archive.
115
116       q[Rfz]
117           Quickly append files to the end of the archive. The R, f, and z
118           modifiers apply to this operation.  This operation quickly adds the
119           files to the archive without checking for duplicates that should be
120           removed first. If no files are specified, the archive is not
121           modified.  Because of the way that llvm-ar constructs the archive
122           file, its dubious whether the q operation is any faster than the r
123           operation.
124
125       r[Rabfuz]
126           Replace or insert file members. The R, a, b, f, u, and z modifiers
127           apply to this operation. This operation will replace existing files
128           or insert them at the end of the archive if they do not exist. If
129           no files are specified, the archive is not modified.
130
131       t[v]
132           Print the table of contents. Without any modifiers, this operation
133           just prints the names of the members to the standard output. With
134           the v modifier, llvm-ar also prints out the file type (B=bitcode,
135           Z=compressed, S=symbol table, blank=regular file), the permission
136           mode, the owner and group, the size, and the date. If any files are
137           specified, the listing is only for those files. If no files are
138           specified, the table of contents for the whole archive is printed.
139
140       x[oP]
141           Extract archive members back to files. The o modifier applies to
142           this operation. This operation retrieves the indicated files from
143           the archive and writes them back to the operating system's file
144           system. If no files are specified, the entire archive is extract.
145
146   Modifiers (operation specific)
147       The modifiers below are specific to certain operations. See the
148       Operations section (above) to determine which modifiers are applicable
149       to which operations.
150
151       [a] When inserting or moving member files, this option specifies the
152           destination of the new files as being "a"fter the relpos member. If
153           relpos is not found, the files are placed at the end of the
154           archive.
155
156       [b] When inserting or moving member files, this option specifies the
157           destination of the new files as being "b"efore the relpos member.
158           If relpos is not found, the files are placed at the end of the
159           archive. This modifier is identical to the the i modifier.
160
161       [f] Normally, llvm-ar stores the full path name to a file as presented
162           to it on the command line. With this option, truncated (15
163           characters max) names are used. This ensures name compatibility
164           with older versions of "ar" but may also thwart correct extraction
165           of the files (duplicates may overwrite). If used with the R option,
166           the directory recursion will be performed but the file names will
167           all be "f"lattened to simple file names.
168
169       [i] A synonym for the b option.
170
171       [k] Normally, llvm-ar will not print the contents of bitcode files when
172           the p operation is used. This modifier defeats the default and
173           allows the bitcode members to be printed.
174
175       [N] This option is ignored by llvm-ar but provided for compatibility.
176
177       [o] When extracting files, this option will cause llvm-ar to preserve
178           the original modification times of the files it writes.
179
180       [P] use full path names when matching
181
182       [R] This modifier instructions the r option to recursively process
183           directories.  Without R, directories are ignored and only those
184           files that refer to files will be added to the archive. When R is
185           used, any directories specified with files will be scanned
186           (recursively) to find files to be added to the archive. Any file
187           whose name begins with a dot will not be added.
188
189       [u] When replacing existing files in the archive, only replace those
190           files that have a time stamp than the time stamp of the member in
191           the archive.
192
193       [z] When inserting or replacing any file in the archive, compress the
194           file first.  This modifier is safe to use when (previously)
195           compressed bitcode files are added to the archive; the compressed
196           bitcode files will not be doubly compressed.
197
198   Modifiers (generic)
199       The modifiers below may be applied to any operation.
200
201       [c] For all operations, llvm-ar will always create the archive if it
202           doesn't exist. Normally, llvm-ar will print a warning message
203           indicating that the archive is being created. Using this modifier
204           turns off that warning.
205
206       [s] This modifier requests that an archive index (or symbol table) be
207           added to the archive. This is the default mode of operation. The
208           symbol table will contain all the externally visible functions and
209           global variables defined by all the bitcode files in the archive.
210           Using this modifier is more efficient that using llvm-ranlib which
211           also creates the symbol table.
212
213       [S] This modifier is the opposite of the s modifier. It instructs llvm-
214           ar to not build the symbol table. If both s and S are used, the
215           last modifier to occur in the options will prevail.
216
217       [v] This modifier instructs llvm-ar to be verbose about what it is
218           doing. Each editing operation taken against the archive will
219           produce a line of output saying what is being done.
220

STANDARDS

222       The llvm-ar utility is intended to provide a superset of the IEEE Std
223       1003.2 (POSIX.2) functionality for "ar". llvm-ar can read both SVR4 and
224       BSD4.4 (or Mac OS X) archives. If the "f" modifier is given to the "x"
225       or "r" operations then llvm-ar will write SVR4 compatible archives.
226       Without this modifier, llvm-ar will write BSD4.4 compatible archives
227       that have long names immediately after the header and indicated using
228       the "#1/ddd" notation for the name in the header.
229

FILE FORMAT

231       The file format for LLVM Archive files is similar to that of BSD 4.4 or
232       Mac OSX archive files. In fact, except for the symbol table, the "ar"
233       commands on those operating systems should be able to read LLVM archive
234       files. The details of the file format follow.
235
236       Each archive begins with the archive magic number which is the eight
237       printable characters "!<arch>\n" where \n represents the newline
238       character (0x0A).  Following the magic number, the file is composed of
239       even length members that begin with an archive header and end with a \n
240       padding character if necessary (to make the length even). Each file
241       member is composed of a header (defined below), an optional newline-
242       terminated "long file name" and the contents of the file.
243
244       The fields of the header are described in the items below. All fields
245       of the header contain only ASCII characters, are left justified and are
246       right padded with space characters.
247
248       name - char[16]
249           This field of the header provides the name of the archive member.
250           If the name is longer than 15 characters or contains a slash (/)
251           character, then this field contains "#1/nnn" where "nnn" provides
252           the length of the name and the "#1/" is literal.  In this case, the
253           actual name of the file is provided in the "nnn" bytes immediately
254           following the header. If the name is 15 characters or less, it is
255           contained directly in this field and terminated with a slash (/)
256           character.
257
258       date - char[12]
259           This field provides the date of modification of the file in the
260           form of a decimal encoded number that provides the number of
261           seconds since the epoch (since 00:00:00 Jan 1, 1970) per Posix
262           specifications.
263
264       uid - char[6]
265           This field provides the user id of the file encoded as a decimal
266           ASCII string.  This field might not make much sense on non-Unix
267           systems. On Unix, it is the same value as the st_uid field of the
268           stat structure returned by the stat(2) operating system call.
269
270       gid - char[6]
271           This field provides the group id of the file encoded as a decimal
272           ASCII string.  This field might not make much sense on non-Unix
273           systems. On Unix, it is the same value as the st_gid field of the
274           stat structure returned by the stat(2) operating system call.
275
276       mode - char[8]
277           This field provides the access mode of the file encoded as an octal
278           ASCII string. This field might not make much sense on non-Unix
279           systems. On Unix, it is the same value as the st_mode field of the
280           stat structure returned by the stat(2) operating system call.
281
282       size - char[10]
283           This field provides the size of the file, in bytes, encoded as a
284           decimal ASCII string. If the size field is negative (starts with a
285           minus sign, 0x02D), then the archive member is stored in compressed
286           form. The first byte of the archive member's data indicates the
287           compression type used. A value of 0 (0x30) indicates that no
288           compression was used. A value of 2 (0x32) indicates that bzip2
289           compression was used.
290
291       fmag - char[2]
292           This field is the archive file member magic number. Its content is
293           always the two characters back tick (0x60) and newline (0x0A). This
294           provides some measure utility in identifying archive files that
295           have been corrupted.
296
297       The LLVM symbol table has the special name "#_LLVM_SYM_TAB_#". It is
298       presumed that no regular archive member file will want this name. The
299       LLVM symbol table is simply composed of a sequence of triplets: byte
300       offset, length of symbol, and the symbol itself. Symbols are not null
301       or newline terminated. Here are the details on each of these items:
302
303       offset - vbr encoded 32-bit integer
304           The offset item provides the offset into the archive file where the
305           bitcode member is stored that is associated with the symbol. The
306           offset value is 0 based at the start of the first "normal" file
307           member. To derive the actual file offset of the member, you must
308           add the number of bytes occupied by the file signature (8 bytes)
309           and the symbol tables. The value of this item is encoded using
310           variable bit rate encoding to reduce the size of the symbol table.
311           Variable bit rate encoding uses the high bit (0x80) of each byte to
312           indicate if there are more bytes to follow. The remaining 7 bits in
313           each byte carry bits from the value. The final byte does not have
314           the high bit set.
315
316       length - vbr encoded 32-bit integer
317           The length item provides the length of the symbol that follows.
318           Like this offset item, the length is variable bit rate encoded.
319
320       symbol - character array
321           The symbol item provides the text of the symbol that is associated
322           with the offset. The symbol is not terminated by any character. Its
323           length is provided by the length field. Note that is allowed (but
324           unwise) to use non-printing characters (even 0x00) in the symbol.
325           This allows for multiple encodings of symbol names.
326

EXIT STATUS

328       If llvm-ar succeeds, it will exit with 0.  A usage error, results in an
329       exit code of 1. A hard (file system typically) error results in an exit
330       code of 2. Miscellaneous or unknown errors result in an exit code of 3.
331

SEE ALSO

333       llvm-ranlib, ar(1)
334

AUTHORS

336       Maintained by the LLVM Team (<http://llvm.org>).
337
338
339
340CVS                               2010-05-07                        LLVM-AR(1)
Impressum