xref: /dragonfly/contrib/gdb-7/bfd/genlink.h (revision 86d7f5d3)
1*86d7f5d3SJohn Marino /* genlink.h -- interface to the BFD generic linker
2*86d7f5d3SJohn Marino    Copyright 1993, 1994, 1996, 2002, 2005, 2007 Free Software Foundation, Inc.
3*86d7f5d3SJohn Marino    Written by Ian Lance Taylor, Cygnus Support.
4*86d7f5d3SJohn Marino 
5*86d7f5d3SJohn Marino    This file is part of BFD, the Binary File Descriptor library.
6*86d7f5d3SJohn Marino 
7*86d7f5d3SJohn Marino    This program is free software; you can redistribute it and/or modify
8*86d7f5d3SJohn Marino    it under the terms of the GNU General Public License as published by
9*86d7f5d3SJohn Marino    the Free Software Foundation; either version 3 of the License, or
10*86d7f5d3SJohn Marino    (at your option) any later version.
11*86d7f5d3SJohn Marino 
12*86d7f5d3SJohn Marino    This program is distributed in the hope that it will be useful,
13*86d7f5d3SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*86d7f5d3SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*86d7f5d3SJohn Marino    GNU General Public License for more details.
16*86d7f5d3SJohn Marino 
17*86d7f5d3SJohn Marino    You should have received a copy of the GNU General Public License
18*86d7f5d3SJohn Marino    along with this program; if not, write to the Free Software
19*86d7f5d3SJohn Marino    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20*86d7f5d3SJohn Marino    MA 02110-1301, USA.  */
21*86d7f5d3SJohn Marino 
22*86d7f5d3SJohn Marino #ifndef GENLINK_H
23*86d7f5d3SJohn Marino #define GENLINK_H
24*86d7f5d3SJohn Marino 
25*86d7f5d3SJohn Marino /* This header file is internal to BFD.  It describes the internal
26*86d7f5d3SJohn Marino    structures and functions used by the BFD generic linker, in case
27*86d7f5d3SJohn Marino    any of the more specific linkers want to use or call them.  Note
28*86d7f5d3SJohn Marino    that some functions, such as _bfd_generic_link_hash_table_create,
29*86d7f5d3SJohn Marino    are declared in libbfd.h, because they are expected to be widely
30*86d7f5d3SJohn Marino    used.  The functions and structures in this file will probably only
31*86d7f5d3SJohn Marino    be used by a few files besides linker.c itself.  In fact, this file
32*86d7f5d3SJohn Marino    is not particularly complete; I have only put in the interfaces I
33*86d7f5d3SJohn Marino    actually needed.  */
34*86d7f5d3SJohn Marino 
35*86d7f5d3SJohn Marino /* The generic linker uses a hash table which is a derived class of
36*86d7f5d3SJohn Marino    the standard linker hash table, just as the other backend specific
37*86d7f5d3SJohn Marino    linkers do.  Do not confuse the generic linker hash table with the
38*86d7f5d3SJohn Marino    standard BFD linker hash table it is built upon.  */
39*86d7f5d3SJohn Marino 
40*86d7f5d3SJohn Marino /* Generic linker hash table entries.  */
41*86d7f5d3SJohn Marino 
42*86d7f5d3SJohn Marino struct generic_link_hash_entry
43*86d7f5d3SJohn Marino {
44*86d7f5d3SJohn Marino   struct bfd_link_hash_entry root;
45*86d7f5d3SJohn Marino   /* Whether this symbol has been written out.  */
46*86d7f5d3SJohn Marino   bfd_boolean written;
47*86d7f5d3SJohn Marino   /* Symbol from input BFD.  */
48*86d7f5d3SJohn Marino   asymbol *sym;
49*86d7f5d3SJohn Marino };
50*86d7f5d3SJohn Marino 
51*86d7f5d3SJohn Marino /* Generic linker hash table.  */
52*86d7f5d3SJohn Marino 
53*86d7f5d3SJohn Marino struct generic_link_hash_table
54*86d7f5d3SJohn Marino {
55*86d7f5d3SJohn Marino   struct bfd_link_hash_table root;
56*86d7f5d3SJohn Marino };
57*86d7f5d3SJohn Marino 
58*86d7f5d3SJohn Marino /* Look up an entry in a generic link hash table.  */
59*86d7f5d3SJohn Marino 
60*86d7f5d3SJohn Marino #define _bfd_generic_link_hash_lookup(table, string, create, copy, follow) \
61*86d7f5d3SJohn Marino   ((struct generic_link_hash_entry *) \
62*86d7f5d3SJohn Marino    bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
63*86d7f5d3SJohn Marino 
64*86d7f5d3SJohn Marino /* Traverse a generic link hash table.  */
65*86d7f5d3SJohn Marino 
66*86d7f5d3SJohn Marino #define _bfd_generic_link_hash_traverse(table, func, info)		\
67*86d7f5d3SJohn Marino   (bfd_link_hash_traverse						\
68*86d7f5d3SJohn Marino    (&(table)->root,							\
69*86d7f5d3SJohn Marino     (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func),	\
70*86d7f5d3SJohn Marino     (info)))
71*86d7f5d3SJohn Marino 
72*86d7f5d3SJohn Marino /* Get the generic link hash table from the info structure.  This is
73*86d7f5d3SJohn Marino    just a cast.  */
74*86d7f5d3SJohn Marino 
75*86d7f5d3SJohn Marino #define _bfd_generic_hash_table(p) \
76*86d7f5d3SJohn Marino   ((struct generic_link_hash_table *) ((p)->hash))
77*86d7f5d3SJohn Marino 
78*86d7f5d3SJohn Marino /* The generic linker reads in the asymbol structures for an input BFD
79*86d7f5d3SJohn Marino    and keeps them in the outsymbol and symcount fields.  */
80*86d7f5d3SJohn Marino 
81*86d7f5d3SJohn Marino #define _bfd_generic_link_get_symbols(abfd)  ((abfd)->outsymbols)
82*86d7f5d3SJohn Marino #define _bfd_generic_link_get_symcount(abfd) ((abfd)->symcount)
83*86d7f5d3SJohn Marino 
84*86d7f5d3SJohn Marino /* Add the symbols of input_bfd to the symbols being built for
85*86d7f5d3SJohn Marino    output_bfd.  */
86*86d7f5d3SJohn Marino extern bfd_boolean _bfd_generic_link_output_symbols
87*86d7f5d3SJohn Marino   (bfd *, bfd *, struct bfd_link_info *, size_t *);
88*86d7f5d3SJohn Marino 
89*86d7f5d3SJohn Marino /* This structure is used to pass information to
90*86d7f5d3SJohn Marino    _bfd_generic_link_write_global_symbol, which may be called via
91*86d7f5d3SJohn Marino    _bfd_generic_link_hash_traverse.  */
92*86d7f5d3SJohn Marino 
93*86d7f5d3SJohn Marino struct generic_write_global_symbol_info
94*86d7f5d3SJohn Marino {
95*86d7f5d3SJohn Marino   struct bfd_link_info *info;
96*86d7f5d3SJohn Marino   bfd *output_bfd;
97*86d7f5d3SJohn Marino   size_t *psymalloc;
98*86d7f5d3SJohn Marino };
99*86d7f5d3SJohn Marino 
100*86d7f5d3SJohn Marino /* Write out a single global symbol.  This is expected to be called
101*86d7f5d3SJohn Marino    via _bfd_generic_link_hash_traverse.  The second argument must
102*86d7f5d3SJohn Marino    actually be a struct generic_write_global_symbol_info *.  */
103*86d7f5d3SJohn Marino extern bfd_boolean _bfd_generic_link_write_global_symbol
104*86d7f5d3SJohn Marino   (struct generic_link_hash_entry *, void *);
105*86d7f5d3SJohn Marino 
106*86d7f5d3SJohn Marino /* Generic link hash table entry creation routine.  */
107*86d7f5d3SJohn Marino struct bfd_hash_entry *_bfd_generic_link_hash_newfunc
108*86d7f5d3SJohn Marino   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
109*86d7f5d3SJohn Marino 
110*86d7f5d3SJohn Marino #endif
111