blob: 27b6396d221a3554e6064bc048bcfde05ba09d54 [file] [log] [blame]
Reid Spencere26ed7a2004-11-11 09:21:18 +00001=pod
2
3=head1 NAME
4
5llvm-ar - LLVM archiver
6
7=head1 SYNOPSIS
8
Reid Spencer742ecbc2004-11-12 00:15:43 +00009B<llvm-ar> [-X32_64] [-]{dmpqrtx}[Rabfikouz] [relpos] [count] <archive> [files...]
Reid Spencere26ed7a2004-11-11 09:21:18 +000010
11
12=head1 DESCRIPTION
13
14The B<llvm-ar> command is similar to the common Unix utility, C<ar>. It
15archives several files together into a single file. The intent for this is
16to produce archive libraries by LLVM bytecode that can be linked into an
17LLVM program. However, the archive can contain any kind of file. If requested,
18B<llvm-ar> can generate a symbol table that makes linking faster because
19only the symbol table needs to be consulted, not each individual file member
20of the archive.
21
22While the B<llvm-ar> command produces files that are similar to the format
23used by older C<ar> implementations, it has several significant departures
24in order to make the archive appropriate for LLVM. Consequently, archives
25produced with B<llvm-ar> probably won't be readable or editable with any
26C<ar> implementation unless the archive content is very simple.
27
28Here's where B<llvm-ar> departs from previous C<ar> implementations:
29
30=over
31
32=item I<Symbol Table>
33
34Since B<llvm-ar> is intended to archive bytecode files, the symbol table
35won't make much sense to anything but LLVM. Consequently, the symbol table's
36format has been simplified. It consists simply of a sequence of pairs
37of a file member index number as an LSB 4byte integer and a null-terminated
38string.
39
40=item I<Long Paths>
41
42Some C<ar> implementations (SVR4) use a separate file member to record long
43path names (> 15 characters). B<llvm-ar> takes the BSD 4.4 and Mac OS X
44approach which is to simply store the full path name immediately preceding
45the data for the file. The path name is null terminated and may contain the
46slash (/) character.
47
48=item I<Compression>
49
50B<llvm-ar> can compress the members of an archive to save space. The
51compression used depends on what's available on the platform but favors
52bzip2 and then zlib. Note that for very small files, bzip2 may increase
53the file size but generally does about 10% better than zlib on LLVM
54bytecode files.
55
56=item I<Directory Recursion>
57
58Most C<ar> implementations do not recurse through directories but simply
59ignore directories if they are presented to the program in the F<files>
60option. B<llvm-ar>, however, can recurse through directory structures and
61add all the files under a directory, if requested.
62
63=item I<TOC Verbose Output>
64
65When B<llvm-ar> prints out the verbose table of contents (C<tv> option), it
66precedes the usual output with a character indicating the basic kind of
67content in the file. A blank means the file is a regular file. A 'Z' means
68the file is compressed. A 'B' means the file is an LLVM bytecode file. An
69'S' means the file is the symbol table.
70
71=back
72
73=head1 OPTIONS
74
75The options to B<llvm-ar> are compatible with other C<ar> implementations.
76However, there are a few modifiers (F<zR>) that are not found in other
77C<ar>s. The options to B<llvm-ar> specify a single basic operation to
78perform on the archive, a variety of modifiers for that operation, the
79name of the archive file, and an optional list of file names. These options
80are used to determine how B<llvm-ar> should process the archive file.
81
82The Operations and Modifiers are explained in the sections below. The minimal
83set of options is at least one operator and the name of the archive. Typically
84archive files end with a C<.a> suffix, but this is not required. Following
85the F<achive-name> comes a list of F<files> that indicate the specific members
86of the archive to operate on. If the F<files> option is not specified, it
87generally means either "none" or "all" members, depending on the operation.
88
89=head2 Operations
90
91=over
92
93=item d
94
95Delete files from the archive. No modifiers are applicable to this operation.
96The F<files> options specify which members should be removed from the
97archive. It is not an error if a specified file does not appear in the archive.
98If no F<files> are specified, the archive is not modified.
99
100=item m[abi]
101
102Move files from one location in the archive to another. The F<a>, F<b>, and
103F<i> modifiers apply to this operation. The F<files> will all be moved
104to the location given by the modifiers. If no modifiers are used, the files
105will be moved to the end of the archive. If no F<files> are specified, the
106archive is not modified.
107
Reid Spencer742ecbc2004-11-12 00:15:43 +0000108=item p[k]
Reid Spencere26ed7a2004-11-11 09:21:18 +0000109
Reid Spencer742ecbc2004-11-12 00:15:43 +0000110Print files to the standard output. The F<k> modifier applies to this
Reid Spencere26ed7a2004-11-11 09:21:18 +0000111operation. This operation simply prints the F<files> indicated to the
112standard output. If no F<files> are specified, the entire archive is printed.
113Printing bytecode files is ill-advised as they might confuse your terminal
114settings. The F<p> operation never modifies the archive.
115
116=item q[Rfz]
117
118Quickly append files to the end of the archive. The F<R>, F<f>, and F<z>
119modifiers apply to this operation. This operation quickly adds the
120F<files> to the archive without checking for duplicates that shoud be
121removed first. If no F<files> are specified, the archive is not modified.
122Becasue of the way that B<llvm-ar> constructs the archive file, its dubious
123whether the F<q> operation is any faster than the F<r> operation.
124
125=item r[Rabfuz]
126
127Replace or insert file members. The F<R>, F<a>, F<b>, F<f>, F<u>, and F<z>
128modifiers apply to this operation. This operation will replace existing
129F<files> or insert them at the end of the archive if they do not exist. If no
130F<files> are specified, the archive is not modified.
131
132=item t[v]
133
134Print the table of contents. Without any modifiers, this operation just prints
135the names of the members to the standard output. With the F<v> modifier,
136B<llvm-ar> also prints out the file type (B=bytecode, Z=compressed, S=symbol
137table, blank=regular file), the permission mode, the owner and group, the
138size, and the date. If any F<files> are specified, the listing is only for
139those files. If no F<files> are specified, the table of contents for the
140whole archive is printed.
141
Reid Spencer742ecbc2004-11-12 00:15:43 +0000142=item x[oP]
Reid Spencere26ed7a2004-11-11 09:21:18 +0000143
144Extract archive members back to files. The F<o> modifier applies to this
145operation. This operation retrieves the indicated F<files> from the archive
146and writes them back to the operating system's file system. If no
147F<files> are specified, the entire archive is extract.
148
149=back
150
151=head2 Modifiers (operation specific)
152
Reid Spencer742ecbc2004-11-12 00:15:43 +0000153The modifiers below are specific to certain operations. See the Operations
154section (above) to determine which modifiers are applicable to which operations.
155
Reid Spencere26ed7a2004-11-11 09:21:18 +0000156=over
157
158=item [a]
159
Reid Spencer742ecbc2004-11-12 00:15:43 +0000160When inserting or moving member files, this option specifies the destination of
161the new files as being C<a>fter the F<relpos> member. If F<relpos> is not found,
162the files are placed at the end of the archive.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000163
164=item [b]
165
Reid Spencer742ecbc2004-11-12 00:15:43 +0000166When inserting or moving member files, this option specifies the destination of
167the new files as being C<b>efore the F<relpos> member. If F<relpos> is not
168found, the files are placed at the end of the archive. This modifier is
169identical to the the F<i> modifier.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000170
171=item [f]
172
Reid Spencer742ecbc2004-11-12 00:15:43 +0000173Normally, B<llvm-ar> stores the full path name to a file as presented to it on
174the command line. With this option, truncated (15 characters max) names are
175used. This ensures name compatibility with older versions of C<ar> but may also
176thwart correct extraction of the files (duplicates may overwrite). If used with
177the F<R> option, the directory recursion will be performed but the file names
178will all be C<f>lattened to simple file names.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000179
180=item [i]
181
Reid Spencer742ecbc2004-11-12 00:15:43 +0000182A synonym for the F<b> option.
183
184=item [k]
185
186Normally, B<llvm-ar> will not print the contents of bytecode files when the
187F<p> operation is used. This modifier defeats the default and allows the
188bytecode members to be printed.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000189
190=item [N]
191
Reid Spencer742ecbc2004-11-12 00:15:43 +0000192This option is ignored by B<llvm-ar> but provided for compatibility.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000193
194=item [o]
195
Reid Spencer742ecbc2004-11-12 00:15:43 +0000196When extracting files, this option will cause B<llvm-ar> to preserve the
197original modification times of the files it writes.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000198
199=item [P]
200
201use full path names when matching
202
Reid Spencer742ecbc2004-11-12 00:15:43 +0000203=item [R]
Reid Spencere26ed7a2004-11-11 09:21:18 +0000204
Reid Spencer742ecbc2004-11-12 00:15:43 +0000205This modifier instructions the F<r> option to recursively process directories.
206Without F<R>, directories are ignored and only those F<files> that refer to
207files will be added to the archive. When F<R> is used, any directories specified
208with F<files> will be scanned (recursively) to find files to be added to the
209archive. Any file whose name begins with a dot will not be added.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000210
211=item [u]
212
Reid Spencer742ecbc2004-11-12 00:15:43 +0000213When replacing existing files in the archive, only replace those files that have
214a timestamp than the timestamp of the member in the archive.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000215
216=item [z]
217
Reid Spencer742ecbc2004-11-12 00:15:43 +0000218When inserting or replacing any file in the archive, compress the file first.
219The compression will attempt to use the zlib compression algorithm. This
220modifier is safe to use when (previously) compressed bytecode files are added to
221the archive; the compress bytecode files will not be doubly compressed.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000222
223=back
224
225=head2 Modifiers (generic)
226
Reid Spencer742ecbc2004-11-12 00:15:43 +0000227The modifiers below may be applied to any operation.
228
Reid Spencere26ed7a2004-11-11 09:21:18 +0000229=over
230
231=item [c]
232
Reid Spencer742ecbc2004-11-12 00:15:43 +0000233For all operations, B<llvm-ar> will always create the archive if it doesn't
234exist. Normally, B<llvm-ar> will print a warning message indicating that the
235archive is being created. Using this modifier turns off that warning.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000236
237=item [s]
238
Reid Spencer742ecbc2004-11-12 00:15:43 +0000239This modifier requests that an archive index (or symbol table) be added to the
240archive. This is the default mode of operation. The symbol table will contain
241all the externally visible functions and global variables defined by all the
242bytecode files in the archive. Using this modifer is more efficient that using
243L<llvm-ranlib|llvm-ranlib> which also creates the symbol table.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000244
245=item [S]
246
Reid Spencer742ecbc2004-11-12 00:15:43 +0000247This modifier is the opposite of the F<s> modifier. It instructs B<llvm-ar> to
248not build the symbol table. If both F<s> and F<S> are used, the last modifier to
249occur in the options will prevail.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000250
251=item [v]
252
Reid Spencer742ecbc2004-11-12 00:15:43 +0000253This modifier instructs B<llvm-ar> to be verbose about what it is doing. Each
254editing operation taken agains the archive will produce a line of output saying
255what is being done.
Reid Spencere26ed7a2004-11-11 09:21:18 +0000256
257=back
258
Reid Spencer742ecbc2004-11-12 00:15:43 +0000259=head1 FILE FORMAT
260
261The file format for LLVM Archive files is similar to that of BSD 4.4 or Mac OSX
262archive files. In fact, except for the symbol table, the C<ar> commands on those
263operating systems should be able to read LLVM archive files. The details of the
264file format follow.
265
266Each archive begins with the archive magic number which is the eight printable
267characters !<arch>\n where \n represents the newline character (0x0A). Following
268the magic number, the file is composed of even length members that begin with an
269archive header and end with a \n padding character if necessary (to make the
270length even). Each file member is composed of a header (defined below), an
271optional null-terminated "long file name" and the contents of the file.
272
273The fields of the header are described in the items below. All fields of the
274header contain only ASCII characters, are left justified and are right padded
275with space characters.
276
277=over
278
279=item name - char[16]
280
281This field of the header provides the name of the archive member. If the name is
282longer than 15 characters or contains a slash (/) character, then this field
283contains C<#1/nnn> where C<nnn> provides the length of the name and the C<#1/>
284is literal. In this case, the actual name of the file is provided in the C<nnn>
285bytes immediately following the header. If the name is 15 characters or less, it
286is contained directly in this field and terminated with a slash (/) character.
287
288=item date - char[12]
289
290This field provides the date of modification of the file in the form of a
291decimal encoded number that provides the number of seconds since the epoch
292(since 00:00:00 Jan 1, 1970) per Posix specifications.
293
294=item uid - char[6]
295
296This field provides the user id of the file encoded as a decimal ascii string.
297This field might not make much sense on non-Unix systems. On Unix, it is the
298same value as the st_uid field of the stat structure returned by the stat(2)
299operating system call.
300
301=item gid - char[6]
302
303This field provides the group id of the file encoded as a decimal ascii string.
304This field might not make much sense on non-Unix systems. On Unix, it is the
305same value as the st_gid field of the stat structure returned by the stat(2)
306operating system call.
307
308=item mode - char[8]
309
310This field provides the access mode of the file encoded as an octal ascii
311string. This field might not make much sense on non-Unix systems. On Unix, it
312is the same value as the st_mode field of the stat structure returned by the
313stat(2) operating system call.
314
315=item size - char[10]
316
317This field provides the size of the file, in bytes, encoded as a decimal ascii
318string. If the size field is negative (starts with a minus sign, 0x02D), then
319the archive member is stored in compressed form. The first byte of the archive
320member's data indicates the compression type used. A value of 0 (0x30) indicates
321that no compression was used. A value of 1 (0x31) indicates that zlib
322compression was used. A value of 2 (0x32) indicates that bzip2 compression was
323used.
324
325=item fmag - char[2]
326
327This field is the archive file member magic number. Its content is always the
328two characters backtick (0x60) and newline (0x0A). This provides some measure
329utility in identifying archive files that have been corrupted.
330
Reid Spencer2152cca2004-11-12 00:16:51 +0000331=back
332
Reid Spencere26ed7a2004-11-11 09:21:18 +0000333=head1 EXIT STATUS
334
335If B<llvm-as> succeeds, it will exit with 0. A usage error, results
336in an exit code of 1. A hard (file system typically) error results in an
337exit code of 2. Miscellaneous or unknown errors result in an
338exit code of 3.
339
340=head1 SEE ALSO
341
Reid Spencer742ecbc2004-11-12 00:15:43 +0000342L<llvm-ld|llvm-ld>, L<llvm-ranlib|llvm-ranlib>
Reid Spencere26ed7a2004-11-11 09:21:18 +0000343
344=head1 AUTHORS
345
346Maintained by the LLVM Team (L<http://llvm.cs.uiuc.edu>).
347
348=cut