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