ar.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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</title>
  14. <meta name="description" content="GNU Binary Utilities: ar">
  15. <meta name="keywords" content="GNU Binary Utilities: ar">
  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="index.html#Top" rel="up" title="Top">
  24. <link href="ar-cmdline.html#ar-cmdline" rel="next" title="ar cmdline">
  25. <link href="index.html#Top" rel="prev" title="Top">
  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"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="nm.html#nm" accesskey="n" rel="next">nm</a>, Previous: <a href="index.html#Top" accesskey="p" rel="prev">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>
  60. </div>
  61. <hr>
  62. <a name="ar-1"></a>
  63. <h2 class="chapter">1 ar</h2>
  64. <a name="index-ar"></a>
  65. <a name="index-archives"></a>
  66. <a name="index-collections-of-files"></a>
  67. <div class="smallexample">
  68. <pre class="smallexample">ar [-]<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;]
  69. ar -M [ &lt;mri-script ]
  70. </pre></div>
  71. <p>The <small>GNU</small> <code>ar</code> program creates, modifies, and extracts from
  72. archives. An <em>archive</em> is a single file holding a collection of
  73. other files in a structure that makes it possible to retrieve
  74. the original individual files (called <em>members</em> of the archive).
  75. </p>
  76. <p>The original files&rsquo; contents, mode (permissions), timestamp, owner, and
  77. group are preserved in the archive, and can be restored on
  78. extraction.
  79. </p>
  80. <a name="index-name-length"></a>
  81. <p><small>GNU</small> <code>ar</code> can maintain archives whose members have names of any
  82. length; however, depending on how <code>ar</code> is configured on your
  83. system, a limit on member-name length may be imposed for compatibility
  84. with archive formats maintained with other tools. If it exists, the
  85. limit is often 15 characters (typical of formats related to a.out) or 16
  86. characters (typical of formats related to coff).
  87. </p>
  88. <a name="index-libraries"></a>
  89. <p><code>ar</code> is considered a binary utility because archives of this sort
  90. are most often used as <em>libraries</em> holding commonly needed
  91. subroutines.
  92. </p>
  93. <a name="index-symbol-index"></a>
  94. <p><code>ar</code> creates an index to the symbols defined in relocatable
  95. object modules in the archive when you specify the modifier &lsquo;<samp>s</samp>&rsquo;.
  96. Once created, this index is updated in the archive whenever <code>ar</code>
  97. makes a change to its contents (save for the &lsquo;<samp>q</samp>&rsquo; update operation).
  98. An archive with such an index speeds up linking to the library, and
  99. allows routines in the library to call each other without regard to
  100. their placement in the archive.
  101. </p>
  102. <p>You may use &lsquo;<samp>nm -s</samp>&rsquo; or &lsquo;<samp>nm --print-armap</samp>&rsquo; to list this index
  103. table. If an archive lacks the table, another form of <code>ar</code> called
  104. <code>ranlib</code> can be used to add just the table.
  105. </p>
  106. <a name="index-thin-archives"></a>
  107. <p><small>GNU</small> <code>ar</code> can optionally create a <em>thin</em> archive,
  108. which contains a symbol index and references to the original copies
  109. of the member files of the archive. This is useful for building
  110. libraries for use within a local build tree, where the relocatable
  111. objects are expected to remain available, and copying the contents of
  112. each object would only waste time and space.
  113. </p>
  114. <p>An archive can either be <em>thin</em> or it can be normal. It cannot
  115. be both at the same time. Once an archive is created its format
  116. cannot be changed without first deleting it and then creating a new
  117. archive in its place.
  118. </p>
  119. <p>Thin archives are also <em>flattened</em>, so that adding one thin
  120. archive to another thin archive does not nest it, as would happen with
  121. a normal archive. Instead the elements of the first archive are added
  122. individually to the second archive.
  123. </p>
  124. <p>The paths to the elements of the archive are stored relative to the
  125. archive itself.
  126. </p>
  127. <a name="index-compatibility_002c-ar"></a>
  128. <a name="index-ar-compatibility"></a>
  129. <p><small>GNU</small> <code>ar</code> is designed to be compatible with two different
  130. facilities. You can control its activity using command-line options,
  131. like the different varieties of <code>ar</code> on Unix systems; or, if you
  132. specify the single command-line option <samp>-M</samp>, you can control it
  133. with a script supplied via standard input, like the MRI &ldquo;librarian&rdquo;
  134. program.
  135. </p>
  136. <table class="menu" border="0" cellspacing="0">
  137. <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
  138. </td></tr>
  139. <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
  140. </td></tr>
  141. </table>
  142. <hr>
  143. <div class="header">
  144. <p>
  145. Next: <a href="nm.html#nm" accesskey="n" rel="next">nm</a>, Previous: <a href="index.html#Top" accesskey="p" rel="prev">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>
  146. </div>
  147. </body>
  148. </html>