blob: bfa1c84e7054762b211e5b433a024c197a471a5a [file] [log] [blame]
Fuad Tabbafed62072020-09-23 14:47:51 +01001<!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
5Copyright (C) 1991 - 2013 Free Software Foundation, Inc.
6
7Permission is granted to copy, distribute and/or modify this document
8under the terms of the GNU Free Documentation License, Version 1.3 or
9any later version published by the Free Software Foundation; with the
10Invariant Sections being "GNU General Public License" and "Funding
11Free Software", the Front-Cover texts being (a) (see below), and with
12the Back-Cover Texts being (b) (see below). A copy of the license is
13included in the section entitled "GNU Free Documentation License".
14
15(a) The FSF's Front-Cover Text is:
16
17A GNU Manual
18
19(b) The FSF's Back-Cover Text is:
20
21You have freedom to copy and modify this GNU Manual, like GNU
22 software. Copies published by the Free Software Foundation raise
23 funds for GNU development. -->
24<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
25<head>
26<title>Untitled Document: Adding symbols from an object file</title>
27
28<meta name="description" content="Untitled Document: Adding symbols from an object file">
29<meta name="keywords" content="Untitled Document: Adding symbols from an object file">
30<meta name="resource-type" content="document">
31<meta name="distribution" content="global">
32<meta name="Generator" content="makeinfo">
33<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
34<link href="index.html#Top" rel="start" title="Top">
35<link href="BFD-Index.html#BFD-Index" rel="index" title="BFD Index">
36<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
37<link href="Adding-Symbols-to-the-Hash-Table.html#Adding-Symbols-to-the-Hash-Table" rel="up" title="Adding Symbols to the Hash Table">
38<link href="Adding-symbols-from-an-archive.html#Adding-symbols-from-an-archive" rel="next" title="Adding symbols from an archive">
39<link href="Differing-file-formats.html#Differing-file-formats" rel="prev" title="Differing file formats">
40<style type="text/css">
41<!--
42a.summary-letter {text-decoration: none}
43blockquote.smallquotation {font-size: smaller}
44div.display {margin-left: 3.2em}
45div.example {margin-left: 3.2em}
46div.indentedblock {margin-left: 3.2em}
47div.lisp {margin-left: 3.2em}
48div.smalldisplay {margin-left: 3.2em}
49div.smallexample {margin-left: 3.2em}
50div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
51div.smalllisp {margin-left: 3.2em}
52kbd {font-style:oblique}
53pre.display {font-family: inherit}
54pre.format {font-family: inherit}
55pre.menu-comment {font-family: serif}
56pre.menu-preformatted {font-family: serif}
57pre.smalldisplay {font-family: inherit; font-size: smaller}
58pre.smallexample {font-size: smaller}
59pre.smallformat {font-family: inherit; font-size: smaller}
60pre.smalllisp {font-size: smaller}
61span.nocodebreak {white-space:nowrap}
62span.nolinebreak {white-space:nowrap}
63span.roman {font-family:serif; font-weight:normal}
64span.sansserif {font-family:sans-serif; font-weight:normal}
65ul.no-bullet {list-style: none}
66-->
67</style>
68
69
70</head>
71
72<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
73<a name="Adding-symbols-from-an-object-file"></a>
74<div class="header">
75<p>
76Next: <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>
77</div>
78<hr>
79<a name="Adding-symbols-from-an-object-file-1"></a>
80<h4 class="subsubsection">2.17.2.2 Adding symbols from an object file</h4>
81<p>When the <code>_bfd_link_add_symbols</code> routine is passed an object
82file, it must add all externally visible symbols in that
83object file to the hash table. The actual work of adding the
84symbol to the hash table is normally handled by the function
85<code>_bfd_generic_link_add_one_symbol</code>. The
86<code>_bfd_link_add_symbols</code> routine is responsible for reading
87all the symbols from the object file and passing the correct
88information to <code>_bfd_generic_link_add_one_symbol</code>.
89</p>
90<p>The <code>_bfd_link_add_symbols</code> routine should not use
91<code>bfd_canonicalize_symtab</code> to read the symbols. The point of
92providing this routine is to avoid the overhead of converting
93the symbols into generic <code>asymbol</code> structures.
94</p>
95<a name="index-_005fbfd_005fgeneric_005flink_005fadd_005fone_005fsymbol"></a>
96<p><code>_bfd_generic_link_add_one_symbol</code> handles the details of
97combining common symbols, warning about multiple definitions,
98and so forth. It takes arguments which describe the symbol to
99add, notably symbol flags, a section, and an offset. The
100symbol flags include such things as <code>BSF_WEAK</code> or
101<code>BSF_INDIRECT</code>. The section is a section in the object
102file, or something like <code>bfd_und_section_ptr</code> for an undefined
103symbol or <code>bfd_com_section_ptr</code> for a common symbol.
104</p>
105<p>If the <code>_bfd_final_link</code> routine is also going to need to
106read the symbol information, the <code>_bfd_link_add_symbols</code>
107routine should save it somewhere attached to the object file
108BFD. However, the information should only be saved if the
109<code>keep_memory</code> field of the <code>info</code> argument is TRUE, so
110that the <code>-no-keep-memory</code> linker switch is effective.
111</p>
112<p>The a.out function which adds symbols from an object file is
113<code>aout_link_add_object_symbols</code>, and most of the interesting
114work is in <code>aout_link_add_symbols</code>. The latter saves
115pointers to the hash tables entries created by
116<code>_bfd_generic_link_add_one_symbol</code> indexed by symbol number,
117so that the <code>_bfd_final_link</code> routine does not have to call
118the hash table lookup routine to locate the entry.
119</p>
120<hr>
121<div class="header">
122<p>
123Next: <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>
124</div>
125
126
127
128</body>
129</html>