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