Debian Codegraph @

upstream/fedora-rawhide/man1/ar.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.48)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "AR 1"
61 .TH AR 1 2026-05-14 binutils-2.46.50 "GNU Development Tools"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 ar \- create, modify, and extract from archives
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 ar [\fB\-X32_64\fR]
71 [\fB\-\fR]\fIp\fR[\fImod\fR]
72 [\fB\-\-plugin\fR \fIname\fR]
73 [\fB\-\-target\fR \fIbfdname\fR]
74 [\fB\-\-output\fR \fIdirname\fR]
75 [\fB\-\-record\-libdeps\fR \fIlibdeps\fR]
76 [\fB\-\-thin\fR]
77 [\fIrelpos\fR] [\fIcount\fR] \fIarchive\fR [\fImember\fR...]
78 ar \fB\-M\fR [< mri\-script]
79 .SH DESCRIPTION
80 .IX Header "DESCRIPTION"
81 The GNU \fBar\fR program creates, modifies, and extracts from
82 archives. An \fIarchive\fR is a single file holding a collection of
83 other files in a structure that makes it possible to retrieve
84 the original individual files (called \fImembers\fR of the archive).
85 .PP
86 The original files\*(Aq contents, mode (permissions), timestamp, owner, and
87 group are preserved in the archive, and can be restored on
88 extraction.
89 .PP
90 GNU \fBar\fR can maintain archives whose members have names of any
91 length; however, depending on how \fBar\fR is configured on your
92 system, a limit on member\-name length may be imposed for compatibility
93 with archive formats maintained with other tools. If it exists, the
94 limit is often 15 characters (typical of formats related to a.out) or 16
95 characters (typical of formats related to coff).
96 .PP
97 \&\fBar\fR is considered a binary utility because archives of this sort
98 are most often used as \fIlibraries\fR holding commonly needed
99 subroutines. Since libraries often will depend on other libraries,
100 \&\fBar\fR can also record the dependencies of a library when the
101 \&\fB\-\-record\-libdeps\fR option is specified.
102 .PP
103 \&\fBar\fR creates an index to the symbols defined in relocatable
104 object modules in the archive when you specify the modifier \fBs\fR.
105 Once created, this index is updated in the archive whenever \fBar\fR
106 makes a change to its contents (save for the \fBq\fR update operation).
107 An archive with such an index speeds up linking to the library.
108 .PP
109 You may use \fBnm \-s\fR or \fBnm \-\-print\-armap\fR to list this index
110 table. If an archive lacks the table, another form of \fBar\fR called
111 \&\fBranlib\fR can be used to add just the table.
112 .PP
113 GNU \fBar\fR can optionally create a \fIthin\fR archive,
114 which contains a symbol index and references to the original copies
115 of the member files of the archive. This is useful for building
116 libraries for use within a local build tree, where the relocatable
117 objects are expected to remain available, and copying the contents of
118 each object would only waste time and space.
119 .PP
120 An archive can either be \fIthin\fR or it can be normal. It cannot
121 be both at the same time. Once an archive is created its format
122 cannot be changed without first deleting it and then creating a new
123 archive in its place.
124 .PP
125 Thin archives are also \fIflattened\fR, so that adding one thin
126 archive to another thin archive does not nest it, as would happen with
127 a normal archive. Instead the elements of the first archive are added
128 individually to the second archive.
129 .PP
130 The paths to the elements of the archive are stored relative to the
131 archive itself.
132 .PP
133 GNU \fBar\fR is designed to be compatible with two different
134 facilities. You can control its activity using command\-line options,
135 like the different varieties of \fBar\fR on Unix systems; or, if you
136 specify the single command\-line option \fB\-M\fR, you can control it
137 with a script supplied via standard input, like the MRI "librarian"
138 program.
139 .SH OPTIONS
140 .IX Header "OPTIONS"
141 GNU \fBar\fR allows you to mix the operation code \fIp\fR and modifier
142 flags \fImod\fR in any order, within the first command\-line argument.
143 .PP
144 If you wish, you may begin the first command\-line argument with a
145 dash.
146 .PP
147 The \fIp\fR keyletter specifies what operation to execute; it may be
148 any of the following, but you must specify only one of them:
149 .IP \fBd\fR 4
150 .IX Item "d"
151 \&\fIDelete\fR modules from the archive. Specify the names of modules to
152 be deleted as \fImember\fR...; the archive is untouched if you
153 specify no files to delete.
154 .Sp
155 If you specify the \fBv\fR modifier, \fBar\fR lists each module
156 as it is deleted.
157 .IP \fBm\fR 4
158 .IX Item "m"
159 Use this operation to \fImove\fR members in an archive.
160 .Sp
161 The ordering of members in an archive can make a difference in how
162 programs are linked using the library, if a symbol is defined in more
163 than one member.
164 .Sp
165 If no modifiers are used with \f(CW\*(C`m\*(C'\fR, any members you name in the
166 \&\fImember\fR arguments are moved to the \fIend\fR of the archive;
167 you can use the \fBa\fR, \fBb\fR, or \fBi\fR modifiers to move them to a
168 specified place instead.
169 .IP \fBp\fR 4
170 .IX Item "p"
171 \&\fIPrint\fR the specified members of the archive, to the standard
172 output file. If the \fBv\fR modifier is specified, show the member
173 name before copying its contents to standard output.
174 .Sp
175 If you specify no \fImember\fR arguments, all the files in the archive are
176 printed.
177 .IP \fBq\fR 4
178 .IX Item "q"
179 \&\fIQuick append\fR; Historically, add the files \fImember\fR... to the end of
180 \&\fIarchive\fR, without checking for replacement.
181 .Sp
182 The modifiers \fBa\fR, \fBb\fR, and \fBi\fR do \fInot\fR affect this
183 operation; new members are always placed at the end of the archive.
184 .Sp
185 The modifier \fBv\fR makes \fBar\fR list each file as it is appended.
186 .Sp
187 Since the point of this operation is speed, implementations of
188 \&\fBar\fR have the option of not updating the archive\*(Aqs symbol
189 table if one exists. Too many different systems however assume that
190 symbol tables are always up\-to\-date, so GNU \fBar\fR will
191 rebuild the table even with a quick append.
192 .Sp
193 Note \- GNU \fBar\fR treats the command \fBqs\fR as a
194 synonym for \fBr\fR \- replacing already existing files in the
195 archive and appending new ones at the end.
196 .IP \fBr\fR 4
197 .IX Item "r"
198 Insert the files \fImember\fR... into \fIarchive\fR (with
199 \&\fIreplacement\fR). This operation differs from \fBq\fR in that any
200 previously existing members are deleted if their names match those being
201 added.
202 .Sp
203 If one of the files named in \fImember\fR... does not exist, \fBar\fR
204 displays an error message, and leaves undisturbed any existing members
205 of the archive matching that name.
206 .Sp
207 By default, new members are added at the end of the file; but you may
208 use one of the modifiers \fBa\fR, \fBb\fR, or \fBi\fR to request
209 placement relative to some existing member.
210 .Sp
211 The modifier \fBv\fR used with this operation elicits a line of
212 output for each file inserted, along with one of the letters \fBa\fR or
213 \&\fBr\fR to indicate whether the file was appended (no old member
214 deleted) or replaced.
215 .IP \fBs\fR 4
216 .IX Item "s"
217 Add an index to the archive, or update it if it already exists. Note
218 this command is an exception to the rule that there can only be one
219 command letter, as it is possible to use it as either a command or a
220 modifier. In either case it does the same thing.
221 .IP \fBt\fR 4
222 .IX Item "t"
223 Display a \fItable\fR listing the contents of \fIarchive\fR, or those
224 of the files listed in \fImember\fR... that are present in the
225 archive. Normally only the member name is shown, but if the modifier
226 \&\fBO\fR is specified, then the corresponding offset of the member is also
227 displayed. Finally, in order to see the modes (permissions), timestamp,
228 owner, group, and size the \fBv\fR modifier should be included.
229 .Sp
230 If you do not specify a \fImember\fR, all files in the archive
231 are listed.
232 .Sp
233 If there is more than one file with the same name (say, \fBfie\fR) in
234 an archive (say \fBb.a\fR), \fBar t b.a fie\fR lists only the
235 first instance; to see them all, you must ask for a complete
236 listing\-\-\-in our example, \fBar t b.a\fR.
237 .IP \fBx\fR 4
238 .IX Item "x"
239 \&\fIExtract\fR members (named \fImember\fR) from the archive. You can
240 use the \fBv\fR modifier with this operation, to request that
241 \&\fBar\fR list each name as it extracts it.
242 .Sp
243 If you do not specify a \fImember\fR, all files in the archive
244 are extracted.
245 .Sp
246 Files cannot be extracted from a thin archive, and there are
247 restrictions on extracting from archives created with \fBP\fR: The
248 paths must not be absolute, may not contain \f(CW\*(C`..\*(C'\fR, and any
249 subdirectories in the paths must exist. If it is desired to avoid
250 these restrictions then used the \fB\-\-output\fR option to specify
251 an output directory.
252 .PP
253 A number of modifiers (\fImod\fR) may immediately follow the \fIp\fR
254 keyletter, to specify variations on an operation\*(Aqs behavior:
255 .IP \fBa\fR 4
256 .IX Item "a"
257 Add new files \fIafter\fR an existing member of the
258 archive. If you use the modifier \fBa\fR, the name of an existing archive
259 member must be present as the \fIrelpos\fR argument, before the
260 \&\fIarchive\fR specification.
261 .IP \fBb\fR 4
262 .IX Item "b"
263 Add new files \fIbefore\fR an existing member of the
264 archive. If you use the modifier \fBb\fR, the name of an existing archive
265 member must be present as the \fIrelpos\fR argument, before the
266 \&\fIarchive\fR specification. (same as \fBi\fR).
267 .IP \fBc\fR 4
268 .IX Item "c"
269 \&\fICreate\fR the archive. The specified \fIarchive\fR is always
270 created if it did not exist, when you request an update. But a warning is
271 issued unless you specify in advance that you expect to create it, by
272 using this modifier.
273 .IP \fBD\fR 4
274 .IX Item "D"
275 Operate in \fIdeterministic\fR mode. When adding files and the archive
276 index use zero for UIDs, GIDs, timestamps, and use consistent file modes
277 for all files. When this option is used, if \fBar\fR is used with
278 identical options and identical input files, multiple runs will create
279 identical output files regardless of the input files\*(Aq owners, groups,
280 file modes, or modification times.
281 .Sp
282 If \fIbinutils\fR was configured with
283 \&\fB\-\-enable\-deterministic\-archives\fR, then this mode is on by default.
284 It can be disabled with the \fBU\fR modifier, below.
285 .IP \fBf\fR 4
286 .IX Item "f"
287 Truncate names in the archive. GNU \fBar\fR will normally permit file
288 names of any length. This will cause it to create archives which are
289 not compatible with the native \fBar\fR program on some systems. If
290 this is a concern, the \fBf\fR modifier may be used to truncate file
291 names when putting them in the archive.
292 .IP \fBi\fR 4
293 .IX Item "i"
294 Insert new files \fIbefore\fR an existing member of the
295 archive. If you use the modifier \fBi\fR, the name of an existing archive
296 member must be present as the \fIrelpos\fR argument, before the
297 \&\fIarchive\fR specification. (same as \fBb\fR).
298 .IP \fBl\fR 4
299 .IX Item "l"
300 Specify dependencies of this library. The dependencies must immediately
301 follow this option character, must use the same syntax as the linker
302 command line, and must be specified within a single argument. I.e., if
303 multiple items are needed, they must be quoted to form a single command
304 line argument. For example \fBl "\-L/usr/local/lib \-lmydep1 \-lmydep2"\fR
305 .IP \fBN\fR 4
306 .IX Item "N"
307 Uses the \fIcount\fR parameter. This is used if there are multiple
308 entries in the archive with the same name. Extract or delete instance
309 \&\fIcount\fR of the given name from the archive.
310 .IP \fBo\fR 4
311 .IX Item "o"
312 Preserve the \fIoriginal\fR dates of members when extracting them. If
313 you do not specify this modifier, files extracted from the archive
314 are stamped with the time of extraction.
315 .IP \fBO\fR 4
316 .IX Item "O"
317 Display member offsets inside the archive. Use together with the \fBt\fR
318 option.
319 .IP \fBP\fR 4
320 .IX Item "P"
321 Use the full path name when matching or storing names in the archive.
322 Archives created with full path names are not POSIX compliant, and
323 thus may not work with tools other than up to date GNU tools.
324 Modifying such archives with GNU \fBar\fR without using
325 \&\fBP\fR will remove the full path names unless the archive is a
326 thin archive. Note that \fBP\fR may be useful when adding files to
327 a thin archive since \fBr\fR without \fBP\fR ignores the path
328 when choosing which element to replace. Thus
329 .Sp
330 .Vb 1
331 \& ar rcST archive.a subdir/file1 subdir/file2 file1
332 .Ve
333 .Sp
334 will result in the first \f(CW\*(C`subdir/file1\*(C'\fR being replaced with
335 \&\f(CW\*(C`file1\*(C'\fR from the current directory. Adding \fBP\fR will
336 prevent this replacement.
337 .IP \fBs\fR 4
338 .IX Item "s"
339 Write an object\-file index into the archive, or update an existing one,
340 even if no other change is made to the archive. You may use this modifier
341 flag either with any operation, or alone. Running \fBar s\fR on an
342 archive is equivalent to running \fBranlib\fR on it.
343 .IP \fBS\fR 4
344 .IX Item "S"
345 Do not generate an archive symbol table. This can speed up building a
346 large library in several steps, but will negatively impact performance
347 if the resulting archive is used with the linker. In order to build a
348 symbol table, you must omit the \fBS\fR modifier on the last execution
349 of \fBar\fR, or you must run \fBranlib\fR on the archive.
350 .IP \fBT\fR 4
351 .IX Item "T"
352 Deprecated alias for \fB\-\-thin\fR. \fBT\fR is not recommended because in
353 many ar implementations \fBT\fR has a different meaning, as specified by
354 X/Open System Interface.
355 .IP \fBu\fR 4
356 .IX Item "u"
357 Normally, \fBar r\fR... inserts all files
358 listed into the archive. If you would like to insert \fIonly\fR those
359 of the files you list that are newer than existing members of the same
360 names, use this modifier. The \fBu\fR modifier is allowed only for the
361 operation \fBr\fR (replace). In particular, the combination \fBqu\fR is
362 not allowed, since checking the timestamps would lose any speed
363 advantage from the operation \fBq\fR.
364 .Sp
365 Note \- if an archive has been created in a deterministic manner, eg
366 via the use of the \fBD\fR modifier, then replacement will always
367 happen and the \fBu\fR modifier will be ineffective.
368 .IP \fBU\fR 4
369 .IX Item "U"
370 Do \fInot\fR operate in \fIdeterministic\fR mode. This is the inverse
371 of the \fBD\fR modifier, above: added files and the archive index will
372 get their actual UID, GID, timestamp, and file mode values.
373 .Sp
374 This is the default unless \fIbinutils\fR was configured with
375 \&\fB\-\-enable\-deterministic\-archives\fR.
376 .IP \fBv\fR 4
377 .IX Item "v"
378 This modifier requests the \fIverbose\fR version of an operation. Many
379 operations display additional information, such as filenames processed,
380 when the modifier \fBv\fR is appended.
381 .IP \fBV\fR 4
382 .IX Item "V"
383 This modifier shows the version number of \fBar\fR.
384 .PP
385 The \fBar\fR program also supports some command\-line options which
386 are neither modifiers nor actions, but which do change its behaviour
387 in specific ways:
388 .IP \fB\-\-help\fR 4
389 .IX Item "--help"
390 Displays the list of command\-line options supported by \fBar\fR
391 and then exits.
392 .IP \fB\-\-version\fR 4
393 .IX Item "--version"
394 Displays the version information of \fBar\fR and then exits.
395 .IP \fB\-X32_64\fR 4
396 .IX Item "-X32_64"
397 \&\fBar\fR ignores an initial option spelled \fB\-X32_64\fR, for
398 compatibility with AIX. The behaviour produced by this option is the
399 default for GNU \fBar\fR. \fBar\fR does not support any
400 of the other \fB\-X\fR options; in particular, it does not support
401 \&\fB\-X32\fR which is the default for AIX \fBar\fR.
402 .IP "\fB\-\-plugin\fR \fIname\fR" 4
403 .IX Item "--plugin name"
404 The optional command\-line switch \fB\-\-plugin\fR \fIname\fR causes
405 \&\fBar\fR to load the plugin called \fIname\fR which adds support
406 for more file formats, including object files with link\-time
407 optimization information.
408 .Sp
409 This option is only available if the toolchain has been built with
410 plugin support enabled.
411 .Sp
412 If \fB\-\-plugin\fR is not provided, but plugin support has been
413 enabled then \fBar\fR iterates over the files in
414 \&\fI${libdir}/bfd\-plugins\fR in alphabetic order and the first
415 plugin that claims the object in question is used.
416 .Sp
417 Please note that this plugin search directory is \fInot\fR the one
418 used by \fBld\fR\*(Aqs \fB\-plugin\fR option. In order to make
419 \&\fBar\fR use the linker plugin it must be copied into the
420 \&\fI${libdir}/bfd\-plugins\fR directory. For GCC based compilations
421 the linker plugin is called \fIliblto_plugin.so.0.0.0\fR. For Clang
422 based compilations it is called \fILLVMgold.so\fR. The GCC plugin
423 is always backwards compatible with earlier versions, so it is
424 sufficient to just copy the newest one.
425 .IP "\fB\-\-target\fR \fItarget\fR" 4
426 .IX Item "--target target"
427 The optional command\-line switch \fB\-\-target\fR \fIbfdname\fR
428 specifies that the archive members are in an object code format
429 different from your system\*(Aqs default format. See
430 .IP "\fB\-\-output\fR \fIdirname\fR" 4
431 .IX Item "--output dirname"
432 The \fB\-\-output\fR option can be used to specify a path to a
433 directory into which archive members should be extracted. If this
434 option is not specified then the current directory will be used.
435 .Sp
436 Note \- although the presence of this option does imply a \fBx\fR
437 extraction operation that option must still be included on the command
438 line.
439 .IP "\fB\-\-record\-libdeps\fR \fIlibdeps\fR" 4
440 .IX Item "--record-libdeps libdeps"
441 The \fB\-\-record\-libdeps\fR option is identical to the \fBl\fR modifier,
442 just handled in long form.
443 .IP \fB\-\-thin\fR 4
444 .IX Item "--thin"
445 Make the specified \fIarchive\fR a \fIthin\fR archive. If it already
446 exists and is a regular archive, the existing members must be present
447 in the same directory as \fIarchive\fR.
448 .IP \fB@\fR\fIfile\fR 4
449 .IX Item "@file"
450 Read command\-line options from \fIfile\fR. The options read are
451 inserted in place of the original @\fIfile\fR option. If \fIfile\fR
452 does not exist, or cannot be read, then the option will be treated
453 literally, and not removed.
454 .Sp
455 Options in \fIfile\fR are separated by whitespace. A whitespace
456 character may be included in an option by surrounding the entire
457 option in either single or double quotes. Any character (including a
458 backslash) may be included by prefixing the character to be included
459 with a backslash. The \fIfile\fR may itself contain additional
460 @\fIfile\fR options; any such options will be processed recursively.
461 .SH "SEE ALSO"
462 .IX Header "SEE ALSO"
463 \&\fBnm\fR\|(1), \fBranlib\fR\|(1), and the Info entries for \fIbinutils\fR.
464 .SH COPYRIGHT
465 .IX Header "COPYRIGHT"
466 Copyright (c) 1991\-2026 Free Software Foundation, Inc.
467 .PP
468 Permission is granted to copy, distribute and/or modify this document
469 under the terms of the GNU Free Documentation License, Version 1.3
470 or any later version published by the Free Software Foundation;
471 with no Invariant Sections, with no Front\-Cover Texts, and with no
472 Back\-Cover Texts. A copy of the license is included in the
473 section entitled "GNU Free Documentation License".