Fuad Tabba | fed6207 | 2020-09-23 14:47:51 +0100 | [diff] [blame^] | 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 | |
| 5 | Copyright (C) 1991 - 2013 Free Software Foundation, Inc. |
| 6 | |
| 7 | Permission is granted to copy, distribute and/or modify this document |
| 8 | under the terms of the GNU Free Documentation License, Version 1.3 or |
| 9 | any later version published by the Free Software Foundation; with the |
| 10 | Invariant Sections being "GNU General Public License" and "Funding |
| 11 | Free Software", the Front-Cover texts being (a) (see below), and with |
| 12 | the Back-Cover Texts being (b) (see below). A copy of the license is |
| 13 | included in the section entitled "GNU Free Documentation License". |
| 14 | |
| 15 | (a) The FSF's Front-Cover Text is: |
| 16 | |
| 17 | A GNU Manual |
| 18 | |
| 19 | (b) The FSF's Back-Cover Text is: |
| 20 | |
| 21 | You 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 | <!-- |
| 42 | a.summary-letter {text-decoration: none} |
| 43 | blockquote.smallquotation {font-size: smaller} |
| 44 | div.display {margin-left: 3.2em} |
| 45 | div.example {margin-left: 3.2em} |
| 46 | div.indentedblock {margin-left: 3.2em} |
| 47 | div.lisp {margin-left: 3.2em} |
| 48 | div.smalldisplay {margin-left: 3.2em} |
| 49 | div.smallexample {margin-left: 3.2em} |
| 50 | div.smallindentedblock {margin-left: 3.2em; font-size: smaller} |
| 51 | div.smalllisp {margin-left: 3.2em} |
| 52 | kbd {font-style:oblique} |
| 53 | pre.display {font-family: inherit} |
| 54 | pre.format {font-family: inherit} |
| 55 | pre.menu-comment {font-family: serif} |
| 56 | pre.menu-preformatted {font-family: serif} |
| 57 | pre.smalldisplay {font-family: inherit; font-size: smaller} |
| 58 | pre.smallexample {font-size: smaller} |
| 59 | pre.smallformat {font-family: inherit; font-size: smaller} |
| 60 | pre.smalllisp {font-size: smaller} |
| 61 | span.nocodebreak {white-space:nowrap} |
| 62 | span.nolinebreak {white-space:nowrap} |
| 63 | span.roman {font-family:serif; font-weight:normal} |
| 64 | span.sansserif {font-family:sans-serif; font-weight:normal} |
| 65 | ul.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> |
| 76 | 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> [<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 |
| 82 | file, it must add all externally visible symbols in that |
| 83 | object file to the hash table. The actual work of adding the |
| 84 | symbol 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 |
| 87 | all the symbols from the object file and passing the correct |
| 88 | information 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 |
| 92 | providing this routine is to avoid the overhead of converting |
| 93 | the 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 |
| 97 | combining common symbols, warning about multiple definitions, |
| 98 | and so forth. It takes arguments which describe the symbol to |
| 99 | add, notably symbol flags, a section, and an offset. The |
| 100 | symbol flags include such things as <code>BSF_WEAK</code> or |
| 101 | <code>BSF_INDIRECT</code>. The section is a section in the object |
| 102 | file, or something like <code>bfd_und_section_ptr</code> for an undefined |
| 103 | symbol 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 |
| 106 | read the symbol information, the <code>_bfd_link_add_symbols</code> |
| 107 | routine should save it somewhere attached to the object file |
| 108 | BFD. However, the information should only be saved if the |
| 109 | <code>keep_memory</code> field of the <code>info</code> argument is TRUE, so |
| 110 | that 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 |
| 114 | work is in <code>aout_link_add_symbols</code>. The latter saves |
| 115 | pointers to the hash tables entries created by |
| 116 | <code>_bfd_generic_link_add_one_symbol</code> indexed by symbol number, |
| 117 | so that the <code>_bfd_final_link</code> routine does not have to call |
| 118 | the hash table lookup routine to locate the entry. |
| 119 | </p> |
| 120 | <hr> |
| 121 | <div class="header"> |
| 122 | <p> |
| 123 | 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> [<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> |