You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 line
6.6KB

  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-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
  19. <head>
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  21. <title>Adding symbols from an object file (Untitled Document)</title>
  22. <meta name="description" content="Adding symbols from an object file (Untitled Document)">
  23. <meta name="keywords" content="Adding symbols from an object file (Untitled Document)">
  24. <meta name="resource-type" content="document">
  25. <meta name="distribution" content="global">
  26. <meta name="Generator" content="makeinfo">
  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="Adding-symbols-from-an-archive.html#Adding-symbols-from-an-archive" rel="next" title="Adding symbols from an archive">
  32. <link href="Differing-file-formats.html#Differing-file-formats" rel="prev" title="Differing file formats">
  33. <style type="text/css">
  34. <!--
  35. a.summary-letter {text-decoration: none}
  36. blockquote.indentedblock {margin-right: 0em}
  37. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  38. blockquote.smallquotation {font-size: smaller}
  39. div.display {margin-left: 3.2em}
  40. div.example {margin-left: 3.2em}
  41. div.lisp {margin-left: 3.2em}
  42. div.smalldisplay {margin-left: 3.2em}
  43. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  55. span.roman {font-family: initial; font-weight: normal}
  56. span.sansserif {font-family: sans-serif; font-weight: normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en">
  62. <a name="Adding-symbols-from-an-object-file"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Adding-symbols-from-an-archive.html#Adding-symbols-from-an-archive" accesskey="n" rel="next">Adding symbols from an archive</a>, Previous: <a href="Differing-file-formats.html#Differing-file-formats" accesskey="p" rel="prev">Differing file formats</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>
  66. </div>
  67. <hr>
  68. <a name="Adding-symbols-from-an-object-file-1"></a>
  69. <h4 class="subsubsection">2.17.2.2 Adding symbols from an object file</h4>
  70. <p>When the <code>_bfd_link_add_symbols</code> routine is passed an object
  71. file, it must add all externally visible symbols in that
  72. object file to the hash table. The actual work of adding the
  73. symbol to the hash table is normally handled by the function
  74. <code>_bfd_generic_link_add_one_symbol</code>. The
  75. <code>_bfd_link_add_symbols</code> routine is responsible for reading
  76. all the symbols from the object file and passing the correct
  77. information to <code>_bfd_generic_link_add_one_symbol</code>.
  78. </p>
  79. <p>The <code>_bfd_link_add_symbols</code> routine should not use
  80. <code>bfd_canonicalize_symtab</code> to read the symbols. The point of
  81. providing this routine is to avoid the overhead of converting
  82. the symbols into generic <code>asymbol</code> structures.
  83. </p>
  84. <a name="index-_005fbfd_005fgeneric_005flink_005fadd_005fone_005fsymbol"></a>
  85. <p><code>_bfd_generic_link_add_one_symbol</code> handles the details of
  86. combining common symbols, warning about multiple definitions,
  87. and so forth. It takes arguments which describe the symbol to
  88. add, notably symbol flags, a section, and an offset. The
  89. symbol flags include such things as <code>BSF_WEAK</code> or
  90. <code>BSF_INDIRECT</code>. The section is a section in the object
  91. file, or something like <code>bfd_und_section_ptr</code> for an undefined
  92. symbol or <code>bfd_com_section_ptr</code> for a common symbol.
  93. </p>
  94. <p>If the <code>_bfd_final_link</code> routine is also going to need to
  95. read the symbol information, the <code>_bfd_link_add_symbols</code>
  96. routine should save it somewhere attached to the object file
  97. BFD. However, the information should only be saved if the
  98. <code>keep_memory</code> field of the <code>info</code> argument is TRUE, so
  99. that the <code>-no-keep-memory</code> linker switch is effective.
  100. </p>
  101. <p>The a.out function which adds symbols from an object file is
  102. <code>aout_link_add_object_symbols</code>, and most of the interesting
  103. work is in <code>aout_link_add_symbols</code>. The latter saves
  104. pointers to the hash tables entries created by
  105. <code>_bfd_generic_link_add_one_symbol</code> indexed by symbol number,
  106. so that the <code>_bfd_final_link</code> routine does not have to call
  107. the hash table lookup routine to locate the entry.
  108. </p>
  109. <hr>
  110. <div class="header">
  111. <p>
  112. Next: <a href="Adding-symbols-from-an-archive.html#Adding-symbols-from-an-archive" accesskey="n" rel="next">Adding symbols from an archive</a>, Previous: <a href="Differing-file-formats.html#Differing-file-formats" accesskey="p" rel="prev">Differing file formats</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>
  113. </div>
  114. </body>
  115. </html>