[gdb/testsuite] Handle USE_TUI in gdb.tui/corefile-run.exp
[binutils-gdb.git] / ld / ldemul.h
blobf3e8bb697f4ba27e76a1c2f4d2afa53ee241c45d
1 /* ld-emul.h - Linker emulation header file
2 Copyright (C) 1991-2023 Free Software Foundation, Inc.
4 This file is part of the GNU Binutils.
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.
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.
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. */
21 #ifndef LDEMUL_H
22 #define LDEMUL_H
24 /* Forward declaration for ldemul_add_options() and others. */
25 struct option;
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_before_plugin_all_symbols_read
36 (void);
37 extern void ldemul_after_open
38 (void);
39 extern void ldemul_after_check_relocs
40 (void);
41 extern void ldemul_before_place_orphans
42 (void);
43 extern void ldemul_after_allocation
44 (void);
45 extern void ldemul_before_allocation
46 (void);
47 extern void ldemul_set_output_arch
48 (void);
49 extern char *ldemul_choose_target
50 (int, char**);
51 extern void ldemul_choose_mode
52 (char *);
53 extern void ldemul_list_emulations
54 (FILE *);
55 extern void ldemul_list_emulation_options
56 (FILE *);
57 extern char *ldemul_get_script
58 (int *isfile);
59 extern void ldemul_finish
60 (void);
61 extern void ldemul_set_symbols
62 (void);
63 extern void ldemul_create_output_section_statements
64 (void);
65 extern lang_output_section_statement_type *ldemul_place_orphan
66 (asection *, const char *, int);
67 extern bool ldemul_parse_args
68 (int, char **);
69 extern void ldemul_add_options
70 (int, char **, int, struct option **, int, struct option **);
71 extern bool ldemul_handle_option
72 (int);
73 extern bool ldemul_unrecognized_file
74 (struct lang_input_statement_struct *);
75 extern bool ldemul_recognized_file
76 (struct lang_input_statement_struct *);
77 extern bool ldemul_open_dynamic_archive
78 (const char *, struct search_dirs *, struct lang_input_statement_struct *);
79 extern char *ldemul_default_target
80 (int, char**);
81 extern void after_parse_default
82 (void);
83 extern void after_open_default
84 (void);
85 extern void after_check_relocs_default
86 (void);
87 extern void before_place_orphans_default
88 (void);
89 extern void after_allocation_default
90 (void);
91 extern void before_allocation_default
92 (void);
93 extern void finish_default
94 (void);
95 extern void finish_default
96 (void);
97 extern void set_output_arch_default
98 (void);
99 extern void syslib_default
100 (char*);
101 extern void hll_default
102 (char*);
103 extern int ldemul_find_potential_libraries
104 (char *, struct lang_input_statement_struct *);
105 extern struct bfd_elf_version_expr *ldemul_new_vers_pattern
106 (struct bfd_elf_version_expr *);
107 extern void ldemul_extra_map_file_text
108 (bfd *, struct bfd_link_info *, FILE *);
109 /* Return 1 if we are emitting CTF early, and 0 if ldemul_examine_strtab_for_ctf
110 will be called by the target. */
111 extern int ldemul_emit_ctf_early
112 (void);
113 /* Called from per-target code to examine the strtab and symtab. */
114 extern void ldemul_acquire_strings_for_ctf
115 (struct ctf_dict *, struct elf_strtab_hash *);
116 extern void ldemul_new_dynsym_for_ctf
117 (struct ctf_dict *, int symidx, struct elf_internal_sym *);
119 extern bool ldemul_print_symbol
120 (struct bfd_link_hash_entry *hash_entry, void *ptr);
122 typedef struct ld_emulation_xfer_struct {
123 /* Run before parsing the command line and script file.
124 Set the architecture, maybe other things. */
125 void (*before_parse) (void);
127 /* Handle the SYSLIB (low level library) script command. */
128 void (*syslib) (char *);
130 /* Handle the HLL (high level library) script command. */
131 void (*hll) (char *);
133 /* Run after parsing the command line and script file. */
134 void (*after_parse) (void);
136 /* Run before calling plugin 'all symbols read' hook. */
137 void (*before_plugin_all_symbols_read) (void);
139 /* Run after opening all input files, and loading the symbols. */
140 void (*after_open) (void);
142 /* Run after checking relocations. */
143 void (*after_check_relocs) (void);
145 /* Run before placing orphans. */
146 void (*before_place_orphans) (void);
148 /* Run after allocating output sections. */
149 void (*after_allocation) (void);
151 /* Set the output architecture and machine if possible. */
152 void (*set_output_arch) (void);
154 /* Decide which target name to use. */
155 char * (*choose_target) (int, char**);
157 /* Run before allocating output sections. */
158 void (*before_allocation) (void);
160 /* Return the appropriate linker script. */
161 char * (*get_script) (int *isfile);
163 /* The name of this emulation. */
164 char *emulation_name;
166 /* The output format. */
167 char *target_name;
169 /* Run after assigning values from the script. */
170 void (*finish) (void);
172 /* Create any output sections needed by the target. */
173 void (*create_output_section_statements) (void);
175 /* Try to open a dynamic library. ARCH is an architecture name, and
176 is normally the empty string. ENTRY is the lang_input_statement
177 that should be opened. */
178 bool (*open_dynamic_archive)
179 (const char *arch, struct search_dirs *,
180 struct lang_input_statement_struct *entry);
182 /* Place an orphan section. Return TRUE if it was placed, FALSE if
183 the default action should be taken. This field may be NULL, in
184 which case the default action will always be taken. */
185 lang_output_section_statement_type *(*place_orphan)
186 (asection *, const char *, int);
188 /* Run after assigning parsing with the args, but before
189 reading the script. Used to initialize symbols used in the script. */
190 void (*set_symbols) (void);
192 /* Parse args which the base linker doesn't understand.
193 Return TRUE if the arg needs no further processing. */
194 bool (*parse_args) (int, char **);
196 /* Hook to add options to parameters passed by the base linker to
197 getopt_long and getopt_long_only calls. */
198 void (*add_options)
199 (int, char **, int, struct option **, int, struct option **);
201 /* Companion to the above to handle an option. Returns TRUE if it is
202 one of our options. */
203 bool (*handle_option) (int);
205 /* Run to handle files which are not recognized as object files or
206 archives. Return TRUE if the file was handled. */
207 bool (*unrecognized_file)
208 (struct lang_input_statement_struct *);
210 /* Run to list the command line options which parse_args handles. */
211 void (* list_options) (FILE *);
213 /* Run to specially handle files which *are* recognized as object
214 files or archives. Return TRUE if the file was handled. */
215 bool (*recognized_file)
216 (struct lang_input_statement_struct *);
218 /* Called when looking for libraries in a directory specified
219 via a linker command line option or linker script option.
220 Files that match the pattern "lib*.a" have already been scanned.
221 (For VMS files matching ":lib*.a" have also been scanned). */
222 int (* find_potential_libraries)
223 (char *, struct lang_input_statement_struct *);
225 /* Called when adding a new version pattern. PowerPC64-ELF uses
226 this hook to add a pattern matching ".foo" for every "foo". */
227 struct bfd_elf_version_expr * (*new_vers_pattern)
228 (struct bfd_elf_version_expr *);
230 /* Called when printing the map file, in case there are
231 emulation-specific sections for it. */
232 void (*extra_map_file_text)
233 (bfd *, struct bfd_link_info *, FILE *);
235 /* If this returns true, we emit CTF as early as possible: if false, we emit
236 CTF once the strtab and symtab are laid out. */
237 int (*emit_ctf_early)
238 (void);
240 /* Called to examine the string table late enough in linking that it is
241 finally laid out. If emit_ctf_early returns true, this is not called, and
242 ldemul_maybe_emit_ctf emits CTF in 'early' mode: otherwise, it waits
243 until 'late'. (Late mode needs explicit support at per-target link time to
244 get called at all). If set, called by ld when the examine_strtab
245 bfd_link_callback is invoked by per-target code. */
246 void (*acquire_strings_for_ctf) (struct ctf_dict *, struct elf_strtab_hash *);
248 /* Called when a new symbol is added to the dynamic symbol table. If
249 emit_ctf_early returns true, this is not called, and ldemul_maybe_emit_ctf
250 emits CTF in 'early' mode: otherwise, it waits until 'late'. (Late mode
251 needs explicit support at per-target link time to get called at all). If
252 set, called by ld when the ctf_new_symbol bfd_link_callback is invoked by
253 per-target code. Called with a NULL symbol when no further symbols will be
254 provided. */
255 void (*new_dynsym_for_ctf) (struct ctf_dict *, int, struct elf_internal_sym *);
257 /* Called when printing a symbol to the map file. AIX uses this
258 hook to flag gc'd symbols. */
259 bool (*print_symbol)
260 (struct bfd_link_hash_entry *hash_entry, void *ptr);
262 } ld_emulation_xfer_type;
264 typedef enum {
265 intel_ic960_ld_mode_enum,
266 default_mode_enum,
267 intel_gld960_ld_mode_enum
268 } lang_emulation_mode_enum_type;
270 extern ld_emulation_xfer_type *ld_emulations[];
272 #endif