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