1 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
9 .de Vb \" Begin verbatim text
14 .de Ve \" End verbatim text
18 .\" Set up some character translations and predefined strings. \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote. \*(C+ will
21 .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
29 . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD. Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
54 .\" Avoid warning from groff about undefined register 'F'.
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{\
62 . tm Index:\\$1\t\\n%\t"\\$2"
72 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73 .\" Fear. Run. Save yourself. No user-serviceable parts.
74 . \" fudge factors for nroff and troff
83 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89 . \" simple accents for nroff and troff
99 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
100 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
101 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
102 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
103 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
104 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
106 . \" troff and (daisy-wheel) nroff accents
107 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
108 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
109 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
110 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
111 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
112 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
113 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
114 .ds ae a\h'-(\w'a'u*4/10)'e
115 .ds Ae A\h'-(\w'A'u*4/10)'E
116 . \" corrections for vroff
117 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
118 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
119 . \" for low resolution devices (crt and lpr)
120 .if \n(.H>23 .if \n(.V>19 \
133 .\" ========================================================================
136 .TH AR 1 "2022-02-09" "binutils-2.38" "GNU Development Tools"
137 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
138 .\" way too many mistakes in technical documents.
142 ar \- create, modify, and extract from archives
144 .IX Header "SYNOPSIS"
145 ar [\fB\-X32_64\fR] [\fB\-\fR]\fIp\fR[\fImod\fR] [\fB\-\-plugin\fR \fIname\fR] [\fB\-\-target\fR \fIbfdname\fR] [\fB\-\-output\fR \fIdirname\fR] [\fB\-\-record\-libdeps\fR \fIlibdeps\fR] [\fB\-\-thin\fR] [\fIrelpos\fR] [\fIcount\fR] \fIarchive\fR [\fImember\fR...]
147 .IX Header "DESCRIPTION"
148 The \s-1GNU\s0 \fBar\fR program creates, modifies, and extracts from
149 archives. An \fIarchive\fR is a single file holding a collection of
150 other files in a structure that makes it possible to retrieve
151 the original individual files (called \fImembers\fR of the archive).
153 The original files' contents, mode (permissions), timestamp, owner, and
154 group are preserved in the archive, and can be restored on
157 \&\s-1GNU\s0 \fBar\fR can maintain archives whose members have names of any
158 length; however, depending on how \fBar\fR is configured on your
159 system, a limit on member-name length may be imposed for compatibility
160 with archive formats maintained with other tools. If it exists, the
161 limit is often 15 characters (typical of formats related to a.out) or 16
162 characters (typical of formats related to coff).
164 \&\fBar\fR is considered a binary utility because archives of this sort
165 are most often used as \fIlibraries\fR holding commonly needed
166 subroutines. Since libraries often will depend on other libraries,
167 \&\fBar\fR can also record the dependencies of a library when the
168 \&\fB\-\-record\-libdeps\fR option is specified.
170 \&\fBar\fR creates an index to the symbols defined in relocatable
171 object modules in the archive when you specify the modifier \fBs\fR.
172 Once created, this index is updated in the archive whenever \fBar\fR
173 makes a change to its contents (save for the \fBq\fR update operation).
174 An archive with such an index speeds up linking to the library, and
175 allows routines in the library to call each other without regard to
176 their placement in the archive.
178 You may use \fBnm \-s\fR or \fBnm \-\-print\-armap\fR to list this index
179 table. If an archive lacks the table, another form of \fBar\fR called
180 \&\fBranlib\fR can be used to add just the table.
182 \&\s-1GNU\s0 \fBar\fR can optionally create a \fIthin\fR archive,
183 which contains a symbol index and references to the original copies
184 of the member files of the archive. This is useful for building
185 libraries for use within a local build tree, where the relocatable
186 objects are expected to remain available, and copying the contents of
187 each object would only waste time and space.
189 An archive can either be \fIthin\fR or it can be normal. It cannot
190 be both at the same time. Once an archive is created its format
191 cannot be changed without first deleting it and then creating a new
192 archive in its place.
194 Thin archives are also \fIflattened\fR, so that adding one thin
195 archive to another thin archive does not nest it, as would happen with
196 a normal archive. Instead the elements of the first archive are added
197 individually to the second archive.
199 The paths to the elements of the archive are stored relative to the
202 \&\s-1GNU\s0 \fBar\fR is designed to be compatible with two different
203 facilities. You can control its activity using command-line options,
204 like the different varieties of \fBar\fR on Unix systems; or, if you
205 specify the single command-line option \fB\-M\fR, you can control it
206 with a script supplied via standard input, like the \s-1MRI\s0 \*(L"librarian\*(R"
210 \&\s-1GNU\s0 \fBar\fR allows you to mix the operation code \fIp\fR and modifier
211 flags \fImod\fR in any order, within the first command-line argument.
213 If you wish, you may begin the first command-line argument with a
216 The \fIp\fR keyletter specifies what operation to execute; it may be
217 any of the following, but you must specify only one of them:
220 \&\fIDelete\fR modules from the archive. Specify the names of modules to
221 be deleted as \fImember\fR...; the archive is untouched if you
222 specify no files to delete.
224 If you specify the \fBv\fR modifier, \fBar\fR lists each module
228 Use this operation to \fImove\fR members in an archive.
230 The ordering of members in an archive can make a difference in how
231 programs are linked using the library, if a symbol is defined in more
234 If no modifiers are used with \f(CW\*(C`m\*(C'\fR, any members you name in the
235 \&\fImember\fR arguments are moved to the \fIend\fR of the archive;
236 you can use the \fBa\fR, \fBb\fR, or \fBi\fR modifiers to move them to a
237 specified place instead.
240 \&\fIPrint\fR the specified members of the archive, to the standard
241 output file. If the \fBv\fR modifier is specified, show the member
242 name before copying its contents to standard output.
244 If you specify no \fImember\fR arguments, all the files in the archive are
248 \&\fIQuick append\fR; Historically, add the files \fImember\fR... to the end of
249 \&\fIarchive\fR, without checking for replacement.
251 The modifiers \fBa\fR, \fBb\fR, and \fBi\fR do \fInot\fR affect this
252 operation; new members are always placed at the end of the archive.
254 The modifier \fBv\fR makes \fBar\fR list each file as it is appended.
256 Since the point of this operation is speed, implementations of
257 \&\fBar\fR have the option of not updating the archive's symbol
258 table if one exists. Too many different systems however assume that
259 symbol tables are always up-to-date, so \s-1GNU\s0 \fBar\fR will
260 rebuild the table even with a quick append.
262 Note \- \s-1GNU\s0 \fBar\fR treats the command \fBqs\fR as a
263 synonym for \fBr\fR \- replacing already existing files in the
264 archive and appending new ones at the end.
267 Insert the files \fImember\fR... into \fIarchive\fR (with
268 \&\fIreplacement\fR). This operation differs from \fBq\fR in that any
269 previously existing members are deleted if their names match those being
272 If one of the files named in \fImember\fR... does not exist, \fBar\fR
273 displays an error message, and leaves undisturbed any existing members
274 of the archive matching that name.
276 By default, new members are added at the end of the file; but you may
277 use one of the modifiers \fBa\fR, \fBb\fR, or \fBi\fR to request
278 placement relative to some existing member.
280 The modifier \fBv\fR used with this operation elicits a line of
281 output for each file inserted, along with one of the letters \fBa\fR or
282 \&\fBr\fR to indicate whether the file was appended (no old member
283 deleted) or replaced.
286 Add an index to the archive, or update it if it already exists. Note
287 this command is an exception to the rule that there can only be one
288 command letter, as it is possible to use it as either a command or a
289 modifier. In either case it does the same thing.
292 Display a \fItable\fR listing the contents of \fIarchive\fR, or those
293 of the files listed in \fImember\fR... that are present in the
294 archive. Normally only the member name is shown, but if the modifier
295 \&\fBO\fR is specified, then the corresponding offset of the member is also
296 displayed. Finally, in order to see the modes (permissions), timestamp,
297 owner, group, and size the \fBv\fR modifier should be included.
299 If you do not specify a \fImember\fR, all files in the archive
302 If there is more than one file with the same name (say, \fBfie\fR) in
303 an archive (say \fBb.a\fR), \fBar t b.a fie\fR lists only the
304 first instance; to see them all, you must ask for a complete
305 listing\-\-\-in our example, \fBar t b.a\fR.
308 \&\fIExtract\fR members (named \fImember\fR) from the archive. You can
309 use the \fBv\fR modifier with this operation, to request that
310 \&\fBar\fR list each name as it extracts it.
312 If you do not specify a \fImember\fR, all files in the archive
315 Files cannot be extracted from a thin archive, and there are
316 restrictions on extracting from archives created with \fBP\fR: The
317 paths must not be absolute, may not contain \f(CW\*(C`..\*(C'\fR, and any
318 subdirectories in the paths must exist. If it is desired to avoid
319 these restrictions then used the \fB\-\-output\fR option to specify
322 A number of modifiers (\fImod\fR) may immediately follow the \fIp\fR
323 keyletter, to specify variations on an operation's behavior:
326 Add new files \fIafter\fR an existing member of the
327 archive. If you use the modifier \fBa\fR, the name of an existing archive
328 member must be present as the \fIrelpos\fR argument, before the
329 \&\fIarchive\fR specification.
332 Add new files \fIbefore\fR an existing member of the
333 archive. If you use the modifier \fBb\fR, the name of an existing archive
334 member must be present as the \fIrelpos\fR argument, before the
335 \&\fIarchive\fR specification. (same as \fBi\fR).
338 \&\fICreate\fR the archive. The specified \fIarchive\fR is always
339 created if it did not exist, when you request an update. But a warning is
340 issued unless you specify in advance that you expect to create it, by
344 Operate in \fIdeterministic\fR mode. When adding files and the archive
345 index use zero for UIDs, GIDs, timestamps, and use consistent file modes
346 for all files. When this option is used, if \fBar\fR is used with
347 identical options and identical input files, multiple runs will create
348 identical output files regardless of the input files' owners, groups,
349 file modes, or modification times.
351 If \fIbinutils\fR was configured with
352 \&\fB\-\-enable\-deterministic\-archives\fR, then this mode is on by default.
353 It can be disabled with the \fBU\fR modifier, below.
356 Truncate names in the archive. \s-1GNU\s0 \fBar\fR will normally permit file
357 names of any length. This will cause it to create archives which are
358 not compatible with the native \fBar\fR program on some systems. If
359 this is a concern, the \fBf\fR modifier may be used to truncate file
360 names when putting them in the archive.
363 Insert new files \fIbefore\fR an existing member of the
364 archive. If you use the modifier \fBi\fR, the name of an existing archive
365 member must be present as the \fIrelpos\fR argument, before the
366 \&\fIarchive\fR specification. (same as \fBb\fR).
369 Specify dependencies of this library. The dependencies must immediately
370 follow this option character, must use the same syntax as the linker
371 command line, and must be specified within a single argument. I.e., if
372 multiple items are needed, they must be quoted to form a single command
373 line argument. For example \fBL \*(L"\-L/usr/local/lib \-lmydep1 \-lmydep2\*(R"\fR
376 Uses the \fIcount\fR parameter. This is used if there are multiple
377 entries in the archive with the same name. Extract or delete instance
378 \&\fIcount\fR of the given name from the archive.
381 Preserve the \fIoriginal\fR dates of members when extracting them. If
382 you do not specify this modifier, files extracted from the archive
383 are stamped with the time of extraction.
386 Display member offsets inside the archive. Use together with the \fBt\fR
390 Use the full path name when matching or storing names in the archive.
391 Archives created with full path names are not \s-1POSIX\s0 compliant, and
392 thus may not work with tools other than up to date \s-1GNU\s0 tools.
393 Modifying such archives with \s-1GNU\s0 \fBar\fR without using
394 \&\fBP\fR will remove the full path names unless the archive is a
395 thin archive. Note that \fBP\fR may be useful when adding files to
396 a thin archive since \fBr\fR without \fBP\fR ignores the path
397 when choosing which element to replace. Thus
400 \& ar rcST archive.a subdir/file1 subdir/file2 file1
403 will result in the first \f(CW\*(C`subdir/file1\*(C'\fR being replaced with
404 \&\f(CW\*(C`file1\*(C'\fR from the current directory. Adding \fBP\fR will
405 prevent this replacement.
408 Write an object-file index into the archive, or update an existing one,
409 even if no other change is made to the archive. You may use this modifier
410 flag either with any operation, or alone. Running \fBar s\fR on an
411 archive is equivalent to running \fBranlib\fR on it.
414 Do not generate an archive symbol table. This can speed up building a
415 large library in several steps. The resulting archive can not be used
416 with the linker. In order to build a symbol table, you must omit the
417 \&\fBS\fR modifier on the last execution of \fBar\fR, or you must run
418 \&\fBranlib\fR on the archive.
421 Deprecated alias for \fB\-\-thin\fR. \fBT\fR is not recommended because in
422 many ar implementations \fBT\fR has a different meaning, as specified by
423 X/Open System Interface.
426 Normally, \fBar r\fR... inserts all files
427 listed into the archive. If you would like to insert \fIonly\fR those
428 of the files you list that are newer than existing members of the same
429 names, use this modifier. The \fBu\fR modifier is allowed only for the
430 operation \fBr\fR (replace). In particular, the combination \fBqu\fR is
431 not allowed, since checking the timestamps would lose any speed
432 advantage from the operation \fBq\fR.
435 Do \fInot\fR operate in \fIdeterministic\fR mode. This is the inverse
436 of the \fBD\fR modifier, above: added files and the archive index will
437 get their actual \s-1UID, GID,\s0 timestamp, and file mode values.
439 This is the default unless \fIbinutils\fR was configured with
440 \&\fB\-\-enable\-deterministic\-archives\fR.
443 This modifier requests the \fIverbose\fR version of an operation. Many
444 operations display additional information, such as filenames processed,
445 when the modifier \fBv\fR is appended.
448 This modifier shows the version number of \fBar\fR.
450 The \fBar\fR program also supports some command-line options which
451 are neither modifiers nor actions, but which do change its behaviour
453 .IP "\fB\-\-help\fR" 4
455 Displays the list of command-line options supported by \fBar\fR
457 .IP "\fB\-\-version\fR" 4
459 Displays the version information of \fBar\fR and then exits.
460 .IP "\fB\-X32_64\fR" 4
462 \&\fBar\fR ignores an initial option spelled \fB\-X32_64\fR, for
463 compatibility with \s-1AIX.\s0 The behaviour produced by this option is the
464 default for \s-1GNU\s0 \fBar\fR. \fBar\fR does not support any
465 of the other \fB\-X\fR options; in particular, it does not support
466 \&\fB\-X32\fR which is the default for \s-1AIX\s0 \fBar\fR.
467 .IP "\fB\-\-plugin\fR \fIname\fR" 4
468 .IX Item "--plugin name"
469 The optional command-line switch \fB\-\-plugin\fR \fIname\fR causes
470 \&\fBar\fR to load the plugin called \fIname\fR which adds support
471 for more file formats, including object files with link-time
472 optimization information.
474 This option is only available if the toolchain has been built with
475 plugin support enabled.
477 If \fB\-\-plugin\fR is not provided, but plugin support has been
478 enabled then \fBar\fR iterates over the files in
479 \&\fI${libdir}/bfd\-plugins\fR in alphabetic order and the first
480 plugin that claims the object in question is used.
482 Please note that this plugin search directory is \fInot\fR the one
483 used by \fBld\fR's \fB\-plugin\fR option. In order to make
484 \&\fBar\fR use the linker plugin it must be copied into the
485 \&\fI${libdir}/bfd\-plugins\fR directory. For \s-1GCC\s0 based compilations
486 the linker plugin is called \fIliblto_plugin.so.0.0.0\fR. For Clang
487 based compilations it is called \fILLVMgold.so\fR. The \s-1GCC\s0 plugin
488 is always backwards compatible with earlier versions, so it is
489 sufficient to just copy the newest one.
490 .IP "\fB\-\-target\fR \fItarget\fR" 4
491 .IX Item "--target target"
492 The optional command-line switch \fB\-\-target\fR \fIbfdname\fR
493 specifies that the archive members are in an object code format
494 different from your system's default format. See
495 .IP "\fB\-\-output\fR \fIdirname\fR" 4
496 .IX Item "--output dirname"
497 The \fB\-\-output\fR option can be used to specify a path to a
498 directory into which archive members should be extracted. If this
499 option is not specified then the current directory will be used.
501 Note \- although the presence of this option does imply a \fBx\fR
502 extraction operation that option must still be included on the command
504 .IP "\fB\-\-record\-libdeps\fR \fIlibdeps\fR" 4
505 .IX Item "--record-libdeps libdeps"
506 The \fB\-\-record\-libdeps\fR option is identical to the \fBl\fR modifier,
507 just handled in long form.
508 .IP "\fB\-\-thin\fR" 4
510 Make the specified \fIarchive\fR a \fIthin\fR archive. If it already
511 exists and is a regular archive, the existing members must be present
512 in the same directory as \fIarchive\fR.
513 .IP "\fB@\fR\fIfile\fR" 4
515 Read command-line options from \fIfile\fR. The options read are
516 inserted in place of the original @\fIfile\fR option. If \fIfile\fR
517 does not exist, or cannot be read, then the option will be treated
518 literally, and not removed.
520 Options in \fIfile\fR are separated by whitespace. A whitespace
521 character may be included in an option by surrounding the entire
522 option in either single or double quotes. Any character (including a
523 backslash) may be included by prefixing the character to be included
524 with a backslash. The \fIfile\fR may itself contain additional
525 @\fIfile\fR options; any such options will be processed recursively.
527 .IX Header "SEE ALSO"
528 \&\fBnm\fR\|(1), \fBranlib\fR\|(1), and the Info entries for \fIbinutils\fR.
530 .IX Header "COPYRIGHT"
531 Copyright (c) 1991\-2022 Free Software Foundation, Inc.
533 Permission is granted to copy, distribute and/or modify this document
534 under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3
535 or any later version published by the Free Software Foundation;
536 with no Invariant Sections, with no Front-Cover Texts, and with no
537 Back-Cover Texts. A copy of the license is included in the
538 section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".