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