xref: /dflybsd-src/contrib/gdb-7/include/bfdlink.h (revision 5796c8dc12c637f18a1740c26afd8d40ffa9b719)
1*5796c8dcSSimon Schubert /* bfdlink.h -- header file for BFD link routines
2*5796c8dcSSimon Schubert    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3*5796c8dcSSimon Schubert    2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4*5796c8dcSSimon Schubert    Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support.
5*5796c8dcSSimon Schubert 
6*5796c8dcSSimon Schubert    This file is part of BFD, the Binary File Descriptor library.
7*5796c8dcSSimon Schubert 
8*5796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
9*5796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
10*5796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
11*5796c8dcSSimon Schubert    (at your option) any later version.
12*5796c8dcSSimon Schubert 
13*5796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
14*5796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
15*5796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*5796c8dcSSimon Schubert    GNU General Public License for more details.
17*5796c8dcSSimon Schubert 
18*5796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
19*5796c8dcSSimon Schubert    along with this program; if not, write to the Free Software
20*5796c8dcSSimon Schubert    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21*5796c8dcSSimon Schubert    MA 02110-1301, USA.  */
22*5796c8dcSSimon Schubert 
23*5796c8dcSSimon Schubert #ifndef BFDLINK_H
24*5796c8dcSSimon Schubert #define BFDLINK_H
25*5796c8dcSSimon Schubert 
26*5796c8dcSSimon Schubert /* Which symbols to strip during a link.  */
27*5796c8dcSSimon Schubert enum bfd_link_strip
28*5796c8dcSSimon Schubert {
29*5796c8dcSSimon Schubert   strip_none,		/* Don't strip any symbols.  */
30*5796c8dcSSimon Schubert   strip_debugger,	/* Strip debugging symbols.  */
31*5796c8dcSSimon Schubert   strip_some,		/* keep_hash is the list of symbols to keep.  */
32*5796c8dcSSimon Schubert   strip_all		/* Strip all symbols.  */
33*5796c8dcSSimon Schubert };
34*5796c8dcSSimon Schubert 
35*5796c8dcSSimon Schubert /* Which local symbols to discard during a link.  This is irrelevant
36*5796c8dcSSimon Schubert    if strip_all is used.  */
37*5796c8dcSSimon Schubert enum bfd_link_discard
38*5796c8dcSSimon Schubert {
39*5796c8dcSSimon Schubert   discard_sec_merge,	/* Discard local temporary symbols in SEC_MERGE
40*5796c8dcSSimon Schubert 			   sections.  */
41*5796c8dcSSimon Schubert   discard_none,		/* Don't discard any locals.  */
42*5796c8dcSSimon Schubert   discard_l,		/* Discard local temporary symbols.  */
43*5796c8dcSSimon Schubert   discard_all		/* Discard all locals.  */
44*5796c8dcSSimon Schubert };
45*5796c8dcSSimon Schubert 
46*5796c8dcSSimon Schubert /* Describes the type of hash table entry structure being used.
47*5796c8dcSSimon Schubert    Different hash table structure have different fields and so
48*5796c8dcSSimon Schubert    support different linking features.  */
49*5796c8dcSSimon Schubert enum bfd_link_hash_table_type
50*5796c8dcSSimon Schubert   {
51*5796c8dcSSimon Schubert     bfd_link_generic_hash_table,
52*5796c8dcSSimon Schubert     bfd_link_elf_hash_table
53*5796c8dcSSimon Schubert   };
54*5796c8dcSSimon Schubert 
55*5796c8dcSSimon Schubert /* These are the possible types of an entry in the BFD link hash
56*5796c8dcSSimon Schubert    table.  */
57*5796c8dcSSimon Schubert 
58*5796c8dcSSimon Schubert enum bfd_link_hash_type
59*5796c8dcSSimon Schubert {
60*5796c8dcSSimon Schubert   bfd_link_hash_new,		/* Symbol is new.  */
61*5796c8dcSSimon Schubert   bfd_link_hash_undefined,	/* Symbol seen before, but undefined.  */
62*5796c8dcSSimon Schubert   bfd_link_hash_undefweak,	/* Symbol is weak and undefined.  */
63*5796c8dcSSimon Schubert   bfd_link_hash_defined,	/* Symbol is defined.  */
64*5796c8dcSSimon Schubert   bfd_link_hash_defweak,	/* Symbol is weak and defined.  */
65*5796c8dcSSimon Schubert   bfd_link_hash_common,		/* Symbol is common.  */
66*5796c8dcSSimon Schubert   bfd_link_hash_indirect,	/* Symbol is an indirect link.  */
67*5796c8dcSSimon Schubert   bfd_link_hash_warning		/* Like indirect, but warn if referenced.  */
68*5796c8dcSSimon Schubert };
69*5796c8dcSSimon Schubert 
70*5796c8dcSSimon Schubert enum bfd_link_common_skip_ar_aymbols
71*5796c8dcSSimon Schubert {
72*5796c8dcSSimon Schubert   bfd_link_common_skip_none,
73*5796c8dcSSimon Schubert   bfd_link_common_skip_text,
74*5796c8dcSSimon Schubert   bfd_link_common_skip_data,
75*5796c8dcSSimon Schubert   bfd_link_common_skip_all
76*5796c8dcSSimon Schubert };
77*5796c8dcSSimon Schubert 
78*5796c8dcSSimon Schubert struct bfd_link_hash_common_entry
79*5796c8dcSSimon Schubert   {
80*5796c8dcSSimon Schubert     unsigned int alignment_power;	/* Alignment.  */
81*5796c8dcSSimon Schubert     asection *section;		/* Symbol section.  */
82*5796c8dcSSimon Schubert   };
83*5796c8dcSSimon Schubert 
84*5796c8dcSSimon Schubert /* The linking routines use a hash table which uses this structure for
85*5796c8dcSSimon Schubert    its elements.  */
86*5796c8dcSSimon Schubert 
87*5796c8dcSSimon Schubert struct bfd_link_hash_entry
88*5796c8dcSSimon Schubert {
89*5796c8dcSSimon Schubert   /* Base hash table entry structure.  */
90*5796c8dcSSimon Schubert   struct bfd_hash_entry root;
91*5796c8dcSSimon Schubert 
92*5796c8dcSSimon Schubert   /* Type of this entry.  */
93*5796c8dcSSimon Schubert   enum bfd_link_hash_type type;
94*5796c8dcSSimon Schubert 
95*5796c8dcSSimon Schubert   /* A union of information depending upon the type.  */
96*5796c8dcSSimon Schubert   union
97*5796c8dcSSimon Schubert     {
98*5796c8dcSSimon Schubert       /* Nothing is kept for bfd_hash_new.  */
99*5796c8dcSSimon Schubert       /* bfd_link_hash_undefined, bfd_link_hash_undefweak.  */
100*5796c8dcSSimon Schubert       struct
101*5796c8dcSSimon Schubert 	{
102*5796c8dcSSimon Schubert 	  /* Undefined and common symbols are kept in a linked list through
103*5796c8dcSSimon Schubert 	     this field.  This field is present in all of the union element
104*5796c8dcSSimon Schubert 	     so that we don't need to remove entries from the list when we
105*5796c8dcSSimon Schubert 	     change their type.  Removing entries would either require the
106*5796c8dcSSimon Schubert 	     list to be doubly linked, which would waste more memory, or
107*5796c8dcSSimon Schubert 	     require a traversal.  When an undefined or common symbol is
108*5796c8dcSSimon Schubert 	     created, it should be added to this list, the head of which is in
109*5796c8dcSSimon Schubert 	     the link hash table itself.  As symbols are defined, they need
110*5796c8dcSSimon Schubert 	     not be removed from the list; anything which reads the list must
111*5796c8dcSSimon Schubert 	     doublecheck the symbol type.
112*5796c8dcSSimon Schubert 
113*5796c8dcSSimon Schubert 	     Weak symbols are not kept on this list.
114*5796c8dcSSimon Schubert 
115*5796c8dcSSimon Schubert 	     Defined and defweak symbols use this field as a reference marker.
116*5796c8dcSSimon Schubert 	     If the field is not NULL, or this structure is the tail of the
117*5796c8dcSSimon Schubert 	     undefined symbol list, the symbol has been referenced.  If the
118*5796c8dcSSimon Schubert 	     symbol is undefined and becomes defined, this field will
119*5796c8dcSSimon Schubert 	     automatically be non-NULL since the symbol will have been on the
120*5796c8dcSSimon Schubert 	     undefined symbol list.  */
121*5796c8dcSSimon Schubert 	  struct bfd_link_hash_entry *next;
122*5796c8dcSSimon Schubert 	  bfd *abfd;		/* BFD symbol was found in.  */
123*5796c8dcSSimon Schubert 	  bfd *weak;		/* BFD weak symbol was found in.  */
124*5796c8dcSSimon Schubert 	} undef;
125*5796c8dcSSimon Schubert       /* bfd_link_hash_defined, bfd_link_hash_defweak.  */
126*5796c8dcSSimon Schubert       struct
127*5796c8dcSSimon Schubert 	{
128*5796c8dcSSimon Schubert 	  struct bfd_link_hash_entry *next;
129*5796c8dcSSimon Schubert 	  asection *section;	/* Symbol section.  */
130*5796c8dcSSimon Schubert 	  bfd_vma value;	/* Symbol value.  */
131*5796c8dcSSimon Schubert 	} def;
132*5796c8dcSSimon Schubert       /* bfd_link_hash_indirect, bfd_link_hash_warning.  */
133*5796c8dcSSimon Schubert       struct
134*5796c8dcSSimon Schubert 	{
135*5796c8dcSSimon Schubert 	  struct bfd_link_hash_entry *next;
136*5796c8dcSSimon Schubert 	  struct bfd_link_hash_entry *link;	/* Real symbol.  */
137*5796c8dcSSimon Schubert 	  const char *warning;	/* Warning (bfd_link_hash_warning only).  */
138*5796c8dcSSimon Schubert 	} i;
139*5796c8dcSSimon Schubert       /* bfd_link_hash_common.  */
140*5796c8dcSSimon Schubert       struct
141*5796c8dcSSimon Schubert 	{
142*5796c8dcSSimon Schubert 	  struct bfd_link_hash_entry *next;
143*5796c8dcSSimon Schubert 	  /* The linker needs to know three things about common
144*5796c8dcSSimon Schubert 	     symbols: the size, the alignment, and the section in
145*5796c8dcSSimon Schubert 	     which the symbol should be placed.  We store the size
146*5796c8dcSSimon Schubert 	     here, and we allocate a small structure to hold the
147*5796c8dcSSimon Schubert 	     section and the alignment.  The alignment is stored as a
148*5796c8dcSSimon Schubert 	     power of two.  We don't store all the information
149*5796c8dcSSimon Schubert 	     directly because we don't want to increase the size of
150*5796c8dcSSimon Schubert 	     the union; this structure is a major space user in the
151*5796c8dcSSimon Schubert 	     linker.  */
152*5796c8dcSSimon Schubert 	  struct bfd_link_hash_common_entry *p;
153*5796c8dcSSimon Schubert 	  bfd_size_type size;	/* Common symbol size.  */
154*5796c8dcSSimon Schubert 	} c;
155*5796c8dcSSimon Schubert     } u;
156*5796c8dcSSimon Schubert };
157*5796c8dcSSimon Schubert 
158*5796c8dcSSimon Schubert /* This is the link hash table.  It is a derived class of
159*5796c8dcSSimon Schubert    bfd_hash_table.  */
160*5796c8dcSSimon Schubert 
161*5796c8dcSSimon Schubert struct bfd_link_hash_table
162*5796c8dcSSimon Schubert {
163*5796c8dcSSimon Schubert   /* The hash table itself.  */
164*5796c8dcSSimon Schubert   struct bfd_hash_table table;
165*5796c8dcSSimon Schubert   /* A linked list of undefined and common symbols, linked through the
166*5796c8dcSSimon Schubert      next field in the bfd_link_hash_entry structure.  */
167*5796c8dcSSimon Schubert   struct bfd_link_hash_entry *undefs;
168*5796c8dcSSimon Schubert   /* Entries are added to the tail of the undefs list.  */
169*5796c8dcSSimon Schubert   struct bfd_link_hash_entry *undefs_tail;
170*5796c8dcSSimon Schubert   /* The type of the link hash table.  */
171*5796c8dcSSimon Schubert   enum bfd_link_hash_table_type type;
172*5796c8dcSSimon Schubert };
173*5796c8dcSSimon Schubert 
174*5796c8dcSSimon Schubert /* Look up an entry in a link hash table.  If FOLLOW is TRUE, this
175*5796c8dcSSimon Schubert    follows bfd_link_hash_indirect and bfd_link_hash_warning links to
176*5796c8dcSSimon Schubert    the real symbol.  */
177*5796c8dcSSimon Schubert extern struct bfd_link_hash_entry *bfd_link_hash_lookup
178*5796c8dcSSimon Schubert   (struct bfd_link_hash_table *, const char *, bfd_boolean create,
179*5796c8dcSSimon Schubert    bfd_boolean copy, bfd_boolean follow);
180*5796c8dcSSimon Schubert 
181*5796c8dcSSimon Schubert /* Look up an entry in the main linker hash table if the symbol might
182*5796c8dcSSimon Schubert    be wrapped.  This should only be used for references to an
183*5796c8dcSSimon Schubert    undefined symbol, not for definitions of a symbol.  */
184*5796c8dcSSimon Schubert 
185*5796c8dcSSimon Schubert extern struct bfd_link_hash_entry *bfd_wrapped_link_hash_lookup
186*5796c8dcSSimon Schubert   (bfd *, struct bfd_link_info *, const char *, bfd_boolean,
187*5796c8dcSSimon Schubert    bfd_boolean, bfd_boolean);
188*5796c8dcSSimon Schubert 
189*5796c8dcSSimon Schubert /* Traverse a link hash table.  */
190*5796c8dcSSimon Schubert extern void bfd_link_hash_traverse
191*5796c8dcSSimon Schubert   (struct bfd_link_hash_table *,
192*5796c8dcSSimon Schubert     bfd_boolean (*) (struct bfd_link_hash_entry *, void *),
193*5796c8dcSSimon Schubert     void *);
194*5796c8dcSSimon Schubert 
195*5796c8dcSSimon Schubert /* Add an entry to the undefs list.  */
196*5796c8dcSSimon Schubert extern void bfd_link_add_undef
197*5796c8dcSSimon Schubert   (struct bfd_link_hash_table *, struct bfd_link_hash_entry *);
198*5796c8dcSSimon Schubert 
199*5796c8dcSSimon Schubert /* Remove symbols from the undefs list that don't belong there.  */
200*5796c8dcSSimon Schubert extern void bfd_link_repair_undef_list
201*5796c8dcSSimon Schubert   (struct bfd_link_hash_table *table);
202*5796c8dcSSimon Schubert 
203*5796c8dcSSimon Schubert /* Read symbols and cache symbol pointer array in outsymbols.  */
204*5796c8dcSSimon Schubert extern bfd_boolean bfd_generic_link_read_symbols (bfd *);
205*5796c8dcSSimon Schubert 
206*5796c8dcSSimon Schubert struct bfd_sym_chain
207*5796c8dcSSimon Schubert {
208*5796c8dcSSimon Schubert   struct bfd_sym_chain *next;
209*5796c8dcSSimon Schubert   const char *name;
210*5796c8dcSSimon Schubert };
211*5796c8dcSSimon Schubert 
212*5796c8dcSSimon Schubert /* How to handle unresolved symbols.
213*5796c8dcSSimon Schubert    There are four possibilities which are enumerated below:  */
214*5796c8dcSSimon Schubert enum report_method
215*5796c8dcSSimon Schubert {
216*5796c8dcSSimon Schubert   /* This is the initial value when then link_info structure is created.
217*5796c8dcSSimon Schubert      It allows the various stages of the linker to determine whether they
218*5796c8dcSSimon Schubert      allowed to set the value.  */
219*5796c8dcSSimon Schubert   RM_NOT_YET_SET = 0,
220*5796c8dcSSimon Schubert   RM_IGNORE,
221*5796c8dcSSimon Schubert   RM_GENERATE_WARNING,
222*5796c8dcSSimon Schubert   RM_GENERATE_ERROR
223*5796c8dcSSimon Schubert };
224*5796c8dcSSimon Schubert 
225*5796c8dcSSimon Schubert struct bfd_elf_dynamic_list;
226*5796c8dcSSimon Schubert 
227*5796c8dcSSimon Schubert /* This structure holds all the information needed to communicate
228*5796c8dcSSimon Schubert    between BFD and the linker when doing a link.  */
229*5796c8dcSSimon Schubert 
230*5796c8dcSSimon Schubert struct bfd_link_info
231*5796c8dcSSimon Schubert {
232*5796c8dcSSimon Schubert   /* TRUE if BFD should generate a relocatable object file.  */
233*5796c8dcSSimon Schubert   unsigned int relocatable: 1;
234*5796c8dcSSimon Schubert 
235*5796c8dcSSimon Schubert   /* TRUE if BFD should generate relocation information in the final
236*5796c8dcSSimon Schubert      executable.  */
237*5796c8dcSSimon Schubert   unsigned int emitrelocations: 1;
238*5796c8dcSSimon Schubert 
239*5796c8dcSSimon Schubert   /* TRUE if BFD should generate a "task linked" object file,
240*5796c8dcSSimon Schubert      similar to relocatable but also with globals converted to
241*5796c8dcSSimon Schubert      statics.  */
242*5796c8dcSSimon Schubert   unsigned int task_link: 1;
243*5796c8dcSSimon Schubert 
244*5796c8dcSSimon Schubert   /* TRUE if BFD should generate a shared object.  */
245*5796c8dcSSimon Schubert   unsigned int shared: 1;
246*5796c8dcSSimon Schubert 
247*5796c8dcSSimon Schubert   /* TRUE if BFD should pre-bind symbols in a shared object.  */
248*5796c8dcSSimon Schubert   unsigned int symbolic: 1;
249*5796c8dcSSimon Schubert 
250*5796c8dcSSimon Schubert   /* TRUE if BFD should export all symbols in the dynamic symbol table
251*5796c8dcSSimon Schubert      of an executable, rather than only those used.  */
252*5796c8dcSSimon Schubert   unsigned int export_dynamic: 1;
253*5796c8dcSSimon Schubert 
254*5796c8dcSSimon Schubert   /* TRUE if shared objects should be linked directly, not shared.  */
255*5796c8dcSSimon Schubert   unsigned int static_link: 1;
256*5796c8dcSSimon Schubert 
257*5796c8dcSSimon Schubert   /* TRUE if the output file should be in a traditional format.  This
258*5796c8dcSSimon Schubert      is equivalent to the setting of the BFD_TRADITIONAL_FORMAT flag
259*5796c8dcSSimon Schubert      on the output file, but may be checked when reading the input
260*5796c8dcSSimon Schubert      files.  */
261*5796c8dcSSimon Schubert   unsigned int traditional_format: 1;
262*5796c8dcSSimon Schubert 
263*5796c8dcSSimon Schubert   /* TRUE if we want to produced optimized output files.  This might
264*5796c8dcSSimon Schubert      need much more time and therefore must be explicitly selected.  */
265*5796c8dcSSimon Schubert   unsigned int optimize: 1;
266*5796c8dcSSimon Schubert 
267*5796c8dcSSimon Schubert   /* TRUE if ok to have multiple definition.  */
268*5796c8dcSSimon Schubert   unsigned int allow_multiple_definition: 1;
269*5796c8dcSSimon Schubert 
270*5796c8dcSSimon Schubert   /* TRUE if ok to have version with no definition.  */
271*5796c8dcSSimon Schubert   unsigned int allow_undefined_version: 1;
272*5796c8dcSSimon Schubert 
273*5796c8dcSSimon Schubert   /* TRUE if a default symbol version should be created and used for
274*5796c8dcSSimon Schubert      exported symbols.  */
275*5796c8dcSSimon Schubert   unsigned int create_default_symver: 1;
276*5796c8dcSSimon Schubert 
277*5796c8dcSSimon Schubert   /* TRUE if a default symbol version should be created and used for
278*5796c8dcSSimon Schubert      imported symbols.  */
279*5796c8dcSSimon Schubert   unsigned int default_imported_symver: 1;
280*5796c8dcSSimon Schubert 
281*5796c8dcSSimon Schubert   /* TRUE if symbols should be retained in memory, FALSE if they
282*5796c8dcSSimon Schubert      should be freed and reread.  */
283*5796c8dcSSimon Schubert   unsigned int keep_memory: 1;
284*5796c8dcSSimon Schubert 
285*5796c8dcSSimon Schubert   /* TRUE if every symbol should be reported back via the notice
286*5796c8dcSSimon Schubert      callback.  */
287*5796c8dcSSimon Schubert   unsigned int notice_all: 1;
288*5796c8dcSSimon Schubert 
289*5796c8dcSSimon Schubert   /* TRUE if executable should not contain copy relocs.
290*5796c8dcSSimon Schubert      Setting this true may result in a non-sharable text segment.  */
291*5796c8dcSSimon Schubert   unsigned int nocopyreloc: 1;
292*5796c8dcSSimon Schubert 
293*5796c8dcSSimon Schubert   /* TRUE if the new ELF dynamic tags are enabled. */
294*5796c8dcSSimon Schubert   unsigned int new_dtags: 1;
295*5796c8dcSSimon Schubert 
296*5796c8dcSSimon Schubert   /* TRUE if non-PLT relocs should be merged into one reloc section
297*5796c8dcSSimon Schubert      and sorted so that relocs against the same symbol come together.  */
298*5796c8dcSSimon Schubert   unsigned int combreloc: 1;
299*5796c8dcSSimon Schubert 
300*5796c8dcSSimon Schubert   /* TRUE if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment
301*5796c8dcSSimon Schubert      should be created.  */
302*5796c8dcSSimon Schubert   unsigned int eh_frame_hdr: 1;
303*5796c8dcSSimon Schubert 
304*5796c8dcSSimon Schubert   /* TRUE if global symbols in discarded sections should be stripped.  */
305*5796c8dcSSimon Schubert   unsigned int strip_discarded: 1;
306*5796c8dcSSimon Schubert 
307*5796c8dcSSimon Schubert   /* TRUE if generating a position independent executable.  */
308*5796c8dcSSimon Schubert   unsigned int pie: 1;
309*5796c8dcSSimon Schubert 
310*5796c8dcSSimon Schubert   /* TRUE if generating an executable, position independent or not.  */
311*5796c8dcSSimon Schubert   unsigned int executable : 1;
312*5796c8dcSSimon Schubert 
313*5796c8dcSSimon Schubert   /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W|PF_X
314*5796c8dcSSimon Schubert      flags.  */
315*5796c8dcSSimon Schubert   unsigned int execstack: 1;
316*5796c8dcSSimon Schubert 
317*5796c8dcSSimon Schubert   /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W
318*5796c8dcSSimon Schubert      flags.  */
319*5796c8dcSSimon Schubert   unsigned int noexecstack: 1;
320*5796c8dcSSimon Schubert 
321*5796c8dcSSimon Schubert   /* TRUE if PT_GNU_RELRO segment should be created.  */
322*5796c8dcSSimon Schubert   unsigned int relro: 1;
323*5796c8dcSSimon Schubert 
324*5796c8dcSSimon Schubert   /* TRUE if we should warn when adding a DT_TEXTREL to a shared object.  */
325*5796c8dcSSimon Schubert   unsigned int warn_shared_textrel: 1;
326*5796c8dcSSimon Schubert 
327*5796c8dcSSimon Schubert   /* TRUE if we should warn alternate ELF machine code.  */
328*5796c8dcSSimon Schubert   unsigned int warn_alternate_em: 1;
329*5796c8dcSSimon Schubert 
330*5796c8dcSSimon Schubert   /* TRUE if unreferenced sections should be removed.  */
331*5796c8dcSSimon Schubert   unsigned int gc_sections: 1;
332*5796c8dcSSimon Schubert 
333*5796c8dcSSimon Schubert   /* TRUE if user shoudl be informed of removed unreferenced sections.  */
334*5796c8dcSSimon Schubert   unsigned int print_gc_sections: 1;
335*5796c8dcSSimon Schubert 
336*5796c8dcSSimon Schubert   /* TRUE if .hash section should be created.  */
337*5796c8dcSSimon Schubert   unsigned int emit_hash: 1;
338*5796c8dcSSimon Schubert 
339*5796c8dcSSimon Schubert   /* TRUE if .gnu.hash section should be created.  */
340*5796c8dcSSimon Schubert   unsigned int emit_gnu_hash: 1;
341*5796c8dcSSimon Schubert 
342*5796c8dcSSimon Schubert   /* If TRUE reduce memory overheads, at the expense of speed. This will
343*5796c8dcSSimon Schubert      cause map file generation to use an O(N^2) algorithm and disable
344*5796c8dcSSimon Schubert      caching ELF symbol buffer.  */
345*5796c8dcSSimon Schubert   unsigned int reduce_memory_overheads: 1;
346*5796c8dcSSimon Schubert 
347*5796c8dcSSimon Schubert   /* TRUE if all data symbols should be dynamic.  */
348*5796c8dcSSimon Schubert    unsigned int dynamic_data: 1;
349*5796c8dcSSimon Schubert 
350*5796c8dcSSimon Schubert   /* TRUE if some symbols have to be dynamic, controlled by
351*5796c8dcSSimon Schubert      --dynamic-list command line options.  */
352*5796c8dcSSimon Schubert   unsigned int dynamic: 1;
353*5796c8dcSSimon Schubert 
354*5796c8dcSSimon Schubert   /* Non-NULL if .note.gnu.build-id section should be created.  */
355*5796c8dcSSimon Schubert   char *emit_note_gnu_build_id;
356*5796c8dcSSimon Schubert 
357*5796c8dcSSimon Schubert   /* What to do with unresolved symbols in an object file.
358*5796c8dcSSimon Schubert      When producing executables the default is GENERATE_ERROR.
359*5796c8dcSSimon Schubert      When producing shared libraries the default is IGNORE.  The
360*5796c8dcSSimon Schubert      assumption with shared libraries is that the reference will be
361*5796c8dcSSimon Schubert      resolved at load/execution time.  */
362*5796c8dcSSimon Schubert   enum report_method unresolved_syms_in_objects;
363*5796c8dcSSimon Schubert 
364*5796c8dcSSimon Schubert   /* What to do with unresolved symbols in a shared library.
365*5796c8dcSSimon Schubert      The same defaults apply.  */
366*5796c8dcSSimon Schubert   enum report_method unresolved_syms_in_shared_libs;
367*5796c8dcSSimon Schubert 
368*5796c8dcSSimon Schubert   /* Which symbols to strip.  */
369*5796c8dcSSimon Schubert   enum bfd_link_strip strip;
370*5796c8dcSSimon Schubert 
371*5796c8dcSSimon Schubert   /* Which local symbols to discard.  */
372*5796c8dcSSimon Schubert   enum bfd_link_discard discard;
373*5796c8dcSSimon Schubert 
374*5796c8dcSSimon Schubert   /* Criteria for skipping symbols when detemining
375*5796c8dcSSimon Schubert      whether to include an object from an archive. */
376*5796c8dcSSimon Schubert   enum bfd_link_common_skip_ar_aymbols common_skip_ar_aymbols;
377*5796c8dcSSimon Schubert 
378*5796c8dcSSimon Schubert   /* Char that may appear as the first char of a symbol, but should be
379*5796c8dcSSimon Schubert      skipped (like symbol_leading_char) when looking up symbols in
380*5796c8dcSSimon Schubert      wrap_hash.  Used by PowerPC Linux for 'dot' symbols.  */
381*5796c8dcSSimon Schubert   char wrap_char;
382*5796c8dcSSimon Schubert 
383*5796c8dcSSimon Schubert   /* Separator between archive and filename in linker script filespecs.  */
384*5796c8dcSSimon Schubert   char path_separator;
385*5796c8dcSSimon Schubert 
386*5796c8dcSSimon Schubert   /* Function callbacks.  */
387*5796c8dcSSimon Schubert   const struct bfd_link_callbacks *callbacks;
388*5796c8dcSSimon Schubert 
389*5796c8dcSSimon Schubert   /* Hash table handled by BFD.  */
390*5796c8dcSSimon Schubert   struct bfd_link_hash_table *hash;
391*5796c8dcSSimon Schubert 
392*5796c8dcSSimon Schubert   /* Hash table of symbols to keep.  This is NULL unless strip is
393*5796c8dcSSimon Schubert      strip_some.  */
394*5796c8dcSSimon Schubert   struct bfd_hash_table *keep_hash;
395*5796c8dcSSimon Schubert 
396*5796c8dcSSimon Schubert   /* Hash table of symbols to report back via the notice callback.  If
397*5796c8dcSSimon Schubert      this is NULL, and notice_all is FALSE, then no symbols are
398*5796c8dcSSimon Schubert      reported back.  */
399*5796c8dcSSimon Schubert   struct bfd_hash_table *notice_hash;
400*5796c8dcSSimon Schubert 
401*5796c8dcSSimon Schubert   /* Hash table of symbols which are being wrapped (the --wrap linker
402*5796c8dcSSimon Schubert      option).  If this is NULL, no symbols are being wrapped.  */
403*5796c8dcSSimon Schubert   struct bfd_hash_table *wrap_hash;
404*5796c8dcSSimon Schubert 
405*5796c8dcSSimon Schubert   /* The output BFD.  */
406*5796c8dcSSimon Schubert   bfd *output_bfd;
407*5796c8dcSSimon Schubert 
408*5796c8dcSSimon Schubert   /* The list of input BFD's involved in the link.  These are chained
409*5796c8dcSSimon Schubert      together via the link_next field.  */
410*5796c8dcSSimon Schubert   bfd *input_bfds;
411*5796c8dcSSimon Schubert   bfd **input_bfds_tail;
412*5796c8dcSSimon Schubert 
413*5796c8dcSSimon Schubert   /* If a symbol should be created for each input BFD, this is section
414*5796c8dcSSimon Schubert      where those symbols should be placed.  It must be a section in
415*5796c8dcSSimon Schubert      the output BFD.  It may be NULL, in which case no such symbols
416*5796c8dcSSimon Schubert      will be created.  This is to support CREATE_OBJECT_SYMBOLS in the
417*5796c8dcSSimon Schubert      linker command language.  */
418*5796c8dcSSimon Schubert   asection *create_object_symbols_section;
419*5796c8dcSSimon Schubert 
420*5796c8dcSSimon Schubert   /* List of global symbol names that are starting points for marking
421*5796c8dcSSimon Schubert      sections against garbage collection.  */
422*5796c8dcSSimon Schubert   struct bfd_sym_chain *gc_sym_list;
423*5796c8dcSSimon Schubert 
424*5796c8dcSSimon Schubert   /* If a base output file is wanted, then this points to it */
425*5796c8dcSSimon Schubert   void *base_file;
426*5796c8dcSSimon Schubert 
427*5796c8dcSSimon Schubert   /* The function to call when the executable or shared object is
428*5796c8dcSSimon Schubert      loaded.  */
429*5796c8dcSSimon Schubert   const char *init_function;
430*5796c8dcSSimon Schubert 
431*5796c8dcSSimon Schubert   /* The function to call when the executable or shared object is
432*5796c8dcSSimon Schubert      unloaded.  */
433*5796c8dcSSimon Schubert   const char *fini_function;
434*5796c8dcSSimon Schubert 
435*5796c8dcSSimon Schubert   /* Number of relaxation passes.  Usually only one relaxation pass
436*5796c8dcSSimon Schubert      is needed.  But a backend can have as many relaxation passes as
437*5796c8dcSSimon Schubert      necessary.  During bfd_relax_section call, it is set to the
438*5796c8dcSSimon Schubert      current pass, starting from 0.  */
439*5796c8dcSSimon Schubert   int relax_pass;
440*5796c8dcSSimon Schubert 
441*5796c8dcSSimon Schubert   /* Number of relaxation trips.  This number is incremented every
442*5796c8dcSSimon Schubert      time the relaxation pass is restarted due to a previous
443*5796c8dcSSimon Schubert      relaxation returning true in *AGAIN.  */
444*5796c8dcSSimon Schubert   int relax_trip;
445*5796c8dcSSimon Schubert 
446*5796c8dcSSimon Schubert   /* Non-zero if auto-import thunks for DATA items in pei386 DLLs
447*5796c8dcSSimon Schubert      should be generated/linked against.  Set to 1 if this feature
448*5796c8dcSSimon Schubert      is explicitly requested by the user, -1 if enabled by default.  */
449*5796c8dcSSimon Schubert   int pei386_auto_import;
450*5796c8dcSSimon Schubert 
451*5796c8dcSSimon Schubert   /* Non-zero if runtime relocs for DATA items with non-zero addends
452*5796c8dcSSimon Schubert      in pei386 DLLs should be generated.  Set to 1 if this feature
453*5796c8dcSSimon Schubert      is explicitly requested by the user, -1 if enabled by default.  */
454*5796c8dcSSimon Schubert   int pei386_runtime_pseudo_reloc;
455*5796c8dcSSimon Schubert 
456*5796c8dcSSimon Schubert   /* How many spare .dynamic DT_NULL entries should be added?  */
457*5796c8dcSSimon Schubert   unsigned int spare_dynamic_tags;
458*5796c8dcSSimon Schubert 
459*5796c8dcSSimon Schubert   /* May be used to set DT_FLAGS for ELF. */
460*5796c8dcSSimon Schubert   bfd_vma flags;
461*5796c8dcSSimon Schubert 
462*5796c8dcSSimon Schubert   /* May be used to set DT_FLAGS_1 for ELF. */
463*5796c8dcSSimon Schubert   bfd_vma flags_1;
464*5796c8dcSSimon Schubert 
465*5796c8dcSSimon Schubert   /* Start and end of RELRO region.  */
466*5796c8dcSSimon Schubert   bfd_vma relro_start, relro_end;
467*5796c8dcSSimon Schubert 
468*5796c8dcSSimon Schubert   /* List of symbols should be dynamic.  */
469*5796c8dcSSimon Schubert   struct bfd_elf_dynamic_list *dynamic_list;
470*5796c8dcSSimon Schubert };
471*5796c8dcSSimon Schubert 
472*5796c8dcSSimon Schubert /* This structures holds a set of callback functions.  These are called
473*5796c8dcSSimon Schubert    by the BFD linker routines.  Except for the info functions, the first
474*5796c8dcSSimon Schubert    argument to each callback function is the bfd_link_info structure
475*5796c8dcSSimon Schubert    being used and each function returns a boolean value.  If the
476*5796c8dcSSimon Schubert    function returns FALSE, then the BFD function which called it should
477*5796c8dcSSimon Schubert    return with a failure indication.  */
478*5796c8dcSSimon Schubert 
479*5796c8dcSSimon Schubert struct bfd_link_callbacks
480*5796c8dcSSimon Schubert {
481*5796c8dcSSimon Schubert   /* A function which is called when an object is added from an
482*5796c8dcSSimon Schubert      archive.  ABFD is the archive element being added.  NAME is the
483*5796c8dcSSimon Schubert      name of the symbol which caused the archive element to be pulled
484*5796c8dcSSimon Schubert      in.  */
485*5796c8dcSSimon Schubert   bfd_boolean (*add_archive_element)
486*5796c8dcSSimon Schubert     (struct bfd_link_info *, bfd *abfd, const char *name);
487*5796c8dcSSimon Schubert   /* A function which is called when a symbol is found with multiple
488*5796c8dcSSimon Schubert      definitions.  NAME is the symbol which is defined multiple times.
489*5796c8dcSSimon Schubert      OBFD is the old BFD, OSEC is the old section, OVAL is the old
490*5796c8dcSSimon Schubert      value, NBFD is the new BFD, NSEC is the new section, and NVAL is
491*5796c8dcSSimon Schubert      the new value.  OBFD may be NULL.  OSEC and NSEC may be
492*5796c8dcSSimon Schubert      bfd_com_section or bfd_ind_section.  */
493*5796c8dcSSimon Schubert   bfd_boolean (*multiple_definition)
494*5796c8dcSSimon Schubert     (struct bfd_link_info *, const char *name,
495*5796c8dcSSimon Schubert      bfd *obfd, asection *osec, bfd_vma oval,
496*5796c8dcSSimon Schubert      bfd *nbfd, asection *nsec, bfd_vma nval);
497*5796c8dcSSimon Schubert   /* A function which is called when a common symbol is defined
498*5796c8dcSSimon Schubert      multiple times.  NAME is the symbol appearing multiple times.
499*5796c8dcSSimon Schubert      OBFD is the BFD of the existing symbol; it may be NULL if this is
500*5796c8dcSSimon Schubert      not known.  OTYPE is the type of the existing symbol, which may
501*5796c8dcSSimon Schubert      be bfd_link_hash_defined, bfd_link_hash_defweak,
502*5796c8dcSSimon Schubert      bfd_link_hash_common, or bfd_link_hash_indirect.  If OTYPE is
503*5796c8dcSSimon Schubert      bfd_link_hash_common, OSIZE is the size of the existing symbol.
504*5796c8dcSSimon Schubert      NBFD is the BFD of the new symbol.  NTYPE is the type of the new
505*5796c8dcSSimon Schubert      symbol, one of bfd_link_hash_defined, bfd_link_hash_common, or
506*5796c8dcSSimon Schubert      bfd_link_hash_indirect.  If NTYPE is bfd_link_hash_common, NSIZE
507*5796c8dcSSimon Schubert      is the size of the new symbol.  */
508*5796c8dcSSimon Schubert   bfd_boolean (*multiple_common)
509*5796c8dcSSimon Schubert     (struct bfd_link_info *, const char *name,
510*5796c8dcSSimon Schubert      bfd *obfd, enum bfd_link_hash_type otype, bfd_vma osize,
511*5796c8dcSSimon Schubert      bfd *nbfd, enum bfd_link_hash_type ntype, bfd_vma nsize);
512*5796c8dcSSimon Schubert   /* A function which is called to add a symbol to a set.  ENTRY is
513*5796c8dcSSimon Schubert      the link hash table entry for the set itself (e.g.,
514*5796c8dcSSimon Schubert      __CTOR_LIST__).  RELOC is the relocation to use for an entry in
515*5796c8dcSSimon Schubert      the set when generating a relocatable file, and is also used to
516*5796c8dcSSimon Schubert      get the size of the entry when generating an executable file.
517*5796c8dcSSimon Schubert      ABFD, SEC and VALUE identify the value to add to the set.  */
518*5796c8dcSSimon Schubert   bfd_boolean (*add_to_set)
519*5796c8dcSSimon Schubert     (struct bfd_link_info *, struct bfd_link_hash_entry *entry,
520*5796c8dcSSimon Schubert      bfd_reloc_code_real_type reloc, bfd *abfd, asection *sec, bfd_vma value);
521*5796c8dcSSimon Schubert   /* A function which is called when the name of a g++ constructor or
522*5796c8dcSSimon Schubert      destructor is found.  This is only called by some object file
523*5796c8dcSSimon Schubert      formats.  CONSTRUCTOR is TRUE for a constructor, FALSE for a
524*5796c8dcSSimon Schubert      destructor.  This will use BFD_RELOC_CTOR when generating a
525*5796c8dcSSimon Schubert      relocatable file.  NAME is the name of the symbol found.  ABFD,
526*5796c8dcSSimon Schubert      SECTION and VALUE are the value of the symbol.  */
527*5796c8dcSSimon Schubert   bfd_boolean (*constructor)
528*5796c8dcSSimon Schubert     (struct bfd_link_info *, bfd_boolean constructor, const char *name,
529*5796c8dcSSimon Schubert      bfd *abfd, asection *sec, bfd_vma value);
530*5796c8dcSSimon Schubert   /* A function which is called to issue a linker warning.  For
531*5796c8dcSSimon Schubert      example, this is called when there is a reference to a warning
532*5796c8dcSSimon Schubert      symbol.  WARNING is the warning to be issued.  SYMBOL is the name
533*5796c8dcSSimon Schubert      of the symbol which triggered the warning; it may be NULL if
534*5796c8dcSSimon Schubert      there is none.  ABFD, SECTION and ADDRESS identify the location
535*5796c8dcSSimon Schubert      which trigerred the warning; either ABFD or SECTION or both may
536*5796c8dcSSimon Schubert      be NULL if the location is not known.  */
537*5796c8dcSSimon Schubert   bfd_boolean (*warning)
538*5796c8dcSSimon Schubert     (struct bfd_link_info *, const char *warning, const char *symbol,
539*5796c8dcSSimon Schubert      bfd *abfd, asection *section, bfd_vma address);
540*5796c8dcSSimon Schubert   /* A function which is called when a relocation is attempted against
541*5796c8dcSSimon Schubert      an undefined symbol.  NAME is the symbol which is undefined.
542*5796c8dcSSimon Schubert      ABFD, SECTION and ADDRESS identify the location from which the
543*5796c8dcSSimon Schubert      reference is made. FATAL indicates whether an undefined symbol is
544*5796c8dcSSimon Schubert      a fatal error or not. In some cases SECTION may be NULL.  */
545*5796c8dcSSimon Schubert   bfd_boolean (*undefined_symbol)
546*5796c8dcSSimon Schubert     (struct bfd_link_info *, const char *name, bfd *abfd,
547*5796c8dcSSimon Schubert      asection *section, bfd_vma address, bfd_boolean fatal);
548*5796c8dcSSimon Schubert   /* A function which is called when a reloc overflow occurs. ENTRY is
549*5796c8dcSSimon Schubert      the link hash table entry for the symbol the reloc is against.
550*5796c8dcSSimon Schubert      NAME is the name of the local symbol or section the reloc is
551*5796c8dcSSimon Schubert      against, RELOC_NAME is the name of the relocation, and ADDEND is
552*5796c8dcSSimon Schubert      any addend that is used.  ABFD, SECTION and ADDRESS identify the
553*5796c8dcSSimon Schubert      location at which the overflow occurs; if this is the result of a
554*5796c8dcSSimon Schubert      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
555*5796c8dcSSimon Schubert      ABFD will be NULL.  */
556*5796c8dcSSimon Schubert   bfd_boolean (*reloc_overflow)
557*5796c8dcSSimon Schubert     (struct bfd_link_info *, struct bfd_link_hash_entry *entry,
558*5796c8dcSSimon Schubert      const char *name, const char *reloc_name, bfd_vma addend,
559*5796c8dcSSimon Schubert      bfd *abfd, asection *section, bfd_vma address);
560*5796c8dcSSimon Schubert   /* A function which is called when a dangerous reloc is performed.
561*5796c8dcSSimon Schubert      MESSAGE is an appropriate message.
562*5796c8dcSSimon Schubert      ABFD, SECTION and ADDRESS identify the location at which the
563*5796c8dcSSimon Schubert      problem occurred; if this is the result of a
564*5796c8dcSSimon Schubert      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
565*5796c8dcSSimon Schubert      ABFD will be NULL.  */
566*5796c8dcSSimon Schubert   bfd_boolean (*reloc_dangerous)
567*5796c8dcSSimon Schubert     (struct bfd_link_info *, const char *message,
568*5796c8dcSSimon Schubert      bfd *abfd, asection *section, bfd_vma address);
569*5796c8dcSSimon Schubert   /* A function which is called when a reloc is found to be attached
570*5796c8dcSSimon Schubert      to a symbol which is not being written out.  NAME is the name of
571*5796c8dcSSimon Schubert      the symbol.  ABFD, SECTION and ADDRESS identify the location of
572*5796c8dcSSimon Schubert      the reloc; if this is the result of a
573*5796c8dcSSimon Schubert      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
574*5796c8dcSSimon Schubert      ABFD will be NULL.  */
575*5796c8dcSSimon Schubert   bfd_boolean (*unattached_reloc)
576*5796c8dcSSimon Schubert     (struct bfd_link_info *, const char *name,
577*5796c8dcSSimon Schubert      bfd *abfd, asection *section, bfd_vma address);
578*5796c8dcSSimon Schubert   /* A function which is called when a symbol in notice_hash is
579*5796c8dcSSimon Schubert      defined or referenced.  NAME is the symbol.  ABFD, SECTION and
580*5796c8dcSSimon Schubert      ADDRESS are the value of the symbol.  If SECTION is
581*5796c8dcSSimon Schubert      bfd_und_section, this is a reference.  */
582*5796c8dcSSimon Schubert   bfd_boolean (*notice)
583*5796c8dcSSimon Schubert     (struct bfd_link_info *, const char *name,
584*5796c8dcSSimon Schubert      bfd *abfd, asection *section, bfd_vma address);
585*5796c8dcSSimon Schubert   /* Error or warning link info message.  */
586*5796c8dcSSimon Schubert   void (*einfo)
587*5796c8dcSSimon Schubert     (const char *fmt, ...);
588*5796c8dcSSimon Schubert   /* General link info message.  */
589*5796c8dcSSimon Schubert   void (*info)
590*5796c8dcSSimon Schubert     (const char *fmt, ...);
591*5796c8dcSSimon Schubert   /* Message to be printed in linker map file.  */
592*5796c8dcSSimon Schubert   void (*minfo)
593*5796c8dcSSimon Schubert     (const char *fmt, ...);
594*5796c8dcSSimon Schubert   /* This callback provides a chance for users of the BFD library to
595*5796c8dcSSimon Schubert      override its decision about whether to place two adjacent sections
596*5796c8dcSSimon Schubert      into the same segment.  */
597*5796c8dcSSimon Schubert   bfd_boolean (*override_segment_assignment)
598*5796c8dcSSimon Schubert     (struct bfd_link_info *, bfd * abfd,
599*5796c8dcSSimon Schubert      asection * current_section, asection * previous_section,
600*5796c8dcSSimon Schubert      bfd_boolean new_segment);
601*5796c8dcSSimon Schubert };
602*5796c8dcSSimon Schubert 
603*5796c8dcSSimon Schubert /* The linker builds link_order structures which tell the code how to
604*5796c8dcSSimon Schubert    include input data in the output file.  */
605*5796c8dcSSimon Schubert 
606*5796c8dcSSimon Schubert /* These are the types of link_order structures.  */
607*5796c8dcSSimon Schubert 
608*5796c8dcSSimon Schubert enum bfd_link_order_type
609*5796c8dcSSimon Schubert {
610*5796c8dcSSimon Schubert   bfd_undefined_link_order,	/* Undefined.  */
611*5796c8dcSSimon Schubert   bfd_indirect_link_order,	/* Built from a section.  */
612*5796c8dcSSimon Schubert   bfd_data_link_order,		/* Set to explicit data.  */
613*5796c8dcSSimon Schubert   bfd_section_reloc_link_order,	/* Relocate against a section.  */
614*5796c8dcSSimon Schubert   bfd_symbol_reloc_link_order	/* Relocate against a symbol.  */
615*5796c8dcSSimon Schubert };
616*5796c8dcSSimon Schubert 
617*5796c8dcSSimon Schubert /* This is the link_order structure itself.  These form a chain
618*5796c8dcSSimon Schubert    attached to the output section whose contents they are describing.  */
619*5796c8dcSSimon Schubert 
620*5796c8dcSSimon Schubert struct bfd_link_order
621*5796c8dcSSimon Schubert {
622*5796c8dcSSimon Schubert   /* Next link_order in chain.  */
623*5796c8dcSSimon Schubert   struct bfd_link_order *next;
624*5796c8dcSSimon Schubert   /* Type of link_order.  */
625*5796c8dcSSimon Schubert   enum bfd_link_order_type type;
626*5796c8dcSSimon Schubert   /* Offset within output section.  */
627*5796c8dcSSimon Schubert   bfd_vma offset;
628*5796c8dcSSimon Schubert   /* Size within output section.  */
629*5796c8dcSSimon Schubert   bfd_size_type size;
630*5796c8dcSSimon Schubert   /* Type specific information.  */
631*5796c8dcSSimon Schubert   union
632*5796c8dcSSimon Schubert     {
633*5796c8dcSSimon Schubert       struct
634*5796c8dcSSimon Schubert 	{
635*5796c8dcSSimon Schubert 	  /* Section to include.  If this is used, then
636*5796c8dcSSimon Schubert 	     section->output_section must be the section the
637*5796c8dcSSimon Schubert 	     link_order is attached to, section->output_offset must
638*5796c8dcSSimon Schubert 	     equal the link_order offset field, and section->size
639*5796c8dcSSimon Schubert 	     must equal the link_order size field.  Maybe these
640*5796c8dcSSimon Schubert 	     restrictions should be relaxed someday.  */
641*5796c8dcSSimon Schubert 	  asection *section;
642*5796c8dcSSimon Schubert 	} indirect;
643*5796c8dcSSimon Schubert       struct
644*5796c8dcSSimon Schubert 	{
645*5796c8dcSSimon Schubert 	  /* Size of contents, or zero when contents size == size
646*5796c8dcSSimon Schubert 	     within output section.
647*5796c8dcSSimon Schubert 	     A non-zero value allows filling of the output section
648*5796c8dcSSimon Schubert 	     with an arbitrary repeated pattern.  */
649*5796c8dcSSimon Schubert 	  unsigned int size;
650*5796c8dcSSimon Schubert 	  /* Data to put into file.  */
651*5796c8dcSSimon Schubert 	  bfd_byte *contents;
652*5796c8dcSSimon Schubert 	} data;
653*5796c8dcSSimon Schubert       struct
654*5796c8dcSSimon Schubert 	{
655*5796c8dcSSimon Schubert 	  /* Description of reloc to generate.  Used for
656*5796c8dcSSimon Schubert 	     bfd_section_reloc_link_order and
657*5796c8dcSSimon Schubert 	     bfd_symbol_reloc_link_order.  */
658*5796c8dcSSimon Schubert 	  struct bfd_link_order_reloc *p;
659*5796c8dcSSimon Schubert 	} reloc;
660*5796c8dcSSimon Schubert     } u;
661*5796c8dcSSimon Schubert };
662*5796c8dcSSimon Schubert 
663*5796c8dcSSimon Schubert /* A linker order of type bfd_section_reloc_link_order or
664*5796c8dcSSimon Schubert    bfd_symbol_reloc_link_order means to create a reloc against a
665*5796c8dcSSimon Schubert    section or symbol, respectively.  This is used to implement -Ur to
666*5796c8dcSSimon Schubert    generate relocs for the constructor tables.  The
667*5796c8dcSSimon Schubert    bfd_link_order_reloc structure describes the reloc that BFD should
668*5796c8dcSSimon Schubert    create.  It is similar to a arelent, but I didn't use arelent
669*5796c8dcSSimon Schubert    because the linker does not know anything about most symbols, and
670*5796c8dcSSimon Schubert    any asymbol structure it creates will be partially meaningless.
671*5796c8dcSSimon Schubert    This information could logically be in the bfd_link_order struct,
672*5796c8dcSSimon Schubert    but I didn't want to waste the space since these types of relocs
673*5796c8dcSSimon Schubert    are relatively rare.  */
674*5796c8dcSSimon Schubert 
675*5796c8dcSSimon Schubert struct bfd_link_order_reloc
676*5796c8dcSSimon Schubert {
677*5796c8dcSSimon Schubert   /* Reloc type.  */
678*5796c8dcSSimon Schubert   bfd_reloc_code_real_type reloc;
679*5796c8dcSSimon Schubert 
680*5796c8dcSSimon Schubert   union
681*5796c8dcSSimon Schubert     {
682*5796c8dcSSimon Schubert       /* For type bfd_section_reloc_link_order, this is the section
683*5796c8dcSSimon Schubert 	 the reloc should be against.  This must be a section in the
684*5796c8dcSSimon Schubert 	 output BFD, not any of the input BFDs.  */
685*5796c8dcSSimon Schubert       asection *section;
686*5796c8dcSSimon Schubert       /* For type bfd_symbol_reloc_link_order, this is the name of the
687*5796c8dcSSimon Schubert 	 symbol the reloc should be against.  */
688*5796c8dcSSimon Schubert       const char *name;
689*5796c8dcSSimon Schubert     } u;
690*5796c8dcSSimon Schubert 
691*5796c8dcSSimon Schubert   /* Addend to use.  The object file should contain zero.  The BFD
692*5796c8dcSSimon Schubert      backend is responsible for filling in the contents of the object
693*5796c8dcSSimon Schubert      file correctly.  For some object file formats (e.g., COFF) the
694*5796c8dcSSimon Schubert      addend must be stored into in the object file, and for some
695*5796c8dcSSimon Schubert      (e.g., SPARC a.out) it is kept in the reloc.  */
696*5796c8dcSSimon Schubert   bfd_vma addend;
697*5796c8dcSSimon Schubert };
698*5796c8dcSSimon Schubert 
699*5796c8dcSSimon Schubert /* Allocate a new link_order for a section.  */
700*5796c8dcSSimon Schubert extern struct bfd_link_order *bfd_new_link_order (bfd *, asection *);
701*5796c8dcSSimon Schubert 
702*5796c8dcSSimon Schubert /* These structures are used to describe version information for the
703*5796c8dcSSimon Schubert    ELF linker.  These structures could be manipulated entirely inside
704*5796c8dcSSimon Schubert    BFD, but it would be a pain.  Instead, the regular linker sets up
705*5796c8dcSSimon Schubert    these structures, and then passes them into BFD.  */
706*5796c8dcSSimon Schubert 
707*5796c8dcSSimon Schubert /* Glob pattern for a version.  */
708*5796c8dcSSimon Schubert 
709*5796c8dcSSimon Schubert struct bfd_elf_version_expr
710*5796c8dcSSimon Schubert {
711*5796c8dcSSimon Schubert   /* Next glob pattern for this version.  */
712*5796c8dcSSimon Schubert   struct bfd_elf_version_expr *next;
713*5796c8dcSSimon Schubert   /* Glob pattern.  */
714*5796c8dcSSimon Schubert   const char *pattern;
715*5796c8dcSSimon Schubert   /* Set if pattern is not a glob.  */
716*5796c8dcSSimon Schubert   unsigned int literal : 1;
717*5796c8dcSSimon Schubert   /* Defined by ".symver".  */
718*5796c8dcSSimon Schubert   unsigned int symver : 1;
719*5796c8dcSSimon Schubert   /* Defined by version script.  */
720*5796c8dcSSimon Schubert   unsigned int script : 1;
721*5796c8dcSSimon Schubert   /* Pattern type.  */
722*5796c8dcSSimon Schubert #define BFD_ELF_VERSION_C_TYPE		1
723*5796c8dcSSimon Schubert #define BFD_ELF_VERSION_CXX_TYPE	2
724*5796c8dcSSimon Schubert #define BFD_ELF_VERSION_JAVA_TYPE	4
725*5796c8dcSSimon Schubert   unsigned int mask : 3;
726*5796c8dcSSimon Schubert };
727*5796c8dcSSimon Schubert 
728*5796c8dcSSimon Schubert struct bfd_elf_version_expr_head
729*5796c8dcSSimon Schubert {
730*5796c8dcSSimon Schubert   /* List of all patterns, both wildcards and non-wildcards.  */
731*5796c8dcSSimon Schubert   struct bfd_elf_version_expr *list;
732*5796c8dcSSimon Schubert   /* Hash table for non-wildcards.  */
733*5796c8dcSSimon Schubert   void *htab;
734*5796c8dcSSimon Schubert   /* Remaining patterns.  */
735*5796c8dcSSimon Schubert   struct bfd_elf_version_expr *remaining;
736*5796c8dcSSimon Schubert   /* What kind of pattern types are present in list (bitmask).  */
737*5796c8dcSSimon Schubert   unsigned int mask;
738*5796c8dcSSimon Schubert };
739*5796c8dcSSimon Schubert 
740*5796c8dcSSimon Schubert /* Version dependencies.  */
741*5796c8dcSSimon Schubert 
742*5796c8dcSSimon Schubert struct bfd_elf_version_deps
743*5796c8dcSSimon Schubert {
744*5796c8dcSSimon Schubert   /* Next dependency for this version.  */
745*5796c8dcSSimon Schubert   struct bfd_elf_version_deps *next;
746*5796c8dcSSimon Schubert   /* The version which this version depends upon.  */
747*5796c8dcSSimon Schubert   struct bfd_elf_version_tree *version_needed;
748*5796c8dcSSimon Schubert };
749*5796c8dcSSimon Schubert 
750*5796c8dcSSimon Schubert /* A node in the version tree.  */
751*5796c8dcSSimon Schubert 
752*5796c8dcSSimon Schubert struct bfd_elf_version_tree
753*5796c8dcSSimon Schubert {
754*5796c8dcSSimon Schubert   /* Next version.  */
755*5796c8dcSSimon Schubert   struct bfd_elf_version_tree *next;
756*5796c8dcSSimon Schubert   /* Name of this version.  */
757*5796c8dcSSimon Schubert   const char *name;
758*5796c8dcSSimon Schubert   /* Version number.  */
759*5796c8dcSSimon Schubert   unsigned int vernum;
760*5796c8dcSSimon Schubert   /* Regular expressions for global symbols in this version.  */
761*5796c8dcSSimon Schubert   struct bfd_elf_version_expr_head globals;
762*5796c8dcSSimon Schubert   /* Regular expressions for local symbols in this version.  */
763*5796c8dcSSimon Schubert   struct bfd_elf_version_expr_head locals;
764*5796c8dcSSimon Schubert   /* List of versions which this version depends upon.  */
765*5796c8dcSSimon Schubert   struct bfd_elf_version_deps *deps;
766*5796c8dcSSimon Schubert   /* Index of the version name.  This is used within BFD.  */
767*5796c8dcSSimon Schubert   unsigned int name_indx;
768*5796c8dcSSimon Schubert   /* Whether this version tree was used.  This is used within BFD.  */
769*5796c8dcSSimon Schubert   int used;
770*5796c8dcSSimon Schubert   /* Matching hook.  */
771*5796c8dcSSimon Schubert   struct bfd_elf_version_expr *(*match)
772*5796c8dcSSimon Schubert     (struct bfd_elf_version_expr_head *head,
773*5796c8dcSSimon Schubert      struct bfd_elf_version_expr *prev, const char *sym);
774*5796c8dcSSimon Schubert };
775*5796c8dcSSimon Schubert 
776*5796c8dcSSimon Schubert struct bfd_elf_dynamic_list
777*5796c8dcSSimon Schubert {
778*5796c8dcSSimon Schubert   struct bfd_elf_version_expr_head head;
779*5796c8dcSSimon Schubert   struct bfd_elf_version_expr *(*match)
780*5796c8dcSSimon Schubert     (struct bfd_elf_version_expr_head *head,
781*5796c8dcSSimon Schubert      struct bfd_elf_version_expr *prev, const char *sym);
782*5796c8dcSSimon Schubert };
783*5796c8dcSSimon Schubert 
784*5796c8dcSSimon Schubert #endif
785