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