2014-04-16 Steve Ellcey <sellcey@mips.com>
[platform/upstream/binutils.git] / ld / ldemul.h
1 /* ld-emul.h - Linker emulation header file
2    Copyright (C) 1991-2014 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_allocation
38   (void);
39 extern void ldemul_before_allocation
40   (void);
41 extern void ldemul_set_output_arch
42   (void);
43 extern char *ldemul_choose_target
44   (int, char**);
45 extern void ldemul_choose_mode
46   (char *);
47 extern void ldemul_list_emulations
48   (FILE *);
49 extern void ldemul_list_emulation_options
50   (FILE *);
51 extern char *ldemul_get_script
52   (int *isfile);
53 extern void ldemul_finish
54   (void);
55 extern void ldemul_set_symbols
56   (void);
57 extern void ldemul_create_output_section_statements
58   (void);
59 extern lang_output_section_statement_type *ldemul_place_orphan
60   (asection *, const char *, int);
61 extern bfd_boolean ldemul_parse_args
62   (int, char **);
63 extern void ldemul_add_options
64   (int, char **, int, struct option **, int, struct option **);
65 extern bfd_boolean ldemul_handle_option
66   (int);
67 extern bfd_boolean ldemul_unrecognized_file
68   (struct lang_input_statement_struct *);
69 extern bfd_boolean ldemul_recognized_file
70   (struct lang_input_statement_struct *);
71 extern bfd_boolean ldemul_open_dynamic_archive
72   (const char *, struct search_dirs *, struct lang_input_statement_struct *);
73 extern char *ldemul_default_target
74   (int, char**);
75 extern void after_parse_default
76   (void);
77 extern void after_open_default
78   (void);
79 extern void after_allocation_default
80   (void);
81 extern void before_allocation_default
82   (void);
83 extern void finish_default
84   (void);
85 extern void finish_default
86   (void);
87 extern void set_output_arch_default
88   (void);
89 extern void syslib_default
90   (char*);
91 extern void hll_default
92   (char*);
93 extern int  ldemul_find_potential_libraries
94   (char *, struct lang_input_statement_struct *);
95 extern struct bfd_elf_version_expr *ldemul_new_vers_pattern
96   (struct bfd_elf_version_expr *);
97
98 typedef struct ld_emulation_xfer_struct {
99   /* Run before parsing the command line and script file.
100      Set the architecture, maybe other things.  */
101   void   (*before_parse) (void);
102
103   /* Handle the SYSLIB (low level library) script command.  */
104   void   (*syslib) (char *);
105
106   /* Handle the HLL (high level library) script command.  */
107   void   (*hll) (char *);
108
109   /* Run after parsing the command line and script file.  */
110   void   (*after_parse) (void);
111
112   /* Run after opening all input files, and loading the symbols.  */
113   void   (*after_open) (void);
114
115   /* Run after allocating output sections.  */
116   void   (*after_allocation)  (void);
117
118   /* Set the output architecture and machine if possible.  */
119   void   (*set_output_arch) (void);
120
121   /* Decide which target name to use.  */
122   char * (*choose_target) (int, char**);
123
124   /* Run before allocating output sections.  */
125   void   (*before_allocation) (void);
126
127   /* Return the appropriate linker script.  */
128   char * (*get_script) (int *isfile);
129
130   /* The name of this emulation.  */
131   char *emulation_name;
132
133   /* The output format.  */
134   char *target_name;
135
136   /* Run after assigning values from the script.  */
137   void  (*finish) (void);
138
139   /* Create any output sections needed by the target.  */
140   void  (*create_output_section_statements) (void);
141
142   /* Try to open a dynamic library.  ARCH is an architecture name, and
143      is normally the empty string.  ENTRY is the lang_input_statement
144      that should be opened.  */
145   bfd_boolean (*open_dynamic_archive)
146     (const char *arch, struct search_dirs *,
147      struct lang_input_statement_struct *entry);
148
149   /* Place an orphan section.  Return TRUE if it was placed, FALSE if
150      the default action should be taken.  This field may be NULL, in
151      which case the default action will always be taken.  */
152   lang_output_section_statement_type *(*place_orphan)
153     (asection *, const char *, int);
154
155   /* Run after assigning parsing with the args, but before
156      reading the script.  Used to initialize symbols used in the script.  */
157   void  (*set_symbols) (void);
158
159   /* Parse args which the base linker doesn't understand.
160      Return TRUE if the arg needs no further processing.  */
161   bfd_boolean (*parse_args) (int, char **);
162
163   /* Hook to add options to parameters passed by the base linker to
164      getopt_long and getopt_long_only calls.  */
165   void (*add_options)
166     (int, char **, int, struct option **, int, struct option **);
167
168   /* Companion to the above to handle an option.  Returns TRUE if it is
169      one of our options.  */
170   bfd_boolean (*handle_option) (int);
171
172   /* Run to handle files which are not recognized as object files or
173      archives.  Return TRUE if the file was handled.  */
174   bfd_boolean (*unrecognized_file)
175     (struct lang_input_statement_struct *);
176
177   /* Run to list the command line options which parse_args handles.  */
178   void (* list_options) (FILE *);
179
180   /* Run to specially handle files which *are* recognized as object
181      files or archives.  Return TRUE if the file was handled.  */
182   bfd_boolean (*recognized_file)
183     (struct lang_input_statement_struct *);
184
185   /* Called when looking for libraries in a directory specified
186      via a linker command line option or linker script option.
187      Files that match the pattern "lib*.a" have already been scanned.
188      (For VMS files matching ":lib*.a" have also been scanned).  */
189   int (* find_potential_libraries)
190     (char *, struct lang_input_statement_struct *);
191
192   /* Called when adding a new version pattern.  PowerPC64-ELF uses
193      this hook to add a pattern matching ".foo" for every "foo".  */
194   struct bfd_elf_version_expr * (*new_vers_pattern)
195     (struct bfd_elf_version_expr *);
196
197 } ld_emulation_xfer_type;
198
199 typedef enum {
200   intel_ic960_ld_mode_enum,
201   default_mode_enum,
202   intel_gld960_ld_mode_enum
203 } lang_emulation_mode_enum_type;
204
205 extern ld_emulation_xfer_type *ld_emulations[];
206
207 #endif