89 lines
		
	
	
	
		
			4.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			89 lines
		
	
	
	
		
			4.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<html lang="en">
 | 
						|
<head>
 | 
						|
<title>Creating a Linker Hash Table - Untitled</title>
 | 
						|
<meta http-equiv="Content-Type" content="text/html">
 | 
						|
<meta name="description" content="Untitled">
 | 
						|
<meta name="generator" content="makeinfo 4.7">
 | 
						|
<link title="Top" rel="start" href="index.html#Top">
 | 
						|
<link rel="up" href="Linker-Functions.html#Linker-Functions" title="Linker Functions">
 | 
						|
<link rel="prev" href="Linker-Functions.html#Linker-Functions" title="Linker Functions">
 | 
						|
<link rel="next" href="Adding-Symbols-to-the-Hash-Table.html#Adding-Symbols-to-the-Hash-Table" title="Adding Symbols to the Hash Table">
 | 
						|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
 | 
						|
<!--
 | 
						|
This file documents the BFD library.
 | 
						|
 | 
						|
Copyright (C) 1991, 2000, 2001, 2003, 2006, 2007 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.1 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; } 
 | 
						|
--></style>
 | 
						|
</head>
 | 
						|
<body>
 | 
						|
<div class="node">
 | 
						|
<p>
 | 
						|
<a name="Creating-a-Linker-Hash-Table"></a>Next: <a rel="next" accesskey="n" href="Adding-Symbols-to-the-Hash-Table.html#Adding-Symbols-to-the-Hash-Table">Adding Symbols to the Hash Table</a>,
 | 
						|
Previous: <a rel="previous" accesskey="p" href="Linker-Functions.html#Linker-Functions">Linker Functions</a>,
 | 
						|
Up: <a rel="up" accesskey="u" href="Linker-Functions.html#Linker-Functions">Linker Functions</a>
 | 
						|
<hr><br>
 | 
						|
</div>
 | 
						|
 | 
						|
<h4 class="subsection">2.17.1 Creating a linker hash table</h4>
 | 
						|
 | 
						|
<p><a name="index-_005fbfd_005flink_005fhash_005ftable_005fcreate-in-target-vector-1369"></a><a name="index-target-vector-_0028_005fbfd_005flink_005fhash_005ftable_005fcreate_0029-1370"></a>The linker routines must create a hash table, which must be
 | 
						|
derived from <code>struct bfd_link_hash_table</code> described in
 | 
						|
<code>bfdlink.c</code>.  See <a href="Hash-Tables.html#Hash-Tables">Hash Tables</a>, for information on how to
 | 
						|
create a derived hash table.  This entry point is called using
 | 
						|
the target vector of the linker output file.
 | 
						|
 | 
						|
   <p>The <code>_bfd_link_hash_table_create</code> entry point must allocate
 | 
						|
and initialize an instance of the desired hash table.  If the
 | 
						|
back end does not require any additional information to be
 | 
						|
stored with the entries in the hash table, the entry point may
 | 
						|
simply create a <code>struct bfd_link_hash_table</code>.  Most likely,
 | 
						|
however, some additional information will be needed.
 | 
						|
 | 
						|
   <p>For example, with each entry in the hash table the a.out
 | 
						|
linker keeps the index the symbol has in the final output file
 | 
						|
(this index number is used so that when doing a relocatable
 | 
						|
link the symbol index used in the output file can be quickly
 | 
						|
filled in when copying over a reloc).  The a.out linker code
 | 
						|
defines the required structures and functions for a hash table
 | 
						|
derived from <code>struct bfd_link_hash_table</code>.  The a.out linker
 | 
						|
hash table is created by the function
 | 
						|
<code>NAME(aout,link_hash_table_create)</code>; it simply allocates
 | 
						|
space for the hash table, initializes it, and returns a
 | 
						|
pointer to it.
 | 
						|
 | 
						|
   <p>When writing the linker routines for a new back end, you will
 | 
						|
generally not know exactly which fields will be required until
 | 
						|
you have finished.  You should simply create a new hash table
 | 
						|
which defines no additional fields, and then simply add fields
 | 
						|
as they become necessary.
 | 
						|
 | 
						|
   </body></html>
 | 
						|
 |