xref: /dflybsd-src/contrib/gdb-7/bfd/genlink.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /* genlink.h -- interface to the BFD generic linker
286d7f5d3SJohn Marino    Copyright 1993, 1994, 1996, 2002, 2005, 2007 Free Software Foundation, Inc.
386d7f5d3SJohn Marino    Written by Ian Lance Taylor, Cygnus Support.
486d7f5d3SJohn Marino 
586d7f5d3SJohn Marino    This file is part of BFD, the Binary File Descriptor library.
686d7f5d3SJohn Marino 
786d7f5d3SJohn Marino    This program is free software; you can redistribute it and/or modify
886d7f5d3SJohn Marino    it under the terms of the GNU General Public License as published by
986d7f5d3SJohn Marino    the Free Software Foundation; either version 3 of the License, or
1086d7f5d3SJohn Marino    (at your option) any later version.
1186d7f5d3SJohn Marino 
1286d7f5d3SJohn Marino    This program is distributed in the hope that it will be useful,
1386d7f5d3SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
1486d7f5d3SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1586d7f5d3SJohn Marino    GNU General Public License for more details.
1686d7f5d3SJohn Marino 
1786d7f5d3SJohn Marino    You should have received a copy of the GNU General Public License
1886d7f5d3SJohn Marino    along with this program; if not, write to the Free Software
1986d7f5d3SJohn Marino    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
2086d7f5d3SJohn Marino    MA 02110-1301, USA.  */
2186d7f5d3SJohn Marino 
2286d7f5d3SJohn Marino #ifndef GENLINK_H
2386d7f5d3SJohn Marino #define GENLINK_H
2486d7f5d3SJohn Marino 
2586d7f5d3SJohn Marino /* This header file is internal to BFD.  It describes the internal
2686d7f5d3SJohn Marino    structures and functions used by the BFD generic linker, in case
2786d7f5d3SJohn Marino    any of the more specific linkers want to use or call them.  Note
2886d7f5d3SJohn Marino    that some functions, such as _bfd_generic_link_hash_table_create,
2986d7f5d3SJohn Marino    are declared in libbfd.h, because they are expected to be widely
3086d7f5d3SJohn Marino    used.  The functions and structures in this file will probably only
3186d7f5d3SJohn Marino    be used by a few files besides linker.c itself.  In fact, this file
3286d7f5d3SJohn Marino    is not particularly complete; I have only put in the interfaces I
3386d7f5d3SJohn Marino    actually needed.  */
3486d7f5d3SJohn Marino 
3586d7f5d3SJohn Marino /* The generic linker uses a hash table which is a derived class of
3686d7f5d3SJohn Marino    the standard linker hash table, just as the other backend specific
3786d7f5d3SJohn Marino    linkers do.  Do not confuse the generic linker hash table with the
3886d7f5d3SJohn Marino    standard BFD linker hash table it is built upon.  */
3986d7f5d3SJohn Marino 
4086d7f5d3SJohn Marino /* Generic linker hash table entries.  */
4186d7f5d3SJohn Marino 
4286d7f5d3SJohn Marino struct generic_link_hash_entry
4386d7f5d3SJohn Marino {
4486d7f5d3SJohn Marino   struct bfd_link_hash_entry root;
4586d7f5d3SJohn Marino   /* Whether this symbol has been written out.  */
4686d7f5d3SJohn Marino   bfd_boolean written;
4786d7f5d3SJohn Marino   /* Symbol from input BFD.  */
4886d7f5d3SJohn Marino   asymbol *sym;
4986d7f5d3SJohn Marino };
5086d7f5d3SJohn Marino 
5186d7f5d3SJohn Marino /* Generic linker hash table.  */
5286d7f5d3SJohn Marino 
5386d7f5d3SJohn Marino struct generic_link_hash_table
5486d7f5d3SJohn Marino {
5586d7f5d3SJohn Marino   struct bfd_link_hash_table root;
5686d7f5d3SJohn Marino };
5786d7f5d3SJohn Marino 
5886d7f5d3SJohn Marino /* Look up an entry in a generic link hash table.  */
5986d7f5d3SJohn Marino 
6086d7f5d3SJohn Marino #define _bfd_generic_link_hash_lookup(table, string, create, copy, follow) \
6186d7f5d3SJohn Marino   ((struct generic_link_hash_entry *) \
6286d7f5d3SJohn Marino    bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
6386d7f5d3SJohn Marino 
6486d7f5d3SJohn Marino /* Traverse a generic link hash table.  */
6586d7f5d3SJohn Marino 
6686d7f5d3SJohn Marino #define _bfd_generic_link_hash_traverse(table, func, info)		\
6786d7f5d3SJohn Marino   (bfd_link_hash_traverse						\
6886d7f5d3SJohn Marino    (&(table)->root,							\
6986d7f5d3SJohn Marino     (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func),	\
7086d7f5d3SJohn Marino     (info)))
7186d7f5d3SJohn Marino 
7286d7f5d3SJohn Marino /* Get the generic link hash table from the info structure.  This is
7386d7f5d3SJohn Marino    just a cast.  */
7486d7f5d3SJohn Marino 
7586d7f5d3SJohn Marino #define _bfd_generic_hash_table(p) \
7686d7f5d3SJohn Marino   ((struct generic_link_hash_table *) ((p)->hash))
7786d7f5d3SJohn Marino 
7886d7f5d3SJohn Marino /* The generic linker reads in the asymbol structures for an input BFD
7986d7f5d3SJohn Marino    and keeps them in the outsymbol and symcount fields.  */
8086d7f5d3SJohn Marino 
8186d7f5d3SJohn Marino #define _bfd_generic_link_get_symbols(abfd)  ((abfd)->outsymbols)
8286d7f5d3SJohn Marino #define _bfd_generic_link_get_symcount(abfd) ((abfd)->symcount)
8386d7f5d3SJohn Marino 
8486d7f5d3SJohn Marino /* Add the symbols of input_bfd to the symbols being built for
8586d7f5d3SJohn Marino    output_bfd.  */
8686d7f5d3SJohn Marino extern bfd_boolean _bfd_generic_link_output_symbols
8786d7f5d3SJohn Marino   (bfd *, bfd *, struct bfd_link_info *, size_t *);
8886d7f5d3SJohn Marino 
8986d7f5d3SJohn Marino /* This structure is used to pass information to
9086d7f5d3SJohn Marino    _bfd_generic_link_write_global_symbol, which may be called via
9186d7f5d3SJohn Marino    _bfd_generic_link_hash_traverse.  */
9286d7f5d3SJohn Marino 
9386d7f5d3SJohn Marino struct generic_write_global_symbol_info
9486d7f5d3SJohn Marino {
9586d7f5d3SJohn Marino   struct bfd_link_info *info;
9686d7f5d3SJohn Marino   bfd *output_bfd;
9786d7f5d3SJohn Marino   size_t *psymalloc;
9886d7f5d3SJohn Marino };
9986d7f5d3SJohn Marino 
10086d7f5d3SJohn Marino /* Write out a single global symbol.  This is expected to be called
10186d7f5d3SJohn Marino    via _bfd_generic_link_hash_traverse.  The second argument must
10286d7f5d3SJohn Marino    actually be a struct generic_write_global_symbol_info *.  */
10386d7f5d3SJohn Marino extern bfd_boolean _bfd_generic_link_write_global_symbol
10486d7f5d3SJohn Marino   (struct generic_link_hash_entry *, void *);
10586d7f5d3SJohn Marino 
10686d7f5d3SJohn Marino /* Generic link hash table entry creation routine.  */
10786d7f5d3SJohn Marino struct bfd_hash_entry *_bfd_generic_link_hash_newfunc
10886d7f5d3SJohn Marino   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
10986d7f5d3SJohn Marino 
11086d7f5d3SJohn Marino #endif
111