Linker-Functions.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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: Linker Functions</title>
  21. <meta name="description" content="Untitled Document: Linker Functions">
  22. <meta name="keywords" content="Untitled Document: Linker Functions">
  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="Creating-a-Linker-Hash-Table.html#Creating-a-Linker-Hash-Table" rel="next" title="Creating a Linker Hash Table">
  32. <link href="File-Caching.html#File-Caching" rel="prev" title="File Caching">
  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="Linker-Functions"></a>
  64. <div class="header">
  65. <p>
  66. Next: <a href="Hash-Tables.html#Hash-Tables" accesskey="n" rel="next">Hash Tables</a>, Previous: <a href="File-Caching.html#File-Caching" accesskey="p" rel="prev">File Caching</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="Linker-Functions-1"></a>
  70. <h3 class="section">2.17 Linker Functions</h3>
  71. <a name="index-Linker"></a>
  72. <p>The linker uses three special entry points in the BFD target
  73. vector. It is not necessary to write special routines for
  74. these entry points when creating a new BFD back end, since
  75. generic versions are provided. However, writing them can
  76. speed up linking and make it use significantly less runtime
  77. memory.
  78. </p>
  79. <p>The first routine creates a hash table used by the other
  80. routines. The second routine adds the symbols from an object
  81. file to the hash table. The third routine takes all the
  82. object files and links them together to create the output
  83. file. These routines are designed so that the linker proper
  84. does not need to know anything about the symbols in the object
  85. files that it is linking. The linker merely arranges the
  86. sections as directed by the linker script and lets BFD handle
  87. the details of symbols and relocs.
  88. </p>
  89. <p>The second routine and third routines are passed a pointer to
  90. a <code>struct bfd_link_info</code> structure (defined in
  91. <code>bfdlink.h</code>) which holds information relevant to the link,
  92. including the linker hash table (which was created by the
  93. first routine) and a set of callback functions to the linker
  94. proper.
  95. </p>
  96. <p>The generic linker routines are in <code>linker.c</code>, and use the
  97. header file <code>genlink.h</code>. As of this writing, the only back
  98. ends which have implemented versions of these routines are
  99. a.out (in <code>aoutx.h</code>) and ECOFF (in <code>ecoff.c</code>). The a.out
  100. routines are used as examples throughout this section.
  101. </p>
  102. <table class="menu" border="0" cellspacing="0">
  103. <tr><td align="left" valign="top">&bull; <a href="Creating-a-Linker-Hash-Table.html#Creating-a-Linker-Hash-Table" accesskey="1">Creating a Linker Hash Table</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  104. </td></tr>
  105. <tr><td align="left" valign="top">&bull; <a href="Adding-Symbols-to-the-Hash-Table.html#Adding-Symbols-to-the-Hash-Table" accesskey="2">Adding Symbols to the Hash Table</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  106. </td></tr>
  107. <tr><td align="left" valign="top">&bull; <a href="Performing-the-Final-Link.html#Performing-the-Final-Link" accesskey="3">Performing the Final Link</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  108. </td></tr>
  109. </table>
  110. <hr>
  111. <div class="header">
  112. <p>
  113. Next: <a href="Hash-Tables.html#Hash-Tables" accesskey="n" rel="next">Hash Tables</a>, Previous: <a href="File-Caching.html#File-Caching" accesskey="p" rel="prev">File Caching</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>
  114. </div>
  115. </body>
  116. </html>