Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* ld-emul.h - Linker emulation header file |
b3adc24a | 2 | Copyright (C) 1991-2020 Free Software Foundation, Inc. |
252b5132 | 3 | |
f96b4a7b | 4 | This file is part of the GNU Binutils. |
252b5132 | 5 | |
f96b4a7b | 6 | This program is free software; you can redistribute it and/or modify |
252b5132 | 7 | it under the terms of the GNU General Public License as published by |
f96b4a7b NC |
8 | the Free Software Foundation; either version 3 of the License, or |
9 | (at your option) any later version. | |
252b5132 | 10 | |
f96b4a7b | 11 | This program is distributed in the hope that it will be useful, |
252b5132 RH |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
f96b4a7b NC |
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. */ | |
252b5132 RH |
20 | |
21 | #ifndef LDEMUL_H | |
22 | #define LDEMUL_H | |
23 | ||
cb9faf63 BE |
24 | /* Forward declaration for ldemul_add_options() and others. */ |
25 | struct option; | |
26 | ||
b34976b6 | 27 | extern void ldemul_hll |
1579bae1 | 28 | (char *); |
b34976b6 | 29 | extern void ldemul_syslib |
1579bae1 | 30 | (char *); |
b34976b6 | 31 | extern void ldemul_after_parse |
1579bae1 | 32 | (void); |
b34976b6 | 33 | extern void ldemul_before_parse |
1579bae1 | 34 | (void); |
b34976b6 | 35 | extern void ldemul_after_open |
1579bae1 | 36 | (void); |
5c3261b0 L |
37 | extern void ldemul_after_check_relocs |
38 | (void); | |
9b538ba7 L |
39 | extern void ldemul_before_place_orphans |
40 | (void); | |
b34976b6 | 41 | extern void ldemul_after_allocation |
1579bae1 | 42 | (void); |
b34976b6 | 43 | extern void ldemul_before_allocation |
1579bae1 | 44 | (void); |
b34976b6 | 45 | extern void ldemul_set_output_arch |
1579bae1 | 46 | (void); |
b34976b6 | 47 | extern char *ldemul_choose_target |
1579bae1 | 48 | (int, char**); |
b34976b6 | 49 | extern void ldemul_choose_mode |
1579bae1 | 50 | (char *); |
b34976b6 | 51 | extern void ldemul_list_emulations |
1579bae1 | 52 | (FILE *); |
b34976b6 | 53 | extern void ldemul_list_emulation_options |
1579bae1 | 54 | (FILE *); |
b34976b6 | 55 | extern char *ldemul_get_script |
1579bae1 | 56 | (int *isfile); |
b34976b6 | 57 | extern void ldemul_finish |
1579bae1 | 58 | (void); |
b34976b6 | 59 | extern void ldemul_set_symbols |
1579bae1 | 60 | (void); |
b34976b6 | 61 | extern void ldemul_create_output_section_statements |
1579bae1 | 62 | (void); |
c2edb4b8 | 63 | extern lang_output_section_statement_type *ldemul_place_orphan |
8a99a385 | 64 | (asection *, const char *, int); |
3bcf5557 | 65 | extern bfd_boolean ldemul_parse_args |
1579bae1 | 66 | (int, char **); |
3bcf5557 | 67 | extern void ldemul_add_options |
1579bae1 | 68 | (int, char **, int, struct option **, int, struct option **); |
3bcf5557 | 69 | extern bfd_boolean ldemul_handle_option |
1579bae1 | 70 | (int); |
b34976b6 | 71 | extern bfd_boolean ldemul_unrecognized_file |
1579bae1 | 72 | (struct lang_input_statement_struct *); |
b34976b6 | 73 | extern bfd_boolean ldemul_recognized_file |
1579bae1 | 74 | (struct lang_input_statement_struct *); |
b34976b6 | 75 | extern bfd_boolean ldemul_open_dynamic_archive |
1579bae1 | 76 | (const char *, struct search_dirs *, struct lang_input_statement_struct *); |
b34976b6 | 77 | extern char *ldemul_default_target |
1579bae1 | 78 | (int, char**); |
b34976b6 | 79 | extern void after_parse_default |
1579bae1 | 80 | (void); |
b34976b6 | 81 | extern void after_open_default |
1579bae1 | 82 | (void); |
5c3261b0 L |
83 | extern void after_check_relocs_default |
84 | (void); | |
9b538ba7 L |
85 | extern void before_place_orphans_default |
86 | (void); | |
b34976b6 | 87 | extern void after_allocation_default |
1579bae1 | 88 | (void); |
b34976b6 | 89 | extern void before_allocation_default |
1579bae1 | 90 | (void); |
046183de | 91 | extern void finish_default |
5e797c2c | 92 | (void); |
1e035701 AM |
93 | extern void finish_default |
94 | (void); | |
b34976b6 | 95 | extern void set_output_arch_default |
1579bae1 | 96 | (void); |
b34976b6 | 97 | extern void syslib_default |
1579bae1 | 98 | (char*); |
b34976b6 | 99 | extern void hll_default |
1579bae1 | 100 | (char*); |
344a211f | 101 | extern int ldemul_find_potential_libraries |
1579bae1 | 102 | (char *, struct lang_input_statement_struct *); |
fac1652d | 103 | extern struct bfd_elf_version_expr *ldemul_new_vers_pattern |
1579bae1 | 104 | (struct bfd_elf_version_expr *); |
7a2f2d82 DD |
105 | extern void ldemul_extra_map_file_text |
106 | (bfd *, struct bfd_link_info *, FILE *); | |
1ff6de03 NA |
107 | /* Return 1 if we are emitting CTF early, and 0 if ldemul_examine_strtab_for_ctf |
108 | will be called by the target. */ | |
109 | extern int ldemul_emit_ctf_early | |
110 | (void); | |
111 | /* Called from per-target code to examine the strtab and symtab. */ | |
112 | extern void ldemul_examine_strtab_for_ctf | |
113 | (struct ctf_file *, struct elf_sym_strtab *, bfd_size_type, | |
114 | struct elf_strtab_hash *); | |
3edf7b9f DR |
115 | extern bfd_boolean ldemul_print_symbol |
116 | (struct bfd_link_hash_entry *hash_entry, void *ptr); | |
252b5132 | 117 | |
89cdebba | 118 | typedef struct ld_emulation_xfer_struct { |
252b5132 RH |
119 | /* Run before parsing the command line and script file. |
120 | Set the architecture, maybe other things. */ | |
1579bae1 | 121 | void (*before_parse) (void); |
252b5132 RH |
122 | |
123 | /* Handle the SYSLIB (low level library) script command. */ | |
1579bae1 | 124 | void (*syslib) (char *); |
252b5132 RH |
125 | |
126 | /* Handle the HLL (high level library) script command. */ | |
1579bae1 | 127 | void (*hll) (char *); |
252b5132 RH |
128 | |
129 | /* Run after parsing the command line and script file. */ | |
1579bae1 | 130 | void (*after_parse) (void); |
252b5132 RH |
131 | |
132 | /* Run after opening all input files, and loading the symbols. */ | |
1579bae1 | 133 | void (*after_open) (void); |
252b5132 | 134 | |
5c3261b0 L |
135 | /* Run after checking relocations. */ |
136 | void (*after_check_relocs) (void); | |
137 | ||
9b538ba7 L |
138 | /* Run before placing orphans. */ |
139 | void (*before_place_orphans) (void); | |
140 | ||
252b5132 | 141 | /* Run after allocating output sections. */ |
1579bae1 | 142 | void (*after_allocation) (void); |
252b5132 RH |
143 | |
144 | /* Set the output architecture and machine if possible. */ | |
1579bae1 | 145 | void (*set_output_arch) (void); |
252b5132 RH |
146 | |
147 | /* Decide which target name to use. */ | |
1579bae1 | 148 | char * (*choose_target) (int, char**); |
252b5132 RH |
149 | |
150 | /* Run before allocating output sections. */ | |
1579bae1 | 151 | void (*before_allocation) (void); |
252b5132 RH |
152 | |
153 | /* Return the appropriate linker script. */ | |
1579bae1 | 154 | char * (*get_script) (int *isfile); |
252b5132 RH |
155 | |
156 | /* The name of this emulation. */ | |
157 | char *emulation_name; | |
158 | ||
159 | /* The output format. */ | |
160 | char *target_name; | |
161 | ||
162 | /* Run after assigning values from the script. */ | |
1579bae1 | 163 | void (*finish) (void); |
252b5132 RH |
164 | |
165 | /* Create any output sections needed by the target. */ | |
1579bae1 | 166 | void (*create_output_section_statements) (void); |
252b5132 RH |
167 | |
168 | /* Try to open a dynamic library. ARCH is an architecture name, and | |
169 | is normally the empty string. ENTRY is the lang_input_statement | |
170 | that should be opened. */ | |
b34976b6 | 171 | bfd_boolean (*open_dynamic_archive) |
1579bae1 AM |
172 | (const char *arch, struct search_dirs *, |
173 | struct lang_input_statement_struct *entry); | |
252b5132 | 174 | |
b34976b6 | 175 | /* Place an orphan section. Return TRUE if it was placed, FALSE if |
252b5132 RH |
176 | the default action should be taken. This field may be NULL, in |
177 | which case the default action will always be taken. */ | |
c2edb4b8 | 178 | lang_output_section_statement_type *(*place_orphan) |
8a99a385 | 179 | (asection *, const char *, int); |
252b5132 | 180 | |
5cc18311 KH |
181 | /* Run after assigning parsing with the args, but before |
182 | reading the script. Used to initialize symbols used in the script. */ | |
1579bae1 | 183 | void (*set_symbols) (void); |
252b5132 | 184 | |
3bcf5557 | 185 | /* Parse args which the base linker doesn't understand. |
3aa97c58 | 186 | Return TRUE if the arg needs no further processing. */ |
1579bae1 | 187 | bfd_boolean (*parse_args) (int, char **); |
3bcf5557 AM |
188 | |
189 | /* Hook to add options to parameters passed by the base linker to | |
190 | getopt_long and getopt_long_only calls. */ | |
191 | void (*add_options) | |
1579bae1 | 192 | (int, char **, int, struct option **, int, struct option **); |
3bcf5557 AM |
193 | |
194 | /* Companion to the above to handle an option. Returns TRUE if it is | |
195 | one of our options. */ | |
1579bae1 | 196 | bfd_boolean (*handle_option) (int); |
252b5132 RH |
197 | |
198 | /* Run to handle files which are not recognized as object files or | |
b34976b6 AM |
199 | archives. Return TRUE if the file was handled. */ |
200 | bfd_boolean (*unrecognized_file) | |
1579bae1 | 201 | (struct lang_input_statement_struct *); |
252b5132 RH |
202 | |
203 | /* Run to list the command line options which parse_args handles. */ | |
1579bae1 | 204 | void (* list_options) (FILE *); |
252b5132 RH |
205 | |
206 | /* Run to specially handle files which *are* recognized as object | |
b34976b6 AM |
207 | files or archives. Return TRUE if the file was handled. */ |
208 | bfd_boolean (*recognized_file) | |
1579bae1 | 209 | (struct lang_input_statement_struct *); |
252b5132 | 210 | |
344a211f NC |
211 | /* Called when looking for libraries in a directory specified |
212 | via a linker command line option or linker script option. | |
213 | Files that match the pattern "lib*.a" have already been scanned. | |
214 | (For VMS files matching ":lib*.a" have also been scanned). */ | |
215 | int (* find_potential_libraries) | |
1579bae1 | 216 | (char *, struct lang_input_statement_struct *); |
5cc18311 | 217 | |
fac1652d AM |
218 | /* Called when adding a new version pattern. PowerPC64-ELF uses |
219 | this hook to add a pattern matching ".foo" for every "foo". */ | |
220 | struct bfd_elf_version_expr * (*new_vers_pattern) | |
1579bae1 | 221 | (struct bfd_elf_version_expr *); |
fac1652d | 222 | |
7a2f2d82 DD |
223 | /* Called when printing the map file, in case there are |
224 | emulation-specific sections for it. */ | |
225 | void (*extra_map_file_text) | |
226 | (bfd *, struct bfd_link_info *, FILE *); | |
227 | ||
1ff6de03 NA |
228 | /* If this returns true, we emit CTF as early as possible: if false, we emit |
229 | CTF once the strtab and symtab are laid out. */ | |
230 | int (*emit_ctf_early) | |
231 | (void); | |
232 | ||
233 | /* Called to examine the string and symbol table late enough in linking that | |
234 | they are finally laid out. If emit_ctf_early returns true, this is not | |
235 | called and ldemul_maybe_emit_ctf() emits CTF in 'early' mode: otherwise, it | |
236 | waits until 'late'. (Late mode needs explicit support at per-target link | |
237 | time to get called at all). If set, called by ld when the examine_strtab | |
238 | bfd_link_callback is invoked by per-target code. */ | |
239 | void (*examine_strtab_for_ctf) (struct ctf_file *, struct elf_sym_strtab *, | |
240 | bfd_size_type, struct elf_strtab_hash *); | |
3edf7b9f DR |
241 | |
242 | /* Called when printing a symbol to the map file. AIX uses this | |
243 | hook to flag gc'd symbols. */ | |
244 | bfd_boolean (*print_symbol) | |
245 | (struct bfd_link_hash_entry *hash_entry, void *ptr); | |
246 | ||
252b5132 RH |
247 | } ld_emulation_xfer_type; |
248 | ||
89cdebba | 249 | typedef enum { |
252b5132 | 250 | intel_ic960_ld_mode_enum, |
89cdebba | 251 | default_mode_enum, |
252b5132 RH |
252 | intel_gld960_ld_mode_enum |
253 | } lang_emulation_mode_enum_type; | |
254 | ||
255 | extern ld_emulation_xfer_type *ld_emulations[]; | |
256 | ||
257 | #endif |