1 /* $MirOS: src/gnu/usr.bin/binutils/ld/ld.h,v 1.5 2005/07/07 16:23:12 tg Exp $ */
2 
3 /* ld.h -- general linker header file
4    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
5    2001, 2002, 2003, 2004, 2005
6    Free Software Foundation, Inc.
7 
8    This file is part of GLD, the Gnu Linker.
9 
10    GLD is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 2, or (at your option)
13    any later version.
14 
15    GLD is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with GLD; see the file COPYING.  If not, write to the Free
22    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23    02110-1301, USA.  */
24 
25 #ifndef LD_H
26 #define LD_H
27 
28 #ifdef HAVE_STDBOOL_H
29 # include <stdbool.h>
30 # define boolean bool
31 #endif
32 
33 #ifdef HAVE_LOCALE_H
34 # include <locale.h>
35 #endif
36 
37 #ifdef ENABLE_NLS
38 # include <libintl.h>
39 # define _(String) gettext (String)
40 # ifdef gettext_noop
41 #  define N_(String) gettext_noop (String)
42 # else
43 #  define N_(String) (String)
44 # endif
45 #else
46 # define gettext(Msgid) (Msgid)
47 # define dgettext(Domainname, Msgid) (Msgid)
48 # define dcgettext(Domainname, Msgid, Category) (Msgid)
49 # define textdomain(Domainname) while (0) /* nothing */
50 # define bindtextdomain(Domainname, Dirname) while (0) /* nothing */
51 # define _(String) (String)
52 # define N_(String) (String)
53 #endif
54 
55 #include "bin-bugs.h"
56 
57 /* Look in this environment name for the linker to pretend to be */
58 #define EMULATION_ENVIRON "LDEMULATION"
59 /* If in there look for the strings: */
60 
61 /* Look in this variable for a target format */
62 #define TARGET_ENVIRON "GNUTARGET"
63 
64 /* Input sections which are put in a section of this name are actually
65    discarded.  */
66 #define DISCARD_SECTION_NAME "/DISCARD/"
67 
68 /* A file name list */
69 typedef struct name_list {
70   const char *name;
71   struct name_list *next;
72 }
73 name_list;
74 
75 /* A wildcard specification.  */
76 
77 typedef enum {
78   none, by_name, by_alignment, by_name_alignment, by_alignment_name
79 } sort_type;
80 
81 extern sort_type sort_section;
82 
83 struct wildcard_spec {
84   const char *name;
85   struct name_list *exclude_name_list;
86   sort_type sorted;
87 };
88 
89 struct wildcard_list {
90   struct wildcard_list *next;
91   struct wildcard_spec spec;
92 };
93 
94 struct map_symbol_def {
95   struct bfd_link_hash_entry *entry;
96   struct map_symbol_def *next;
97 };
98 
99 /* The initial part of fat_user_section_struct has to be idential with
100    lean_user_section_struct.  */
101 typedef struct fat_user_section_struct {
102   /* For input sections, when writing a map file: head / tail of a linked
103      list of hash table entries for symbols defined in this section.  */
104   struct map_symbol_def *map_symbol_def_head;
105   struct map_symbol_def **map_symbol_def_tail;
106 } fat_section_userdata_type;
107 
108 #define get_userdata(x) ((x)->userdata)
109 
110 #define BYTE_SIZE	(1)
111 #define SHORT_SIZE	(2)
112 #define LONG_SIZE	(4)
113 #define QUAD_SIZE	(8)
114 
115 typedef struct {
116   /* 1 => assign space to common symbols even if `relocatable_output'.  */
117   bfd_boolean force_common_definition;
118 
119   /* 1 => do not assign addresses to common symbols.  */
120   bfd_boolean inhibit_common_definition;
121   bfd_boolean relax;
122 
123   /* Name of runtime interpreter to invoke.  */
124   char *interpreter;
125 
126   /* Name to give runtime libary from the -soname argument.  */
127   char *soname;
128 
129   /* Runtime library search path from the -rpath argument.  */
130   char *rpath;
131 
132   /* Link time runtime library search path from the -rpath-link
133      argument.  */
134   char *rpath_link;
135 
136   /* Big or little endian as set on command line.  */
137   enum { ENDIAN_UNSET = 0, ENDIAN_BIG, ENDIAN_LITTLE } endian;
138 
139   /* If TRUE, build MIPS embedded PIC relocation tables in the output
140      file.  */
141   bfd_boolean embedded_relocs;
142 
143   /* If TRUE, force generation of a file with a .exe file.  */
144   bfd_boolean force_exe_suffix;
145 
146   /* If TRUE, generate a cross reference report.  */
147   bfd_boolean cref;
148 
149   /* If TRUE (which is the default), warn about mismatched input
150      files.  */
151   bfd_boolean warn_mismatch;
152 
153   /* Name of shared object whose symbol table should be filtered with
154      this shared object.  From the --filter option.  */
155   char *filter_shlib;
156 
157   /* Name of shared object for whose symbol table this shared object
158      is an auxiliary filter.  From the --auxiliary option.  */
159   char **auxiliary_filters;
160 
161   /* A version symbol to be applied to the symbol names found in the
162      .exports sections.  */
163   char *version_exports_section;
164 
165   /* If TRUE (the default) check section addresses, once compute,
166      fpor overlaps.  */
167   bfd_boolean check_section_addresses;
168 
169   /* If TRUE allow the linking of input files in an unknown architecture
170      assuming that the user knows what they are doing.  This was the old
171      behaviour of the linker.  The new default behaviour is to reject such
172      input files.  */
173   bfd_boolean accept_unknown_input_arch;
174 
175   /* If TRUE reduce memory overheads, at the expense of speed.
176      This will cause map file generation to use an O(N^2) algorithm.  */
177   bfd_boolean reduce_memory_overheads;
178 
179 } args_type;
180 
181 extern args_type command_line;
182 
183 typedef int token_code_type;
184 
185 typedef struct {
186   bfd_size_type specified_data_size;
187   bfd_boolean magic_demand_paged;
188   bfd_boolean make_executable;
189 
190   /* If TRUE, doing a dynamic link.  */
191   bfd_boolean dynamic_link;
192 
193   /* If TRUE, -shared is supported.  */
194   /* ??? A better way to do this is perhaps to define this in the
195      ld_emulation_xfer_struct since this is really a target dependent
196      parameter.  */
197   bfd_boolean has_shared;
198 
199   /* If TRUE, build constructors.  */
200   bfd_boolean build_constructors;
201 
202   /* If TRUE, warn about any constructors.  */
203   bfd_boolean warn_constructors;
204 
205   /* If TRUE, warn about merging common symbols with others.  */
206   bfd_boolean warn_common;
207 
208   /* If TRUE, only warn once about a particular undefined symbol.  */
209   bfd_boolean warn_once;
210 
211   /* If TRUE, warn if multiple global-pointers are needed (Alpha
212      only).  */
213   bfd_boolean warn_multiple_gp;
214 
215   /* If TRUE, warn if the starting address of an output section
216      changes due to the alignment of an input section.  */
217   bfd_boolean warn_section_align;
218 
219   /* If TRUE, warning messages are fatal */
220   bfd_boolean fatal_warnings;
221 
222   bfd_boolean sort_common;
223 
224   bfd_boolean text_read_only;
225 
226   /* Classic ELF executable which has data and bss next to each
227      other with no padding for GOT/PLT. */
228   bfd_boolean data_bss_contig;
229 
230   char *map_filename;
231   FILE *map_file;
232 
233   bfd_boolean stats;
234 
235   /* If set, orphan input sections will be mapped to separate output
236      sections.  */
237   bfd_boolean unique_orphan_sections;
238 
239   unsigned int split_by_reloc;
240   bfd_size_type split_by_file;
241 
242   /* If set, only search library directories explicitly selected
243      on the command line.  */
244   bfd_boolean only_cmd_line_lib_dirs;
245 
246   /* The size of the hash table to use.  */
247   bfd_size_type hash_table_size;
248 } ld_config_type;
249 
250 extern ld_config_type config;
251 
252 extern FILE * saved_script_handle;
253 extern bfd_boolean force_make_executable;
254 
255 /* Non-zero if we are processing a --defsym from the command line.  */
256 extern int parsing_defsym;
257 
258 extern int yyparse (void);
259 extern void add_cref (const char *, bfd *, asection *, bfd_vma);
260 extern void output_cref (FILE *);
261 extern void check_nocrossrefs (void);
262 extern void ld_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
263 
264 /* If gcc >= 2.6, we can give a function name, too.  */
265 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
266 #define __PRETTY_FUNCTION__  NULL
267 #endif
268 
269 #undef abort
270 #define abort() ld_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
271 
272 #endif
273