xref: /dflybsd-src/contrib/binutils-2.34/include/bfdlink.h (revision b52ef7118d1621abed722c5bbbd542210290ecef)
1*fae548d3Szrj /* bfdlink.h -- header file for BFD link routines
2*fae548d3Szrj    Copyright (C) 1993-2020 Free Software Foundation, Inc.
3*fae548d3Szrj    Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support.
4*fae548d3Szrj 
5*fae548d3Szrj    This file is part of BFD, the Binary File Descriptor library.
6*fae548d3Szrj 
7*fae548d3Szrj    This program is free software; you can redistribute it and/or modify
8*fae548d3Szrj    it under the terms of the GNU General Public License as published by
9*fae548d3Szrj    the Free Software Foundation; either version 3 of the License, or
10*fae548d3Szrj    (at your option) any later version.
11*fae548d3Szrj 
12*fae548d3Szrj    This program is distributed in the hope that it will be useful,
13*fae548d3Szrj    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*fae548d3Szrj    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*fae548d3Szrj    GNU General Public License for more details.
16*fae548d3Szrj 
17*fae548d3Szrj    You should have received a copy of the GNU General Public License
18*fae548d3Szrj    along with this program; if not, write to the Free Software
19*fae548d3Szrj    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20*fae548d3Szrj    MA 02110-1301, USA.  */
21*fae548d3Szrj 
22*fae548d3Szrj #ifndef BFDLINK_H
23*fae548d3Szrj #define BFDLINK_H
24*fae548d3Szrj 
25*fae548d3Szrj /* Which symbols to strip during a link.  */
26*fae548d3Szrj enum bfd_link_strip
27*fae548d3Szrj {
28*fae548d3Szrj   strip_none,		/* Don't strip any symbols.  */
29*fae548d3Szrj   strip_debugger,	/* Strip debugging symbols.  */
30*fae548d3Szrj   strip_some,		/* keep_hash is the list of symbols to keep.  */
31*fae548d3Szrj   strip_all		/* Strip all symbols.  */
32*fae548d3Szrj };
33*fae548d3Szrj 
34*fae548d3Szrj /* Which local symbols to discard during a link.  This is irrelevant
35*fae548d3Szrj    if strip_all is used.  */
36*fae548d3Szrj enum bfd_link_discard
37*fae548d3Szrj {
38*fae548d3Szrj   discard_sec_merge,	/* Discard local temporary symbols in SEC_MERGE
39*fae548d3Szrj 			   sections.  */
40*fae548d3Szrj   discard_none,		/* Don't discard any locals.  */
41*fae548d3Szrj   discard_l,		/* Discard local temporary symbols.  */
42*fae548d3Szrj   discard_all		/* Discard all locals.  */
43*fae548d3Szrj };
44*fae548d3Szrj 
45*fae548d3Szrj enum notice_asneeded_action {
46*fae548d3Szrj   notice_as_needed,
47*fae548d3Szrj   notice_not_needed,
48*fae548d3Szrj   notice_needed
49*fae548d3Szrj };
50*fae548d3Szrj 
51*fae548d3Szrj /* Whether to generate ELF common symbols with the STT_COMMON type
52*fae548d3Szrj    during a relocatable link.  */
53*fae548d3Szrj enum bfd_link_elf_stt_common
54*fae548d3Szrj {
55*fae548d3Szrj   unchanged,
56*fae548d3Szrj   elf_stt_common,
57*fae548d3Szrj   no_elf_stt_common
58*fae548d3Szrj };
59*fae548d3Szrj 
60*fae548d3Szrj /* Describes the type of hash table entry structure being used.
61*fae548d3Szrj    Different hash table structure have different fields and so
62*fae548d3Szrj    support different linking features.  */
63*fae548d3Szrj enum bfd_link_hash_table_type
64*fae548d3Szrj   {
65*fae548d3Szrj     bfd_link_generic_hash_table,
66*fae548d3Szrj     bfd_link_elf_hash_table
67*fae548d3Szrj   };
68*fae548d3Szrj 
69*fae548d3Szrj /* These are the possible types of an entry in the BFD link hash
70*fae548d3Szrj    table.  */
71*fae548d3Szrj 
72*fae548d3Szrj enum bfd_link_hash_type
73*fae548d3Szrj {
74*fae548d3Szrj   bfd_link_hash_new,		/* Symbol is new.  */
75*fae548d3Szrj   bfd_link_hash_undefined,	/* Symbol seen before, but undefined.  */
76*fae548d3Szrj   bfd_link_hash_undefweak,	/* Symbol is weak and undefined.  */
77*fae548d3Szrj   bfd_link_hash_defined,	/* Symbol is defined.  */
78*fae548d3Szrj   bfd_link_hash_defweak,	/* Symbol is weak and defined.  */
79*fae548d3Szrj   bfd_link_hash_common,		/* Symbol is common.  */
80*fae548d3Szrj   bfd_link_hash_indirect,	/* Symbol is an indirect link.  */
81*fae548d3Szrj   bfd_link_hash_warning		/* Like indirect, but warn if referenced.  */
82*fae548d3Szrj };
83*fae548d3Szrj 
84*fae548d3Szrj enum bfd_link_common_skip_ar_symbols
85*fae548d3Szrj {
86*fae548d3Szrj   bfd_link_common_skip_none,
87*fae548d3Szrj   bfd_link_common_skip_text,
88*fae548d3Szrj   bfd_link_common_skip_data,
89*fae548d3Szrj   bfd_link_common_skip_all
90*fae548d3Szrj };
91*fae548d3Szrj 
92*fae548d3Szrj struct bfd_link_hash_common_entry
93*fae548d3Szrj   {
94*fae548d3Szrj     unsigned int alignment_power;	/* Alignment.  */
95*fae548d3Szrj     asection *section;		/* Symbol section.  */
96*fae548d3Szrj   };
97*fae548d3Szrj 
98*fae548d3Szrj /* The linking routines use a hash table which uses this structure for
99*fae548d3Szrj    its elements.  */
100*fae548d3Szrj 
101*fae548d3Szrj struct bfd_link_hash_entry
102*fae548d3Szrj {
103*fae548d3Szrj   /* Base hash table entry structure.  */
104*fae548d3Szrj   struct bfd_hash_entry root;
105*fae548d3Szrj 
106*fae548d3Szrj   /* Type of this entry.  */
107*fae548d3Szrj   ENUM_BITFIELD (bfd_link_hash_type) type : 8;
108*fae548d3Szrj 
109*fae548d3Szrj   /* Symbol is referenced in a normal regular object file,
110*fae548d3Szrj      as distinct from a LTO IR object file.  */
111*fae548d3Szrj   unsigned int non_ir_ref_regular : 1;
112*fae548d3Szrj 
113*fae548d3Szrj   /* Symbol is referenced in a normal dynamic object file,
114*fae548d3Szrj      as distinct from a LTO IR object file.  */
115*fae548d3Szrj   unsigned int non_ir_ref_dynamic : 1;
116*fae548d3Szrj 
117*fae548d3Szrj   /* Symbol is a built-in define.  These will be overridden by PROVIDE
118*fae548d3Szrj      in a linker script.  */
119*fae548d3Szrj   unsigned int linker_def : 1;
120*fae548d3Szrj 
121*fae548d3Szrj   /* Symbol defined in a linker script.  */
122*fae548d3Szrj   unsigned int ldscript_def : 1;
123*fae548d3Szrj 
124*fae548d3Szrj   /* Symbol will be converted from absolute to section-relative.  Set for
125*fae548d3Szrj      symbols defined by a script from "dot" (also SEGMENT_START or ORIGIN)
126*fae548d3Szrj      outside of an output section statement.  */
127*fae548d3Szrj   unsigned int rel_from_abs : 1;
128*fae548d3Szrj 
129*fae548d3Szrj   /* A union of information depending upon the type.  */
130*fae548d3Szrj   union
131*fae548d3Szrj     {
132*fae548d3Szrj       /* Nothing is kept for bfd_hash_new.  */
133*fae548d3Szrj       /* bfd_link_hash_undefined, bfd_link_hash_undefweak.  */
134*fae548d3Szrj       struct
135*fae548d3Szrj 	{
136*fae548d3Szrj 	  /* Undefined and common symbols are kept in a linked list through
137*fae548d3Szrj 	     this field.  This field is present in all of the union element
138*fae548d3Szrj 	     so that we don't need to remove entries from the list when we
139*fae548d3Szrj 	     change their type.  Removing entries would either require the
140*fae548d3Szrj 	     list to be doubly linked, which would waste more memory, or
141*fae548d3Szrj 	     require a traversal.  When an undefined or common symbol is
142*fae548d3Szrj 	     created, it should be added to this list, the head of which is in
143*fae548d3Szrj 	     the link hash table itself.  As symbols are defined, they need
144*fae548d3Szrj 	     not be removed from the list; anything which reads the list must
145*fae548d3Szrj 	     doublecheck the symbol type.
146*fae548d3Szrj 
147*fae548d3Szrj 	     Weak symbols are not kept on this list.
148*fae548d3Szrj 
149*fae548d3Szrj 	     Defined and defweak symbols use this field as a reference marker.
150*fae548d3Szrj 	     If the field is not NULL, or this structure is the tail of the
151*fae548d3Szrj 	     undefined symbol list, the symbol has been referenced.  If the
152*fae548d3Szrj 	     symbol is undefined and becomes defined, this field will
153*fae548d3Szrj 	     automatically be non-NULL since the symbol will have been on the
154*fae548d3Szrj 	     undefined symbol list.  */
155*fae548d3Szrj 	  struct bfd_link_hash_entry *next;
156*fae548d3Szrj 	  /* BFD symbol was found in.  */
157*fae548d3Szrj 	  bfd *abfd;
158*fae548d3Szrj 	} undef;
159*fae548d3Szrj       /* bfd_link_hash_defined, bfd_link_hash_defweak.  */
160*fae548d3Szrj       struct
161*fae548d3Szrj 	{
162*fae548d3Szrj 	  struct bfd_link_hash_entry *next;
163*fae548d3Szrj 	  /* Symbol section.  */
164*fae548d3Szrj 	  asection *section;
165*fae548d3Szrj 	  /* Symbol value.  */
166*fae548d3Szrj 	  bfd_vma value;
167*fae548d3Szrj 	} def;
168*fae548d3Szrj       /* bfd_link_hash_indirect, bfd_link_hash_warning.  */
169*fae548d3Szrj       struct
170*fae548d3Szrj 	{
171*fae548d3Szrj 	  struct bfd_link_hash_entry *next;
172*fae548d3Szrj 	  /* Real symbol.  */
173*fae548d3Szrj 	  struct bfd_link_hash_entry *link;
174*fae548d3Szrj 	  /* Warning message (bfd_link_hash_warning only).  */
175*fae548d3Szrj 	  const char *warning;
176*fae548d3Szrj 	} i;
177*fae548d3Szrj       /* bfd_link_hash_common.  */
178*fae548d3Szrj       struct
179*fae548d3Szrj 	{
180*fae548d3Szrj 	  struct bfd_link_hash_entry *next;
181*fae548d3Szrj 	  /* The linker needs to know three things about common
182*fae548d3Szrj 	     symbols: the size, the alignment, and the section in
183*fae548d3Szrj 	     which the symbol should be placed.  We store the size
184*fae548d3Szrj 	     here, and we allocate a small structure to hold the
185*fae548d3Szrj 	     section and the alignment.  The alignment is stored as a
186*fae548d3Szrj 	     power of two.  We don't store all the information
187*fae548d3Szrj 	     directly because we don't want to increase the size of
188*fae548d3Szrj 	     the union; this structure is a major space user in the
189*fae548d3Szrj 	     linker.  */
190*fae548d3Szrj 	  struct bfd_link_hash_common_entry *p;
191*fae548d3Szrj 	  /* Common symbol size.  */
192*fae548d3Szrj 	  bfd_size_type size;
193*fae548d3Szrj 	} c;
194*fae548d3Szrj     } u;
195*fae548d3Szrj };
196*fae548d3Szrj 
197*fae548d3Szrj /* This is the link hash table.  It is a derived class of
198*fae548d3Szrj    bfd_hash_table.  */
199*fae548d3Szrj 
200*fae548d3Szrj struct bfd_link_hash_table
201*fae548d3Szrj {
202*fae548d3Szrj   /* The hash table itself.  */
203*fae548d3Szrj   struct bfd_hash_table table;
204*fae548d3Szrj   /* A linked list of undefined and common symbols, linked through the
205*fae548d3Szrj      next field in the bfd_link_hash_entry structure.  */
206*fae548d3Szrj   struct bfd_link_hash_entry *undefs;
207*fae548d3Szrj   /* Entries are added to the tail of the undefs list.  */
208*fae548d3Szrj   struct bfd_link_hash_entry *undefs_tail;
209*fae548d3Szrj   /* Function to free the hash table on closing BFD.  */
210*fae548d3Szrj   void (*hash_table_free) (bfd *);
211*fae548d3Szrj   /* The type of the link hash table.  */
212*fae548d3Szrj   enum bfd_link_hash_table_type type;
213*fae548d3Szrj };
214*fae548d3Szrj 
215*fae548d3Szrj /* Look up an entry in a link hash table.  If FOLLOW is TRUE, this
216*fae548d3Szrj    follows bfd_link_hash_indirect and bfd_link_hash_warning links to
217*fae548d3Szrj    the real symbol.  */
218*fae548d3Szrj extern struct bfd_link_hash_entry *bfd_link_hash_lookup
219*fae548d3Szrj   (struct bfd_link_hash_table *, const char *, bfd_boolean create,
220*fae548d3Szrj    bfd_boolean copy, bfd_boolean follow);
221*fae548d3Szrj 
222*fae548d3Szrj /* Look up an entry in the main linker hash table if the symbol might
223*fae548d3Szrj    be wrapped.  This should only be used for references to an
224*fae548d3Szrj    undefined symbol, not for definitions of a symbol.  */
225*fae548d3Szrj 
226*fae548d3Szrj extern struct bfd_link_hash_entry *bfd_wrapped_link_hash_lookup
227*fae548d3Szrj   (bfd *, struct bfd_link_info *, const char *, bfd_boolean,
228*fae548d3Szrj    bfd_boolean, bfd_boolean);
229*fae548d3Szrj 
230*fae548d3Szrj /* If H is a wrapped symbol, ie. the symbol name starts with "__wrap_"
231*fae548d3Szrj    and the remainder is found in wrap_hash, return the real symbol.  */
232*fae548d3Szrj 
233*fae548d3Szrj extern struct bfd_link_hash_entry *unwrap_hash_lookup
234*fae548d3Szrj   (struct bfd_link_info *, bfd *, struct bfd_link_hash_entry *);
235*fae548d3Szrj 
236*fae548d3Szrj /* Traverse a link hash table.  */
237*fae548d3Szrj extern void bfd_link_hash_traverse
238*fae548d3Szrj   (struct bfd_link_hash_table *,
239*fae548d3Szrj     bfd_boolean (*) (struct bfd_link_hash_entry *, void *),
240*fae548d3Szrj     void *);
241*fae548d3Szrj 
242*fae548d3Szrj /* Add an entry to the undefs list.  */
243*fae548d3Szrj extern void bfd_link_add_undef
244*fae548d3Szrj   (struct bfd_link_hash_table *, struct bfd_link_hash_entry *);
245*fae548d3Szrj 
246*fae548d3Szrj /* Remove symbols from the undefs list that don't belong there.  */
247*fae548d3Szrj extern void bfd_link_repair_undef_list
248*fae548d3Szrj   (struct bfd_link_hash_table *table);
249*fae548d3Szrj 
250*fae548d3Szrj /* Read symbols and cache symbol pointer array in outsymbols.  */
251*fae548d3Szrj extern bfd_boolean bfd_generic_link_read_symbols (bfd *);
252*fae548d3Szrj 
253*fae548d3Szrj /* Check the relocs in the BFD.  Called after all the input
254*fae548d3Szrj    files have been loaded, and garbage collection has tagged
255*fae548d3Szrj    any unneeded sections.  */
256*fae548d3Szrj extern bfd_boolean bfd_link_check_relocs (bfd *,struct bfd_link_info *);
257*fae548d3Szrj 
258*fae548d3Szrj struct bfd_sym_chain
259*fae548d3Szrj {
260*fae548d3Szrj   struct bfd_sym_chain *next;
261*fae548d3Szrj   const char *name;
262*fae548d3Szrj };
263*fae548d3Szrj 
264*fae548d3Szrj /* How to handle unresolved symbols.
265*fae548d3Szrj    There are four possibilities which are enumerated below:  */
266*fae548d3Szrj enum report_method
267*fae548d3Szrj {
268*fae548d3Szrj   /* This is the initial value when then link_info structure is created.
269*fae548d3Szrj      It allows the various stages of the linker to determine whether they
270*fae548d3Szrj      allowed to set the value.  */
271*fae548d3Szrj   RM_NOT_YET_SET = 0,
272*fae548d3Szrj   RM_IGNORE,
273*fae548d3Szrj   RM_GENERATE_WARNING,
274*fae548d3Szrj   RM_GENERATE_ERROR
275*fae548d3Szrj };
276*fae548d3Szrj 
277*fae548d3Szrj typedef enum {with_flags, without_flags} flag_type;
278*fae548d3Szrj 
279*fae548d3Szrj /* A section flag list.  */
280*fae548d3Szrj struct flag_info_list
281*fae548d3Szrj {
282*fae548d3Szrj   flag_type with;
283*fae548d3Szrj   const char *name;
284*fae548d3Szrj   bfd_boolean valid;
285*fae548d3Szrj   struct flag_info_list *next;
286*fae548d3Szrj };
287*fae548d3Szrj 
288*fae548d3Szrj /* Section flag info.  */
289*fae548d3Szrj struct flag_info
290*fae548d3Szrj {
291*fae548d3Szrj   flagword only_with_flags;
292*fae548d3Szrj   flagword not_with_flags;
293*fae548d3Szrj   struct flag_info_list *flag_list;
294*fae548d3Szrj   bfd_boolean flags_initialized;
295*fae548d3Szrj };
296*fae548d3Szrj 
297*fae548d3Szrj struct bfd_elf_dynamic_list;
298*fae548d3Szrj struct bfd_elf_version_tree;
299*fae548d3Szrj 
300*fae548d3Szrj /* Types of output.  */
301*fae548d3Szrj 
302*fae548d3Szrj enum output_type
303*fae548d3Szrj {
304*fae548d3Szrj   type_pde,
305*fae548d3Szrj   type_pie,
306*fae548d3Szrj   type_relocatable,
307*fae548d3Szrj   type_dll,
308*fae548d3Szrj };
309*fae548d3Szrj 
310*fae548d3Szrj #define bfd_link_pde(info)	   ((info)->type == type_pde)
311*fae548d3Szrj #define bfd_link_dll(info)	   ((info)->type == type_dll)
312*fae548d3Szrj #define bfd_link_relocatable(info) ((info)->type == type_relocatable)
313*fae548d3Szrj #define bfd_link_pie(info)	   ((info)->type == type_pie)
314*fae548d3Szrj #define bfd_link_executable(info)  (bfd_link_pde (info) || bfd_link_pie (info))
315*fae548d3Szrj #define bfd_link_pic(info)	   (bfd_link_dll (info) || bfd_link_pie (info))
316*fae548d3Szrj 
317*fae548d3Szrj /* This structure holds all the information needed to communicate
318*fae548d3Szrj    between BFD and the linker when doing a link.  */
319*fae548d3Szrj 
320*fae548d3Szrj struct bfd_link_info
321*fae548d3Szrj {
322*fae548d3Szrj   /* Output type.  */
323*fae548d3Szrj   ENUM_BITFIELD (output_type) type : 2;
324*fae548d3Szrj 
325*fae548d3Szrj   /* TRUE if BFD should pre-bind symbols in a shared object.  */
326*fae548d3Szrj   unsigned int symbolic: 1;
327*fae548d3Szrj 
328*fae548d3Szrj   /* TRUE if executable should not contain copy relocs.
329*fae548d3Szrj      Setting this true may result in a non-sharable text segment.  */
330*fae548d3Szrj   unsigned int nocopyreloc: 1;
331*fae548d3Szrj 
332*fae548d3Szrj   /* TRUE if BFD should export all symbols in the dynamic symbol table
333*fae548d3Szrj      of an executable, rather than only those used.  */
334*fae548d3Szrj   unsigned int export_dynamic: 1;
335*fae548d3Szrj 
336*fae548d3Szrj   /* TRUE if a default symbol version should be created and used for
337*fae548d3Szrj      exported symbols.  */
338*fae548d3Szrj   unsigned int create_default_symver: 1;
339*fae548d3Szrj 
340*fae548d3Szrj   /* TRUE if unreferenced sections should be removed.  */
341*fae548d3Szrj   unsigned int gc_sections: 1;
342*fae548d3Szrj 
343*fae548d3Szrj   /* TRUE if exported symbols should be kept during section gc.  */
344*fae548d3Szrj   unsigned int gc_keep_exported: 1;
345*fae548d3Szrj 
346*fae548d3Szrj   /* TRUE if every symbol should be reported back via the notice
347*fae548d3Szrj      callback.  */
348*fae548d3Szrj   unsigned int notice_all: 1;
349*fae548d3Szrj 
350*fae548d3Szrj   /* TRUE if the LTO plugin is active.  */
351*fae548d3Szrj   unsigned int lto_plugin_active: 1;
352*fae548d3Szrj 
353*fae548d3Szrj   /* TRUE if global symbols in discarded sections should be stripped.  */
354*fae548d3Szrj   unsigned int strip_discarded: 1;
355*fae548d3Szrj 
356*fae548d3Szrj   /* TRUE if all data symbols should be dynamic.  */
357*fae548d3Szrj   unsigned int dynamic_data: 1;
358*fae548d3Szrj 
359*fae548d3Szrj   /* TRUE if section groups should be resolved.  */
360*fae548d3Szrj   unsigned int resolve_section_groups: 1;
361*fae548d3Szrj 
362*fae548d3Szrj   /* Set if output file is big-endian, or if that is unknown, from
363*fae548d3Szrj      the command line or first input file endianness.  */
364*fae548d3Szrj   unsigned int big_endian : 1;
365*fae548d3Szrj 
366*fae548d3Szrj   /* Which symbols to strip.  */
367*fae548d3Szrj   ENUM_BITFIELD (bfd_link_strip) strip : 2;
368*fae548d3Szrj 
369*fae548d3Szrj   /* Which local symbols to discard.  */
370*fae548d3Szrj   ENUM_BITFIELD (bfd_link_discard) discard : 2;
371*fae548d3Szrj 
372*fae548d3Szrj   /* Whether to generate ELF common symbols with the STT_COMMON type.  */
373*fae548d3Szrj   ENUM_BITFIELD (bfd_link_elf_stt_common) elf_stt_common : 2;
374*fae548d3Szrj 
375*fae548d3Szrj   /* Criteria for skipping symbols when determining
376*fae548d3Szrj      whether to include an object from an archive. */
377*fae548d3Szrj   ENUM_BITFIELD (bfd_link_common_skip_ar_symbols) common_skip_ar_symbols : 2;
378*fae548d3Szrj 
379*fae548d3Szrj   /* What to do with unresolved symbols in an object file.
380*fae548d3Szrj      When producing executables the default is GENERATE_ERROR.
381*fae548d3Szrj      When producing shared libraries the default is IGNORE.  The
382*fae548d3Szrj      assumption with shared libraries is that the reference will be
383*fae548d3Szrj      resolved at load/execution time.  */
384*fae548d3Szrj   ENUM_BITFIELD (report_method) unresolved_syms_in_objects : 2;
385*fae548d3Szrj 
386*fae548d3Szrj   /* What to do with unresolved symbols in a shared library.
387*fae548d3Szrj      The same defaults apply.  */
388*fae548d3Szrj   ENUM_BITFIELD (report_method) unresolved_syms_in_shared_libs : 2;
389*fae548d3Szrj 
390*fae548d3Szrj   /* TRUE if shared objects should be linked directly, not shared.  */
391*fae548d3Szrj   unsigned int static_link: 1;
392*fae548d3Szrj 
393*fae548d3Szrj   /* TRUE if symbols should be retained in memory, FALSE if they
394*fae548d3Szrj      should be freed and reread.  */
395*fae548d3Szrj   unsigned int keep_memory: 1;
396*fae548d3Szrj 
397*fae548d3Szrj   /* TRUE if BFD should generate relocation information in the final
398*fae548d3Szrj      executable.  */
399*fae548d3Szrj   unsigned int emitrelocations: 1;
400*fae548d3Szrj 
401*fae548d3Szrj   /* TRUE if PT_GNU_RELRO segment should be created.  */
402*fae548d3Szrj   unsigned int relro: 1;
403*fae548d3Szrj 
404*fae548d3Szrj   /* TRUE if separate code segment should be created.  */
405*fae548d3Szrj   unsigned int separate_code: 1;
406*fae548d3Szrj 
407*fae548d3Szrj   /* Nonzero if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment
408*fae548d3Szrj      should be created.  1 for DWARF2 tables, 2 for compact tables.  */
409*fae548d3Szrj   unsigned int eh_frame_hdr_type: 2;
410*fae548d3Szrj 
411*fae548d3Szrj   /* TRUE if we should warn when adding a DT_TEXTREL to a shared object.  */
412*fae548d3Szrj   unsigned int warn_shared_textrel: 1;
413*fae548d3Szrj 
414*fae548d3Szrj   /* TRUE if we should error when adding a DT_TEXTREL.  */
415*fae548d3Szrj   unsigned int error_textrel: 1;
416*fae548d3Szrj 
417*fae548d3Szrj   /* TRUE if .hash section should be created.  */
418*fae548d3Szrj   unsigned int emit_hash: 1;
419*fae548d3Szrj 
420*fae548d3Szrj   /* TRUE if .gnu.hash section should be created.  */
421*fae548d3Szrj   unsigned int emit_gnu_hash: 1;
422*fae548d3Szrj 
423*fae548d3Szrj   /* If TRUE reduce memory overheads, at the expense of speed. This will
424*fae548d3Szrj      cause map file generation to use an O(N^2) algorithm and disable
425*fae548d3Szrj      caching ELF symbol buffer.  */
426*fae548d3Szrj   unsigned int reduce_memory_overheads: 1;
427*fae548d3Szrj 
428*fae548d3Szrj   /* TRUE if the output file should be in a traditional format.  This
429*fae548d3Szrj      is equivalent to the setting of the BFD_TRADITIONAL_FORMAT flag
430*fae548d3Szrj      on the output file, but may be checked when reading the input
431*fae548d3Szrj      files.  */
432*fae548d3Szrj   unsigned int traditional_format: 1;
433*fae548d3Szrj 
434*fae548d3Szrj   /* TRUE if non-PLT relocs should be merged into one reloc section
435*fae548d3Szrj      and sorted so that relocs against the same symbol come together.  */
436*fae548d3Szrj   unsigned int combreloc: 1;
437*fae548d3Szrj 
438*fae548d3Szrj   /* TRUE if a default symbol version should be created and used for
439*fae548d3Szrj      imported symbols.  */
440*fae548d3Szrj   unsigned int default_imported_symver: 1;
441*fae548d3Szrj 
442*fae548d3Szrj   /* TRUE if the new ELF dynamic tags are enabled. */
443*fae548d3Szrj   unsigned int new_dtags: 1;
444*fae548d3Szrj 
445*fae548d3Szrj   /* FALSE if .eh_frame unwind info should be generated for PLT and other
446*fae548d3Szrj      linker created sections, TRUE if it should be omitted.  */
447*fae548d3Szrj   unsigned int no_ld_generated_unwind_info: 1;
448*fae548d3Szrj 
449*fae548d3Szrj   /* TRUE if BFD should generate a "task linked" object file,
450*fae548d3Szrj      similar to relocatable but also with globals converted to
451*fae548d3Szrj      statics.  */
452*fae548d3Szrj   unsigned int task_link: 1;
453*fae548d3Szrj 
454*fae548d3Szrj   /* TRUE if ok to have multiple definition.  */
455*fae548d3Szrj   unsigned int allow_multiple_definition: 1;
456*fae548d3Szrj 
457*fae548d3Szrj   /* TRUE if ok to have prohibit multiple definition of absolute symbols.  */
458*fae548d3Szrj   unsigned int prohibit_multiple_definition_absolute: 1;
459*fae548d3Szrj 
460*fae548d3Szrj   /* TRUE if ok to have version with no definition.  */
461*fae548d3Szrj   unsigned int allow_undefined_version: 1;
462*fae548d3Szrj 
463*fae548d3Szrj   /* TRUE if some symbols have to be dynamic, controlled by
464*fae548d3Szrj      --dynamic-list command line options.  */
465*fae548d3Szrj   unsigned int dynamic: 1;
466*fae548d3Szrj 
467*fae548d3Szrj   /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W|PF_X
468*fae548d3Szrj      flags.  */
469*fae548d3Szrj   unsigned int execstack: 1;
470*fae548d3Szrj 
471*fae548d3Szrj   /* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W
472*fae548d3Szrj      flags.  */
473*fae548d3Szrj   unsigned int noexecstack: 1;
474*fae548d3Szrj 
475*fae548d3Szrj   /* TRUE if we want to produced optimized output files.  This might
476*fae548d3Szrj      need much more time and therefore must be explicitly selected.  */
477*fae548d3Szrj   unsigned int optimize: 1;
478*fae548d3Szrj 
479*fae548d3Szrj   /* TRUE if user should be informed of removed unreferenced sections.  */
480*fae548d3Szrj   unsigned int print_gc_sections: 1;
481*fae548d3Szrj 
482*fae548d3Szrj   /* TRUE if we should warn alternate ELF machine code.  */
483*fae548d3Szrj   unsigned int warn_alternate_em: 1;
484*fae548d3Szrj 
485*fae548d3Szrj   /* TRUE if the linker script contained an explicit PHDRS command.  */
486*fae548d3Szrj   unsigned int user_phdrs: 1;
487*fae548d3Szrj 
488*fae548d3Szrj   /* TRUE if program headers ought to be loaded.  */
489*fae548d3Szrj   unsigned int load_phdrs: 1;
490*fae548d3Szrj 
491*fae548d3Szrj   /* TRUE if we should check relocations after all input files have
492*fae548d3Szrj      been opened.  */
493*fae548d3Szrj   unsigned int check_relocs_after_open_input: 1;
494*fae548d3Szrj 
495*fae548d3Szrj   /* TRUE if generation of .interp/PT_INTERP should be suppressed.  */
496*fae548d3Szrj   unsigned int nointerp: 1;
497*fae548d3Szrj 
498*fae548d3Szrj   /* TRUE if common symbols should be treated as undefined.  */
499*fae548d3Szrj   unsigned int inhibit_common_definition : 1;
500*fae548d3Szrj 
501*fae548d3Szrj   /* TRUE if "-Map map" is passed to linker.  */
502*fae548d3Szrj   unsigned int has_map_file : 1;
503*fae548d3Szrj 
504*fae548d3Szrj   /* Char that may appear as the first char of a symbol, but should be
505*fae548d3Szrj      skipped (like symbol_leading_char) when looking up symbols in
506*fae548d3Szrj      wrap_hash.  Used by PowerPC Linux for 'dot' symbols.  */
507*fae548d3Szrj   char wrap_char;
508*fae548d3Szrj 
509*fae548d3Szrj   /* Separator between archive and filename in linker script filespecs.  */
510*fae548d3Szrj   char path_separator;
511*fae548d3Szrj 
512*fae548d3Szrj   /* Compress DWARF debug sections.  */
513*fae548d3Szrj   enum compressed_debug_section_type compress_debug;
514*fae548d3Szrj 
515*fae548d3Szrj   /* Default stack size.  Zero means default (often zero itself), -1
516*fae548d3Szrj      means explicitly zero-sized.  */
517*fae548d3Szrj   bfd_signed_vma stacksize;
518*fae548d3Szrj 
519*fae548d3Szrj   /* Enable or disable target specific optimizations.
520*fae548d3Szrj 
521*fae548d3Szrj      Not all targets have optimizations to enable.
522*fae548d3Szrj 
523*fae548d3Szrj      Normally these optimizations are disabled by default but some targets
524*fae548d3Szrj      prefer to enable them by default.  So this field is a tri-state variable.
525*fae548d3Szrj      The values are:
526*fae548d3Szrj 
527*fae548d3Szrj      zero: Enable the optimizations (either from --relax being specified on
528*fae548d3Szrj        the command line or the backend's before_allocation emulation function.
529*fae548d3Szrj 
530*fae548d3Szrj      positive: The user has requested that these optimizations be disabled.
531*fae548d3Szrj        (Via the --no-relax command line option).
532*fae548d3Szrj 
533*fae548d3Szrj      negative: The optimizations are disabled.  (Set when initializing the
534*fae548d3Szrj        args_type structure in ldmain.c:main.  */
535*fae548d3Szrj   signed int disable_target_specific_optimizations;
536*fae548d3Szrj 
537*fae548d3Szrj   /* Function callbacks.  */
538*fae548d3Szrj   const struct bfd_link_callbacks *callbacks;
539*fae548d3Szrj 
540*fae548d3Szrj   /* Hash table handled by BFD.  */
541*fae548d3Szrj   struct bfd_link_hash_table *hash;
542*fae548d3Szrj 
543*fae548d3Szrj   /* Hash table of symbols to keep.  This is NULL unless strip is
544*fae548d3Szrj      strip_some.  */
545*fae548d3Szrj   struct bfd_hash_table *keep_hash;
546*fae548d3Szrj 
547*fae548d3Szrj   /* Hash table of symbols to report back via the notice callback.  If
548*fae548d3Szrj      this is NULL, and notice_all is FALSE, then no symbols are
549*fae548d3Szrj      reported back.  */
550*fae548d3Szrj   struct bfd_hash_table *notice_hash;
551*fae548d3Szrj 
552*fae548d3Szrj   /* Hash table of symbols which are being wrapped (the --wrap linker
553*fae548d3Szrj      option).  If this is NULL, no symbols are being wrapped.  */
554*fae548d3Szrj   struct bfd_hash_table *wrap_hash;
555*fae548d3Szrj 
556*fae548d3Szrj   /* Hash table of symbols which may be left unresolved during
557*fae548d3Szrj      a link.  If this is NULL, no symbols can be left unresolved.  */
558*fae548d3Szrj   struct bfd_hash_table *ignore_hash;
559*fae548d3Szrj 
560*fae548d3Szrj   /* The output BFD.  */
561*fae548d3Szrj   bfd *output_bfd;
562*fae548d3Szrj 
563*fae548d3Szrj   /* The import library generated.  */
564*fae548d3Szrj   bfd *out_implib_bfd;
565*fae548d3Szrj 
566*fae548d3Szrj   /* The list of input BFD's involved in the link.  These are chained
567*fae548d3Szrj      together via the link.next field.  */
568*fae548d3Szrj   bfd *input_bfds;
569*fae548d3Szrj   bfd **input_bfds_tail;
570*fae548d3Szrj 
571*fae548d3Szrj   /* If a symbol should be created for each input BFD, this is section
572*fae548d3Szrj      where those symbols should be placed.  It must be a section in
573*fae548d3Szrj      the output BFD.  It may be NULL, in which case no such symbols
574*fae548d3Szrj      will be created.  This is to support CREATE_OBJECT_SYMBOLS in the
575*fae548d3Szrj      linker command language.  */
576*fae548d3Szrj   asection *create_object_symbols_section;
577*fae548d3Szrj 
578*fae548d3Szrj   /* List of global symbol names that are starting points for marking
579*fae548d3Szrj      sections against garbage collection.  */
580*fae548d3Szrj   struct bfd_sym_chain *gc_sym_list;
581*fae548d3Szrj 
582*fae548d3Szrj   /* If a base output file is wanted, then this points to it */
583*fae548d3Szrj   void *base_file;
584*fae548d3Szrj 
585*fae548d3Szrj   /* The function to call when the executable or shared object is
586*fae548d3Szrj      loaded.  */
587*fae548d3Szrj   const char *init_function;
588*fae548d3Szrj 
589*fae548d3Szrj   /* The function to call when the executable or shared object is
590*fae548d3Szrj      unloaded.  */
591*fae548d3Szrj   const char *fini_function;
592*fae548d3Szrj 
593*fae548d3Szrj   /* Number of relaxation passes.  Usually only one relaxation pass
594*fae548d3Szrj      is needed.  But a backend can have as many relaxation passes as
595*fae548d3Szrj      necessary.  During bfd_relax_section call, it is set to the
596*fae548d3Szrj      current pass, starting from 0.  */
597*fae548d3Szrj   int relax_pass;
598*fae548d3Szrj 
599*fae548d3Szrj   /* Number of relaxation trips.  This number is incremented every
600*fae548d3Szrj      time the relaxation pass is restarted due to a previous
601*fae548d3Szrj      relaxation returning true in *AGAIN.  */
602*fae548d3Szrj   int relax_trip;
603*fae548d3Szrj 
604*fae548d3Szrj   /* > 0 to treat protected data defined in the shared library as
605*fae548d3Szrj      reference external.  0 to treat it as internal.  -1 to let
606*fae548d3Szrj      backend to decide.  */
607*fae548d3Szrj   int extern_protected_data;
608*fae548d3Szrj 
609*fae548d3Szrj   /* 1 to make undefined weak symbols dynamic when building a dynamic
610*fae548d3Szrj      object.  0 to resolve undefined weak symbols to zero.  -1 to let
611*fae548d3Szrj      the backend decide.  */
612*fae548d3Szrj   int dynamic_undefined_weak;
613*fae548d3Szrj 
614*fae548d3Szrj   /* Non-zero if auto-import thunks for DATA items in pei386 DLLs
615*fae548d3Szrj      should be generated/linked against.  Set to 1 if this feature
616*fae548d3Szrj      is explicitly requested by the user, -1 if enabled by default.  */
617*fae548d3Szrj   int pei386_auto_import;
618*fae548d3Szrj 
619*fae548d3Szrj   /* Non-zero if runtime relocs for DATA items with non-zero addends
620*fae548d3Szrj      in pei386 DLLs should be generated.  Set to 1 if this feature
621*fae548d3Szrj      is explicitly requested by the user, -1 if enabled by default.  */
622*fae548d3Szrj   int pei386_runtime_pseudo_reloc;
623*fae548d3Szrj 
624*fae548d3Szrj   /* How many spare .dynamic DT_NULL entries should be added?  */
625*fae548d3Szrj   unsigned int spare_dynamic_tags;
626*fae548d3Szrj 
627*fae548d3Szrj   /* May be used to set DT_FLAGS for ELF. */
628*fae548d3Szrj   bfd_vma flags;
629*fae548d3Szrj 
630*fae548d3Szrj   /* May be used to set DT_FLAGS_1 for ELF. */
631*fae548d3Szrj   bfd_vma flags_1;
632*fae548d3Szrj 
633*fae548d3Szrj   /* Start and end of RELRO region.  */
634*fae548d3Szrj   bfd_vma relro_start, relro_end;
635*fae548d3Szrj 
636*fae548d3Szrj   /* List of symbols should be dynamic.  */
637*fae548d3Szrj   struct bfd_elf_dynamic_list *dynamic_list;
638*fae548d3Szrj 
639*fae548d3Szrj   /* The version information.  */
640*fae548d3Szrj   struct bfd_elf_version_tree *version_info;
641*fae548d3Szrj };
642*fae548d3Szrj 
643*fae548d3Szrj /* Some forward-definitions used by some callbacks.  */
644*fae548d3Szrj 
645*fae548d3Szrj struct elf_strtab_hash;
646*fae548d3Szrj struct elf_sym_strtab;
647*fae548d3Szrj 
648*fae548d3Szrj /* This structures holds a set of callback functions.  These are called
649*fae548d3Szrj    by the BFD linker routines.  */
650*fae548d3Szrj 
651*fae548d3Szrj struct bfd_link_callbacks
652*fae548d3Szrj {
653*fae548d3Szrj   /* A function which is called when an object is added from an
654*fae548d3Szrj      archive.  ABFD is the archive element being added.  NAME is the
655*fae548d3Szrj      name of the symbol which caused the archive element to be pulled
656*fae548d3Szrj      in.  This function may set *SUBSBFD to point to an alternative
657*fae548d3Szrj      BFD from which symbols should in fact be added in place of the
658*fae548d3Szrj      original BFD's symbols.  Returns TRUE if the object should be
659*fae548d3Szrj      added, FALSE if it should be skipped.  */
660*fae548d3Szrj   bfd_boolean (*add_archive_element)
661*fae548d3Szrj     (struct bfd_link_info *, bfd *abfd, const char *name, bfd **subsbfd);
662*fae548d3Szrj   /* A function which is called when a symbol is found with multiple
663*fae548d3Szrj      definitions.  H is the symbol which is defined multiple times.
664*fae548d3Szrj      NBFD is the new BFD, NSEC is the new section, and NVAL is the new
665*fae548d3Szrj      value.  NSEC may be bfd_com_section or bfd_ind_section.  */
666*fae548d3Szrj   void (*multiple_definition)
667*fae548d3Szrj     (struct bfd_link_info *, struct bfd_link_hash_entry *h,
668*fae548d3Szrj      bfd *nbfd, asection *nsec, bfd_vma nval);
669*fae548d3Szrj   /* A function which is called when a common symbol is defined
670*fae548d3Szrj      multiple times.  H is the symbol appearing multiple times.
671*fae548d3Szrj      NBFD is the BFD of the new symbol.  NTYPE is the type of the new
672*fae548d3Szrj      symbol, one of bfd_link_hash_defined, bfd_link_hash_common, or
673*fae548d3Szrj      bfd_link_hash_indirect.  If NTYPE is bfd_link_hash_common, NSIZE
674*fae548d3Szrj      is the size of the new symbol.  */
675*fae548d3Szrj   void (*multiple_common)
676*fae548d3Szrj     (struct bfd_link_info *, struct bfd_link_hash_entry *h,
677*fae548d3Szrj      bfd *nbfd, enum bfd_link_hash_type ntype, bfd_vma nsize);
678*fae548d3Szrj   /* A function which is called to add a symbol to a set.  ENTRY is
679*fae548d3Szrj      the link hash table entry for the set itself (e.g.,
680*fae548d3Szrj      __CTOR_LIST__).  RELOC is the relocation to use for an entry in
681*fae548d3Szrj      the set when generating a relocatable file, and is also used to
682*fae548d3Szrj      get the size of the entry when generating an executable file.
683*fae548d3Szrj      ABFD, SEC and VALUE identify the value to add to the set.  */
684*fae548d3Szrj   void (*add_to_set)
685*fae548d3Szrj     (struct bfd_link_info *, struct bfd_link_hash_entry *entry,
686*fae548d3Szrj      bfd_reloc_code_real_type reloc, bfd *abfd, asection *sec, bfd_vma value);
687*fae548d3Szrj   /* A function which is called when the name of a g++ constructor or
688*fae548d3Szrj      destructor is found.  This is only called by some object file
689*fae548d3Szrj      formats.  CONSTRUCTOR is TRUE for a constructor, FALSE for a
690*fae548d3Szrj      destructor.  This will use BFD_RELOC_CTOR when generating a
691*fae548d3Szrj      relocatable file.  NAME is the name of the symbol found.  ABFD,
692*fae548d3Szrj      SECTION and VALUE are the value of the symbol.  */
693*fae548d3Szrj   void (*constructor)
694*fae548d3Szrj     (struct bfd_link_info *, bfd_boolean constructor, const char *name,
695*fae548d3Szrj      bfd *abfd, asection *sec, bfd_vma value);
696*fae548d3Szrj   /* A function which is called to issue a linker warning.  For
697*fae548d3Szrj      example, this is called when there is a reference to a warning
698*fae548d3Szrj      symbol.  WARNING is the warning to be issued.  SYMBOL is the name
699*fae548d3Szrj      of the symbol which triggered the warning; it may be NULL if
700*fae548d3Szrj      there is none.  ABFD, SECTION and ADDRESS identify the location
701*fae548d3Szrj      which trigerred the warning; either ABFD or SECTION or both may
702*fae548d3Szrj      be NULL if the location is not known.  */
703*fae548d3Szrj   void (*warning)
704*fae548d3Szrj     (struct bfd_link_info *, const char *warning, const char *symbol,
705*fae548d3Szrj      bfd *abfd, asection *section, bfd_vma address);
706*fae548d3Szrj   /* A function which is called when a relocation is attempted against
707*fae548d3Szrj      an undefined symbol.  NAME is the symbol which is undefined.
708*fae548d3Szrj      ABFD, SECTION and ADDRESS identify the location from which the
709*fae548d3Szrj      reference is made. IS_FATAL indicates whether an undefined symbol is
710*fae548d3Szrj      a fatal error or not. In some cases SECTION may be NULL.  */
711*fae548d3Szrj   void (*undefined_symbol)
712*fae548d3Szrj     (struct bfd_link_info *, const char *name, bfd *abfd,
713*fae548d3Szrj      asection *section, bfd_vma address, bfd_boolean is_fatal);
714*fae548d3Szrj   /* A function which is called when a reloc overflow occurs. ENTRY is
715*fae548d3Szrj      the link hash table entry for the symbol the reloc is against.
716*fae548d3Szrj      NAME is the name of the local symbol or section the reloc is
717*fae548d3Szrj      against, RELOC_NAME is the name of the relocation, and ADDEND is
718*fae548d3Szrj      any addend that is used.  ABFD, SECTION and ADDRESS identify the
719*fae548d3Szrj      location at which the overflow occurs; if this is the result of a
720*fae548d3Szrj      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
721*fae548d3Szrj      ABFD will be NULL.  */
722*fae548d3Szrj   void (*reloc_overflow)
723*fae548d3Szrj     (struct bfd_link_info *, struct bfd_link_hash_entry *entry,
724*fae548d3Szrj      const char *name, const char *reloc_name, bfd_vma addend,
725*fae548d3Szrj      bfd *abfd, asection *section, bfd_vma address);
726*fae548d3Szrj   /* A function which is called when a dangerous reloc is performed.
727*fae548d3Szrj      MESSAGE is an appropriate message.
728*fae548d3Szrj      ABFD, SECTION and ADDRESS identify the location at which the
729*fae548d3Szrj      problem occurred; if this is the result of a
730*fae548d3Szrj      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
731*fae548d3Szrj      ABFD will be NULL.  */
732*fae548d3Szrj   void (*reloc_dangerous)
733*fae548d3Szrj     (struct bfd_link_info *, const char *message,
734*fae548d3Szrj      bfd *abfd, asection *section, bfd_vma address);
735*fae548d3Szrj   /* A function which is called when a reloc is found to be attached
736*fae548d3Szrj      to a symbol which is not being written out.  NAME is the name of
737*fae548d3Szrj      the symbol.  ABFD, SECTION and ADDRESS identify the location of
738*fae548d3Szrj      the reloc; if this is the result of a
739*fae548d3Szrj      bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
740*fae548d3Szrj      ABFD will be NULL.  */
741*fae548d3Szrj   void (*unattached_reloc)
742*fae548d3Szrj     (struct bfd_link_info *, const char *name,
743*fae548d3Szrj      bfd *abfd, asection *section, bfd_vma address);
744*fae548d3Szrj   /* A function which is called when a symbol in notice_hash is
745*fae548d3Szrj      defined or referenced.  H is the symbol, INH the indirect symbol
746*fae548d3Szrj      if applicable.  ABFD, SECTION and ADDRESS are the (new) value of
747*fae548d3Szrj      the symbol.  If SECTION is bfd_und_section, this is a reference.
748*fae548d3Szrj      FLAGS are the symbol BSF_* flags.  */
749*fae548d3Szrj   bfd_boolean (*notice)
750*fae548d3Szrj     (struct bfd_link_info *, struct bfd_link_hash_entry *h,
751*fae548d3Szrj      struct bfd_link_hash_entry *inh,
752*fae548d3Szrj      bfd *abfd, asection *section, bfd_vma address, flagword flags);
753*fae548d3Szrj   /* Error or warning link info message.  */
754*fae548d3Szrj   void (*einfo)
755*fae548d3Szrj     (const char *fmt, ...);
756*fae548d3Szrj   /* General link info message.  */
757*fae548d3Szrj   void (*info)
758*fae548d3Szrj     (const char *fmt, ...);
759*fae548d3Szrj   /* Message to be printed in linker map file.  */
760*fae548d3Szrj   void (*minfo)
761*fae548d3Szrj     (const char *fmt, ...);
762*fae548d3Szrj   /* This callback provides a chance for users of the BFD library to
763*fae548d3Szrj      override its decision about whether to place two adjacent sections
764*fae548d3Szrj      into the same segment.  */
765*fae548d3Szrj   bfd_boolean (*override_segment_assignment)
766*fae548d3Szrj     (struct bfd_link_info *, bfd * abfd,
767*fae548d3Szrj      asection * current_section, asection * previous_section,
768*fae548d3Szrj      bfd_boolean new_segment);
769*fae548d3Szrj   /* This callback provides a chance for callers of the BFD to examine the
770*fae548d3Szrj      ELF string table and symbol table once they are complete and indexes and
771*fae548d3Szrj      offsets assigned.  */
772*fae548d3Szrj   void (*examine_strtab)
773*fae548d3Szrj     (struct elf_sym_strtab *syms, bfd_size_type symcount,
774*fae548d3Szrj      struct elf_strtab_hash *symstrtab);
775*fae548d3Szrj   /* This callback should emit the CTF section into a non-loadable section in
776*fae548d3Szrj      the output BFD named .ctf or a name beginning with ".ctf.".  */
777*fae548d3Szrj   void (*emit_ctf)
778*fae548d3Szrj     (void);
779*fae548d3Szrj };
780*fae548d3Szrj 
781*fae548d3Szrj /* The linker builds link_order structures which tell the code how to
782*fae548d3Szrj    include input data in the output file.  */
783*fae548d3Szrj 
784*fae548d3Szrj /* These are the types of link_order structures.  */
785*fae548d3Szrj 
786*fae548d3Szrj enum bfd_link_order_type
787*fae548d3Szrj {
788*fae548d3Szrj   bfd_undefined_link_order,	/* Undefined.  */
789*fae548d3Szrj   bfd_indirect_link_order,	/* Built from a section.  */
790*fae548d3Szrj   bfd_data_link_order,		/* Set to explicit data.  */
791*fae548d3Szrj   bfd_section_reloc_link_order,	/* Relocate against a section.  */
792*fae548d3Szrj   bfd_symbol_reloc_link_order	/* Relocate against a symbol.  */
793*fae548d3Szrj };
794*fae548d3Szrj 
795*fae548d3Szrj /* This is the link_order structure itself.  These form a chain
796*fae548d3Szrj    attached to the output section whose contents they are describing.  */
797*fae548d3Szrj 
798*fae548d3Szrj struct bfd_link_order
799*fae548d3Szrj {
800*fae548d3Szrj   /* Next link_order in chain.  */
801*fae548d3Szrj   struct bfd_link_order *next;
802*fae548d3Szrj   /* Type of link_order.  */
803*fae548d3Szrj   enum bfd_link_order_type type;
804*fae548d3Szrj   /* Offset within output section.  */
805*fae548d3Szrj   bfd_vma offset;
806*fae548d3Szrj   /* Size within output section.  */
807*fae548d3Szrj   bfd_size_type size;
808*fae548d3Szrj   /* Type specific information.  */
809*fae548d3Szrj   union
810*fae548d3Szrj     {
811*fae548d3Szrj       struct
812*fae548d3Szrj 	{
813*fae548d3Szrj 	  /* Section to include.  If this is used, then
814*fae548d3Szrj 	     section->output_section must be the section the
815*fae548d3Szrj 	     link_order is attached to, section->output_offset must
816*fae548d3Szrj 	     equal the link_order offset field, and section->size
817*fae548d3Szrj 	     must equal the link_order size field.  Maybe these
818*fae548d3Szrj 	     restrictions should be relaxed someday.  */
819*fae548d3Szrj 	  asection *section;
820*fae548d3Szrj 	} indirect;
821*fae548d3Szrj       struct
822*fae548d3Szrj 	{
823*fae548d3Szrj 	  /* Size of contents, or zero when contents should be filled by
824*fae548d3Szrj 	     the architecture-dependent fill function.
825*fae548d3Szrj 	     A non-zero value allows filling of the output section
826*fae548d3Szrj 	     with an arbitrary repeated pattern.  */
827*fae548d3Szrj 	  unsigned int size;
828*fae548d3Szrj 	  /* Data to put into file.  */
829*fae548d3Szrj 	  bfd_byte *contents;
830*fae548d3Szrj 	} data;
831*fae548d3Szrj       struct
832*fae548d3Szrj 	{
833*fae548d3Szrj 	  /* Description of reloc to generate.  Used for
834*fae548d3Szrj 	     bfd_section_reloc_link_order and
835*fae548d3Szrj 	     bfd_symbol_reloc_link_order.  */
836*fae548d3Szrj 	  struct bfd_link_order_reloc *p;
837*fae548d3Szrj 	} reloc;
838*fae548d3Szrj     } u;
839*fae548d3Szrj };
840*fae548d3Szrj 
841*fae548d3Szrj /* A linker order of type bfd_section_reloc_link_order or
842*fae548d3Szrj    bfd_symbol_reloc_link_order means to create a reloc against a
843*fae548d3Szrj    section or symbol, respectively.  This is used to implement -Ur to
844*fae548d3Szrj    generate relocs for the constructor tables.  The
845*fae548d3Szrj    bfd_link_order_reloc structure describes the reloc that BFD should
846*fae548d3Szrj    create.  It is similar to a arelent, but I didn't use arelent
847*fae548d3Szrj    because the linker does not know anything about most symbols, and
848*fae548d3Szrj    any asymbol structure it creates will be partially meaningless.
849*fae548d3Szrj    This information could logically be in the bfd_link_order struct,
850*fae548d3Szrj    but I didn't want to waste the space since these types of relocs
851*fae548d3Szrj    are relatively rare.  */
852*fae548d3Szrj 
853*fae548d3Szrj struct bfd_link_order_reloc
854*fae548d3Szrj {
855*fae548d3Szrj   /* Reloc type.  */
856*fae548d3Szrj   bfd_reloc_code_real_type reloc;
857*fae548d3Szrj 
858*fae548d3Szrj   union
859*fae548d3Szrj     {
860*fae548d3Szrj       /* For type bfd_section_reloc_link_order, this is the section
861*fae548d3Szrj 	 the reloc should be against.  This must be a section in the
862*fae548d3Szrj 	 output BFD, not any of the input BFDs.  */
863*fae548d3Szrj       asection *section;
864*fae548d3Szrj       /* For type bfd_symbol_reloc_link_order, this is the name of the
865*fae548d3Szrj 	 symbol the reloc should be against.  */
866*fae548d3Szrj       const char *name;
867*fae548d3Szrj     } u;
868*fae548d3Szrj 
869*fae548d3Szrj   /* Addend to use.  The object file should contain zero.  The BFD
870*fae548d3Szrj      backend is responsible for filling in the contents of the object
871*fae548d3Szrj      file correctly.  For some object file formats (e.g., COFF) the
872*fae548d3Szrj      addend must be stored into in the object file, and for some
873*fae548d3Szrj      (e.g., SPARC a.out) it is kept in the reloc.  */
874*fae548d3Szrj   bfd_vma addend;
875*fae548d3Szrj };
876*fae548d3Szrj 
877*fae548d3Szrj /* Allocate a new link_order for a section.  */
878*fae548d3Szrj extern struct bfd_link_order *bfd_new_link_order (bfd *, asection *);
879*fae548d3Szrj 
880*fae548d3Szrj struct bfd_section_already_linked;
881*fae548d3Szrj 
882*fae548d3Szrj extern bfd_boolean bfd_section_already_linked_table_init (void);
883*fae548d3Szrj extern void bfd_section_already_linked_table_free (void);
884*fae548d3Szrj extern bfd_boolean _bfd_handle_already_linked
885*fae548d3Szrj   (struct bfd_section *, struct bfd_section_already_linked *,
886*fae548d3Szrj    struct bfd_link_info *);
887*fae548d3Szrj 
888*fae548d3Szrj extern struct bfd_section *_bfd_nearby_section
889*fae548d3Szrj   (bfd *, struct bfd_section *, bfd_vma);
890*fae548d3Szrj 
891*fae548d3Szrj extern void _bfd_fix_excluded_sec_syms
892*fae548d3Szrj   (bfd *, struct bfd_link_info *);
893*fae548d3Szrj 
894*fae548d3Szrj /* These structures are used to describe version information for the
895*fae548d3Szrj    ELF linker.  These structures could be manipulated entirely inside
896*fae548d3Szrj    BFD, but it would be a pain.  Instead, the regular linker sets up
897*fae548d3Szrj    these structures, and then passes them into BFD.  */
898*fae548d3Szrj 
899*fae548d3Szrj /* Glob pattern for a version.  */
900*fae548d3Szrj 
901*fae548d3Szrj struct bfd_elf_version_expr
902*fae548d3Szrj {
903*fae548d3Szrj   /* Next glob pattern for this version.  */
904*fae548d3Szrj   struct bfd_elf_version_expr *next;
905*fae548d3Szrj   /* Glob pattern.  */
906*fae548d3Szrj   const char *pattern;
907*fae548d3Szrj   /* Set if pattern is not a glob.  */
908*fae548d3Szrj   unsigned int literal : 1;
909*fae548d3Szrj   /* Defined by ".symver".  */
910*fae548d3Szrj   unsigned int symver : 1;
911*fae548d3Szrj   /* Defined by version script.  */
912*fae548d3Szrj   unsigned int script : 1;
913*fae548d3Szrj   /* Pattern type.  */
914*fae548d3Szrj #define BFD_ELF_VERSION_C_TYPE		1
915*fae548d3Szrj #define BFD_ELF_VERSION_CXX_TYPE	2
916*fae548d3Szrj #define BFD_ELF_VERSION_JAVA_TYPE	4
917*fae548d3Szrj   unsigned int mask : 3;
918*fae548d3Szrj };
919*fae548d3Szrj 
920*fae548d3Szrj struct bfd_elf_version_expr_head
921*fae548d3Szrj {
922*fae548d3Szrj   /* List of all patterns, both wildcards and non-wildcards.  */
923*fae548d3Szrj   struct bfd_elf_version_expr *list;
924*fae548d3Szrj   /* Hash table for non-wildcards.  */
925*fae548d3Szrj   void *htab;
926*fae548d3Szrj   /* Remaining patterns.  */
927*fae548d3Szrj   struct bfd_elf_version_expr *remaining;
928*fae548d3Szrj   /* What kind of pattern types are present in list (bitmask).  */
929*fae548d3Szrj   unsigned int mask;
930*fae548d3Szrj };
931*fae548d3Szrj 
932*fae548d3Szrj /* Version dependencies.  */
933*fae548d3Szrj 
934*fae548d3Szrj struct bfd_elf_version_deps
935*fae548d3Szrj {
936*fae548d3Szrj   /* Next dependency for this version.  */
937*fae548d3Szrj   struct bfd_elf_version_deps *next;
938*fae548d3Szrj   /* The version which this version depends upon.  */
939*fae548d3Szrj   struct bfd_elf_version_tree *version_needed;
940*fae548d3Szrj };
941*fae548d3Szrj 
942*fae548d3Szrj /* A node in the version tree.  */
943*fae548d3Szrj 
944*fae548d3Szrj struct bfd_elf_version_tree
945*fae548d3Szrj {
946*fae548d3Szrj   /* Next version.  */
947*fae548d3Szrj   struct bfd_elf_version_tree *next;
948*fae548d3Szrj   /* Name of this version.  */
949*fae548d3Szrj   const char *name;
950*fae548d3Szrj   /* Version number.  */
951*fae548d3Szrj   unsigned int vernum;
952*fae548d3Szrj   /* Regular expressions for global symbols in this version.  */
953*fae548d3Szrj   struct bfd_elf_version_expr_head globals;
954*fae548d3Szrj   /* Regular expressions for local symbols in this version.  */
955*fae548d3Szrj   struct bfd_elf_version_expr_head locals;
956*fae548d3Szrj   /* List of versions which this version depends upon.  */
957*fae548d3Szrj   struct bfd_elf_version_deps *deps;
958*fae548d3Szrj   /* Index of the version name.  This is used within BFD.  */
959*fae548d3Szrj   unsigned int name_indx;
960*fae548d3Szrj   /* Whether this version tree was used.  This is used within BFD.  */
961*fae548d3Szrj   int used;
962*fae548d3Szrj   /* Matching hook.  */
963*fae548d3Szrj   struct bfd_elf_version_expr *(*match)
964*fae548d3Szrj     (struct bfd_elf_version_expr_head *head,
965*fae548d3Szrj      struct bfd_elf_version_expr *prev, const char *sym);
966*fae548d3Szrj };
967*fae548d3Szrj 
968*fae548d3Szrj struct bfd_elf_dynamic_list
969*fae548d3Szrj {
970*fae548d3Szrj   struct bfd_elf_version_expr_head head;
971*fae548d3Szrj   struct bfd_elf_version_expr *(*match)
972*fae548d3Szrj     (struct bfd_elf_version_expr_head *head,
973*fae548d3Szrj      struct bfd_elf_version_expr *prev, const char *sym);
974*fae548d3Szrj };
975*fae548d3Szrj 
976*fae548d3Szrj #endif
977