You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
7.7 KiB
HTML
175 lines
7.7 KiB
HTML
4 years ago
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>Writing the symbol table - Untitled</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html">
|
||
|
<meta name="description" content="Untitled">
|
||
|
<meta name="generator" content="makeinfo 4.13">
|
||
|
<link title="Top" rel="start" href="index.html#Top">
|
||
|
<link rel="up" href="Performing-the-Final-Link.html#Performing-the-Final-Link" title="Performing the Final Link">
|
||
|
<link rel="prev" href="Relocating-the-section-contents.html#Relocating-the-section-contents" title="Relocating the section contents">
|
||
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
||
|
<!--
|
||
|
This file documents the BFD library.
|
||
|
|
||
|
Copyright (C) 1991-2015 Free Software Foundation, Inc.
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document
|
||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||
|
any later version published by the Free Software Foundation; with the
|
||
|
Invariant Sections being ``GNU General Public License'' and ``Funding
|
||
|
Free Software'', the Front-Cover texts being (a) (see below), and with
|
||
|
the Back-Cover Texts being (b) (see below). A copy of the license is
|
||
|
included in the section entitled ``GNU Free Documentation License''.
|
||
|
|
||
|
(a) The FSF's Front-Cover Text is:
|
||
|
|
||
|
A GNU Manual
|
||
|
|
||
|
(b) The FSF's Back-Cover Text is:
|
||
|
|
||
|
You have freedom to copy and modify this GNU Manual, like GNU
|
||
|
software. Copies published by the Free Software Foundation raise
|
||
|
funds for GNU development.-->
|
||
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
||
|
<style type="text/css"><!--
|
||
|
pre.display { font-family:inherit }
|
||
|
pre.format { font-family:inherit }
|
||
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
||
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
||
|
pre.smallexample { font-size:smaller }
|
||
|
pre.smalllisp { font-size:smaller }
|
||
|
span.sc { font-variant:small-caps }
|
||
|
span.roman { font-family:serif; font-weight:normal; }
|
||
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="node">
|
||
|
<a name="Writing-the-symbol-table"></a>
|
||
|
<p>
|
||
|
Previous: <a rel="previous" accesskey="p" href="Relocating-the-section-contents.html#Relocating-the-section-contents">Relocating the section contents</a>,
|
||
|
Up: <a rel="up" accesskey="u" href="Performing-the-Final-Link.html#Performing-the-Final-Link">Performing the Final Link</a>
|
||
|
<hr>
|
||
|
</div>
|
||
|
|
||
|
<h5 class="subsubsection">2.17.3.3 Writing the symbol table</h5>
|
||
|
|
||
|
<p>The <code>_bfd_final_link</code> function must gather all the symbols
|
||
|
in the input files and write them out. It must also write out
|
||
|
all the symbols in the global hash table. This must be
|
||
|
controlled by the <code>strip</code> and <code>discard</code> fields of the
|
||
|
<code>bfd_link_info</code> structure.
|
||
|
|
||
|
<p>The local symbols of the input files will not have been
|
||
|
entered into the linker hash table. The <code>_bfd_final_link</code>
|
||
|
routine must consider each input file and include the symbols
|
||
|
in the output file. It may be convenient to do this when
|
||
|
looking through the <code>link_order</code> structures, or it may be
|
||
|
done by stepping through the <code>input_bfds</code> list.
|
||
|
|
||
|
<p>The <code>_bfd_final_link</code> routine must also traverse the global
|
||
|
hash table to gather all the externally visible symbols. It
|
||
|
is possible that most of the externally visible symbols may be
|
||
|
written out when considering the symbols of each input file,
|
||
|
but it is still necessary to traverse the hash table since the
|
||
|
linker script may have defined some symbols that are not in
|
||
|
any of the input files.
|
||
|
|
||
|
<p>The <code>strip</code> field of the <code>bfd_link_info</code> structure
|
||
|
controls which symbols are written out. The possible values
|
||
|
are listed in <code>bfdlink.h</code>. If the value is <code>strip_some</code>,
|
||
|
then the <code>keep_hash</code> field of the <code>bfd_link_info</code>
|
||
|
structure is a hash table of symbols to keep; each symbol
|
||
|
should be looked up in this hash table, and only symbols which
|
||
|
are present should be included in the output file.
|
||
|
|
||
|
<p>If the <code>strip</code> field of the <code>bfd_link_info</code> structure
|
||
|
permits local symbols to be written out, the <code>discard</code> field
|
||
|
is used to further controls which local symbols are included
|
||
|
in the output file. If the value is <code>discard_l</code>, then all
|
||
|
local symbols which begin with a certain prefix are discarded;
|
||
|
this is controlled by the <code>bfd_is_local_label_name</code> entry point.
|
||
|
|
||
|
<p>The a.out backend handles symbols by calling
|
||
|
<code>aout_link_write_symbols</code> on each input BFD and then
|
||
|
traversing the global hash table with the function
|
||
|
<code>aout_link_write_other_symbol</code>. It builds a string table
|
||
|
while writing out the symbols, which is written to the output
|
||
|
file at the end of <code>NAME(aout,final_link)</code>.
|
||
|
|
||
|
<p><a name="index-bfd_005flink_005fsplit_005fsection-2350"></a>
|
||
|
|
||
|
<h5 class="subsubsection">2.17.3.4 <code>bfd_link_split_section</code></h5>
|
||
|
|
||
|
<p><strong>Synopsis</strong>
|
||
|
<pre class="example"> bfd_boolean bfd_link_split_section (bfd *abfd, asection *sec);
|
||
|
</pre>
|
||
|
<p><strong>Description</strong><br>
|
||
|
Return nonzero if <var>sec</var> should be split during a
|
||
|
reloceatable or final link.
|
||
|
<pre class="example"> #define bfd_link_split_section(abfd, sec) \
|
||
|
BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec))
|
||
|
|
||
|
</pre>
|
||
|
<p><a name="index-bfd_005fsection_005falready_005flinked-2351"></a>
|
||
|
|
||
|
<h5 class="subsubsection">2.17.3.5 <code>bfd_section_already_linked</code></h5>
|
||
|
|
||
|
<p><strong>Synopsis</strong>
|
||
|
<pre class="example"> bfd_boolean bfd_section_already_linked (bfd *abfd,
|
||
|
asection *sec,
|
||
|
struct bfd_link_info *info);
|
||
|
</pre>
|
||
|
<p><strong>Description</strong><br>
|
||
|
Check if <var>data</var> has been already linked during a reloceatable
|
||
|
or final link. Return TRUE if it has.
|
||
|
<pre class="example"> #define bfd_section_already_linked(abfd, sec, info) \
|
||
|
BFD_SEND (abfd, _section_already_linked, (abfd, sec, info))
|
||
|
|
||
|
</pre>
|
||
|
<p><a name="index-bfd_005fgeneric_005fdefine_005fcommon_005fsymbol-2352"></a>
|
||
|
|
||
|
<h5 class="subsubsection">2.17.3.6 <code>bfd_generic_define_common_symbol</code></h5>
|
||
|
|
||
|
<p><strong>Synopsis</strong>
|
||
|
<pre class="example"> bfd_boolean bfd_generic_define_common_symbol
|
||
|
(bfd *output_bfd, struct bfd_link_info *info,
|
||
|
struct bfd_link_hash_entry *h);
|
||
|
</pre>
|
||
|
<p><strong>Description</strong><br>
|
||
|
Convert common symbol <var>h</var> into a defined symbol.
|
||
|
Return TRUE on success and FALSE on failure.
|
||
|
<pre class="example"> #define bfd_define_common_symbol(output_bfd, info, h) \
|
||
|
BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
|
||
|
|
||
|
</pre>
|
||
|
<p><a name="index-bfd_005ffind_005fversion_005ffor_005fsym-2353"></a>
|
||
|
|
||
|
<h5 class="subsubsection">2.17.3.7 <code>bfd_find_version_for_sym</code></h5>
|
||
|
|
||
|
<p><strong>Synopsis</strong>
|
||
|
<pre class="example"> struct bfd_elf_version_tree * bfd_find_version_for_sym
|
||
|
(struct bfd_elf_version_tree *verdefs,
|
||
|
const char *sym_name, bfd_boolean *hide);
|
||
|
</pre>
|
||
|
<p><strong>Description</strong><br>
|
||
|
Search an elf version script tree for symbol versioning
|
||
|
info and export / don't-export status for a given symbol.
|
||
|
Return non-NULL on success and NULL on failure; also sets
|
||
|
the output ‘<samp><span class="samp">hide</span></samp>’ boolean parameter.
|
||
|
|
||
|
<p><a name="index-bfd_005fhide_005fsym_005fby_005fversion-2354"></a>
|
||
|
|
||
|
<h5 class="subsubsection">2.17.3.8 <code>bfd_hide_sym_by_version</code></h5>
|
||
|
|
||
|
<p><strong>Synopsis</strong>
|
||
|
<pre class="example"> bfd_boolean bfd_hide_sym_by_version
|
||
|
(struct bfd_elf_version_tree *verdefs, const char *sym_name);
|
||
|
</pre>
|
||
|
<p><strong>Description</strong><br>
|
||
|
Search an elf version script tree for symbol versioning
|
||
|
info for a given symbol. Return TRUE if the symbol is hidden.
|
||
|
|
||
|
</body></html>
|
||
|
|