Archives.html 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the BFD library.
  4. Copyright (C) 1991-2017 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3 or
  7. any later version published by the Free Software Foundation; with the
  8. Invariant Sections being "GNU General Public License" and "Funding
  9. Free Software", the Front-Cover texts being (a) (see below), and with
  10. the Back-Cover Texts being (b) (see below). A copy of the license is
  11. included in the section entitled "GNU Free Documentation License".
  12. (a) The FSF's Front-Cover Text is:
  13. A GNU Manual
  14. (b) The FSF's Back-Cover Text is:
  15. You have freedom to copy and modify this GNU Manual, like GNU
  16. software. Copies published by the Free Software Foundation raise
  17. funds for GNU development. -->
  18. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  19. <head>
  20. <title>Untitled Document: Archives</title>
  21. <meta name="description" content="Untitled Document: Archives">
  22. <meta name="keywords" content="Untitled Document: Archives">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  27. <link href="index.html#Top" rel="start" title="Top">
  28. <link href="BFD-Index.html#BFD-Index" rel="index" title="BFD Index">
  29. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  30. <link href="BFD-front-end.html#BFD-front-end" rel="up" title="BFD front end">
  31. <link href="Formats.html#Formats" rel="next" title="Formats">
  32. <link href="symbol-handling-functions.html#symbol-handling-functions" rel="prev" title="symbol handling functions">
  33. <style type="text/css">
  34. <!--
  35. a.summary-letter {text-decoration: none}
  36. blockquote.smallquotation {font-size: smaller}
  37. div.display {margin-left: 3.2em}
  38. div.example {margin-left: 3.2em}
  39. div.indentedblock {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  44. div.smalllisp {margin-left: 3.2em}
  45. kbd {font-style:oblique}
  46. pre.display {font-family: inherit}
  47. pre.format {font-family: inherit}
  48. pre.menu-comment {font-family: serif}
  49. pre.menu-preformatted {font-family: serif}
  50. pre.smalldisplay {font-family: inherit; font-size: smaller}
  51. pre.smallexample {font-size: smaller}
  52. pre.smallformat {font-family: inherit; font-size: smaller}
  53. pre.smalllisp {font-size: smaller}
  54. span.nocodebreak {white-space:nowrap}
  55. span.nolinebreak {white-space:nowrap}
  56. span.roman {font-family:serif; font-weight:normal}
  57. span.sansserif {font-family:sans-serif; font-weight:normal}
  58. ul.no-bullet {list-style: none}
  59. -->
  60. </style>
  61. </head>
  62. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  63. <a name="Archives"></a>
  64. <div class="header">
  65. <p>
  66. Next: <a href="Formats.html#Formats" accesskey="n" rel="next">Formats</a>, Previous: <a href="Symbols.html#Symbols" accesskey="p" rel="prev">Symbols</a>, Up: <a href="BFD-front-end.html#BFD-front-end" accesskey="u" rel="up">BFD front end</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="BFD-Index.html#BFD-Index" title="Index" rel="index">Index</a>]</p>
  67. </div>
  68. <hr>
  69. <a name="Archives-1"></a>
  70. <h3 class="section">2.8 Archives</h3>
  71. <p><strong>Description</strong><br>
  72. An archive (or library) is just another BFD. It has a symbol
  73. table, although there&rsquo;s not much a user program will do with it.
  74. </p>
  75. <p>The big difference between an archive BFD and an ordinary BFD
  76. is that the archive doesn&rsquo;t have sections. Instead it has a
  77. chain of BFDs that are considered its contents. These BFDs can
  78. be manipulated like any other. The BFDs contained in an
  79. archive opened for reading will all be opened for reading. You
  80. may put either input or output BFDs into an archive opened for
  81. output; they will be handled correctly when the archive is closed.
  82. </p>
  83. <p>Use <code>bfd_openr_next_archived_file</code> to step through
  84. the contents of an archive opened for input. You don&rsquo;t
  85. have to read the entire archive if you don&rsquo;t want
  86. to! Read it until you find what you want.
  87. </p>
  88. <p>A BFD returned by <code>bfd_openr_next_archived_file</code> can be
  89. closed manually with <code>bfd_close</code>. If you do not close it,
  90. then a second iteration through the members of an archive may
  91. return the same BFD. If you close the archive BFD, then all
  92. the member BFDs will automatically be closed as well.
  93. </p>
  94. <p>Archive contents of output BFDs are chained through the
  95. <code>archive_next</code> pointer in a BFD. The first one is findable
  96. through the <code>archive_head</code> slot of the archive. Set it with
  97. <code>bfd_set_archive_head</code> (q.v.). A given BFD may be in only
  98. one open output archive at a time.
  99. </p>
  100. <p>As expected, the BFD archive code is more general than the
  101. archive code of any given environment. BFD archives may
  102. contain files of different formats (e.g., a.out and coff) and
  103. even different architectures. You may even place archives
  104. recursively into archives!
  105. </p>
  106. <p>This can cause unexpected confusion, since some archive
  107. formats are more expressive than others. For instance, Intel
  108. COFF archives can preserve long filenames; SunOS a.out archives
  109. cannot. If you move a file from the first to the second
  110. format and back again, the filename may be truncated.
  111. Likewise, different a.out environments have different
  112. conventions as to how they truncate filenames, whether they
  113. preserve directory names in filenames, etc. When
  114. interoperating with native tools, be sure your files are
  115. homogeneous.
  116. </p>
  117. <p>Beware: most of these formats do not react well to the
  118. presence of spaces in filenames. We do the best we can, but
  119. can&rsquo;t always handle this case due to restrictions in the format of
  120. archives. Many Unix utilities are braindead in regards to
  121. spaces and such in filenames anyway, so this shouldn&rsquo;t be much
  122. of a restriction.
  123. </p>
  124. <p>Archives are supported in BFD in <code>archive.c</code>.
  125. </p>
  126. <a name="Archive-functions"></a>
  127. <h4 class="subsection">2.8.1 Archive functions</h4>
  128. <a name="index-bfd_005fget_005fnext_005fmapent"></a>
  129. <a name="bfd_005fget_005fnext_005fmapent"></a>
  130. <h4 class="subsubsection">2.8.1.1 <code>bfd_get_next_mapent</code></h4>
  131. <p><strong>Synopsis</strong>
  132. </p><div class="example">
  133. <pre class="example">symindex bfd_get_next_mapent
  134. (bfd *abfd, symindex previous, carsym **sym);
  135. </pre></div>
  136. <p><strong>Description</strong><br>
  137. Step through archive <var>abfd</var>&rsquo;s symbol table (if it
  138. has one). Successively update <var>sym</var> with the next symbol&rsquo;s
  139. information, returning that symbol&rsquo;s (internal) index into the
  140. symbol table.
  141. </p>
  142. <p>Supply <code>BFD_NO_MORE_SYMBOLS</code> as the <var>previous</var> entry to get
  143. the first one; returns <code>BFD_NO_MORE_SYMBOLS</code> when you&rsquo;ve already
  144. got the last one.
  145. </p>
  146. <p>A <code>carsym</code> is a canonical archive symbol. The only
  147. user-visible element is its name, a null-terminated string.
  148. </p>
  149. <a name="index-bfd_005fset_005farchive_005fhead"></a>
  150. <a name="bfd_005fset_005farchive_005fhead"></a>
  151. <h4 class="subsubsection">2.8.1.2 <code>bfd_set_archive_head</code></h4>
  152. <p><strong>Synopsis</strong>
  153. </p><div class="example">
  154. <pre class="example">bfd_boolean bfd_set_archive_head (bfd *output, bfd *new_head);
  155. </pre></div>
  156. <p><strong>Description</strong><br>
  157. Set the head of the chain of
  158. BFDs contained in the archive <var>output</var> to <var>new_head</var>.
  159. </p>
  160. <a name="index-bfd_005fopenr_005fnext_005farchived_005ffile"></a>
  161. <a name="bfd_005fopenr_005fnext_005farchived_005ffile"></a>
  162. <h4 class="subsubsection">2.8.1.3 <code>bfd_openr_next_archived_file</code></h4>
  163. <p><strong>Synopsis</strong>
  164. </p><div class="example">
  165. <pre class="example">bfd *bfd_openr_next_archived_file (bfd *archive, bfd *previous);
  166. </pre></div>
  167. <p><strong>Description</strong><br>
  168. Provided a BFD, <var>archive</var>, containing an archive and NULL, open
  169. an input BFD on the first contained element and returns that.
  170. Subsequent calls should pass
  171. the archive and the previous return value to return a created
  172. BFD to the next contained element. NULL is returned when there
  173. are no more.
  174. </p>
  175. <hr>
  176. <div class="header">
  177. <p>
  178. Next: <a href="Formats.html#Formats" accesskey="n" rel="next">Formats</a>, Previous: <a href="Symbols.html#Symbols" accesskey="p" rel="prev">Symbols</a>, Up: <a href="BFD-front-end.html#BFD-front-end" accesskey="u" rel="up">BFD front end</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="BFD-Index.html#BFD-Index" title="Index" rel="index">Index</a>]</p>
  179. </div>
  180. </body>
  181. </html>