1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Copyright (C) 1991-2021 Free Software Foundation, Inc.
4
5Permission is granted to copy, distribute and/or modify this document
6under the terms of the GNU Free Documentation License, Version 1.3
7or any later version published by the Free Software Foundation;
8with no Invariant Sections, with no Front-Cover Texts, and with no
9Back-Cover Texts.  A copy of the license is included in the
10section entitled "GNU Free Documentation License".
11 -->
12<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
13<head>
14<title>GNU Binary Utilities: ar</title>
15
16<meta name="description" content="GNU Binary Utilities: ar">
17<meta name="keywords" content="GNU Binary Utilities: ar">
18<meta name="resource-type" content="document">
19<meta name="distribution" content="global">
20<meta name="Generator" content="makeinfo">
21<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
22<link href="index.html#Top" rel="start" title="Top">
23<link href="Binutils-Index.html#Binutils-Index" rel="index" title="Binutils Index">
24<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
25<link href="index.html#Top" rel="up" title="Top">
26<link href="ar-cmdline.html#ar-cmdline" rel="next" title="ar cmdline">
27<link href="index.html#Top" rel="previous" title="Top">
28<style type="text/css">
29<!--
30a.summary-letter {text-decoration: none}
31blockquote.smallquotation {font-size: smaller}
32div.display {margin-left: 3.2em}
33div.example {margin-left: 3.2em}
34div.indentedblock {margin-left: 3.2em}
35div.lisp {margin-left: 3.2em}
36div.smalldisplay {margin-left: 3.2em}
37div.smallexample {margin-left: 3.2em}
38div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
39div.smalllisp {margin-left: 3.2em}
40kbd {font-style:oblique}
41pre.display {font-family: inherit}
42pre.format {font-family: inherit}
43pre.menu-comment {font-family: serif}
44pre.menu-preformatted {font-family: serif}
45pre.smalldisplay {font-family: inherit; font-size: smaller}
46pre.smallexample {font-size: smaller}
47pre.smallformat {font-family: inherit; font-size: smaller}
48pre.smalllisp {font-size: smaller}
49span.nocodebreak {white-space:nowrap}
50span.nolinebreak {white-space:nowrap}
51span.roman {font-family:serif; font-weight:normal}
52span.sansserif {font-family:sans-serif; font-weight:normal}
53ul.no-bullet {list-style: none}
54-->
55</style>
56
57
58</head>
59
60<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
61<a name="ar"></a>
62<div class="header">
63<p>
64Next: <a href="nm.html#nm" accesskey="n" rel="next">nm</a>, Previous: <a href="index.html#Top" accesskey="p" rel="previous">Top</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
65</div>
66<hr>
67<a name="ar-1"></a>
68<h2 class="chapter">1 ar</h2>
69
70<a name="index-ar"></a>
71<a name="index-archives"></a>
72<a name="index-collections-of-files"></a>
73
74
75<div class="smallexample">
76<pre class="smallexample">ar [-]<var>p</var>[<var>mod</var>] [<samp>--plugin</samp> <var>name</var>] [<samp>--target</samp> <var>bfdname</var>] [<samp>--output</samp> <var>dirname</var>] [<samp>--record-libdeps</samp> <var>libdeps</var>] [<var>relpos</var>] [<var>count</var>] <var>archive</var> [<var>member</var>&hellip;]
77ar -M [ &lt;mri-script ]
78</pre></div>
79
80
81<p>The <small>GNU</small> <code>ar</code> program creates, modifies, and extracts from
82archives.  An <em>archive</em> is a single file holding a collection of
83other files in a structure that makes it possible to retrieve
84the original individual files (called <em>members</em> of the archive).
85</p>
86<p>The original files&rsquo; contents, mode (permissions), timestamp, owner, and
87group are preserved in the archive, and can be restored on
88extraction.
89</p>
90<a name="index-name-length"></a>
91<p><small>GNU</small> <code>ar</code> can maintain archives whose members have names of any
92length; however, depending on how <code>ar</code> is configured on your
93system, a limit on member-name length may be imposed for compatibility
94with archive formats maintained with other tools.  If it exists, the
95limit is often 15 characters (typical of formats related to a.out) or 16
96characters (typical of formats related to coff).
97</p>
98<a name="index-libraries"></a>
99<p><code>ar</code> is considered a binary utility because archives of this sort
100are most often used as <em>libraries</em> holding commonly needed
101subroutines.  Since libraries often will depend on other libraries,
102<code>ar</code> can also record the dependencies of a library when the
103<samp>--record-libdeps</samp> option is specified.
104</p>
105<a name="index-symbol-index"></a>
106<p><code>ar</code> creates an index to the symbols defined in relocatable
107object modules in the archive when you specify the modifier &lsquo;<samp>s</samp>&rsquo;.
108Once created, this index is updated in the archive whenever <code>ar</code>
109makes a change to its contents (save for the &lsquo;<samp>q</samp>&rsquo; update operation).
110An archive with such an index speeds up linking to the library, and
111allows routines in the library to call each other without regard to
112their placement in the archive.
113</p>
114<p>You may use &lsquo;<samp>nm -s</samp>&rsquo; or &lsquo;<samp>nm --print-armap</samp>&rsquo; to list this index
115table.  If an archive lacks the table, another form of <code>ar</code> called
116<code>ranlib</code> can be used to add just the table.
117</p>
118<a name="index-thin-archives"></a>
119<p><small>GNU</small> <code>ar</code> can optionally create a <em>thin</em> archive,
120which contains a symbol index and references to the original copies
121of the member files of the archive.  This is useful for building
122libraries for use within a local build tree, where the relocatable
123objects are expected to remain available, and copying the contents of
124each object would only waste time and space.
125</p>
126<p>An archive can either be <em>thin</em> or it can be normal.  It cannot
127be both at the same time.  Once an archive is created its format
128cannot be changed without first deleting it and then creating a new
129archive in its place.
130</p>
131<p>Thin archives are also <em>flattened</em>, so that adding one thin
132archive to another thin archive does not nest it, as would happen with
133a normal archive.  Instead the elements of the first archive are added
134individually to the second archive.
135</p>
136<p>The paths to the elements of the archive are stored relative to the
137archive itself.
138</p>
139<a name="index-compatibility_002c-ar"></a>
140<a name="index-ar-compatibility"></a>
141<p><small>GNU</small> <code>ar</code> is designed to be compatible with two different
142facilities.  You can control its activity using command-line options,
143like the different varieties of <code>ar</code> on Unix systems; or, if you
144specify the single command-line option <samp>-M</samp>, you can control it
145with a script supplied via standard input, like the MRI &ldquo;librarian&rdquo;
146program.
147</p>
148
149<table class="menu" border="0" cellspacing="0">
150<tr><td align="left" valign="top">&bull; <a href="ar-cmdline.html#ar-cmdline" accesskey="1">ar cmdline</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Controlling <code>ar</code> on the command line
151</td></tr>
152<tr><td align="left" valign="top">&bull; <a href="ar-scripts.html#ar-scripts" accesskey="2">ar scripts</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Controlling <code>ar</code> with a script
153</td></tr>
154</table>
155
156<hr>
157<div class="header">
158<p>
159Next: <a href="nm.html#nm" accesskey="n" rel="next">nm</a>, Previous: <a href="index.html#Top" accesskey="p" rel="previous">Top</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
160</div>
161
162
163
164</body>
165</html>
166