xref: /openbsd/gnu/usr.bin/binutils/ld/ldemul.h (revision 007c2a45)
12159047fSniklas /* ld-emul.h - Linker emulation header file
2*007c2a45Smiod    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2003
3b55d4692Sfgsch    Free Software Foundation, Inc.
42159047fSniklas 
52159047fSniklas    This file is part of GLD, the Gnu Linker.
62159047fSniklas 
72159047fSniklas    GLD is free software; you can redistribute it and/or modify
82159047fSniklas    it under the terms of the GNU General Public License as published by
92159047fSniklas    the Free Software Foundation; either version 1, or (at your option)
102159047fSniklas    any later version.
112159047fSniklas 
122159047fSniklas    GLD is distributed in the hope that it will be useful,
132159047fSniklas    but WITHOUT ANY WARRANTY; without even the implied warranty of
142159047fSniklas    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
152159047fSniklas    GNU General Public License for more details.  */
162159047fSniklas 
172159047fSniklas #ifndef LDEMUL_H
182159047fSniklas #define LDEMUL_H
192159047fSniklas 
20c074d1c9Sdrahn extern void ldemul_hll
21*007c2a45Smiod   (char *);
22c074d1c9Sdrahn extern void ldemul_syslib
23*007c2a45Smiod   (char *);
24c074d1c9Sdrahn extern void ldemul_after_parse
25*007c2a45Smiod   (void);
26c074d1c9Sdrahn extern void ldemul_before_parse
27*007c2a45Smiod   (void);
28c074d1c9Sdrahn extern void ldemul_after_open
29*007c2a45Smiod   (void);
30c074d1c9Sdrahn extern void ldemul_after_allocation
31*007c2a45Smiod   (void);
32c074d1c9Sdrahn extern void ldemul_before_allocation
33*007c2a45Smiod   (void);
34c074d1c9Sdrahn extern void ldemul_set_output_arch
35*007c2a45Smiod   (void);
36c074d1c9Sdrahn extern char *ldemul_choose_target
37*007c2a45Smiod   (int, char**);
38c074d1c9Sdrahn extern void ldemul_choose_mode
39*007c2a45Smiod   (char *);
40c074d1c9Sdrahn extern void ldemul_list_emulations
41*007c2a45Smiod   (FILE *);
42c074d1c9Sdrahn extern void ldemul_list_emulation_options
43*007c2a45Smiod   (FILE *);
44c074d1c9Sdrahn extern char *ldemul_get_script
45*007c2a45Smiod   (int *isfile);
46c074d1c9Sdrahn extern void ldemul_finish
47*007c2a45Smiod   (void);
48c074d1c9Sdrahn extern void ldemul_set_symbols
49*007c2a45Smiod   (void);
50c074d1c9Sdrahn extern void ldemul_create_output_section_statements
51*007c2a45Smiod   (void);
52c074d1c9Sdrahn extern bfd_boolean ldemul_place_orphan
53*007c2a45Smiod   (struct lang_input_statement_struct *, asection *);
54c074d1c9Sdrahn extern bfd_boolean ldemul_parse_args
55*007c2a45Smiod   (int, char **);
56c074d1c9Sdrahn extern void ldemul_add_options
57*007c2a45Smiod   (int, char **, int, struct option **, int, struct option **);
58c074d1c9Sdrahn extern bfd_boolean ldemul_handle_option
59*007c2a45Smiod   (int);
60c074d1c9Sdrahn extern bfd_boolean ldemul_unrecognized_file
61*007c2a45Smiod   (struct lang_input_statement_struct *);
62c074d1c9Sdrahn extern bfd_boolean ldemul_recognized_file
63*007c2a45Smiod   (struct lang_input_statement_struct *);
64c074d1c9Sdrahn extern bfd_boolean ldemul_open_dynamic_archive
65*007c2a45Smiod   (const char *, struct search_dirs *, struct lang_input_statement_struct *);
66c074d1c9Sdrahn extern char *ldemul_default_target
67*007c2a45Smiod   (int, char**);
68c074d1c9Sdrahn extern void after_parse_default
69*007c2a45Smiod   (void);
70c074d1c9Sdrahn extern void after_open_default
71*007c2a45Smiod   (void);
72c074d1c9Sdrahn extern void after_allocation_default
73*007c2a45Smiod   (void);
74c074d1c9Sdrahn extern void before_allocation_default
75*007c2a45Smiod   (void);
76c074d1c9Sdrahn extern void set_output_arch_default
77*007c2a45Smiod   (void);
78c074d1c9Sdrahn extern void syslib_default
79*007c2a45Smiod   (char*);
80c074d1c9Sdrahn extern void hll_default
81*007c2a45Smiod   (char*);
82b305b0f1Sespie extern int  ldemul_find_potential_libraries
83*007c2a45Smiod   (char *, struct lang_input_statement_struct *);
84c074d1c9Sdrahn extern struct bfd_elf_version_expr *ldemul_new_vers_pattern
85*007c2a45Smiod   (struct bfd_elf_version_expr *);
862159047fSniklas 
87b55d4692Sfgsch typedef struct ld_emulation_xfer_struct {
882159047fSniklas   /* Run before parsing the command line and script file.
892159047fSniklas      Set the architecture, maybe other things.  */
90*007c2a45Smiod   void   (*before_parse) (void);
912159047fSniklas 
922159047fSniklas   /* Handle the SYSLIB (low level library) script command.  */
93*007c2a45Smiod   void   (*syslib) (char *);
942159047fSniklas 
952159047fSniklas   /* Handle the HLL (high level library) script command.  */
96*007c2a45Smiod   void   (*hll) (char *);
972159047fSniklas 
982159047fSniklas   /* Run after parsing the command line and script file.  */
99*007c2a45Smiod   void   (*after_parse) (void);
1002159047fSniklas 
1012159047fSniklas   /* Run after opening all input files, and loading the symbols.  */
102*007c2a45Smiod   void   (*after_open) (void);
1032159047fSniklas 
1042159047fSniklas   /* Run after allocating output sections.  */
105*007c2a45Smiod   void   (*after_allocation)  (void);
1062159047fSniklas 
1072159047fSniklas   /* Set the output architecture and machine if possible.  */
108*007c2a45Smiod   void   (*set_output_arch) (void);
1092159047fSniklas 
1102159047fSniklas   /* Decide which target name to use.  */
111*007c2a45Smiod   char * (*choose_target) (int, char**);
1122159047fSniklas 
1132159047fSniklas   /* Run before allocating output sections.  */
114*007c2a45Smiod   void   (*before_allocation) (void);
1152159047fSniklas 
1162159047fSniklas   /* Return the appropriate linker script.  */
117*007c2a45Smiod   char * (*get_script) (int *isfile);
1182159047fSniklas 
1192159047fSniklas   /* The name of this emulation.  */
1202159047fSniklas   char *emulation_name;
1212159047fSniklas 
1222159047fSniklas   /* The output format.  */
1232159047fSniklas   char *target_name;
1242159047fSniklas 
1252159047fSniklas   /* Run after assigning values from the script.  */
126*007c2a45Smiod   void	(*finish) (void);
1272159047fSniklas 
1282159047fSniklas   /* Create any output sections needed by the target.  */
129*007c2a45Smiod   void	(*create_output_section_statements) (void);
1302159047fSniklas 
1312159047fSniklas   /* Try to open a dynamic library.  ARCH is an architecture name, and
1322159047fSniklas      is normally the empty string.  ENTRY is the lang_input_statement
1332159047fSniklas      that should be opened.  */
134c074d1c9Sdrahn   bfd_boolean (*open_dynamic_archive)
135*007c2a45Smiod     (const char *arch, struct search_dirs *,
136*007c2a45Smiod      struct lang_input_statement_struct *entry);
1372159047fSniklas 
138c074d1c9Sdrahn   /* Place an orphan section.  Return TRUE if it was placed, FALSE if
1392159047fSniklas      the default action should be taken.  This field may be NULL, in
1402159047fSniklas      which case the default action will always be taken.  */
141c074d1c9Sdrahn   bfd_boolean (*place_orphan)
142*007c2a45Smiod     (struct lang_input_statement_struct *, asection *);
1432159047fSniklas 
1442159047fSniklas   /* Run after assigning parsing with the args, but before
1452159047fSniklas      reading the script.  Used to initialize symbols used in the script.  */
146*007c2a45Smiod   void	(*set_symbols) (void);
1472159047fSniklas 
148c074d1c9Sdrahn   /* Parse args which the base linker doesn't understand.
149c074d1c9Sdrahn      Return TRUE if the arg needs no further processing.  */
150*007c2a45Smiod   bfd_boolean (*parse_args) (int, char **);
151c074d1c9Sdrahn 
152c074d1c9Sdrahn   /* Hook to add options to parameters passed by the base linker to
153c074d1c9Sdrahn      getopt_long and getopt_long_only calls.  */
154c074d1c9Sdrahn   void (*add_options)
155*007c2a45Smiod     (int, char **, int, struct option **, int, struct option **);
156c074d1c9Sdrahn 
157c074d1c9Sdrahn   /* Companion to the above to handle an option.  Returns TRUE if it is
158c074d1c9Sdrahn      one of our options.  */
159*007c2a45Smiod   bfd_boolean (*handle_option) (int);
1602159047fSniklas 
161191aa565Sniklas   /* Run to handle files which are not recognized as object files or
162c074d1c9Sdrahn      archives.  Return TRUE if the file was handled.  */
163c074d1c9Sdrahn   bfd_boolean (*unrecognized_file)
164*007c2a45Smiod     (struct lang_input_statement_struct *);
165191aa565Sniklas 
166b305b0f1Sespie   /* Run to list the command line options which parse_args handles.  */
167*007c2a45Smiod   void (* list_options) (FILE *);
168b305b0f1Sespie 
169b305b0f1Sespie   /* Run to specially handle files which *are* recognized as object
170c074d1c9Sdrahn      files or archives.  Return TRUE if the file was handled.  */
171c074d1c9Sdrahn   bfd_boolean (*recognized_file)
172*007c2a45Smiod     (struct lang_input_statement_struct *);
173b305b0f1Sespie 
174b305b0f1Sespie   /* Called when looking for libraries in a directory specified
175b305b0f1Sespie      via a linker command line option or linker script option.
176b305b0f1Sespie      Files that match the pattern "lib*.a" have already been scanned.
177b305b0f1Sespie      (For VMS files matching ":lib*.a" have also been scanned).  */
178b305b0f1Sespie   int (* find_potential_libraries)
179*007c2a45Smiod     (char *, struct lang_input_statement_struct *);
180b305b0f1Sespie 
181c074d1c9Sdrahn   /* Called when adding a new version pattern.  PowerPC64-ELF uses
182c074d1c9Sdrahn      this hook to add a pattern matching ".foo" for every "foo".  */
183c074d1c9Sdrahn   struct bfd_elf_version_expr * (*new_vers_pattern)
184*007c2a45Smiod     (struct bfd_elf_version_expr *);
185c074d1c9Sdrahn 
1862159047fSniklas } ld_emulation_xfer_type;
1872159047fSniklas 
188b55d4692Sfgsch typedef enum {
1892159047fSniklas   intel_ic960_ld_mode_enum,
1902159047fSniklas   default_mode_enum,
1912159047fSniklas   intel_gld960_ld_mode_enum
1922159047fSniklas } lang_emulation_mode_enum_type;
1932159047fSniklas 
1942159047fSniklas extern ld_emulation_xfer_type *ld_emulations[];
1952159047fSniklas 
1962159047fSniklas #endif
197