1 /* ld-emul.h - Linker emulation header file
2 Copyright (C) 1991-2019 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. */
24 /* Forward declaration for ldemul_add_options() and others. */
27 extern void ldemul_hll
29 extern void ldemul_syslib
31 extern void ldemul_after_parse
33 extern void ldemul_before_parse
35 extern void ldemul_after_open
37 extern void ldemul_after_check_relocs
39 extern void ldemul_after_allocation
41 extern void ldemul_before_allocation
43 extern void ldemul_set_output_arch
45 extern char *ldemul_choose_target
47 extern void ldemul_choose_mode
49 extern void ldemul_list_emulations
51 extern void ldemul_list_emulation_options
53 extern char *ldemul_get_script
55 extern void ldemul_finish
57 extern void ldemul_set_symbols
59 extern void ldemul_create_output_section_statements
61 extern lang_output_section_statement_type
*ldemul_place_orphan
62 (asection
*, const char *, int);
63 extern bfd_boolean ldemul_parse_args
65 extern void ldemul_add_options
66 (int, char **, int, struct option
**, int, struct option
**);
67 extern bfd_boolean ldemul_handle_option
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
77 extern void after_parse_default
79 extern void after_open_default
81 extern void after_check_relocs_default
83 extern void after_allocation_default
85 extern void before_allocation_default
87 extern void finish_default
89 extern void finish_default
91 extern void set_output_arch_default
93 extern void syslib_default
95 extern void hll_default
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 /* Return 1 if we are emitting CTF early, and 0 if ldemul_examine_strtab_for_ctf
104 will be called by the target. */
105 extern int ldemul_emit_ctf_early
107 /* Called from per-target code to examine the strtab and symtab. */
108 extern void ldemul_examine_strtab_for_ctf
109 (struct ctf_file
*, struct elf_sym_strtab
*, bfd_size_type
,
110 struct elf_strtab_hash
*);
112 typedef struct ld_emulation_xfer_struct
{
113 /* Run before parsing the command line and script file.
114 Set the architecture, maybe other things. */
115 void (*before_parse
) (void);
117 /* Handle the SYSLIB (low level library) script command. */
118 void (*syslib
) (char *);
120 /* Handle the HLL (high level library) script command. */
121 void (*hll
) (char *);
123 /* Run after parsing the command line and script file. */
124 void (*after_parse
) (void);
126 /* Run after opening all input files, and loading the symbols. */
127 void (*after_open
) (void);
129 /* Run after checking relocations. */
130 void (*after_check_relocs
) (void);
132 /* Run after allocating output sections. */
133 void (*after_allocation
) (void);
135 /* Set the output architecture and machine if possible. */
136 void (*set_output_arch
) (void);
138 /* Decide which target name to use. */
139 char * (*choose_target
) (int, char**);
141 /* Run before allocating output sections. */
142 void (*before_allocation
) (void);
144 /* Return the appropriate linker script. */
145 char * (*get_script
) (int *isfile
);
147 /* The name of this emulation. */
148 char *emulation_name
;
150 /* The output format. */
153 /* Run after assigning values from the script. */
154 void (*finish
) (void);
156 /* Create any output sections needed by the target. */
157 void (*create_output_section_statements
) (void);
159 /* Try to open a dynamic library. ARCH is an architecture name, and
160 is normally the empty string. ENTRY is the lang_input_statement
161 that should be opened. */
162 bfd_boolean (*open_dynamic_archive
)
163 (const char *arch
, struct search_dirs
*,
164 struct lang_input_statement_struct
*entry
);
166 /* Place an orphan section. Return TRUE if it was placed, FALSE if
167 the default action should be taken. This field may be NULL, in
168 which case the default action will always be taken. */
169 lang_output_section_statement_type
*(*place_orphan
)
170 (asection
*, const char *, int);
172 /* Run after assigning parsing with the args, but before
173 reading the script. Used to initialize symbols used in the script. */
174 void (*set_symbols
) (void);
176 /* Parse args which the base linker doesn't understand.
177 Return TRUE if the arg needs no further processing. */
178 bfd_boolean (*parse_args
) (int, char **);
180 /* Hook to add options to parameters passed by the base linker to
181 getopt_long and getopt_long_only calls. */
183 (int, char **, int, struct option
**, int, struct option
**);
185 /* Companion to the above to handle an option. Returns TRUE if it is
186 one of our options. */
187 bfd_boolean (*handle_option
) (int);
189 /* Run to handle files which are not recognized as object files or
190 archives. Return TRUE if the file was handled. */
191 bfd_boolean (*unrecognized_file
)
192 (struct lang_input_statement_struct
*);
194 /* Run to list the command line options which parse_args handles. */
195 void (* list_options
) (FILE *);
197 /* Run to specially handle files which *are* recognized as object
198 files or archives. Return TRUE if the file was handled. */
199 bfd_boolean (*recognized_file
)
200 (struct lang_input_statement_struct
*);
202 /* Called when looking for libraries in a directory specified
203 via a linker command line option or linker script option.
204 Files that match the pattern "lib*.a" have already been scanned.
205 (For VMS files matching ":lib*.a" have also been scanned). */
206 int (* find_potential_libraries
)
207 (char *, struct lang_input_statement_struct
*);
209 /* Called when adding a new version pattern. PowerPC64-ELF uses
210 this hook to add a pattern matching ".foo" for every "foo". */
211 struct bfd_elf_version_expr
* (*new_vers_pattern
)
212 (struct bfd_elf_version_expr
*);
214 /* Called when printing the map file, in case there are
215 emulation-specific sections for it. */
216 void (*extra_map_file_text
)
217 (bfd
*, struct bfd_link_info
*, FILE *);
219 /* If this returns true, we emit CTF as early as possible: if false, we emit
220 CTF once the strtab and symtab are laid out. */
221 int (*emit_ctf_early
)
224 /* Called to examine the string and symbol table late enough in linking that
225 they are finally laid out. If emit_ctf_early returns true, this is not
226 called and ldemul_maybe_emit_ctf() emits CTF in 'early' mode: otherwise, it
227 waits until 'late'. (Late mode needs explicit support at per-target link
228 time to get called at all). If set, called by ld when the examine_strtab
229 bfd_link_callback is invoked by per-target code. */
230 void (*examine_strtab_for_ctf
) (struct ctf_file
*, struct elf_sym_strtab
*,
231 bfd_size_type
, struct elf_strtab_hash
*);
232 } ld_emulation_xfer_type
;
235 intel_ic960_ld_mode_enum
,
237 intel_gld960_ld_mode_enum
238 } lang_emulation_mode_enum_type
;
240 extern ld_emulation_xfer_type
*ld_emulations
[];