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