]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - usr.bin/clang/llvm-ar/llvm-ar.1
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / usr.bin / clang / llvm-ar / llvm-ar.1
1 .\" $FreeBSD$
2 .TH "LLVM-AR" "1" "2013-04-11" "3.3" "LLVM"
3 .SH NAME
4 llvm-ar \- LLVM archiver
5 .
6 .nr rst2man-indent-level 0
7 .
8 .de1 rstReportMargin
9 \\$1 \\n[an-margin]
10 level \\n[rst2man-indent-level]
11 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
12 -
13 \\n[rst2man-indent0]
14 \\n[rst2man-indent1]
15 \\n[rst2man-indent2]
16 ..
17 .de1 INDENT
18 .\" .rstReportMargin pre:
19 . RS \\$1
20 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
21 . nr rst2man-indent-level +1
22 .\" .rstReportMargin post:
23 ..
24 .de UNINDENT
25 . RE
26 .\" indent \\n[an-margin]
27 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
28 .nr rst2man-indent-level -1
29 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
30 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
31 ..
32 .\" Man page generated from reStructuredText.
33 .
34 .SH SYNOPSIS
35 .sp
36 \fBllvm\-ar\fP [\-]{dmpqrtx}[Rabfikou] [relpos] [count] <archive> [files...]
37 .SH DESCRIPTION
38 .sp
39 The \fBllvm\-ar\fP command is similar to the common Unix utility, \fBar\fP. It
40 archives several files together into a single file. The intent for this is
41 to produce archive libraries by LLVM bitcode that can be linked into an
42 LLVM program. However, the archive can contain any kind of file. By default,
43 \fBllvm\-ar\fP generates a symbol table that makes linking faster because
44 only the symbol table needs to be consulted, not each individual file member
45 of the archive.
46 .sp
47 The \fBllvm\-ar\fP command can be used to \fIread\fP both SVR4 and BSD style archive
48 files. However, it cannot be used to write them.  While the \fBllvm\-ar\fP command
49 produces files that are \fIalmost\fP identical to the format used by other \fBar\fP
50 implementations, it has two significant departures in order to make the
51 archive appropriate for LLVM. The first departure is that \fBllvm\-ar\fP only
52 uses BSD4.4 style long path names (stored immediately after the header) and
53 never contains a string table for long names. The second departure is that the
54 symbol table is formated for efficient construction of an in\-memory data
55 structure that permits rapid (red\-black tree) lookups. Consequently, archives
56 produced with \fBllvm\-ar\fP usually won\(aqt be readable or editable with any
57 \fBar\fP implementation or useful for linking.  Using the \fBf\fP modifier to flatten
58 file names will make the archive readable by other \fBar\fP implementations
59 but not for linking because the symbol table format for LLVM is unique. If an
60 SVR4 or BSD style archive is used with the \fBr\fP (replace) or \fBq\fP (quick
61 update) operations, the archive will be reconstructed in LLVM format. This
62 means that the string table will be dropped (in deference to BSD 4.4 long names)
63 and an LLVM symbol table will be added (by default). The system symbol table
64 will be retained.
65 .sp
66 Here\(aqs where \fBllvm\-ar\fP departs from previous \fBar\fP implementations:
67 .sp
68 \fISymbol Table\fP
69 .INDENT 0.0
70 .INDENT 3.5
71 Since \fBllvm\-ar\fP is intended to archive bitcode files, the symbol table
72 won\(aqt make much sense to anything but LLVM. Consequently, the symbol table\(aqs
73 format has been simplified. It consists simply of a sequence of pairs
74 of a file member index number as an LSB 4byte integer and a null\-terminated
75 string.
76 .UNINDENT
77 .UNINDENT
78 .sp
79 \fILong Paths\fP
80 .INDENT 0.0
81 .INDENT 3.5
82 Some \fBar\fP implementations (SVR4) use a separate file member to record long
83 path names (> 15 characters). \fBllvm\-ar\fP takes the BSD 4.4 and Mac OS X
84 approach which is to simply store the full path name immediately preceding
85 the data for the file. The path name is null terminated and may contain the
86 slash (/) character.
87 .UNINDENT
88 .UNINDENT
89 .sp
90 \fIDirectory Recursion\fP
91 .INDENT 0.0
92 .INDENT 3.5
93 Most \fBar\fP implementations do not recurse through directories but simply
94 ignore directories if they are presented to the program in the \fIfiles\fP
95 option. \fBllvm\-ar\fP, however, can recurse through directory structures and
96 add all the files under a directory, if requested.
97 .UNINDENT
98 .UNINDENT
99 .sp
100 \fITOC Verbose Output\fP
101 .INDENT 0.0
102 .INDENT 3.5
103 When \fBllvm\-ar\fP prints out the verbose table of contents (\fBtv\fP option), it
104 precedes the usual output with a character indicating the basic kind of
105 content in the file. A blank means the file is a regular file. A \(aqB\(aq means
106 the file is an LLVM bitcode file. An \(aqS\(aq means the file is the symbol table.
107 .UNINDENT
108 .UNINDENT
109 .SH OPTIONS
110 .sp
111 The options to \fBllvm\-ar\fP are compatible with other \fBar\fP implementations.
112 However, there are a few modifiers (\fIR\fP) that are not found in other \fBar\fP
113 implementations. The options to \fBllvm\-ar\fP specify a single basic operation to
114 perform on the archive, a variety of modifiers for that operation, the name of
115 the archive file, and an optional list of file names. These options are used to
116 determine how \fBllvm\-ar\fP should process the archive file.
117 .sp
118 The Operations and Modifiers are explained in the sections below. The minimal
119 set of options is at least one operator and the name of the archive. Typically
120 archive files end with a \fB.a\fP suffix, but this is not required. Following
121 the \fIarchive\-name\fP comes a list of \fIfiles\fP that indicate the specific members
122 of the archive to operate on. If the \fIfiles\fP option is not specified, it
123 generally means either "none" or "all" members, depending on the operation.
124 .SS Operations
125 .sp
126 d
127 .INDENT 0.0
128 .INDENT 3.5
129 Delete files from the archive. No modifiers are applicable to this operation.
130 The \fIfiles\fP options specify which members should be removed from the
131 archive. It is not an error if a specified file does not appear in the archive.
132 If no \fIfiles\fP are specified, the archive is not modified.
133 .UNINDENT
134 .UNINDENT
135 .sp
136 m[abi]
137 .INDENT 0.0
138 .INDENT 3.5
139 Move files from one location in the archive to another. The \fIa\fP, \fIb\fP, and
140 \fIi\fP modifiers apply to this operation. The \fIfiles\fP will all be moved
141 to the location given by the modifiers. If no modifiers are used, the files
142 will be moved to the end of the archive. If no \fIfiles\fP are specified, the
143 archive is not modified.
144 .UNINDENT
145 .UNINDENT
146 .sp
147 p[k]
148 .INDENT 0.0
149 .INDENT 3.5
150 Print files to the standard output. The \fIk\fP modifier applies to this
151 operation. This operation simply prints the \fIfiles\fP indicated to the
152 standard output. If no \fIfiles\fP are specified, the entire archive is printed.
153 Printing bitcode files is ill\-advised as they might confuse your terminal
154 settings. The \fIp\fP operation never modifies the archive.
155 .UNINDENT
156 .UNINDENT
157 .sp
158 q[Rf]
159 .INDENT 0.0
160 .INDENT 3.5
161 Quickly append files to the end of the archive. The \fIR\fP, and \fIf\fP
162 modifiers apply to this operation.  This operation quickly adds the
163 \fIfiles\fP to the archive without checking for duplicates that should be
164 removed first. If no \fIfiles\fP are specified, the archive is not modified.
165 Because of the way that \fBllvm\-ar\fP constructs the archive file, its dubious
166 whether the \fIq\fP operation is any faster than the \fIr\fP operation.
167 .UNINDENT
168 .UNINDENT
169 .sp
170 r[Rabfu]
171 .INDENT 0.0
172 .INDENT 3.5
173 Replace or insert file members. The \fIR\fP, \fIa\fP, \fIb\fP, \fIf\fP, and \fIu\fP
174 modifiers apply to this operation. This operation will replace existing
175 \fIfiles\fP or insert them at the end of the archive if they do not exist. If no
176 \fIfiles\fP are specified, the archive is not modified.
177 .UNINDENT
178 .UNINDENT
179 .sp
180 t[v]
181 .INDENT 0.0
182 .INDENT 3.5
183 Print the table of contents. Without any modifiers, this operation just prints
184 the names of the members to the standard output. With the \fIv\fP modifier,
185 \fBllvm\-ar\fP also prints out the file type (B=bitcode, S=symbol
186 table, blank=regular file), the permission mode, the owner and group, the
187 size, and the date. If any \fIfiles\fP are specified, the listing is only for
188 those files. If no \fIfiles\fP are specified, the table of contents for the
189 whole archive is printed.
190 .UNINDENT
191 .UNINDENT
192 .sp
193 x[oP]
194 .INDENT 0.0
195 .INDENT 3.5
196 Extract archive members back to files. The \fIo\fP modifier applies to this
197 operation. This operation retrieves the indicated \fIfiles\fP from the archive
198 and writes them back to the operating system\(aqs file system. If no
199 \fIfiles\fP are specified, the entire archive is extract.
200 .UNINDENT
201 .UNINDENT
202 .SS Modifiers (operation specific)
203 .sp
204 The modifiers below are specific to certain operations. See the Operations
205 section (above) to determine which modifiers are applicable to which operations.
206 .sp
207 [a]
208 .INDENT 0.0
209 .INDENT 3.5
210 When inserting or moving member files, this option specifies the destination of
211 the new files as being after the \fIrelpos\fP member. If \fIrelpos\fP is not found,
212 the files are placed at the end of the archive.
213 .UNINDENT
214 .UNINDENT
215 .sp
216 [b]
217 .INDENT 0.0
218 .INDENT 3.5
219 When inserting or moving member files, this option specifies the destination of
220 the new files as being before the \fIrelpos\fP member. If \fIrelpos\fP is not
221 found, the files are placed at the end of the archive. This modifier is
222 identical to the \fIi\fP modifier.
223 .UNINDENT
224 .UNINDENT
225 .sp
226 [f]
227 .INDENT 0.0
228 .INDENT 3.5
229 Normally, \fBllvm\-ar\fP stores the full path name to a file as presented to it on
230 the command line. With this option, truncated (15 characters max) names are
231 used. This ensures name compatibility with older versions of \fBar\fP but may also
232 thwart correct extraction of the files (duplicates may overwrite). If used with
233 the \fIR\fP option, the directory recursion will be performed but the file names
234 will all be flattened to simple file names.
235 .UNINDENT
236 .UNINDENT
237 .sp
238 [i]
239 .INDENT 0.0
240 .INDENT 3.5
241 A synonym for the \fIb\fP option.
242 .UNINDENT
243 .UNINDENT
244 .sp
245 [k]
246 .INDENT 0.0
247 .INDENT 3.5
248 Normally, \fBllvm\-ar\fP will not print the contents of bitcode files when the
249 \fIp\fP operation is used. This modifier defeats the default and allows the
250 bitcode members to be printed.
251 .UNINDENT
252 .UNINDENT
253 .sp
254 [N]
255 .INDENT 0.0
256 .INDENT 3.5
257 This option is ignored by \fBllvm\-ar\fP but provided for compatibility.
258 .UNINDENT
259 .UNINDENT
260 .sp
261 [o]
262 .INDENT 0.0
263 .INDENT 3.5
264 When extracting files, this option will cause \fBllvm\-ar\fP to preserve the
265 original modification times of the files it writes.
266 .UNINDENT
267 .UNINDENT
268 .sp
269 [P]
270 .INDENT 0.0
271 .INDENT 3.5
272 use full path names when matching
273 .UNINDENT
274 .UNINDENT
275 .sp
276 [R]
277 .INDENT 0.0
278 .INDENT 3.5
279 This modifier instructions the \fIr\fP option to recursively process directories.
280 Without \fIR\fP, directories are ignored and only those \fIfiles\fP that refer to
281 files will be added to the archive. When \fIR\fP is used, any directories specified
282 with \fIfiles\fP will be scanned (recursively) to find files to be added to the
283 archive. Any file whose name begins with a dot will not be added.
284 .UNINDENT
285 .UNINDENT
286 .sp
287 [u]
288 .INDENT 0.0
289 .INDENT 3.5
290 When replacing existing files in the archive, only replace those files that have
291 a time stamp than the time stamp of the member in the archive.
292 .UNINDENT
293 .UNINDENT
294 .SS Modifiers (generic)
295 .sp
296 The modifiers below may be applied to any operation.
297 .sp
298 [c]
299 .INDENT 0.0
300 .INDENT 3.5
301 For all operations, \fBllvm\-ar\fP will always create the archive if it doesn\(aqt
302 exist. Normally, \fBllvm\-ar\fP will print a warning message indicating that the
303 archive is being created. Using this modifier turns off that warning.
304 .UNINDENT
305 .UNINDENT
306 .sp
307 [s]
308 .INDENT 0.0
309 .INDENT 3.5
310 This modifier requests that an archive index (or symbol table) be added to the
311 archive. This is the default mode of operation. The symbol table will contain
312 all the externally visible functions and global variables defined by all the
313 bitcode files in the archive. Using this modifier is more efficient that using
314 llvm\-ranlib|llvm\-ranlib which also creates the symbol table.
315 .UNINDENT
316 .UNINDENT
317 .sp
318 [S]
319 .INDENT 0.0
320 .INDENT 3.5
321 This modifier is the opposite of the \fIs\fP modifier. It instructs \fBllvm\-ar\fP to
322 not build the symbol table. If both \fIs\fP and \fIS\fP are used, the last modifier to
323 occur in the options will prevail.
324 .UNINDENT
325 .UNINDENT
326 .sp
327 [v]
328 .INDENT 0.0
329 .INDENT 3.5
330 This modifier instructs \fBllvm\-ar\fP to be verbose about what it is doing. Each
331 editing operation taken against the archive will produce a line of output saying
332 what is being done.
333 .UNINDENT
334 .UNINDENT
335 .SH STANDARDS
336 .sp
337 The \fBllvm\-ar\fP utility is intended to provide a superset of the IEEE Std 1003.2
338 (POSIX.2) functionality for \fBar\fP. \fBllvm\-ar\fP can read both SVR4 and BSD4.4 (or
339 Mac OS X) archives. If the \fBf\fP modifier is given to the \fBx\fP or \fBr\fP operations
340 then \fBllvm\-ar\fP will write SVR4 compatible archives. Without this modifier,
341 \fBllvm\-ar\fP will write BSD4.4 compatible archives that have long names
342 immediately after the header and indicated using the "#1/ddd" notation for the
343 name in the header.
344 .SH FILE FORMAT
345 .sp
346 The file format for LLVM Archive files is similar to that of BSD 4.4 or Mac OSX
347 archive files. In fact, except for the symbol table, the \fBar\fP commands on those
348 operating systems should be able to read LLVM archive files. The details of the
349 file format follow.
350 .sp
351 Each archive begins with the archive magic number which is the eight printable
352 characters "!<arch>n" where n represents the newline character (0x0A).
353 Following the magic number, the file is composed of even length members that
354 begin with an archive header and end with a n padding character if necessary
355 (to make the length even). Each file member is composed of a header (defined
356 below), an optional newline\-terminated "long file name" and the contents of
357 the file.
358 .sp
359 The fields of the header are described in the items below. All fields of the
360 header contain only ASCII characters, are left justified and are right padded
361 with space characters.
362 .sp
363 name \- char[16]
364 .INDENT 0.0
365 .INDENT 3.5
366 This field of the header provides the name of the archive member. If the name is
367 longer than 15 characters or contains a slash (/) character, then this field
368 contains \fB#1/nnn\fP where \fBnnn\fP provides the length of the name and the \fB#1/\fP
369 is literal.  In this case, the actual name of the file is provided in the \fBnnn\fP
370 bytes immediately following the header. If the name is 15 characters or less, it
371 is contained directly in this field and terminated with a slash (/) character.
372 .UNINDENT
373 .UNINDENT
374 .sp
375 date \- char[12]
376 .INDENT 0.0
377 .INDENT 3.5
378 This field provides the date of modification of the file in the form of a
379 decimal encoded number that provides the number of seconds since the epoch
380 (since 00:00:00 Jan 1, 1970) per Posix specifications.
381 .UNINDENT
382 .UNINDENT
383 .sp
384 uid \- char[6]
385 .INDENT 0.0
386 .INDENT 3.5
387 This field provides the user id of the file encoded as a decimal ASCII string.
388 This field might not make much sense on non\-Unix systems. On Unix, it is the
389 same value as the st_uid field of the stat structure returned by the stat(2)
390 operating system call.
391 .UNINDENT
392 .UNINDENT
393 .sp
394 gid \- char[6]
395 .INDENT 0.0
396 .INDENT 3.5
397 This field provides the group id of the file encoded as a decimal ASCII string.
398 This field might not make much sense on non\-Unix systems. On Unix, it is the
399 same value as the st_gid field of the stat structure returned by the stat(2)
400 operating system call.
401 .UNINDENT
402 .UNINDENT
403 .sp
404 mode \- char[8]
405 .INDENT 0.0
406 .INDENT 3.5
407 This field provides the access mode of the file encoded as an octal ASCII
408 string. This field might not make much sense on non\-Unix systems. On Unix, it
409 is the same value as the st_mode field of the stat structure returned by the
410 stat(2) operating system call.
411 .UNINDENT
412 .UNINDENT
413 .sp
414 size \- char[10]
415 .INDENT 0.0
416 .INDENT 3.5
417 This field provides the size of the file, in bytes, encoded as a decimal ASCII
418 string.
419 .UNINDENT
420 .UNINDENT
421 .sp
422 fmag \- char[2]
423 .INDENT 0.0
424 .INDENT 3.5
425 This field is the archive file member magic number. Its content is always the
426 two characters back tick (0x60) and newline (0x0A). This provides some measure
427 utility in identifying archive files that have been corrupted.
428 .UNINDENT
429 .UNINDENT
430 .sp
431 The LLVM symbol table has the special name "#_LLVM_SYM_TAB_#". It is presumed
432 that no regular archive member file will want this name. The LLVM symbol table
433 is simply composed of a sequence of triplets: byte offset, length of symbol,
434 and the symbol itself. Symbols are not null or newline terminated. Here are
435 the details on each of these items:
436 .sp
437 offset \- vbr encoded 32\-bit integer
438 .INDENT 0.0
439 .INDENT 3.5
440 The offset item provides the offset into the archive file where the bitcode
441 member is stored that is associated with the symbol. The offset value is 0
442 based at the start of the first "normal" file member. To derive the actual
443 file offset of the member, you must add the number of bytes occupied by the file
444 signature (8 bytes) and the symbol tables. The value of this item is encoded
445 using variable bit rate encoding to reduce the size of the symbol table.
446 Variable bit rate encoding uses the high bit (0x80) of each byte to indicate
447 if there are more bytes to follow. The remaining 7 bits in each byte carry bits
448 from the value. The final byte does not have the high bit set.
449 .UNINDENT
450 .UNINDENT
451 .sp
452 length \- vbr encoded 32\-bit integer
453 .INDENT 0.0
454 .INDENT 3.5
455 The length item provides the length of the symbol that follows. Like this
456 \fIoffset\fP item, the length is variable bit rate encoded.
457 .UNINDENT
458 .UNINDENT
459 .sp
460 symbol \- character array
461 .INDENT 0.0
462 .INDENT 3.5
463 The symbol item provides the text of the symbol that is associated with the
464 \fIoffset\fP. The symbol is not terminated by any character. Its length is provided
465 by the \fIlength\fP field. Note that is allowed (but unwise) to use non\-printing
466 characters (even 0x00) in the symbol. This allows for multiple encodings of
467 symbol names.
468 .UNINDENT
469 .UNINDENT
470 .SH EXIT STATUS
471 .sp
472 If \fBllvm\-ar\fP succeeds, it will exit with 0.  A usage error, results
473 in an exit code of 1. A hard (file system typically) error results in an
474 exit code of 2. Miscellaneous or unknown errors result in an
475 exit code of 3.
476 .SH SEE ALSO
477 .sp
478 llvm\-ranlib|llvm\-ranlib, ar(1)
479 .SH AUTHOR
480 Maintained by The LLVM Team (http://llvm.org/).
481 .SH COPYRIGHT
482 2003-2013, LLVM Project
483 .\" Generated by docutils manpage writer.
484 .