ar-cmdline.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3
  6. or any later version published by the Free Software Foundation;
  7. with no Invariant Sections, with no Front-Cover Texts, and with no
  8. Back-Cover Texts. A copy of the license is included in the
  9. section entitled "GNU Free Documentation License".
  10. -->
  11. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  12. <head>
  13. <title>GNU Binary Utilities: ar cmdline</title>
  14. <meta name="description" content="GNU Binary Utilities: ar cmdline">
  15. <meta name="keywords" content="GNU Binary Utilities: ar cmdline">
  16. <meta name="resource-type" content="document">
  17. <meta name="distribution" content="global">
  18. <meta name="Generator" content="makeinfo">
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <link href="index.html#Top" rel="start" title="Top">
  21. <link href="Binutils-Index.html#Binutils-Index" rel="index" title="Binutils Index">
  22. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  23. <link href="ar.html#ar" rel="up" title="ar">
  24. <link href="ar-scripts.html#ar-scripts" rel="next" title="ar scripts">
  25. <link href="ar.html#ar" rel="prev" title="ar">
  26. <style type="text/css">
  27. <!--
  28. a.summary-letter {text-decoration: none}
  29. blockquote.smallquotation {font-size: smaller}
  30. div.display {margin-left: 3.2em}
  31. div.example {margin-left: 3.2em}
  32. div.indentedblock {margin-left: 3.2em}
  33. div.lisp {margin-left: 3.2em}
  34. div.smalldisplay {margin-left: 3.2em}
  35. div.smallexample {margin-left: 3.2em}
  36. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  37. div.smalllisp {margin-left: 3.2em}
  38. kbd {font-style:oblique}
  39. pre.display {font-family: inherit}
  40. pre.format {font-family: inherit}
  41. pre.menu-comment {font-family: serif}
  42. pre.menu-preformatted {font-family: serif}
  43. pre.smalldisplay {font-family: inherit; font-size: smaller}
  44. pre.smallexample {font-size: smaller}
  45. pre.smallformat {font-family: inherit; font-size: smaller}
  46. pre.smalllisp {font-size: smaller}
  47. span.nocodebreak {white-space:nowrap}
  48. span.nolinebreak {white-space:nowrap}
  49. span.roman {font-family:serif; font-weight:normal}
  50. span.sansserif {font-family:sans-serif; font-weight:normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  56. <a name="ar-cmdline"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="ar-scripts.html#ar-scripts" accesskey="n" rel="next">ar scripts</a>, Up: <a href="ar.html#ar" accesskey="u" rel="up">ar</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>
  60. </div>
  61. <hr>
  62. <a name="Controlling-ar-on-the-Command-Line"></a>
  63. <h3 class="section">1.1 Controlling <code>ar</code> on the Command Line</h3>
  64. <div class="smallexample">
  65. <pre class="smallexample">ar [<samp>-X32_64</samp>] [<samp>-</samp>]<var>p</var>[<var>mod</var>] [<samp>--plugin</samp> <var>name</var>] [<samp>--target</samp> <var>bfdname</var>] [<var>relpos</var>] [<var>count</var>] <var>archive</var> [<var>member</var>&hellip;]
  66. </pre></div>
  67. <a name="index-Unix-compatibility_002c-ar"></a>
  68. <p>When you use <code>ar</code> in the Unix style, <code>ar</code> insists on at least two
  69. arguments to execute: one keyletter specifying the <em>operation</em>
  70. (optionally accompanied by other keyletters specifying
  71. <em>modifiers</em>), and the archive name to act on.
  72. </p>
  73. <p>Most operations can also accept further <var>member</var> arguments,
  74. specifying particular files to operate on.
  75. </p>
  76. <p><small>GNU</small> <code>ar</code> allows you to mix the operation code <var>p</var> and modifier
  77. flags <var>mod</var> in any order, within the first command-line argument.
  78. </p>
  79. <p>If you wish, you may begin the first command-line argument with a
  80. dash.
  81. </p>
  82. <a name="index-operations-on-archive"></a>
  83. <p>The <var>p</var> keyletter specifies what operation to execute; it may be
  84. any of the following, but you must specify only one of them:
  85. </p>
  86. <dl compact="compact">
  87. <dt>&lsquo;<samp>d</samp>&rsquo;</dt>
  88. <dd><a name="index-deleting-from-archive"></a>
  89. <p><em>Delete</em> modules from the archive. Specify the names of modules to
  90. be deleted as <var>member</var>&hellip;; the archive is untouched if you
  91. specify no files to delete.
  92. </p>
  93. <p>If you specify the &lsquo;<samp>v</samp>&rsquo; modifier, <code>ar</code> lists each module
  94. as it is deleted.
  95. </p>
  96. </dd>
  97. <dt>&lsquo;<samp>m</samp>&rsquo;</dt>
  98. <dd><a name="index-moving-in-archive"></a>
  99. <p>Use this operation to <em>move</em> members in an archive.
  100. </p>
  101. <p>The ordering of members in an archive can make a difference in how
  102. programs are linked using the library, if a symbol is defined in more
  103. than one member.
  104. </p>
  105. <p>If no modifiers are used with <code>m</code>, any members you name in the
  106. <var>member</var> arguments are moved to the <em>end</em> of the archive;
  107. you can use the &lsquo;<samp>a</samp>&rsquo;, &lsquo;<samp>b</samp>&rsquo;, or &lsquo;<samp>i</samp>&rsquo; modifiers to move them to a
  108. specified place instead.
  109. </p>
  110. </dd>
  111. <dt>&lsquo;<samp>p</samp>&rsquo;</dt>
  112. <dd><a name="index-printing-from-archive"></a>
  113. <p><em>Print</em> the specified members of the archive, to the standard
  114. output file. If the &lsquo;<samp>v</samp>&rsquo; modifier is specified, show the member
  115. name before copying its contents to standard output.
  116. </p>
  117. <p>If you specify no <var>member</var> arguments, all the files in the archive are
  118. printed.
  119. </p>
  120. </dd>
  121. <dt>&lsquo;<samp>q</samp>&rsquo;</dt>
  122. <dd><a name="index-quick-append-to-archive"></a>
  123. <p><em>Quick append</em>; Historically, add the files <var>member</var>&hellip; to the end of
  124. <var>archive</var>, without checking for replacement.
  125. </p>
  126. <p>The modifiers &lsquo;<samp>a</samp>&rsquo;, &lsquo;<samp>b</samp>&rsquo;, and &lsquo;<samp>i</samp>&rsquo; do <em>not</em> affect this
  127. operation; new members are always placed at the end of the archive.
  128. </p>
  129. <p>The modifier &lsquo;<samp>v</samp>&rsquo; makes <code>ar</code> list each file as it is appended.
  130. </p>
  131. <p>Since the point of this operation is speed, implementations of
  132. <code>ar</code> have the option of not updating the archive&rsquo;s symbol
  133. table if one exists. Too many different systems however assume that
  134. symbol tables are always up-to-date, so <small>GNU</small> <code>ar</code> will
  135. rebuild the table even with a quick append.
  136. </p>
  137. <p>Note - <small>GNU</small> <code>ar</code> treats the command &lsquo;<samp>qs</samp>&rsquo; as a
  138. synonym for &lsquo;<samp>r</samp>&rsquo; - replacing already existing files in the
  139. archive and appending new ones at the end.
  140. </p>
  141. </dd>
  142. <dt>&lsquo;<samp>r</samp>&rsquo;</dt>
  143. <dd><a name="index-replacement-in-archive"></a>
  144. <p>Insert the files <var>member</var>&hellip; into <var>archive</var> (with
  145. <em>replacement</em>). This operation differs from &lsquo;<samp>q</samp>&rsquo; in that any
  146. previously existing members are deleted if their names match those being
  147. added.
  148. </p>
  149. <p>If one of the files named in <var>member</var>&hellip; does not exist, <code>ar</code>
  150. displays an error message, and leaves undisturbed any existing members
  151. of the archive matching that name.
  152. </p>
  153. <p>By default, new members are added at the end of the file; but you may
  154. use one of the modifiers &lsquo;<samp>a</samp>&rsquo;, &lsquo;<samp>b</samp>&rsquo;, or &lsquo;<samp>i</samp>&rsquo; to request
  155. placement relative to some existing member.
  156. </p>
  157. <p>The modifier &lsquo;<samp>v</samp>&rsquo; used with this operation elicits a line of
  158. output for each file inserted, along with one of the letters &lsquo;<samp>a</samp>&rsquo; or
  159. &lsquo;<samp>r</samp>&rsquo; to indicate whether the file was appended (no old member
  160. deleted) or replaced.
  161. </p>
  162. </dd>
  163. <dt>&lsquo;<samp>s</samp>&rsquo;</dt>
  164. <dd><a name="index-ranlib"></a>
  165. <p>Add an index to the archive, or update it if it already exists. Note
  166. this command is an exception to the rule that there can only be one
  167. command letter, as it is possible to use it as either a command or a
  168. modifier. In either case it does the same thing.
  169. </p>
  170. </dd>
  171. <dt>&lsquo;<samp>t</samp>&rsquo;</dt>
  172. <dd><a name="index-contents-of-archive"></a>
  173. <p>Display a <em>table</em> listing the contents of <var>archive</var>, or those
  174. of the files listed in <var>member</var>&hellip; that are present in the
  175. archive. Normally only the member name is shown; if you also want to
  176. see the modes (permissions), timestamp, owner, group, and size, you can
  177. request that by also specifying the &lsquo;<samp>v</samp>&rsquo; modifier.
  178. </p>
  179. <p>If you do not specify a <var>member</var>, all files in the archive
  180. are listed.
  181. </p>
  182. <a name="index-repeated-names-in-archive"></a>
  183. <a name="index-name-duplication-in-archive"></a>
  184. <p>If there is more than one file with the same name (say, &lsquo;<samp>fie</samp>&rsquo;) in
  185. an archive (say &lsquo;<samp>b.a</samp>&rsquo;), &lsquo;<samp>ar t b.a fie</samp>&rsquo; lists only the
  186. first instance; to see them all, you must ask for a complete
  187. listing&mdash;in our example, &lsquo;<samp>ar t b.a</samp>&rsquo;.
  188. </p>
  189. </dd>
  190. <dt>&lsquo;<samp>x</samp>&rsquo;</dt>
  191. <dd><a name="index-extract-from-archive"></a>
  192. <p><em>Extract</em> members (named <var>member</var>) from the archive. You can
  193. use the &lsquo;<samp>v</samp>&rsquo; modifier with this operation, to request that
  194. <code>ar</code> list each name as it extracts it.
  195. </p>
  196. <p>If you do not specify a <var>member</var>, all files in the archive
  197. are extracted.
  198. </p>
  199. <p>Files cannot be extracted from a thin archive.
  200. </p>
  201. </dd>
  202. <dt>&lsquo;<samp>--help</samp>&rsquo;</dt>
  203. <dd><p>Displays the list of command line options supported by <code>ar</code>
  204. and then exits.
  205. </p>
  206. </dd>
  207. <dt>&lsquo;<samp>--version</samp>&rsquo;</dt>
  208. <dd><p>Displays the version information of <code>ar</code> and then exits.
  209. </p>
  210. </dd>
  211. </dl>
  212. <p>A number of modifiers (<var>mod</var>) may immediately follow the <var>p</var>
  213. keyletter, to specify variations on an operation&rsquo;s behavior:
  214. </p>
  215. <dl compact="compact">
  216. <dt>&lsquo;<samp>a</samp>&rsquo;</dt>
  217. <dd><a name="index-relative-placement-in-archive"></a>
  218. <p>Add new files <em>after</em> an existing member of the
  219. archive. If you use the modifier &lsquo;<samp>a</samp>&rsquo;, the name of an existing archive
  220. member must be present as the <var>relpos</var> argument, before the
  221. <var>archive</var> specification.
  222. </p>
  223. </dd>
  224. <dt>&lsquo;<samp>b</samp>&rsquo;</dt>
  225. <dd><p>Add new files <em>before</em> an existing member of the
  226. archive. If you use the modifier &lsquo;<samp>b</samp>&rsquo;, the name of an existing archive
  227. member must be present as the <var>relpos</var> argument, before the
  228. <var>archive</var> specification. (same as &lsquo;<samp>i</samp>&rsquo;).
  229. </p>
  230. </dd>
  231. <dt>&lsquo;<samp>c</samp>&rsquo;</dt>
  232. <dd><a name="index-creating-archives"></a>
  233. <p><em>Create</em> the archive. The specified <var>archive</var> is always
  234. created if it did not exist, when you request an update. But a warning is
  235. issued unless you specify in advance that you expect to create it, by
  236. using this modifier.
  237. </p>
  238. </dd>
  239. <dt>&lsquo;<samp>D</samp>&rsquo;</dt>
  240. <dd><a name="index-deterministic-archives"></a>
  241. <a name="index-_002d_002denable_002ddeterministic_002darchives"></a>
  242. <p>Operate in <em>deterministic</em> mode. When adding files and the archive
  243. index use zero for UIDs, GIDs, timestamps, and use consistent file modes
  244. for all files. When this option is used, if <code>ar</code> is used with
  245. identical options and identical input files, multiple runs will create
  246. identical output files regardless of the input files&rsquo; owners, groups,
  247. file modes, or modification times.
  248. </p>
  249. <p>If <samp>binutils</samp> was configured with
  250. <samp>--enable-deterministic-archives</samp>, then this mode is on by default.
  251. It can be disabled with the &lsquo;<samp>U</samp>&rsquo; modifier, below.
  252. </p>
  253. </dd>
  254. <dt>&lsquo;<samp>f</samp>&rsquo;</dt>
  255. <dd><p>Truncate names in the archive. <small>GNU</small> <code>ar</code> will normally permit file
  256. names of any length. This will cause it to create archives which are
  257. not compatible with the native <code>ar</code> program on some systems. If
  258. this is a concern, the &lsquo;<samp>f</samp>&rsquo; modifier may be used to truncate file
  259. names when putting them in the archive.
  260. </p>
  261. </dd>
  262. <dt>&lsquo;<samp>i</samp>&rsquo;</dt>
  263. <dd><p>Insert new files <em>before</em> an existing member of the
  264. archive. If you use the modifier &lsquo;<samp>i</samp>&rsquo;, the name of an existing archive
  265. member must be present as the <var>relpos</var> argument, before the
  266. <var>archive</var> specification. (same as &lsquo;<samp>b</samp>&rsquo;).
  267. </p>
  268. </dd>
  269. <dt>&lsquo;<samp>l</samp>&rsquo;</dt>
  270. <dd><p>This modifier is accepted but not used.
  271. </p>
  272. </dd>
  273. <dt>&lsquo;<samp>N</samp>&rsquo;</dt>
  274. <dd><p>Uses the <var>count</var> parameter. This is used if there are multiple
  275. entries in the archive with the same name. Extract or delete instance
  276. <var>count</var> of the given name from the archive.
  277. </p>
  278. </dd>
  279. <dt>&lsquo;<samp>o</samp>&rsquo;</dt>
  280. <dd><a name="index-dates-in-archive"></a>
  281. <p>Preserve the <em>original</em> dates of members when extracting them. If
  282. you do not specify this modifier, files extracted from the archive
  283. are stamped with the time of extraction.
  284. </p>
  285. </dd>
  286. <dt>&lsquo;<samp>P</samp>&rsquo;</dt>
  287. <dd><p>Use the full path name when matching names in the archive. <small>GNU</small>
  288. <code>ar</code> can not create an archive with a full path name (such archives
  289. are not POSIX complaint), but other archive creators can. This option
  290. will cause <small>GNU</small> <code>ar</code> to match file names using a complete path
  291. name, which can be convenient when extracting a single file from an
  292. archive created by another tool.
  293. </p>
  294. </dd>
  295. <dt>&lsquo;<samp>s</samp>&rsquo;</dt>
  296. <dd><a name="index-writing-archive-index"></a>
  297. <p>Write an object-file index into the archive, or update an existing one,
  298. even if no other change is made to the archive. You may use this modifier
  299. flag either with any operation, or alone. Running &lsquo;<samp>ar s</samp>&rsquo; on an
  300. archive is equivalent to running &lsquo;<samp>ranlib</samp>&rsquo; on it.
  301. </p>
  302. </dd>
  303. <dt>&lsquo;<samp>S</samp>&rsquo;</dt>
  304. <dd><a name="index-not-writing-archive-index"></a>
  305. <p>Do not generate an archive symbol table. This can speed up building a
  306. large library in several steps. The resulting archive can not be used
  307. with the linker. In order to build a symbol table, you must omit the
  308. &lsquo;<samp>S</samp>&rsquo; modifier on the last execution of &lsquo;<samp>ar</samp>&rsquo;, or you must run
  309. &lsquo;<samp>ranlib</samp>&rsquo; on the archive.
  310. </p>
  311. </dd>
  312. <dt>&lsquo;<samp>T</samp>&rsquo;</dt>
  313. <dd><a name="index-creating-thin-archive"></a>
  314. <p>Make the specified <var>archive</var> a <em>thin</em> archive. If it already
  315. exists and is a regular archive, the existing members must be present
  316. in the same directory as <var>archive</var>.
  317. </p>
  318. </dd>
  319. <dt>&lsquo;<samp>u</samp>&rsquo;</dt>
  320. <dd><a name="index-updating-an-archive"></a>
  321. <p>Normally, &lsquo;<samp>ar r</samp>&rsquo;&hellip; inserts all files
  322. listed into the archive. If you would like to insert <em>only</em> those
  323. of the files you list that are newer than existing members of the same
  324. names, use this modifier. The &lsquo;<samp>u</samp>&rsquo; modifier is allowed only for the
  325. operation &lsquo;<samp>r</samp>&rsquo; (replace). In particular, the combination &lsquo;<samp>qu</samp>&rsquo; is
  326. not allowed, since checking the timestamps would lose any speed
  327. advantage from the operation &lsquo;<samp>q</samp>&rsquo;.
  328. </p>
  329. </dd>
  330. <dt>&lsquo;<samp>U</samp>&rsquo;</dt>
  331. <dd><a name="index-deterministic-archives-1"></a>
  332. <a name="index-_002d_002denable_002ddeterministic_002darchives-1"></a>
  333. <p>Do <em>not</em> operate in <em>deterministic</em> mode. This is the inverse
  334. of the &lsquo;<samp>D</samp>&rsquo; modifier, above: added files and the archive index will
  335. get their actual UID, GID, timestamp, and file mode values.
  336. </p>
  337. <p>This is the default unless <samp>binutils</samp> was configured with
  338. <samp>--enable-deterministic-archives</samp>.
  339. </p>
  340. </dd>
  341. <dt>&lsquo;<samp>v</samp>&rsquo;</dt>
  342. <dd><p>This modifier requests the <em>verbose</em> version of an operation. Many
  343. operations display additional information, such as filenames processed,
  344. when the modifier &lsquo;<samp>v</samp>&rsquo; is appended.
  345. </p>
  346. </dd>
  347. <dt>&lsquo;<samp>V</samp>&rsquo;</dt>
  348. <dd><p>This modifier shows the version number of <code>ar</code>.
  349. </p></dd>
  350. </dl>
  351. <p><code>ar</code> ignores an initial option spelt &lsquo;<samp>-X32_64</samp>&rsquo;, for
  352. compatibility with AIX. The behaviour produced by this option is the
  353. default for <small>GNU</small> <code>ar</code>. <code>ar</code> does not support any of the other
  354. &lsquo;<samp>-X</samp>&rsquo; options; in particular, it does not support <samp>-X32</samp>
  355. which is the default for AIX <code>ar</code>.
  356. </p>
  357. <p>The optional command line switch <samp>--plugin</samp> <var>name</var> causes
  358. <code>ar</code> to load the plugin called <var>name</var> which adds support
  359. for more file formats. This option is only available if the toolchain
  360. has been built with plugin support enabled.
  361. </p>
  362. <p>The optional command line switch <samp>--target</samp> <var>bfdname</var>
  363. specifies that the archive members are in an object code format
  364. different from your system&rsquo;s default format. See
  365. See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information.
  366. </p>
  367. <hr>
  368. <div class="header">
  369. <p>
  370. Next: <a href="ar-scripts.html#ar-scripts" accesskey="n" rel="next">ar scripts</a>, Up: <a href="ar.html#ar" accesskey="u" rel="up">ar</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>
  371. </div>
  372. </body>
  373. </html>