ldemul.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* ld-emul.h - Linker emulation header file
  2. Copyright (C) 1991-2017 Free Software Foundation, Inc.
  3. This file is part of the GNU Binutils.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. #ifndef LDEMUL_H
  17. #define LDEMUL_H
  18. /* Forward declaration for ldemul_add_options() and others. */
  19. struct option;
  20. extern void ldemul_hll
  21. (char *);
  22. extern void ldemul_syslib
  23. (char *);
  24. extern void ldemul_after_parse
  25. (void);
  26. extern void ldemul_before_parse
  27. (void);
  28. extern void ldemul_after_open
  29. (void);
  30. extern void ldemul_after_allocation
  31. (void);
  32. extern void ldemul_before_allocation
  33. (void);
  34. extern void ldemul_set_output_arch
  35. (void);
  36. extern char *ldemul_choose_target
  37. (int, char**);
  38. extern void ldemul_choose_mode
  39. (char *);
  40. extern void ldemul_list_emulations
  41. (FILE *);
  42. extern void ldemul_list_emulation_options
  43. (FILE *);
  44. extern char *ldemul_get_script
  45. (int *isfile);
  46. extern void ldemul_finish
  47. (void);
  48. extern void ldemul_set_symbols
  49. (void);
  50. extern void ldemul_create_output_section_statements
  51. (void);
  52. extern lang_output_section_statement_type *ldemul_place_orphan
  53. (asection *, const char *, int);
  54. extern bfd_boolean ldemul_parse_args
  55. (int, char **);
  56. extern void ldemul_add_options
  57. (int, char **, int, struct option **, int, struct option **);
  58. extern bfd_boolean ldemul_handle_option
  59. (int);
  60. extern bfd_boolean ldemul_unrecognized_file
  61. (struct lang_input_statement_struct *);
  62. extern bfd_boolean ldemul_recognized_file
  63. (struct lang_input_statement_struct *);
  64. extern bfd_boolean ldemul_open_dynamic_archive
  65. (const char *, struct search_dirs *, struct lang_input_statement_struct *);
  66. extern char *ldemul_default_target
  67. (int, char**);
  68. extern void after_parse_default
  69. (void);
  70. extern void after_open_default
  71. (void);
  72. extern void after_allocation_default
  73. (void);
  74. extern void before_allocation_default
  75. (void);
  76. extern void finish_default
  77. (void);
  78. extern void finish_default
  79. (void);
  80. extern void set_output_arch_default
  81. (void);
  82. extern void syslib_default
  83. (char*);
  84. extern void hll_default
  85. (char*);
  86. extern int ldemul_find_potential_libraries
  87. (char *, struct lang_input_statement_struct *);
  88. extern struct bfd_elf_version_expr *ldemul_new_vers_pattern
  89. (struct bfd_elf_version_expr *);
  90. extern void ldemul_extra_map_file_text
  91. (bfd *, struct bfd_link_info *, FILE *);
  92. typedef struct ld_emulation_xfer_struct {
  93. /* Run before parsing the command line and script file.
  94. Set the architecture, maybe other things. */
  95. void (*before_parse) (void);
  96. /* Handle the SYSLIB (low level library) script command. */
  97. void (*syslib) (char *);
  98. /* Handle the HLL (high level library) script command. */
  99. void (*hll) (char *);
  100. /* Run after parsing the command line and script file. */
  101. void (*after_parse) (void);
  102. /* Run after opening all input files, and loading the symbols. */
  103. void (*after_open) (void);
  104. /* Run after allocating output sections. */
  105. void (*after_allocation) (void);
  106. /* Set the output architecture and machine if possible. */
  107. void (*set_output_arch) (void);
  108. /* Decide which target name to use. */
  109. char * (*choose_target) (int, char**);
  110. /* Run before allocating output sections. */
  111. void (*before_allocation) (void);
  112. /* Return the appropriate linker script. */
  113. char * (*get_script) (int *isfile);
  114. /* The name of this emulation. */
  115. char *emulation_name;
  116. /* The output format. */
  117. char *target_name;
  118. /* Run after assigning values from the script. */
  119. void (*finish) (void);
  120. /* Create any output sections needed by the target. */
  121. void (*create_output_section_statements) (void);
  122. /* Try to open a dynamic library. ARCH is an architecture name, and
  123. is normally the empty string. ENTRY is the lang_input_statement
  124. that should be opened. */
  125. bfd_boolean (*open_dynamic_archive)
  126. (const char *arch, struct search_dirs *,
  127. struct lang_input_statement_struct *entry);
  128. /* Place an orphan section. Return TRUE if it was placed, FALSE if
  129. the default action should be taken. This field may be NULL, in
  130. which case the default action will always be taken. */
  131. lang_output_section_statement_type *(*place_orphan)
  132. (asection *, const char *, int);
  133. /* Run after assigning parsing with the args, but before
  134. reading the script. Used to initialize symbols used in the script. */
  135. void (*set_symbols) (void);
  136. /* Parse args which the base linker doesn't understand.
  137. Return TRUE if the arg needs no further processing. */
  138. bfd_boolean (*parse_args) (int, char **);
  139. /* Hook to add options to parameters passed by the base linker to
  140. getopt_long and getopt_long_only calls. */
  141. void (*add_options)
  142. (int, char **, int, struct option **, int, struct option **);
  143. /* Companion to the above to handle an option. Returns TRUE if it is
  144. one of our options. */
  145. bfd_boolean (*handle_option) (int);
  146. /* Run to handle files which are not recognized as object files or
  147. archives. Return TRUE if the file was handled. */
  148. bfd_boolean (*unrecognized_file)
  149. (struct lang_input_statement_struct *);
  150. /* Run to list the command line options which parse_args handles. */
  151. void (* list_options) (FILE *);
  152. /* Run to specially handle files which *are* recognized as object
  153. files or archives. Return TRUE if the file was handled. */
  154. bfd_boolean (*recognized_file)
  155. (struct lang_input_statement_struct *);
  156. /* Called when looking for libraries in a directory specified
  157. via a linker command line option or linker script option.
  158. Files that match the pattern "lib*.a" have already been scanned.
  159. (For VMS files matching ":lib*.a" have also been scanned). */
  160. int (* find_potential_libraries)
  161. (char *, struct lang_input_statement_struct *);
  162. /* Called when adding a new version pattern. PowerPC64-ELF uses
  163. this hook to add a pattern matching ".foo" for every "foo". */
  164. struct bfd_elf_version_expr * (*new_vers_pattern)
  165. (struct bfd_elf_version_expr *);
  166. /* Called when printing the map file, in case there are
  167. emulation-specific sections for it. */
  168. void (*extra_map_file_text)
  169. (bfd *, struct bfd_link_info *, FILE *);
  170. } ld_emulation_xfer_type;
  171. typedef enum {
  172. intel_ic960_ld_mode_enum,
  173. default_mode_enum,
  174. intel_gld960_ld_mode_enum
  175. } lang_emulation_mode_enum_type;
  176. extern ld_emulation_xfer_type *ld_emulations[];
  177. #endif