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