genlink.h 3.9 KB

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