Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

314 lines
14KB

  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>Writing the symbol table (Untitled Document)</title>
  22. <meta name="description" content="Writing the symbol table (Untitled Document)">
  23. <meta name="keywords" content="Writing the symbol table (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="Performing-the-Final-Link.html#Performing-the-Final-Link" rel="up" title="Performing the Final Link">
  31. <link href="Hash-Tables.html#Hash-Tables" rel="next" title="Hash Tables">
  32. <link href="Relocating-the-section-contents.html#Relocating-the-section-contents" rel="prev" title="Relocating the section contents">
  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="Writing-the-symbol-table"></a>
  63. <div class="header">
  64. <p>
  65. Previous: <a href="Relocating-the-section-contents.html#Relocating-the-section-contents" accesskey="p" rel="prev">Relocating the section contents</a>, Up: <a href="Performing-the-Final-Link.html#Performing-the-Final-Link" accesskey="u" rel="up">Performing the Final Link</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="Writing-the-symbol-table-1"></a>
  69. <h4 class="subsubsection">2.17.3.3 Writing the symbol table</h4>
  70. <p>The <code>_bfd_final_link</code> function must gather all the symbols
  71. in the input files and write them out. It must also write out
  72. all the symbols in the global hash table. This must be
  73. controlled by the <code>strip</code> and <code>discard</code> fields of the
  74. <code>bfd_link_info</code> structure.
  75. </p>
  76. <p>The local symbols of the input files will not have been
  77. entered into the linker hash table. The <code>_bfd_final_link</code>
  78. routine must consider each input file and include the symbols
  79. in the output file. It may be convenient to do this when
  80. looking through the <code>link_order</code> structures, or it may be
  81. done by stepping through the <code>input_bfds</code> list.
  82. </p>
  83. <p>The <code>_bfd_final_link</code> routine must also traverse the global
  84. hash table to gather all the externally visible symbols. It
  85. is possible that most of the externally visible symbols may be
  86. written out when considering the symbols of each input file,
  87. but it is still necessary to traverse the hash table since the
  88. linker script may have defined some symbols that are not in
  89. any of the input files.
  90. </p>
  91. <p>The <code>strip</code> field of the <code>bfd_link_info</code> structure
  92. controls which symbols are written out. The possible values
  93. are listed in <code>bfdlink.h</code>. If the value is <code>strip_some</code>,
  94. then the <code>keep_hash</code> field of the <code>bfd_link_info</code>
  95. structure is a hash table of symbols to keep; each symbol
  96. should be looked up in this hash table, and only symbols which
  97. are present should be included in the output file.
  98. </p>
  99. <p>If the <code>strip</code> field of the <code>bfd_link_info</code> structure
  100. permits local symbols to be written out, the <code>discard</code> field
  101. is used to further controls which local symbols are included
  102. in the output file. If the value is <code>discard_l</code>, then all
  103. local symbols which begin with a certain prefix are discarded;
  104. this is controlled by the <code>bfd_is_local_label_name</code> entry point.
  105. </p>
  106. <p>The a.out backend handles symbols by calling
  107. <code>aout_link_write_symbols</code> on each input BFD and then
  108. traversing the global hash table with the function
  109. <code>aout_link_write_other_symbol</code>. It builds a string table
  110. while writing out the symbols, which is written to the output
  111. file at the end of <code>NAME(aout,final_link)</code>.
  112. </p>
  113. <a name="index-bfd_005flink_005fsplit_005fsection"></a>
  114. <a name="bfd_005flink_005fsplit_005fsection"></a>
  115. <h4 class="subsubsection">2.17.3.4 <code>bfd_link_split_section</code></h4>
  116. <p><strong>Synopsis</strong>
  117. </p><div class="example">
  118. <pre class="example">bfd_boolean bfd_link_split_section (bfd *abfd, asection *sec);
  119. </pre></div>
  120. <p><strong>Description</strong><br>
  121. Return nonzero if <var>sec</var> should be split during a
  122. reloceatable or final link.
  123. </p><div class="example">
  124. <pre class="example">#define bfd_link_split_section(abfd, sec) \
  125. BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec))
  126. </pre></div>
  127. <a name="index-bfd_005fsection_005falready_005flinked"></a>
  128. <a name="bfd_005fsection_005falready_005flinked"></a>
  129. <h4 class="subsubsection">2.17.3.5 <code>bfd_section_already_linked</code></h4>
  130. <p><strong>Synopsis</strong>
  131. </p><div class="example">
  132. <pre class="example">bfd_boolean bfd_section_already_linked (bfd *abfd,
  133. asection *sec,
  134. struct bfd_link_info *info);
  135. </pre></div>
  136. <p><strong>Description</strong><br>
  137. Check if <var>data</var> has been already linked during a reloceatable
  138. or final link. Return TRUE if it has.
  139. </p><div class="example">
  140. <pre class="example">#define bfd_section_already_linked(abfd, sec, info) \
  141. BFD_SEND (abfd, _section_already_linked, (abfd, sec, info))
  142. </pre></div>
  143. <a name="index-bfd_005fgeneric_005fdefine_005fcommon_005fsymbol"></a>
  144. <a name="bfd_005fgeneric_005fdefine_005fcommon_005fsymbol"></a>
  145. <h4 class="subsubsection">2.17.3.6 <code>bfd_generic_define_common_symbol</code></h4>
  146. <p><strong>Synopsis</strong>
  147. </p><div class="example">
  148. <pre class="example">bfd_boolean bfd_generic_define_common_symbol
  149. (bfd *output_bfd, struct bfd_link_info *info,
  150. struct bfd_link_hash_entry *h);
  151. </pre></div>
  152. <p><strong>Description</strong><br>
  153. Convert common symbol <var>h</var> into a defined symbol.
  154. Return TRUE on success and FALSE on failure.
  155. </p><div class="example">
  156. <pre class="example">#define bfd_define_common_symbol(output_bfd, info, h) \
  157. BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
  158. </pre></div>
  159. <a name="index-_005fbfd_005fgeneric_005flink_005fhide_005fsymbol"></a>
  160. <a name="g_t_005fbfd_005fgeneric_005flink_005fhide_005fsymbol"></a>
  161. <h4 class="subsubsection">2.17.3.7 <code>_bfd_generic_link_hide_symbol</code></h4>
  162. <p><strong>Synopsis</strong>
  163. </p><div class="example">
  164. <pre class="example">void _bfd_generic_link_hide_symbol
  165. (bfd *output_bfd, struct bfd_link_info *info,
  166. struct bfd_link_hash_entry *h);
  167. </pre></div>
  168. <p><strong>Description</strong><br>
  169. Hide symbol <var>h</var>.
  170. This is an internal function. It should not be called from
  171. outside the BFD library.
  172. </p><div class="example">
  173. <pre class="example">#define bfd_link_hide_symbol(output_bfd, info, h) \
  174. BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h))
  175. </pre></div>
  176. <a name="index-bfd_005fgeneric_005fdefine_005fstart_005fstop"></a>
  177. <a name="bfd_005fgeneric_005fdefine_005fstart_005fstop"></a>
  178. <h4 class="subsubsection">2.17.3.8 <code>bfd_generic_define_start_stop</code></h4>
  179. <p><strong>Synopsis</strong>
  180. </p><div class="example">
  181. <pre class="example">struct bfd_link_hash_entry *bfd_generic_define_start_stop
  182. (struct bfd_link_info *info,
  183. const char *symbol, asection *sec);
  184. </pre></div>
  185. <p><strong>Description</strong><br>
  186. Define a __start, __stop, .startof. or .sizeof. symbol.
  187. Return the symbol or NULL if no such undefined symbol exists.
  188. </p><div class="example">
  189. <pre class="example">#define bfd_define_start_stop(output_bfd, info, symbol, sec) \
  190. BFD_SEND (output_bfd, _bfd_define_start_stop, (info, symbol, sec))
  191. </pre></div>
  192. <a name="index-bfd_005ffind_005fversion_005ffor_005fsym"></a>
  193. <a name="bfd_005ffind_005fversion_005ffor_005fsym"></a>
  194. <h4 class="subsubsection">2.17.3.9 <code>bfd_find_version_for_sym</code></h4>
  195. <p><strong>Synopsis</strong>
  196. </p><div class="example">
  197. <pre class="example">struct bfd_elf_version_tree * bfd_find_version_for_sym
  198. (struct bfd_elf_version_tree *verdefs,
  199. const char *sym_name, bfd_boolean *hide);
  200. </pre></div>
  201. <p><strong>Description</strong><br>
  202. Search an elf version script tree for symbol versioning
  203. info and export / don&rsquo;t-export status for a given symbol.
  204. Return non-NULL on success and NULL on failure; also sets
  205. the output &lsquo;<samp>hide</samp>&rsquo; boolean parameter.
  206. </p>
  207. <a name="index-bfd_005fhide_005fsym_005fby_005fversion"></a>
  208. <a name="bfd_005fhide_005fsym_005fby_005fversion"></a>
  209. <h4 class="subsubsection">2.17.3.10 <code>bfd_hide_sym_by_version</code></h4>
  210. <p><strong>Synopsis</strong>
  211. </p><div class="example">
  212. <pre class="example">bfd_boolean bfd_hide_sym_by_version
  213. (struct bfd_elf_version_tree *verdefs, const char *sym_name);
  214. </pre></div>
  215. <p><strong>Description</strong><br>
  216. Search an elf version script tree for symbol versioning
  217. info for a given symbol. Return TRUE if the symbol is hidden.
  218. </p>
  219. <a name="index-bfd_005flink_005fcheck_005frelocs"></a>
  220. <a name="bfd_005flink_005fcheck_005frelocs"></a>
  221. <h4 class="subsubsection">2.17.3.11 <code>bfd_link_check_relocs</code></h4>
  222. <p><strong>Synopsis</strong>
  223. </p><div class="example">
  224. <pre class="example">bfd_boolean bfd_link_check_relocs
  225. (bfd *abfd, struct bfd_link_info *info);
  226. </pre></div>
  227. <p><strong>Description</strong><br>
  228. Checks the relocs in ABFD for validity.
  229. Does not execute the relocs.
  230. Return TRUE if everything is OK, FALSE otherwise.
  231. This is the external entry point to this code.
  232. </p>
  233. <a name="index-_005fbfd_005fgeneric_005flink_005fcheck_005frelocs"></a>
  234. <a name="g_t_005fbfd_005fgeneric_005flink_005fcheck_005frelocs"></a>
  235. <h4 class="subsubsection">2.17.3.12 <code>_bfd_generic_link_check_relocs</code></h4>
  236. <p><strong>Synopsis</strong>
  237. </p><div class="example">
  238. <pre class="example">bfd_boolean _bfd_generic_link_check_relocs
  239. (bfd *abfd, struct bfd_link_info *info);
  240. </pre></div>
  241. <p><strong>Description</strong><br>
  242. Stub function for targets that do not implement reloc checking.
  243. Return TRUE.
  244. This is an internal function. It should not be called from
  245. outside the BFD library.
  246. </p>
  247. <a name="index-bfd_005fmerge_005fprivate_005fbfd_005fdata"></a>
  248. <a name="bfd_005fmerge_005fprivate_005fbfd_005fdata"></a>
  249. <h4 class="subsubsection">2.17.3.13 <code>bfd_merge_private_bfd_data</code></h4>
  250. <p><strong>Synopsis</strong>
  251. </p><div class="example">
  252. <pre class="example">bfd_boolean bfd_merge_private_bfd_data
  253. (bfd *ibfd, struct bfd_link_info *info);
  254. </pre></div>
  255. <p><strong>Description</strong><br>
  256. Merge private BFD information from the BFD <var>ibfd</var> to the
  257. the output file BFD when linking. Return <code>TRUE</code> on success,
  258. <code>FALSE</code> on error. Possible error returns are:
  259. </p>
  260. <ul>
  261. <li> <code>bfd_error_no_memory</code> -
  262. Not enough memory exists to create private data for <var>obfd</var>.
  263. </li></ul>
  264. <div class="example">
  265. <pre class="example">#define bfd_merge_private_bfd_data(ibfd, info) \
  266. BFD_SEND ((info)-&gt;output_bfd, _bfd_merge_private_bfd_data, \
  267. (ibfd, info))
  268. </pre></div>
  269. <a name="index-_005fbfd_005fgeneric_005fverify_005fendian_005fmatch"></a>
  270. <a name="g_t_005fbfd_005fgeneric_005fverify_005fendian_005fmatch"></a>
  271. <h4 class="subsubsection">2.17.3.14 <code>_bfd_generic_verify_endian_match</code></h4>
  272. <p><strong>Synopsis</strong>
  273. </p><div class="example">
  274. <pre class="example">bfd_boolean _bfd_generic_verify_endian_match
  275. (bfd *ibfd, struct bfd_link_info *info);
  276. </pre></div>
  277. <p><strong>Description</strong><br>
  278. Can be used from / for bfd_merge_private_bfd_data to check that
  279. endianness matches between input and output file. Returns
  280. TRUE for a match, otherwise returns FALSE and emits an error.
  281. </p>
  282. <hr>
  283. <div class="header">
  284. <p>
  285. Previous: <a href="Relocating-the-section-contents.html#Relocating-the-section-contents" accesskey="p" rel="prev">Relocating the section contents</a>, Up: <a href="Performing-the-Final-Link.html#Performing-the-Final-Link" accesskey="u" rel="up">Performing the Final Link</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>
  286. </div>
  287. </body>
  288. </html>