Adding-symbols-from-an-archive.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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: Adding symbols from an archive</title>
  21. <meta name="description" content="Untitled Document: Adding symbols from an archive">
  22. <meta name="keywords" content="Untitled Document: Adding symbols from an archive">
  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="Adding-Symbols-to-the-Hash-Table.html#Adding-Symbols-to-the-Hash-Table" rel="up" title="Adding Symbols to the Hash Table">
  31. <link href="Performing-the-Final-Link.html#Performing-the-Final-Link" rel="next" title="Performing the Final Link">
  32. <link href="Adding-symbols-from-an-object-file.html#Adding-symbols-from-an-object-file" rel="prev" title="Adding symbols from an object file">
  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="Adding-symbols-from-an-archive"></a>
  64. <div class="header">
  65. <p>
  66. Previous: <a href="Adding-symbols-from-an-object-file.html#Adding-symbols-from-an-object-file" accesskey="p" rel="prev">Adding symbols from an object file</a>, Up: <a href="Adding-Symbols-to-the-Hash-Table.html#Adding-Symbols-to-the-Hash-Table" accesskey="u" rel="up">Adding Symbols to the Hash Table</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="Adding-symbols-from-an-archive-1"></a>
  70. <h4 class="subsubsection">2.17.2.3 Adding symbols from an archive</h4>
  71. <p>When the <code>_bfd_link_add_symbols</code> routine is passed an
  72. archive, it must look through the symbols defined by the
  73. archive and decide which elements of the archive should be
  74. included in the link. For each such element it must call the
  75. <code>add_archive_element</code> linker callback, and it must add the
  76. symbols from the object file to the linker hash table. (The
  77. callback may in fact indicate that a replacement BFD should be
  78. used, in which case the symbols from that BFD should be added
  79. to the linker hash table instead.)
  80. </p>
  81. <a name="index-_005fbfd_005fgeneric_005flink_005fadd_005farchive_005fsymbols"></a>
  82. <p>In most cases the work of looking through the symbols in the
  83. archive should be done by the
  84. <code>_bfd_generic_link_add_archive_symbols</code> function.
  85. <code>_bfd_generic_link_add_archive_symbols</code> is passed a function
  86. to call to make the final decision about adding an archive
  87. element to the link and to do the actual work of adding the
  88. symbols to the linker hash table. If the element is to
  89. be included, the <code>add_archive_element</code> linker callback
  90. routine must be called with the element as an argument, and
  91. the element&rsquo;s symbols must be added to the linker hash table
  92. just as though the element had itself been passed to the
  93. <code>_bfd_link_add_symbols</code> function.
  94. </p>
  95. <p>When the a.out <code>_bfd_link_add_symbols</code> function receives an
  96. archive, it calls <code>_bfd_generic_link_add_archive_symbols</code>
  97. passing <code>aout_link_check_archive_element</code> as the function
  98. argument. <code>aout_link_check_archive_element</code> calls
  99. <code>aout_link_check_ar_symbols</code>. If the latter decides to add
  100. the element (an element is only added if it provides a real,
  101. non-common, definition for a previously undefined or common
  102. symbol) it calls the <code>add_archive_element</code> callback and then
  103. <code>aout_link_check_archive_element</code> calls
  104. <code>aout_link_add_symbols</code> to actually add the symbols to the
  105. linker hash table - possibly those of a substitute BFD, if the
  106. <code>add_archive_element</code> callback avails itself of that option.
  107. </p>
  108. <p>The ECOFF back end is unusual in that it does not normally
  109. call <code>_bfd_generic_link_add_archive_symbols</code>, because ECOFF
  110. archives already contain a hash table of symbols. The ECOFF
  111. back end searches the archive itself to avoid the overhead of
  112. creating a new hash table.
  113. </p>
  114. <hr>
  115. <div class="header">
  116. <p>
  117. Previous: <a href="Adding-symbols-from-an-object-file.html#Adding-symbols-from-an-object-file" accesskey="p" rel="prev">Adding symbols from an object file</a>, Up: <a href="Adding-Symbols-to-the-Hash-Table.html#Adding-Symbols-to-the-Hash-Table" accesskey="u" rel="up">Adding Symbols to the Hash Table</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>
  118. </div>
  119. </body>
  120. </html>