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