xref: /dflybsd-src/contrib/binutils-2.27/bfd/elf-bfd.h (revision e656dc90e3d65d744d534af2f5ea88cf8101ebcf)
1*a9fa9459Szrj /* BFD back-end data structures for ELF files.
2*a9fa9459Szrj    Copyright (C) 1992-2016 Free Software Foundation, Inc.
3*a9fa9459Szrj    Written by Cygnus Support.
4*a9fa9459Szrj 
5*a9fa9459Szrj    This file is part of BFD, the Binary File Descriptor library.
6*a9fa9459Szrj 
7*a9fa9459Szrj    This program is free software; you can redistribute it and/or modify
8*a9fa9459Szrj    it under the terms of the GNU General Public License as published by
9*a9fa9459Szrj    the Free Software Foundation; either version 3 of the License, or
10*a9fa9459Szrj    (at your option) any later version.
11*a9fa9459Szrj 
12*a9fa9459Szrj    This program is distributed in the hope that it will be useful,
13*a9fa9459Szrj    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*a9fa9459Szrj    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*a9fa9459Szrj    GNU General Public License for more details.
16*a9fa9459Szrj 
17*a9fa9459Szrj    You should have received a copy of the GNU General Public License
18*a9fa9459Szrj    along with this program; if not, write to the Free Software
19*a9fa9459Szrj    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20*a9fa9459Szrj    MA 02110-1301, USA.  */
21*a9fa9459Szrj 
22*a9fa9459Szrj #ifndef _LIBELF_H_
23*a9fa9459Szrj #define _LIBELF_H_ 1
24*a9fa9459Szrj 
25*a9fa9459Szrj #include "elf/common.h"
26*a9fa9459Szrj #include "elf/external.h"
27*a9fa9459Szrj #include "elf/internal.h"
28*a9fa9459Szrj #include "bfdlink.h"
29*a9fa9459Szrj 
30*a9fa9459Szrj #ifdef __cplusplus
31*a9fa9459Szrj extern "C" {
32*a9fa9459Szrj #endif
33*a9fa9459Szrj 
34*a9fa9459Szrj /* The number of entries in a section is its size divided by the size
35*a9fa9459Szrj    of a single entry.  This is normally only applicable to reloc and
36*a9fa9459Szrj    symbol table sections.
37*a9fa9459Szrj    PR 9934: It is possible to have relocations that do not refer to
38*a9fa9459Szrj    symbols, thus it is also possible to have a relocation section in
39*a9fa9459Szrj    an object file, but no symbol table.  */
40*a9fa9459Szrj #define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_entsize > 0 ? (shdr)->sh_size / (shdr)->sh_entsize : 0)
41*a9fa9459Szrj 
42*a9fa9459Szrj /* If size isn't specified as 64 or 32, NAME macro should fail.  */
43*a9fa9459Szrj #ifndef NAME
44*a9fa9459Szrj #if ARCH_SIZE == 64
45*a9fa9459Szrj #define NAME(x, y) x ## 64 ## _ ## y
46*a9fa9459Szrj #endif
47*a9fa9459Szrj #if ARCH_SIZE == 32
48*a9fa9459Szrj #define NAME(x, y) x ## 32 ## _ ## y
49*a9fa9459Szrj #endif
50*a9fa9459Szrj #endif
51*a9fa9459Szrj 
52*a9fa9459Szrj #ifndef NAME
53*a9fa9459Szrj #define NAME(x, y) x ## NOSIZE ## _ ## y
54*a9fa9459Szrj #endif
55*a9fa9459Szrj 
56*a9fa9459Szrj #define ElfNAME(X)	NAME(Elf,X)
57*a9fa9459Szrj #define elfNAME(X)	NAME(elf,X)
58*a9fa9459Szrj 
59*a9fa9459Szrj /* Information held for an ELF symbol.  The first field is the
60*a9fa9459Szrj    corresponding asymbol.  Every symbol is an ELF file is actually a
61*a9fa9459Szrj    pointer to this structure, although it is often handled as a
62*a9fa9459Szrj    pointer to an asymbol.  */
63*a9fa9459Szrj 
64*a9fa9459Szrj typedef struct
65*a9fa9459Szrj {
66*a9fa9459Szrj   /* The BFD symbol.  */
67*a9fa9459Szrj   asymbol symbol;
68*a9fa9459Szrj   /* ELF symbol information.  */
69*a9fa9459Szrj   Elf_Internal_Sym internal_elf_sym;
70*a9fa9459Szrj   /* Backend specific information.  */
71*a9fa9459Szrj   union
72*a9fa9459Szrj     {
73*a9fa9459Szrj       unsigned int hppa_arg_reloc;
74*a9fa9459Szrj       void *mips_extr;
75*a9fa9459Szrj       void *any;
76*a9fa9459Szrj     }
77*a9fa9459Szrj   tc_data;
78*a9fa9459Szrj 
79*a9fa9459Szrj   /* Version information.  This is from an Elf_Internal_Versym
80*a9fa9459Szrj      structure in a SHT_GNU_versym section.  It is zero if there is no
81*a9fa9459Szrj      version information.  */
82*a9fa9459Szrj   unsigned short version;
83*a9fa9459Szrj 
84*a9fa9459Szrj } elf_symbol_type;
85*a9fa9459Szrj 
86*a9fa9459Szrj struct elf_strtab_hash;
87*a9fa9459Szrj struct got_entry;
88*a9fa9459Szrj struct plt_entry;
89*a9fa9459Szrj 
90*a9fa9459Szrj union gotplt_union
91*a9fa9459Szrj   {
92*a9fa9459Szrj     bfd_signed_vma refcount;
93*a9fa9459Szrj     bfd_vma offset;
94*a9fa9459Szrj     struct got_entry *glist;
95*a9fa9459Szrj     struct plt_entry *plist;
96*a9fa9459Szrj   };
97*a9fa9459Szrj 
98*a9fa9459Szrj struct elf_link_virtual_table_entry
99*a9fa9459Szrj   {
100*a9fa9459Szrj     /* Virtual table entry use information.  This array is nominally of size
101*a9fa9459Szrj        size/sizeof(target_void_pointer), though we have to be able to assume
102*a9fa9459Szrj        and track a size while the symbol is still undefined.  It is indexed
103*a9fa9459Szrj        via offset/sizeof(target_void_pointer).  */
104*a9fa9459Szrj     size_t size;
105*a9fa9459Szrj     bfd_boolean *used;
106*a9fa9459Szrj 
107*a9fa9459Szrj     /* Virtual table derivation info.  */
108*a9fa9459Szrj     struct elf_link_hash_entry *parent;
109*a9fa9459Szrj   };
110*a9fa9459Szrj 
111*a9fa9459Szrj /* ELF symbol version.  */
112*a9fa9459Szrj enum elf_symbol_version
113*a9fa9459Szrj   {
114*a9fa9459Szrj     unknown = 0,
115*a9fa9459Szrj     unversioned,
116*a9fa9459Szrj     versioned,
117*a9fa9459Szrj     versioned_hidden
118*a9fa9459Szrj   };
119*a9fa9459Szrj 
120*a9fa9459Szrj /* ELF linker hash table entries.  */
121*a9fa9459Szrj 
122*a9fa9459Szrj struct elf_link_hash_entry
123*a9fa9459Szrj {
124*a9fa9459Szrj   struct bfd_link_hash_entry root;
125*a9fa9459Szrj 
126*a9fa9459Szrj   /* Symbol index in output file.  This is initialized to -1.  It is
127*a9fa9459Szrj      set to -2 if the symbol is used by a reloc.  It is set to -3 if
128*a9fa9459Szrj      this symbol is defined in a discarded section.  */
129*a9fa9459Szrj   long indx;
130*a9fa9459Szrj 
131*a9fa9459Szrj   /* Symbol index as a dynamic symbol.  Initialized to -1, and remains
132*a9fa9459Szrj      -1 if this is not a dynamic symbol.  */
133*a9fa9459Szrj   /* ??? Note that this is consistently used as a synonym for tests
134*a9fa9459Szrj      against whether we can perform various simplifying transformations
135*a9fa9459Szrj      to the code.  (E.g. changing a pc-relative jump to a PLT entry
136*a9fa9459Szrj      into a pc-relative jump to the target function.)  That test, which
137*a9fa9459Szrj      is often relatively complex, and someplaces wrong or incomplete,
138*a9fa9459Szrj      should really be replaced by a predicate in elflink.c.
139*a9fa9459Szrj 
140*a9fa9459Szrj      End result: this field -1 does not indicate that the symbol is
141*a9fa9459Szrj      not in the dynamic symbol table, but rather that the symbol is
142*a9fa9459Szrj      not visible outside this DSO.  */
143*a9fa9459Szrj   long dynindx;
144*a9fa9459Szrj 
145*a9fa9459Szrj   /* If this symbol requires an entry in the global offset table, the
146*a9fa9459Szrj      processor specific backend uses this field to track usage and
147*a9fa9459Szrj      final offset.  Two schemes are supported:  The first assumes that
148*a9fa9459Szrj      a symbol may only have one GOT entry, and uses REFCOUNT until
149*a9fa9459Szrj      size_dynamic_sections, at which point the contents of the .got is
150*a9fa9459Szrj      fixed.  Afterward, if OFFSET is -1, then the symbol does not
151*a9fa9459Szrj      require a global offset table entry.  The second scheme allows
152*a9fa9459Szrj      multiple GOT entries per symbol, managed via a linked list
153*a9fa9459Szrj      pointed to by GLIST.  */
154*a9fa9459Szrj   union gotplt_union got;
155*a9fa9459Szrj 
156*a9fa9459Szrj   /* Same, but tracks a procedure linkage table entry.  */
157*a9fa9459Szrj   union gotplt_union plt;
158*a9fa9459Szrj 
159*a9fa9459Szrj   /* Symbol size.  */
160*a9fa9459Szrj   bfd_size_type size;
161*a9fa9459Szrj 
162*a9fa9459Szrj   /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.).  */
163*a9fa9459Szrj   unsigned int type : 8;
164*a9fa9459Szrj 
165*a9fa9459Szrj   /* Symbol st_other value, symbol visibility.  */
166*a9fa9459Szrj   unsigned int other : 8;
167*a9fa9459Szrj 
168*a9fa9459Szrj   /* The symbol's st_target_internal value (see Elf_Internal_Sym).  */
169*a9fa9459Szrj   unsigned int target_internal : 8;
170*a9fa9459Szrj 
171*a9fa9459Szrj   /* Symbol is referenced by a non-shared object (other than the object
172*a9fa9459Szrj      in which it is defined).  */
173*a9fa9459Szrj   unsigned int ref_regular : 1;
174*a9fa9459Szrj   /* Symbol is defined by a non-shared object.  */
175*a9fa9459Szrj   unsigned int def_regular : 1;
176*a9fa9459Szrj   /* Symbol is referenced by a shared object.  */
177*a9fa9459Szrj   unsigned int ref_dynamic : 1;
178*a9fa9459Szrj   /* Symbol is defined by a shared object.  */
179*a9fa9459Szrj   unsigned int def_dynamic : 1;
180*a9fa9459Szrj   /* Symbol has a non-weak reference from a non-shared object (other than
181*a9fa9459Szrj      the object in which it is defined).  */
182*a9fa9459Szrj   unsigned int ref_regular_nonweak : 1;
183*a9fa9459Szrj   /* Dynamic symbol has been adjustd.  */
184*a9fa9459Szrj   unsigned int dynamic_adjusted : 1;
185*a9fa9459Szrj   /* Symbol needs a copy reloc.  */
186*a9fa9459Szrj   unsigned int needs_copy : 1;
187*a9fa9459Szrj   /* Symbol needs a procedure linkage table entry.  */
188*a9fa9459Szrj   unsigned int needs_plt : 1;
189*a9fa9459Szrj   /* Symbol appears in a non-ELF input file.  */
190*a9fa9459Szrj   unsigned int non_elf : 1;
191*a9fa9459Szrj   /* Symbol version information.  */
192*a9fa9459Szrj   ENUM_BITFIELD (elf_symbol_version) versioned : 2;
193*a9fa9459Szrj   /* Symbol was forced to local scope due to a version script file.  */
194*a9fa9459Szrj   unsigned int forced_local : 1;
195*a9fa9459Szrj   /* Symbol was forced to be dynamic due to a version script file.  */
196*a9fa9459Szrj   unsigned int dynamic : 1;
197*a9fa9459Szrj   /* Symbol was marked during garbage collection.  */
198*a9fa9459Szrj   unsigned int mark : 1;
199*a9fa9459Szrj   /* Symbol is referenced by a non-GOT/non-PLT relocation.  This is
200*a9fa9459Szrj      not currently set by all the backends.  */
201*a9fa9459Szrj   unsigned int non_got_ref : 1;
202*a9fa9459Szrj   /* Symbol has a definition in a shared object.
203*a9fa9459Szrj      FIXME: There is no real need for this field if def_dynamic is never
204*a9fa9459Szrj      cleared and all places that test def_dynamic also test def_regular.  */
205*a9fa9459Szrj   unsigned int dynamic_def : 1;
206*a9fa9459Szrj   /* Symbol has a non-weak reference from a shared object.  */
207*a9fa9459Szrj   unsigned int ref_dynamic_nonweak : 1;
208*a9fa9459Szrj   /* Symbol is referenced with a relocation where C/C++ pointer equality
209*a9fa9459Szrj      matters.  */
210*a9fa9459Szrj   unsigned int pointer_equality_needed : 1;
211*a9fa9459Szrj   /* Symbol is a unique global symbol.  */
212*a9fa9459Szrj   unsigned int unique_global : 1;
213*a9fa9459Szrj   /* Symbol is defined by a shared library with non-default visibility
214*a9fa9459Szrj      in a read/write section.  */
215*a9fa9459Szrj   unsigned int protected_def : 1;
216*a9fa9459Szrj 
217*a9fa9459Szrj   /* String table index in .dynstr if this is a dynamic symbol.  */
218*a9fa9459Szrj   unsigned long dynstr_index;
219*a9fa9459Szrj 
220*a9fa9459Szrj   union
221*a9fa9459Szrj   {
222*a9fa9459Szrj     /* If this is a weak defined symbol from a dynamic object, this
223*a9fa9459Szrj        field points to a defined symbol with the same value, if there is
224*a9fa9459Szrj        one.  Otherwise it is NULL.  */
225*a9fa9459Szrj     struct elf_link_hash_entry *weakdef;
226*a9fa9459Szrj 
227*a9fa9459Szrj     /* Hash value of the name computed using the ELF hash function.
228*a9fa9459Szrj        Used part way through size_dynamic_sections, after we've finished
229*a9fa9459Szrj        with weakdefs.  */
230*a9fa9459Szrj     unsigned long elf_hash_value;
231*a9fa9459Szrj   } u;
232*a9fa9459Szrj 
233*a9fa9459Szrj   /* Version information.  */
234*a9fa9459Szrj   union
235*a9fa9459Szrj   {
236*a9fa9459Szrj     /* This field is used for a symbol which is not defined in a
237*a9fa9459Szrj        regular object.  It points to the version information read in
238*a9fa9459Szrj        from the dynamic object.  */
239*a9fa9459Szrj     Elf_Internal_Verdef *verdef;
240*a9fa9459Szrj     /* This field is used for a symbol which is defined in a regular
241*a9fa9459Szrj        object.  It is set up in size_dynamic_sections.  It points to
242*a9fa9459Szrj        the version information we should write out for this symbol.  */
243*a9fa9459Szrj     struct bfd_elf_version_tree *vertree;
244*a9fa9459Szrj   } verinfo;
245*a9fa9459Szrj 
246*a9fa9459Szrj   struct elf_link_virtual_table_entry *vtable;
247*a9fa9459Szrj };
248*a9fa9459Szrj 
249*a9fa9459Szrj /* Will references to this symbol always reference the symbol
250*a9fa9459Szrj    in this object?  */
251*a9fa9459Szrj #define SYMBOL_REFERENCES_LOCAL(INFO, H) \
252*a9fa9459Szrj   _bfd_elf_symbol_refs_local_p (H, INFO, 0)
253*a9fa9459Szrj 
254*a9fa9459Szrj /* Will _calls_ to this symbol always call the version in this object?  */
255*a9fa9459Szrj #define SYMBOL_CALLS_LOCAL(INFO, H) \
256*a9fa9459Szrj   _bfd_elf_symbol_refs_local_p (H, INFO, 1)
257*a9fa9459Szrj 
258*a9fa9459Szrj /* Common symbols that are turned into definitions don't have the
259*a9fa9459Szrj    DEF_REGULAR flag set, so they might appear to be undefined.
260*a9fa9459Szrj    Symbols defined in linker scripts also don't have DEF_REGULAR set.  */
261*a9fa9459Szrj #define ELF_COMMON_DEF_P(H) \
262*a9fa9459Szrj   (!(H)->def_regular							\
263*a9fa9459Szrj    && !(H)->def_dynamic							\
264*a9fa9459Szrj    && (H)->root.type == bfd_link_hash_defined)
265*a9fa9459Szrj 
266*a9fa9459Szrj /* Records local symbols to be emitted in the dynamic symbol table.  */
267*a9fa9459Szrj 
268*a9fa9459Szrj struct elf_link_local_dynamic_entry
269*a9fa9459Szrj {
270*a9fa9459Szrj   struct elf_link_local_dynamic_entry *next;
271*a9fa9459Szrj 
272*a9fa9459Szrj   /* The input bfd this symbol came from.  */
273*a9fa9459Szrj   bfd *input_bfd;
274*a9fa9459Szrj 
275*a9fa9459Szrj   /* The index of the local symbol being copied.  */
276*a9fa9459Szrj   long input_indx;
277*a9fa9459Szrj 
278*a9fa9459Szrj   /* The index in the outgoing dynamic symbol table.  */
279*a9fa9459Szrj   long dynindx;
280*a9fa9459Szrj 
281*a9fa9459Szrj   /* A copy of the input symbol.  */
282*a9fa9459Szrj   Elf_Internal_Sym isym;
283*a9fa9459Szrj };
284*a9fa9459Szrj 
285*a9fa9459Szrj struct elf_link_loaded_list
286*a9fa9459Szrj {
287*a9fa9459Szrj   struct elf_link_loaded_list *next;
288*a9fa9459Szrj   bfd *abfd;
289*a9fa9459Szrj };
290*a9fa9459Szrj 
291*a9fa9459Szrj /* Structures used by the eh_frame optimization code.  */
292*a9fa9459Szrj struct eh_cie_fde
293*a9fa9459Szrj {
294*a9fa9459Szrj   union {
295*a9fa9459Szrj     struct {
296*a9fa9459Szrj       /* If REMOVED == 1, this is the CIE that the FDE originally used.
297*a9fa9459Szrj 	 The CIE belongs to the same .eh_frame input section as the FDE.
298*a9fa9459Szrj 
299*a9fa9459Szrj 	 If REMOVED == 0, this is the CIE that we have chosen to use for
300*a9fa9459Szrj 	 the output FDE.  The CIE's REMOVED field is also 0, but the CIE
301*a9fa9459Szrj 	 might belong to a different .eh_frame input section from the FDE.
302*a9fa9459Szrj 
303*a9fa9459Szrj 	 May be NULL to signify that the FDE should be discarded.  */
304*a9fa9459Szrj       struct eh_cie_fde *cie_inf;
305*a9fa9459Szrj       struct eh_cie_fde *next_for_section;
306*a9fa9459Szrj     } fde;
307*a9fa9459Szrj     struct {
308*a9fa9459Szrj       /* CIEs have three states:
309*a9fa9459Szrj 
310*a9fa9459Szrj 	 - REMOVED && !MERGED: Slated for removal because we haven't yet
311*a9fa9459Szrj 	   proven that an FDE needs it.  FULL_CIE, if nonnull, points to
312*a9fa9459Szrj 	   more detailed information about the CIE.
313*a9fa9459Szrj 
314*a9fa9459Szrj 	 - REMOVED && MERGED: We have merged this CIE with MERGED_WITH,
315*a9fa9459Szrj 	   which may not belong to the same input section.
316*a9fa9459Szrj 
317*a9fa9459Szrj 	 - !REMOVED: We have decided to keep this CIE.  SEC is the
318*a9fa9459Szrj 	   .eh_frame input section that contains the CIE.  */
319*a9fa9459Szrj       union {
320*a9fa9459Szrj 	struct cie *full_cie;
321*a9fa9459Szrj  	struct eh_cie_fde *merged_with;
322*a9fa9459Szrj  	asection *sec;
323*a9fa9459Szrj       } u;
324*a9fa9459Szrj 
325*a9fa9459Szrj       /* The offset of the personality data from the start of the CIE,
326*a9fa9459Szrj 	 or 0 if the CIE doesn't have any.  */
327*a9fa9459Szrj       unsigned int personality_offset : 8;
328*a9fa9459Szrj 
329*a9fa9459Szrj       /* True if we have marked relocations associated with this CIE.  */
330*a9fa9459Szrj       unsigned int gc_mark : 1;
331*a9fa9459Szrj 
332*a9fa9459Szrj       /* True if we have decided to turn an absolute LSDA encoding into
333*a9fa9459Szrj 	 a PC-relative one.  */
334*a9fa9459Szrj       unsigned int make_lsda_relative : 1;
335*a9fa9459Szrj 
336*a9fa9459Szrj       /* True if we have decided to turn an absolute personality
337*a9fa9459Szrj 	 encoding into a PC-relative one.  */
338*a9fa9459Szrj       unsigned int make_per_encoding_relative : 1;
339*a9fa9459Szrj 
340*a9fa9459Szrj       /* True if the CIE contains personality data and if that
341*a9fa9459Szrj 	 data uses a PC-relative encoding.  Always true when
342*a9fa9459Szrj 	 make_per_encoding_relative is.  */
343*a9fa9459Szrj       unsigned int per_encoding_relative : 1;
344*a9fa9459Szrj 
345*a9fa9459Szrj       /* True if we need to add an 'R' (FDE encoding) entry to the
346*a9fa9459Szrj 	 CIE's augmentation data.  */
347*a9fa9459Szrj       unsigned int add_fde_encoding : 1;
348*a9fa9459Szrj 
349*a9fa9459Szrj       /* True if we have merged this CIE with another.  */
350*a9fa9459Szrj       unsigned int merged : 1;
351*a9fa9459Szrj 
352*a9fa9459Szrj       /* Unused bits.  */
353*a9fa9459Szrj       unsigned int pad1 : 18;
354*a9fa9459Szrj     } cie;
355*a9fa9459Szrj   } u;
356*a9fa9459Szrj   unsigned int reloc_index;
357*a9fa9459Szrj   unsigned int size;
358*a9fa9459Szrj   unsigned int offset;
359*a9fa9459Szrj   unsigned int new_offset;
360*a9fa9459Szrj   unsigned int fde_encoding : 8;
361*a9fa9459Szrj   unsigned int lsda_encoding : 8;
362*a9fa9459Szrj   unsigned int lsda_offset : 8;
363*a9fa9459Szrj 
364*a9fa9459Szrj   /* True if this entry represents a CIE, false if it represents an FDE.  */
365*a9fa9459Szrj   unsigned int cie : 1;
366*a9fa9459Szrj 
367*a9fa9459Szrj   /* True if this entry is currently marked for removal.  */
368*a9fa9459Szrj   unsigned int removed : 1;
369*a9fa9459Szrj 
370*a9fa9459Szrj   /* True if we need to add a 'z' (augmentation size) entry to the CIE's
371*a9fa9459Szrj      augmentation data, and an associated byte to each of the CIE's FDEs.  */
372*a9fa9459Szrj   unsigned int add_augmentation_size : 1;
373*a9fa9459Szrj 
374*a9fa9459Szrj   /* True if we have decided to convert absolute FDE relocations into
375*a9fa9459Szrj      relative ones.  This applies to the first relocation in the FDE,
376*a9fa9459Szrj      which is against the code that the FDE describes.  */
377*a9fa9459Szrj   unsigned int make_relative : 1;
378*a9fa9459Szrj 
379*a9fa9459Szrj   /* Unused bits.  */
380*a9fa9459Szrj   unsigned int pad1 : 4;
381*a9fa9459Szrj 
382*a9fa9459Szrj   unsigned int *set_loc;
383*a9fa9459Szrj };
384*a9fa9459Szrj 
385*a9fa9459Szrj struct eh_frame_sec_info
386*a9fa9459Szrj {
387*a9fa9459Szrj   unsigned int count;
388*a9fa9459Szrj   struct cie *cies;
389*a9fa9459Szrj   struct eh_cie_fde entry[1];
390*a9fa9459Szrj };
391*a9fa9459Szrj 
392*a9fa9459Szrj struct eh_frame_array_ent
393*a9fa9459Szrj {
394*a9fa9459Szrj   bfd_vma initial_loc;
395*a9fa9459Szrj   bfd_size_type range;
396*a9fa9459Szrj   bfd_vma fde;
397*a9fa9459Szrj };
398*a9fa9459Szrj 
399*a9fa9459Szrj struct htab;
400*a9fa9459Szrj 
401*a9fa9459Szrj #define DWARF2_EH_HDR 1
402*a9fa9459Szrj #define COMPACT_EH_HDR 2
403*a9fa9459Szrj 
404*a9fa9459Szrj /* Endian-neutral code indicating that a function cannot be unwound.  */
405*a9fa9459Szrj #define COMPACT_EH_CANT_UNWIND_OPCODE 0x015d5d01
406*a9fa9459Szrj 
407*a9fa9459Szrj struct dwarf_eh_frame_hdr_info
408*a9fa9459Szrj {
409*a9fa9459Szrj   struct htab *cies;
410*a9fa9459Szrj   unsigned int fde_count;
411*a9fa9459Szrj   /* TRUE if .eh_frame_hdr should contain the sorted search table.
412*a9fa9459Szrj      We build it if we successfully read all .eh_frame input sections
413*a9fa9459Szrj      and recognize them.  */
414*a9fa9459Szrj   bfd_boolean table;
415*a9fa9459Szrj   struct eh_frame_array_ent *array;
416*a9fa9459Szrj };
417*a9fa9459Szrj 
418*a9fa9459Szrj struct compact_eh_frame_hdr_info
419*a9fa9459Szrj {
420*a9fa9459Szrj   unsigned int allocated_entries;
421*a9fa9459Szrj   /* eh_frame_entry fragments.  */
422*a9fa9459Szrj   asection **entries;
423*a9fa9459Szrj };
424*a9fa9459Szrj 
425*a9fa9459Szrj struct eh_frame_hdr_info
426*a9fa9459Szrj {
427*a9fa9459Szrj   asection *hdr_sec;
428*a9fa9459Szrj   unsigned int array_count;
429*a9fa9459Szrj   bfd_boolean frame_hdr_is_compact;
430*a9fa9459Szrj   union
431*a9fa9459Szrj     {
432*a9fa9459Szrj       struct dwarf_eh_frame_hdr_info dwarf;
433*a9fa9459Szrj       struct compact_eh_frame_hdr_info compact;
434*a9fa9459Szrj     }
435*a9fa9459Szrj   u;
436*a9fa9459Szrj };
437*a9fa9459Szrj 
438*a9fa9459Szrj /* Enum used to identify target specific extensions to the elf_obj_tdata
439*a9fa9459Szrj    and elf_link_hash_table structures.  Note the enums deliberately start
440*a9fa9459Szrj    from 1 so that we can detect an uninitialized field.  The generic value
441*a9fa9459Szrj    is last so that additions to this enum do not need to modify more than
442*a9fa9459Szrj    one line.  */
443*a9fa9459Szrj enum elf_target_id
444*a9fa9459Szrj {
445*a9fa9459Szrj   AARCH64_ELF_DATA = 1,
446*a9fa9459Szrj   ALPHA_ELF_DATA,
447*a9fa9459Szrj   ARM_ELF_DATA,
448*a9fa9459Szrj   AVR_ELF_DATA,
449*a9fa9459Szrj   BFIN_ELF_DATA,
450*a9fa9459Szrj   CRIS_ELF_DATA,
451*a9fa9459Szrj   FRV_ELF_DATA,
452*a9fa9459Szrj   HPPA32_ELF_DATA,
453*a9fa9459Szrj   HPPA64_ELF_DATA,
454*a9fa9459Szrj   I386_ELF_DATA,
455*a9fa9459Szrj   IA64_ELF_DATA,
456*a9fa9459Szrj   LM32_ELF_DATA,
457*a9fa9459Szrj   M32R_ELF_DATA,
458*a9fa9459Szrj   M68HC11_ELF_DATA,
459*a9fa9459Szrj   M68K_ELF_DATA,
460*a9fa9459Szrj   METAG_ELF_DATA,
461*a9fa9459Szrj   MICROBLAZE_ELF_DATA,
462*a9fa9459Szrj   MIPS_ELF_DATA,
463*a9fa9459Szrj   MN10300_ELF_DATA,
464*a9fa9459Szrj   NDS32_ELF_DATA,
465*a9fa9459Szrj   NIOS2_ELF_DATA,
466*a9fa9459Szrj   OR1K_ELF_DATA,
467*a9fa9459Szrj   PPC32_ELF_DATA,
468*a9fa9459Szrj   PPC64_ELF_DATA,
469*a9fa9459Szrj   S390_ELF_DATA,
470*a9fa9459Szrj   SH_ELF_DATA,
471*a9fa9459Szrj   SPARC_ELF_DATA,
472*a9fa9459Szrj   SPU_ELF_DATA,
473*a9fa9459Szrj   TIC6X_ELF_DATA,
474*a9fa9459Szrj   X86_64_ELF_DATA,
475*a9fa9459Szrj   XTENSA_ELF_DATA,
476*a9fa9459Szrj   XGATE_ELF_DATA,
477*a9fa9459Szrj   TILEGX_ELF_DATA,
478*a9fa9459Szrj   TILEPRO_ELF_DATA,
479*a9fa9459Szrj   GENERIC_ELF_DATA
480*a9fa9459Szrj };
481*a9fa9459Szrj 
482*a9fa9459Szrj struct elf_sym_strtab
483*a9fa9459Szrj {
484*a9fa9459Szrj   Elf_Internal_Sym sym;
485*a9fa9459Szrj   unsigned long dest_index;
486*a9fa9459Szrj   unsigned long destshndx_index;
487*a9fa9459Szrj };
488*a9fa9459Szrj 
489*a9fa9459Szrj /* ELF linker hash table.  */
490*a9fa9459Szrj 
491*a9fa9459Szrj struct elf_link_hash_table
492*a9fa9459Szrj {
493*a9fa9459Szrj   struct bfd_link_hash_table root;
494*a9fa9459Szrj 
495*a9fa9459Szrj   /* An identifier used to distinguish different target
496*a9fa9459Szrj      specific extensions to this structure.  */
497*a9fa9459Szrj   enum elf_target_id hash_table_id;
498*a9fa9459Szrj 
499*a9fa9459Szrj   /* Whether we have created the special dynamic sections required
500*a9fa9459Szrj      when linking against or generating a shared object.  */
501*a9fa9459Szrj   bfd_boolean dynamic_sections_created;
502*a9fa9459Szrj 
503*a9fa9459Szrj   /* True if this target has relocatable executables, so needs dynamic
504*a9fa9459Szrj      section symbols.  */
505*a9fa9459Szrj   bfd_boolean is_relocatable_executable;
506*a9fa9459Szrj 
507*a9fa9459Szrj   /* The BFD used to hold special sections created by the linker.
508*a9fa9459Szrj      This will be the first BFD found which requires these sections to
509*a9fa9459Szrj      be created.  */
510*a9fa9459Szrj   bfd *dynobj;
511*a9fa9459Szrj 
512*a9fa9459Szrj   /* The value to use when initialising got.refcount/offset and
513*a9fa9459Szrj      plt.refcount/offset in an elf_link_hash_entry.  Set to zero when
514*a9fa9459Szrj      the values are refcounts.  Set to init_got_offset/init_plt_offset
515*a9fa9459Szrj      in size_dynamic_sections when the values may be offsets.  */
516*a9fa9459Szrj   union gotplt_union init_got_refcount;
517*a9fa9459Szrj   union gotplt_union init_plt_refcount;
518*a9fa9459Szrj 
519*a9fa9459Szrj   /* The value to use for got.refcount/offset and plt.refcount/offset
520*a9fa9459Szrj      when the values may be offsets.  Normally (bfd_vma) -1.  */
521*a9fa9459Szrj   union gotplt_union init_got_offset;
522*a9fa9459Szrj   union gotplt_union init_plt_offset;
523*a9fa9459Szrj 
524*a9fa9459Szrj   /* The number of symbols found in the link which is intended for the
525*a9fa9459Szrj      mandatory DT_SYMTAB tag (.dynsym section) in .dynamic section.  */
526*a9fa9459Szrj   bfd_size_type dynsymcount;
527*a9fa9459Szrj 
528*a9fa9459Szrj   /* The string table of dynamic symbols, which becomes the .dynstr
529*a9fa9459Szrj      section.  */
530*a9fa9459Szrj   struct elf_strtab_hash *dynstr;
531*a9fa9459Szrj 
532*a9fa9459Szrj   /* The number of symbol strings found in the link which must be put
533*a9fa9459Szrj      into the .strtab section.  */
534*a9fa9459Szrj   bfd_size_type strtabcount;
535*a9fa9459Szrj 
536*a9fa9459Szrj   /* The array size of the symbol string table, which becomes the
537*a9fa9459Szrj      .strtab section.  */
538*a9fa9459Szrj   bfd_size_type strtabsize;
539*a9fa9459Szrj 
540*a9fa9459Szrj   /* The array of strings, which becomes the .strtab section.  */
541*a9fa9459Szrj   struct elf_sym_strtab *strtab;
542*a9fa9459Szrj 
543*a9fa9459Szrj   /* The number of buckets in the hash table in the .hash section.
544*a9fa9459Szrj      This is based on the number of dynamic symbols.  */
545*a9fa9459Szrj   bfd_size_type bucketcount;
546*a9fa9459Szrj 
547*a9fa9459Szrj   /* A linked list of DT_NEEDED names found in dynamic objects
548*a9fa9459Szrj      included in the link.  */
549*a9fa9459Szrj   struct bfd_link_needed_list *needed;
550*a9fa9459Szrj 
551*a9fa9459Szrj   /* Sections in the output bfd that provides a section symbol
552*a9fa9459Szrj      to be used by relocations emitted against local symbols.
553*a9fa9459Szrj      Most targets will not use data_index_section.  */
554*a9fa9459Szrj   asection *text_index_section;
555*a9fa9459Szrj   asection *data_index_section;
556*a9fa9459Szrj 
557*a9fa9459Szrj   /* The _GLOBAL_OFFSET_TABLE_ symbol.  */
558*a9fa9459Szrj   struct elf_link_hash_entry *hgot;
559*a9fa9459Szrj 
560*a9fa9459Szrj   /* The _PROCEDURE_LINKAGE_TABLE_ symbol.  */
561*a9fa9459Szrj   struct elf_link_hash_entry *hplt;
562*a9fa9459Szrj 
563*a9fa9459Szrj   /* The _DYNAMIC symbol.  */
564*a9fa9459Szrj   struct elf_link_hash_entry *hdynamic;
565*a9fa9459Szrj 
566*a9fa9459Szrj   /* A pointer to information used to merge SEC_MERGE sections.  */
567*a9fa9459Szrj   void *merge_info;
568*a9fa9459Szrj 
569*a9fa9459Szrj   /* Used to link stabs in sections.  */
570*a9fa9459Szrj   struct stab_info stab_info;
571*a9fa9459Szrj 
572*a9fa9459Szrj   /* Used by eh_frame code when editing .eh_frame.  */
573*a9fa9459Szrj   struct eh_frame_hdr_info eh_info;
574*a9fa9459Szrj 
575*a9fa9459Szrj   /* A linked list of local symbols to be added to .dynsym.  */
576*a9fa9459Szrj   struct elf_link_local_dynamic_entry *dynlocal;
577*a9fa9459Szrj 
578*a9fa9459Szrj   /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
579*a9fa9459Szrj      objects included in the link.  */
580*a9fa9459Szrj   struct bfd_link_needed_list *runpath;
581*a9fa9459Szrj 
582*a9fa9459Szrj   /* Cached first output tls section and size of PT_TLS segment.  */
583*a9fa9459Szrj   asection *tls_sec;
584*a9fa9459Szrj   bfd_size_type tls_size;
585*a9fa9459Szrj 
586*a9fa9459Szrj   /* A linked list of BFD's loaded in the link.  */
587*a9fa9459Szrj   struct elf_link_loaded_list *loaded;
588*a9fa9459Szrj 
589*a9fa9459Szrj   /* Short-cuts to get to dynamic linker sections.  */
590*a9fa9459Szrj   asection *sgot;
591*a9fa9459Szrj   asection *sgotplt;
592*a9fa9459Szrj   asection *srelgot;
593*a9fa9459Szrj   asection *splt;
594*a9fa9459Szrj   asection *srelplt;
595*a9fa9459Szrj   asection *igotplt;
596*a9fa9459Szrj   asection *iplt;
597*a9fa9459Szrj   asection *irelplt;
598*a9fa9459Szrj   asection *irelifunc;
599*a9fa9459Szrj   asection *dynsym;
600*a9fa9459Szrj };
601*a9fa9459Szrj 
602*a9fa9459Szrj /* Look up an entry in an ELF linker hash table.  */
603*a9fa9459Szrj 
604*a9fa9459Szrj #define elf_link_hash_lookup(table, string, create, copy, follow)	\
605*a9fa9459Szrj   ((struct elf_link_hash_entry *)					\
606*a9fa9459Szrj    bfd_link_hash_lookup (&(table)->root, (string), (create),		\
607*a9fa9459Szrj 			 (copy), (follow)))
608*a9fa9459Szrj 
609*a9fa9459Szrj /* Traverse an ELF linker hash table.  */
610*a9fa9459Szrj 
611*a9fa9459Szrj #define elf_link_hash_traverse(table, func, info)			\
612*a9fa9459Szrj   (bfd_link_hash_traverse						\
613*a9fa9459Szrj    (&(table)->root,							\
614*a9fa9459Szrj     (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func),	\
615*a9fa9459Szrj     (info)))
616*a9fa9459Szrj 
617*a9fa9459Szrj /* Get the ELF linker hash table from a link_info structure.  */
618*a9fa9459Szrj 
619*a9fa9459Szrj #define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
620*a9fa9459Szrj 
621*a9fa9459Szrj #define elf_hash_table_id(table)	((table) -> hash_table_id)
622*a9fa9459Szrj 
623*a9fa9459Szrj /* Returns TRUE if the hash table is a struct elf_link_hash_table.  */
624*a9fa9459Szrj #define is_elf_hash_table(htab)					      	\
625*a9fa9459Szrj   (((struct bfd_link_hash_table *) (htab))->type == bfd_link_elf_hash_table)
626*a9fa9459Szrj 
627*a9fa9459Szrj /* Used by bfd_sym_from_r_symndx to cache a small number of local
628*a9fa9459Szrj    symbols.  */
629*a9fa9459Szrj #define LOCAL_SYM_CACHE_SIZE 32
630*a9fa9459Szrj struct sym_cache
631*a9fa9459Szrj {
632*a9fa9459Szrj   bfd *abfd;
633*a9fa9459Szrj   unsigned long indx[LOCAL_SYM_CACHE_SIZE];
634*a9fa9459Szrj   Elf_Internal_Sym sym[LOCAL_SYM_CACHE_SIZE];
635*a9fa9459Szrj };
636*a9fa9459Szrj 
637*a9fa9459Szrj /* Constant information held for an ELF backend.  */
638*a9fa9459Szrj 
639*a9fa9459Szrj struct elf_size_info {
640*a9fa9459Szrj   unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
641*a9fa9459Szrj   unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
642*a9fa9459Szrj 
643*a9fa9459Szrj   /* The size of entries in the .hash section.  */
644*a9fa9459Szrj   unsigned char sizeof_hash_entry;
645*a9fa9459Szrj 
646*a9fa9459Szrj   /* The number of internal relocations to allocate per external
647*a9fa9459Szrj      relocation entry.  */
648*a9fa9459Szrj   unsigned char int_rels_per_ext_rel;
649*a9fa9459Szrj   /* We use some fixed size arrays.  This should be large enough to
650*a9fa9459Szrj      handle all back-ends.  */
651*a9fa9459Szrj #define MAX_INT_RELS_PER_EXT_REL 3
652*a9fa9459Szrj 
653*a9fa9459Szrj   unsigned char arch_size, log_file_align;
654*a9fa9459Szrj   unsigned char elfclass, ev_current;
655*a9fa9459Szrj   int (*write_out_phdrs)
656*a9fa9459Szrj     (bfd *, const Elf_Internal_Phdr *, unsigned int);
657*a9fa9459Szrj   bfd_boolean
658*a9fa9459Szrj     (*write_shdrs_and_ehdr) (bfd *);
659*a9fa9459Szrj   bfd_boolean (*checksum_contents)
660*a9fa9459Szrj     (bfd * , void (*) (const void *, size_t, void *), void *);
661*a9fa9459Szrj   void (*write_relocs)
662*a9fa9459Szrj     (bfd *, asection *, void *);
663*a9fa9459Szrj   bfd_boolean (*swap_symbol_in)
664*a9fa9459Szrj     (bfd *, const void *, const void *, Elf_Internal_Sym *);
665*a9fa9459Szrj   void (*swap_symbol_out)
666*a9fa9459Szrj     (bfd *, const Elf_Internal_Sym *, void *, void *);
667*a9fa9459Szrj   bfd_boolean (*slurp_reloc_table)
668*a9fa9459Szrj     (bfd *, asection *, asymbol **, bfd_boolean);
669*a9fa9459Szrj   long (*slurp_symbol_table)
670*a9fa9459Szrj     (bfd *, asymbol **, bfd_boolean);
671*a9fa9459Szrj   void (*swap_dyn_in)
672*a9fa9459Szrj     (bfd *, const void *, Elf_Internal_Dyn *);
673*a9fa9459Szrj   void (*swap_dyn_out)
674*a9fa9459Szrj     (bfd *, const Elf_Internal_Dyn *, void *);
675*a9fa9459Szrj 
676*a9fa9459Szrj   /* This function is called to swap in a REL relocation.  If an
677*a9fa9459Szrj      external relocation corresponds to more than one internal
678*a9fa9459Szrj      relocation, then all relocations are swapped in at once.  */
679*a9fa9459Szrj   void (*swap_reloc_in)
680*a9fa9459Szrj     (bfd *, const bfd_byte *, Elf_Internal_Rela *);
681*a9fa9459Szrj 
682*a9fa9459Szrj   /* This function is called to swap out a REL relocation.  */
683*a9fa9459Szrj   void (*swap_reloc_out)
684*a9fa9459Szrj     (bfd *, const Elf_Internal_Rela *, bfd_byte *);
685*a9fa9459Szrj 
686*a9fa9459Szrj   /* This function is called to swap in a RELA relocation.  If an
687*a9fa9459Szrj      external relocation corresponds to more than one internal
688*a9fa9459Szrj      relocation, then all relocations are swapped in at once.  */
689*a9fa9459Szrj   void (*swap_reloca_in)
690*a9fa9459Szrj     (bfd *, const bfd_byte *, Elf_Internal_Rela *);
691*a9fa9459Szrj 
692*a9fa9459Szrj   /* This function is called to swap out a RELA relocation.  */
693*a9fa9459Szrj   void (*swap_reloca_out)
694*a9fa9459Szrj     (bfd *, const Elf_Internal_Rela *, bfd_byte *);
695*a9fa9459Szrj };
696*a9fa9459Szrj 
697*a9fa9459Szrj #define elf_symbol_from(ABFD,S) \
698*a9fa9459Szrj 	(((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
699*a9fa9459Szrj 	  && (S)->the_bfd->tdata.elf_obj_data != 0) \
700*a9fa9459Szrj 	 ? (elf_symbol_type *) (S) \
701*a9fa9459Szrj 	 : 0)
702*a9fa9459Szrj 
703*a9fa9459Szrj enum elf_reloc_type_class {
704*a9fa9459Szrj   reloc_class_normal,
705*a9fa9459Szrj   reloc_class_relative,
706*a9fa9459Szrj   reloc_class_copy,
707*a9fa9459Szrj   reloc_class_ifunc,
708*a9fa9459Szrj   reloc_class_plt
709*a9fa9459Szrj };
710*a9fa9459Szrj 
711*a9fa9459Szrj struct elf_reloc_cookie
712*a9fa9459Szrj {
713*a9fa9459Szrj   Elf_Internal_Rela *rels, *rel, *relend;
714*a9fa9459Szrj   Elf_Internal_Sym *locsyms;
715*a9fa9459Szrj   bfd *abfd;
716*a9fa9459Szrj   size_t locsymcount;
717*a9fa9459Szrj   size_t extsymoff;
718*a9fa9459Szrj   struct elf_link_hash_entry **sym_hashes;
719*a9fa9459Szrj   int r_sym_shift;
720*a9fa9459Szrj   bfd_boolean bad_symtab;
721*a9fa9459Szrj };
722*a9fa9459Szrj 
723*a9fa9459Szrj /* The level of IRIX compatibility we're striving for.  */
724*a9fa9459Szrj 
725*a9fa9459Szrj typedef enum {
726*a9fa9459Szrj   ict_none,
727*a9fa9459Szrj   ict_irix5,
728*a9fa9459Szrj   ict_irix6
729*a9fa9459Szrj } irix_compat_t;
730*a9fa9459Szrj 
731*a9fa9459Szrj /* Mapping of ELF section names and types.  */
732*a9fa9459Szrj struct bfd_elf_special_section
733*a9fa9459Szrj {
734*a9fa9459Szrj   const char *prefix;
735*a9fa9459Szrj   unsigned int prefix_length;
736*a9fa9459Szrj   /* 0 means name must match PREFIX exactly.
737*a9fa9459Szrj      -1 means name must start with PREFIX followed by an arbitrary string.
738*a9fa9459Szrj      -2 means name must match PREFIX exactly or consist of PREFIX followed
739*a9fa9459Szrj      by a dot then anything.
740*a9fa9459Szrj      > 0 means name must start with the first PREFIX_LENGTH chars of
741*a9fa9459Szrj      PREFIX and finish with the last SUFFIX_LENGTH chars of PREFIX.  */
742*a9fa9459Szrj   signed int suffix_length;
743*a9fa9459Szrj   unsigned int type;
744*a9fa9459Szrj   bfd_vma attr;
745*a9fa9459Szrj };
746*a9fa9459Szrj 
747*a9fa9459Szrj enum action_discarded
748*a9fa9459Szrj   {
749*a9fa9459Szrj     COMPLAIN = 1,
750*a9fa9459Szrj     PRETEND = 2
751*a9fa9459Szrj   };
752*a9fa9459Szrj 
753*a9fa9459Szrj typedef asection * (*elf_gc_mark_hook_fn)
754*a9fa9459Szrj   (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
755*a9fa9459Szrj    struct elf_link_hash_entry *, Elf_Internal_Sym *);
756*a9fa9459Szrj 
757*a9fa9459Szrj struct elf_backend_data
758*a9fa9459Szrj {
759*a9fa9459Szrj   /* The architecture for this backend.  */
760*a9fa9459Szrj   enum bfd_architecture arch;
761*a9fa9459Szrj 
762*a9fa9459Szrj   /* An identifier used to distinguish different target specific
763*a9fa9459Szrj      extensions to elf_obj_tdata and elf_link_hash_table structures.  */
764*a9fa9459Szrj   enum elf_target_id target_id;
765*a9fa9459Szrj 
766*a9fa9459Szrj   /* The ELF machine code (EM_xxxx) for this backend.  */
767*a9fa9459Szrj   int elf_machine_code;
768*a9fa9459Szrj 
769*a9fa9459Szrj   /* EI_OSABI. */
770*a9fa9459Szrj   int elf_osabi;
771*a9fa9459Szrj 
772*a9fa9459Szrj   /* The maximum page size for this backend.  */
773*a9fa9459Szrj   bfd_vma maxpagesize;
774*a9fa9459Szrj 
775*a9fa9459Szrj   /* The minimum page size for this backend.  An input object will not be
776*a9fa9459Szrj      considered page aligned unless its sections are correctly aligned for
777*a9fa9459Szrj      pages at least this large.  May be smaller than maxpagesize.  */
778*a9fa9459Szrj   bfd_vma minpagesize;
779*a9fa9459Szrj 
780*a9fa9459Szrj   /* The common page size for this backend.  */
781*a9fa9459Szrj   bfd_vma commonpagesize;
782*a9fa9459Szrj 
783*a9fa9459Szrj   /* The BFD flags applied to sections created for dynamic linking.  */
784*a9fa9459Szrj   flagword dynamic_sec_flags;
785*a9fa9459Szrj 
786*a9fa9459Szrj   /* Architecture-specific data for this backend.
787*a9fa9459Szrj      This is actually a pointer to some type like struct elf_ARCH_data.  */
788*a9fa9459Szrj   const void *arch_data;
789*a9fa9459Szrj 
790*a9fa9459Szrj   /* A function to translate an ELF RELA relocation to a BFD arelent
791*a9fa9459Szrj      structure.  */
792*a9fa9459Szrj   void (*elf_info_to_howto)
793*a9fa9459Szrj     (bfd *, arelent *, Elf_Internal_Rela *);
794*a9fa9459Szrj 
795*a9fa9459Szrj   /* A function to translate an ELF REL relocation to a BFD arelent
796*a9fa9459Szrj      structure.  */
797*a9fa9459Szrj   void (*elf_info_to_howto_rel)
798*a9fa9459Szrj     (bfd *, arelent *, Elf_Internal_Rela *);
799*a9fa9459Szrj 
800*a9fa9459Szrj   /* A function to determine whether a symbol is global when
801*a9fa9459Szrj      partitioning the symbol table into local and global symbols.
802*a9fa9459Szrj      This should be NULL for most targets, in which case the correct
803*a9fa9459Szrj      thing will be done.  MIPS ELF, at least on the Irix 5, has
804*a9fa9459Szrj      special requirements.  */
805*a9fa9459Szrj   bfd_boolean (*elf_backend_sym_is_global)
806*a9fa9459Szrj     (bfd *, asymbol *);
807*a9fa9459Szrj 
808*a9fa9459Szrj   /* The remaining functions are hooks which are called only if they
809*a9fa9459Szrj      are not NULL.  */
810*a9fa9459Szrj 
811*a9fa9459Szrj   /* A function to permit a backend specific check on whether a
812*a9fa9459Szrj      particular BFD format is relevant for an object file, and to
813*a9fa9459Szrj      permit the backend to set any global information it wishes.  When
814*a9fa9459Szrj      this is called elf_elfheader is set, but anything else should be
815*a9fa9459Szrj      used with caution.  If this returns FALSE, the check_format
816*a9fa9459Szrj      routine will return a bfd_error_wrong_format error.  */
817*a9fa9459Szrj   bfd_boolean (*elf_backend_object_p)
818*a9fa9459Szrj     (bfd *);
819*a9fa9459Szrj 
820*a9fa9459Szrj   /* A function to do additional symbol processing when reading the
821*a9fa9459Szrj      ELF symbol table.  This is where any processor-specific special
822*a9fa9459Szrj      section indices are handled.  */
823*a9fa9459Szrj   void (*elf_backend_symbol_processing)
824*a9fa9459Szrj     (bfd *, asymbol *);
825*a9fa9459Szrj 
826*a9fa9459Szrj   /* A function to do additional symbol processing after reading the
827*a9fa9459Szrj      entire ELF symbol table.  */
828*a9fa9459Szrj   bfd_boolean (*elf_backend_symbol_table_processing)
829*a9fa9459Szrj     (bfd *, elf_symbol_type *, unsigned int);
830*a9fa9459Szrj 
831*a9fa9459Szrj   /* A function to set the type of the info field.  Processor-specific
832*a9fa9459Szrj      types should be handled here.  */
833*a9fa9459Szrj   int (*elf_backend_get_symbol_type)
834*a9fa9459Szrj     (Elf_Internal_Sym *, int);
835*a9fa9459Szrj 
836*a9fa9459Szrj   /* A function to return the linker hash table entry of a symbol that
837*a9fa9459Szrj      might be satisfied by an archive symbol.  */
838*a9fa9459Szrj   struct elf_link_hash_entry * (*elf_backend_archive_symbol_lookup)
839*a9fa9459Szrj     (bfd *, struct bfd_link_info *, const char *);
840*a9fa9459Szrj 
841*a9fa9459Szrj   /* Return true if local section symbols should have a non-null st_name.
842*a9fa9459Szrj      NULL implies false.  */
843*a9fa9459Szrj   bfd_boolean (*elf_backend_name_local_section_symbols)
844*a9fa9459Szrj     (bfd *);
845*a9fa9459Szrj 
846*a9fa9459Szrj   /* A function to do additional processing on the ELF section header
847*a9fa9459Szrj      just before writing it out.  This is used to set the flags and
848*a9fa9459Szrj      type fields for some sections, or to actually write out data for
849*a9fa9459Szrj      unusual sections.  */
850*a9fa9459Szrj   bfd_boolean (*elf_backend_section_processing)
851*a9fa9459Szrj     (bfd *, Elf_Internal_Shdr *);
852*a9fa9459Szrj 
853*a9fa9459Szrj   /* A function to handle unusual section types when creating BFD
854*a9fa9459Szrj      sections from ELF sections.  */
855*a9fa9459Szrj   bfd_boolean (*elf_backend_section_from_shdr)
856*a9fa9459Szrj     (bfd *, Elf_Internal_Shdr *, const char *, int);
857*a9fa9459Szrj 
858*a9fa9459Szrj   /* A function to convert machine dependent ELF section header flags to
859*a9fa9459Szrj      BFD internal section header flags.  */
860*a9fa9459Szrj   bfd_boolean (*elf_backend_section_flags)
861*a9fa9459Szrj     (flagword *, const Elf_Internal_Shdr *);
862*a9fa9459Szrj 
863*a9fa9459Szrj   /* A function that returns a struct containing ELF section flags and
864*a9fa9459Szrj      type for the given BFD section.   */
865*a9fa9459Szrj   const struct bfd_elf_special_section * (*get_sec_type_attr)
866*a9fa9459Szrj     (bfd *, asection *);
867*a9fa9459Szrj 
868*a9fa9459Szrj   /* A function to handle unusual program segment types when creating BFD
869*a9fa9459Szrj      sections from ELF program segments.  */
870*a9fa9459Szrj   bfd_boolean (*elf_backend_section_from_phdr)
871*a9fa9459Szrj     (bfd *, Elf_Internal_Phdr *, int, const char *);
872*a9fa9459Szrj 
873*a9fa9459Szrj   /* A function to set up the ELF section header for a BFD section in
874*a9fa9459Szrj      preparation for writing it out.  This is where the flags and type
875*a9fa9459Szrj      fields are set for unusual sections.  */
876*a9fa9459Szrj   bfd_boolean (*elf_backend_fake_sections)
877*a9fa9459Szrj     (bfd *, Elf_Internal_Shdr *, asection *);
878*a9fa9459Szrj 
879*a9fa9459Szrj   /* A function to get the ELF section index for a BFD section.  If
880*a9fa9459Szrj      this returns TRUE, the section was found.  If it is a normal ELF
881*a9fa9459Szrj      section, *RETVAL should be left unchanged.  If it is not a normal
882*a9fa9459Szrj      ELF section *RETVAL should be set to the SHN_xxxx index.  */
883*a9fa9459Szrj   bfd_boolean (*elf_backend_section_from_bfd_section)
884*a9fa9459Szrj     (bfd *, asection *, int *retval);
885*a9fa9459Szrj 
886*a9fa9459Szrj   /* If this field is not NULL, it is called by the add_symbols phase
887*a9fa9459Szrj      of a link just before adding a symbol to the global linker hash
888*a9fa9459Szrj      table.  It may modify any of the fields as it wishes.  If *NAME
889*a9fa9459Szrj      is set to NULL, the symbol will be skipped rather than being
890*a9fa9459Szrj      added to the hash table.  This function is responsible for
891*a9fa9459Szrj      handling all processor dependent symbol bindings and section
892*a9fa9459Szrj      indices, and must set at least *FLAGS and *SEC for each processor
893*a9fa9459Szrj      dependent case; failure to do so will cause a link error.  */
894*a9fa9459Szrj   bfd_boolean (*elf_add_symbol_hook)
895*a9fa9459Szrj     (bfd *abfd, struct bfd_link_info *info, Elf_Internal_Sym *,
896*a9fa9459Szrj      const char **name, flagword *flags, asection **sec, bfd_vma *value);
897*a9fa9459Szrj 
898*a9fa9459Szrj   /* If this field is not NULL, it is called by the elf_link_output_sym
899*a9fa9459Szrj      phase of a link for each symbol which will appear in the object file.
900*a9fa9459Szrj      On error, this function returns 0.  1 is returned when the symbol
901*a9fa9459Szrj      should be output, 2 is returned when the symbol should be discarded.  */
902*a9fa9459Szrj   int (*elf_backend_link_output_symbol_hook)
903*a9fa9459Szrj     (struct bfd_link_info *info, const char *, Elf_Internal_Sym *,
904*a9fa9459Szrj      asection *, struct elf_link_hash_entry *);
905*a9fa9459Szrj 
906*a9fa9459Szrj   /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
907*a9fa9459Szrj      linker the first time it encounters a dynamic object in the link.
908*a9fa9459Szrj      This function must create any sections required for dynamic
909*a9fa9459Szrj      linking.  The ABFD argument is a dynamic object.  The .interp,
910*a9fa9459Szrj      .dynamic, .dynsym, .dynstr, and .hash functions have already been
911*a9fa9459Szrj      created, and this function may modify the section flags if
912*a9fa9459Szrj      desired.  This function will normally create the .got and .plt
913*a9fa9459Szrj      sections, but different backends have different requirements.  */
914*a9fa9459Szrj   bfd_boolean (*elf_backend_create_dynamic_sections)
915*a9fa9459Szrj     (bfd *abfd, struct bfd_link_info *info);
916*a9fa9459Szrj 
917*a9fa9459Szrj   /* When creating a shared library, determine whether to omit the
918*a9fa9459Szrj      dynamic symbol for the section.  */
919*a9fa9459Szrj   bfd_boolean (*elf_backend_omit_section_dynsym)
920*a9fa9459Szrj     (bfd *output_bfd, struct bfd_link_info *info, asection *osec);
921*a9fa9459Szrj 
922*a9fa9459Szrj   /* Return TRUE if relocations of targets are compatible to the extent
923*a9fa9459Szrj      that CHECK_RELOCS will properly process them.  PR 4424.  */
924*a9fa9459Szrj   bfd_boolean (*relocs_compatible) (const bfd_target *, const bfd_target *);
925*a9fa9459Szrj 
926*a9fa9459Szrj   /* The CHECK_RELOCS function is called by the add_symbols phase of
927*a9fa9459Szrj      the ELF backend linker.  It is called once for each section with
928*a9fa9459Szrj      relocs of an object file, just after the symbols for the object
929*a9fa9459Szrj      file have been added to the global linker hash table.  The
930*a9fa9459Szrj      function must look through the relocs and do any special handling
931*a9fa9459Szrj      required.  This generally means allocating space in the global
932*a9fa9459Szrj      offset table, and perhaps allocating space for a reloc.  The
933*a9fa9459Szrj      relocs are always passed as Rela structures; if the section
934*a9fa9459Szrj      actually uses Rel structures, the r_addend field will always be
935*a9fa9459Szrj      zero.  */
936*a9fa9459Szrj   bfd_boolean (*check_relocs)
937*a9fa9459Szrj     (bfd *abfd, struct bfd_link_info *info, asection *o,
938*a9fa9459Szrj      const Elf_Internal_Rela *relocs);
939*a9fa9459Szrj 
940*a9fa9459Szrj   /* The CHECK_DIRECTIVES function is called once per input file by
941*a9fa9459Szrj      the add_symbols phase of the ELF backend linker.  The function
942*a9fa9459Szrj      must inspect the bfd and create any additional symbols according
943*a9fa9459Szrj      to any custom directives in the bfd.  */
944*a9fa9459Szrj   bfd_boolean (*check_directives)
945*a9fa9459Szrj     (bfd *abfd, struct bfd_link_info *info);
946*a9fa9459Szrj 
947*a9fa9459Szrj   /* The NOTICE_AS_NEEDED function is called as the linker is about to
948*a9fa9459Szrj      handle an as-needed lib (ACT = notice_as_needed), and after the
949*a9fa9459Szrj      linker has decided to keep the lib (ACT = notice_needed) or when
950*a9fa9459Szrj      the lib is not needed (ACT = notice_not_needed).  */
951*a9fa9459Szrj   bfd_boolean (*notice_as_needed)
952*a9fa9459Szrj     (bfd *abfd, struct bfd_link_info *info, enum notice_asneeded_action act);
953*a9fa9459Szrj 
954*a9fa9459Szrj   /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
955*a9fa9459Szrj      linker for every symbol which is defined by a dynamic object and
956*a9fa9459Szrj      referenced by a regular object.  This is called after all the
957*a9fa9459Szrj      input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
958*a9fa9459Szrj      function has been called.  The hash table entry should be
959*a9fa9459Szrj      bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
960*a9fa9459Szrj      defined in a section from a dynamic object.  Dynamic object
961*a9fa9459Szrj      sections are not included in the final link, and this function is
962*a9fa9459Szrj      responsible for changing the value to something which the rest of
963*a9fa9459Szrj      the link can deal with.  This will normally involve adding an
964*a9fa9459Szrj      entry to the .plt or .got or some such section, and setting the
965*a9fa9459Szrj      symbol to point to that.  */
966*a9fa9459Szrj   bfd_boolean (*elf_backend_adjust_dynamic_symbol)
967*a9fa9459Szrj     (struct bfd_link_info *info, struct elf_link_hash_entry *h);
968*a9fa9459Szrj 
969*a9fa9459Szrj   /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
970*a9fa9459Szrj      after all the linker input files have been seen but before the
971*a9fa9459Szrj      section sizes have been set.  This is called after
972*a9fa9459Szrj      ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS.  */
973*a9fa9459Szrj   bfd_boolean (*elf_backend_always_size_sections)
974*a9fa9459Szrj     (bfd *output_bfd, struct bfd_link_info *info);
975*a9fa9459Szrj 
976*a9fa9459Szrj   /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
977*a9fa9459Szrj      linker after all the linker input files have been seen but before
978*a9fa9459Szrj      the sections sizes have been set.  This is called after
979*a9fa9459Szrj      ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
980*a9fa9459Szrj      It is only called when linking against a dynamic object.  It must
981*a9fa9459Szrj      set the sizes of the dynamic sections, and may fill in their
982*a9fa9459Szrj      contents as well.  The generic ELF linker can handle the .dynsym,
983*a9fa9459Szrj      .dynstr and .hash sections.  This function must handle the
984*a9fa9459Szrj      .interp section and any sections created by the
985*a9fa9459Szrj      CREATE_DYNAMIC_SECTIONS entry point.  */
986*a9fa9459Szrj   bfd_boolean (*elf_backend_size_dynamic_sections)
987*a9fa9459Szrj     (bfd *output_bfd, struct bfd_link_info *info);
988*a9fa9459Szrj 
989*a9fa9459Szrj   /* Set TEXT_INDEX_SECTION and DATA_INDEX_SECTION, the output sections
990*a9fa9459Szrj      we keep to use as a base for relocs and symbols.  */
991*a9fa9459Szrj   void (*elf_backend_init_index_section)
992*a9fa9459Szrj     (bfd *output_bfd, struct bfd_link_info *info);
993*a9fa9459Szrj 
994*a9fa9459Szrj   /* The RELOCATE_SECTION function is called by the ELF backend linker
995*a9fa9459Szrj      to handle the relocations for a section.
996*a9fa9459Szrj 
997*a9fa9459Szrj      The relocs are always passed as Rela structures; if the section
998*a9fa9459Szrj      actually uses Rel structures, the r_addend field will always be
999*a9fa9459Szrj      zero.
1000*a9fa9459Szrj 
1001*a9fa9459Szrj      This function is responsible for adjust the section contents as
1002*a9fa9459Szrj      necessary, and (if using Rela relocs and generating a
1003*a9fa9459Szrj      relocatable output file) adjusting the reloc addend as
1004*a9fa9459Szrj      necessary.
1005*a9fa9459Szrj 
1006*a9fa9459Szrj      This function does not have to worry about setting the reloc
1007*a9fa9459Szrj      address or the reloc symbol index.
1008*a9fa9459Szrj 
1009*a9fa9459Szrj      LOCAL_SYMS is a pointer to the swapped in local symbols.
1010*a9fa9459Szrj 
1011*a9fa9459Szrj      LOCAL_SECTIONS is an array giving the section in the input file
1012*a9fa9459Szrj      corresponding to the st_shndx field of each local symbol.
1013*a9fa9459Szrj 
1014*a9fa9459Szrj      The global hash table entry for the global symbols can be found
1015*a9fa9459Szrj      via elf_sym_hashes (input_bfd).
1016*a9fa9459Szrj 
1017*a9fa9459Szrj      When generating relocatable output, this function must handle
1018*a9fa9459Szrj      STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
1019*a9fa9459Szrj      going to be the section symbol corresponding to the output
1020*a9fa9459Szrj      section, which means that the addend must be adjusted
1021*a9fa9459Szrj      accordingly.
1022*a9fa9459Szrj 
1023*a9fa9459Szrj      Returns FALSE on error, TRUE on success, 2 if successful and
1024*a9fa9459Szrj      relocations should be written for this section.  */
1025*a9fa9459Szrj   int (*elf_backend_relocate_section)
1026*a9fa9459Szrj     (bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd,
1027*a9fa9459Szrj      asection *input_section, bfd_byte *contents, Elf_Internal_Rela *relocs,
1028*a9fa9459Szrj      Elf_Internal_Sym *local_syms, asection **local_sections);
1029*a9fa9459Szrj 
1030*a9fa9459Szrj   /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
1031*a9fa9459Szrj      linker just before it writes a symbol out to the .dynsym section.
1032*a9fa9459Szrj      The processor backend may make any required adjustment to the
1033*a9fa9459Szrj      symbol.  It may also take the opportunity to set contents of the
1034*a9fa9459Szrj      dynamic sections.  Note that FINISH_DYNAMIC_SYMBOL is called on
1035*a9fa9459Szrj      all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
1036*a9fa9459Szrj      on those symbols which are defined by a dynamic object.  */
1037*a9fa9459Szrj   bfd_boolean (*elf_backend_finish_dynamic_symbol)
1038*a9fa9459Szrj     (bfd *output_bfd, struct bfd_link_info *info,
1039*a9fa9459Szrj      struct elf_link_hash_entry *h, Elf_Internal_Sym *sym);
1040*a9fa9459Szrj 
1041*a9fa9459Szrj   /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
1042*a9fa9459Szrj      linker just before it writes all the dynamic sections out to the
1043*a9fa9459Szrj      output file.  The FINISH_DYNAMIC_SYMBOL will have been called on
1044*a9fa9459Szrj      all dynamic symbols.  */
1045*a9fa9459Szrj   bfd_boolean (*elf_backend_finish_dynamic_sections)
1046*a9fa9459Szrj     (bfd *output_bfd, struct bfd_link_info *info);
1047*a9fa9459Szrj 
1048*a9fa9459Szrj   /* A function to do any beginning processing needed for the ELF file
1049*a9fa9459Szrj      before building the ELF headers and computing file positions.  */
1050*a9fa9459Szrj   void (*elf_backend_begin_write_processing)
1051*a9fa9459Szrj     (bfd *, struct bfd_link_info *);
1052*a9fa9459Szrj 
1053*a9fa9459Szrj   /* A function to do any final processing needed for the ELF file
1054*a9fa9459Szrj      before writing it out.  The LINKER argument is TRUE if this BFD
1055*a9fa9459Szrj      was created by the ELF backend linker.  */
1056*a9fa9459Szrj   void (*elf_backend_final_write_processing)
1057*a9fa9459Szrj     (bfd *, bfd_boolean linker);
1058*a9fa9459Szrj 
1059*a9fa9459Szrj   /* This function is called by get_program_header_size.  It should
1060*a9fa9459Szrj      return the number of additional program segments which this BFD
1061*a9fa9459Szrj      will need.  It should return -1 on error.  */
1062*a9fa9459Szrj   int (*elf_backend_additional_program_headers)
1063*a9fa9459Szrj     (bfd *, struct bfd_link_info *);
1064*a9fa9459Szrj 
1065*a9fa9459Szrj   /* This function is called to modify an existing segment map in a
1066*a9fa9459Szrj      backend specific fashion.  */
1067*a9fa9459Szrj   bfd_boolean (*elf_backend_modify_segment_map)
1068*a9fa9459Szrj     (bfd *, struct bfd_link_info *);
1069*a9fa9459Szrj 
1070*a9fa9459Szrj   /* This function is called to modify program headers just before
1071*a9fa9459Szrj      they are written.  */
1072*a9fa9459Szrj   bfd_boolean (*elf_backend_modify_program_headers)
1073*a9fa9459Szrj     (bfd *, struct bfd_link_info *);
1074*a9fa9459Szrj 
1075*a9fa9459Szrj   /* This function is called before section garbage collection to
1076*a9fa9459Szrj      mark entry symbol sections.  */
1077*a9fa9459Szrj   void (*gc_keep)
1078*a9fa9459Szrj     (struct bfd_link_info *);
1079*a9fa9459Szrj 
1080*a9fa9459Szrj   /* This function is called during section garbage collection to
1081*a9fa9459Szrj      mark sections that define global symbols.  */
1082*a9fa9459Szrj   bfd_boolean (*gc_mark_dynamic_ref)
1083*a9fa9459Szrj     (struct elf_link_hash_entry *, void *);
1084*a9fa9459Szrj 
1085*a9fa9459Szrj   /* This function is called during section gc to discover the section a
1086*a9fa9459Szrj      particular relocation refers to.  */
1087*a9fa9459Szrj   elf_gc_mark_hook_fn gc_mark_hook;
1088*a9fa9459Szrj 
1089*a9fa9459Szrj   /* This function, if defined, is called after the first gc marking pass
1090*a9fa9459Szrj      to allow the backend to mark additional sections.  */
1091*a9fa9459Szrj   bfd_boolean (*gc_mark_extra_sections)
1092*a9fa9459Szrj     (struct bfd_link_info *, elf_gc_mark_hook_fn);
1093*a9fa9459Szrj 
1094*a9fa9459Szrj   /* This function, if defined, is called during the sweep phase of gc
1095*a9fa9459Szrj      in order that a backend might update any data structures it might
1096*a9fa9459Szrj      be maintaining.  */
1097*a9fa9459Szrj   bfd_boolean (*gc_sweep_hook)
1098*a9fa9459Szrj     (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
1099*a9fa9459Szrj 
1100*a9fa9459Szrj   /* This function, if defined, is called after the ELF headers have
1101*a9fa9459Szrj      been created.  This allows for things like the OS and ABI versions
1102*a9fa9459Szrj      to be changed.  */
1103*a9fa9459Szrj   void (*elf_backend_post_process_headers)
1104*a9fa9459Szrj     (bfd *, struct bfd_link_info *);
1105*a9fa9459Szrj 
1106*a9fa9459Szrj   /* This function, if defined, prints a symbol to file and returns the
1107*a9fa9459Szrj      name of the symbol to be printed.  It should return NULL to fall
1108*a9fa9459Szrj      back to default symbol printing.  */
1109*a9fa9459Szrj   const char *(*elf_backend_print_symbol_all)
1110*a9fa9459Szrj     (bfd *, void *, asymbol *);
1111*a9fa9459Szrj 
1112*a9fa9459Szrj   /* This function, if defined, is called after all local symbols and
1113*a9fa9459Szrj      global symbols converted to locals are emitted into the symtab
1114*a9fa9459Szrj      section.  It allows the backend to emit special local symbols
1115*a9fa9459Szrj      not handled in the hash table.  */
1116*a9fa9459Szrj   bfd_boolean (*elf_backend_output_arch_local_syms)
1117*a9fa9459Szrj     (bfd *, struct bfd_link_info *, void *,
1118*a9fa9459Szrj      bfd_boolean (*) (void *, const char *, Elf_Internal_Sym *, asection *,
1119*a9fa9459Szrj 		      struct elf_link_hash_entry *));
1120*a9fa9459Szrj 
1121*a9fa9459Szrj   /* This function, if defined, is called after all symbols are emitted
1122*a9fa9459Szrj      into the symtab section.  It allows the backend to emit special
1123*a9fa9459Szrj      global symbols not handled in the hash table.  */
1124*a9fa9459Szrj   bfd_boolean (*elf_backend_output_arch_syms)
1125*a9fa9459Szrj     (bfd *, struct bfd_link_info *, void *,
1126*a9fa9459Szrj      bfd_boolean (*) (void *, const char *, Elf_Internal_Sym *, asection *,
1127*a9fa9459Szrj 		      struct elf_link_hash_entry *));
1128*a9fa9459Szrj 
1129*a9fa9459Szrj   /* Copy any information related to dynamic linking from a pre-existing
1130*a9fa9459Szrj      symbol to a newly created symbol.  Also called to copy flags and
1131*a9fa9459Szrj      other back-end info to a weakdef, in which case the symbol is not
1132*a9fa9459Szrj      newly created and plt/got refcounts and dynamic indices should not
1133*a9fa9459Szrj      be copied.  */
1134*a9fa9459Szrj   void (*elf_backend_copy_indirect_symbol)
1135*a9fa9459Szrj     (struct bfd_link_info *, struct elf_link_hash_entry *,
1136*a9fa9459Szrj      struct elf_link_hash_entry *);
1137*a9fa9459Szrj 
1138*a9fa9459Szrj   /* Modify any information related to dynamic linking such that the
1139*a9fa9459Szrj      symbol is not exported.  */
1140*a9fa9459Szrj   void (*elf_backend_hide_symbol)
1141*a9fa9459Szrj     (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
1142*a9fa9459Szrj 
1143*a9fa9459Szrj   /* A function to do additional symbol fixup, called by
1144*a9fa9459Szrj      _bfd_elf_fix_symbol_flags.  */
1145*a9fa9459Szrj   bfd_boolean (*elf_backend_fixup_symbol)
1146*a9fa9459Szrj     (struct bfd_link_info *, struct elf_link_hash_entry *);
1147*a9fa9459Szrj 
1148*a9fa9459Szrj   /* Merge the backend specific symbol attribute.  */
1149*a9fa9459Szrj   void (*elf_backend_merge_symbol_attribute)
1150*a9fa9459Szrj     (struct elf_link_hash_entry *, const Elf_Internal_Sym *, bfd_boolean,
1151*a9fa9459Szrj      bfd_boolean);
1152*a9fa9459Szrj 
1153*a9fa9459Szrj   /* This function, if defined, will return a string containing the
1154*a9fa9459Szrj      name of a target-specific dynamic tag.  */
1155*a9fa9459Szrj   char *(*elf_backend_get_target_dtag)
1156*a9fa9459Szrj     (bfd_vma);
1157*a9fa9459Szrj 
1158*a9fa9459Szrj   /* Decide whether an undefined symbol is special and can be ignored.
1159*a9fa9459Szrj      This is the case for OPTIONAL symbols on IRIX.  */
1160*a9fa9459Szrj   bfd_boolean (*elf_backend_ignore_undef_symbol)
1161*a9fa9459Szrj     (struct elf_link_hash_entry *);
1162*a9fa9459Szrj 
1163*a9fa9459Szrj   /* Emit relocations.  Overrides default routine for emitting relocs,
1164*a9fa9459Szrj      except during a relocatable link, or if all relocs are being emitted.  */
1165*a9fa9459Szrj   bfd_boolean (*elf_backend_emit_relocs)
1166*a9fa9459Szrj     (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
1167*a9fa9459Szrj      struct elf_link_hash_entry **);
1168*a9fa9459Szrj 
1169*a9fa9459Szrj   /* Count relocations.  Not called for relocatable links
1170*a9fa9459Szrj      or if all relocs are being preserved in the output.  */
1171*a9fa9459Szrj   unsigned int (*elf_backend_count_relocs)
1172*a9fa9459Szrj     (struct bfd_link_info *, asection *);
1173*a9fa9459Szrj 
1174*a9fa9459Szrj   /* Count additionals relocations.  Called for relocatable links if
1175*a9fa9459Szrj      additional relocations needs to be created.  */
1176*a9fa9459Szrj   unsigned int (*elf_backend_count_additional_relocs)
1177*a9fa9459Szrj     (asection *);
1178*a9fa9459Szrj 
1179*a9fa9459Szrj   /* Say whether to sort relocs output by ld -r and ld --emit-relocs,
1180*a9fa9459Szrj      by r_offset.  If NULL, default to true.  */
1181*a9fa9459Szrj   bfd_boolean (*sort_relocs_p)
1182*a9fa9459Szrj     (asection *);
1183*a9fa9459Szrj 
1184*a9fa9459Szrj   /* This function, if defined, is called when an NT_PRSTATUS note is found
1185*a9fa9459Szrj      in a core file.  */
1186*a9fa9459Szrj   bfd_boolean (*elf_backend_grok_prstatus)
1187*a9fa9459Szrj     (bfd *, Elf_Internal_Note *);
1188*a9fa9459Szrj 
1189*a9fa9459Szrj   /* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
1190*a9fa9459Szrj      note is found in a core file.  */
1191*a9fa9459Szrj   bfd_boolean (*elf_backend_grok_psinfo)
1192*a9fa9459Szrj     (bfd *, Elf_Internal_Note *);
1193*a9fa9459Szrj 
1194*a9fa9459Szrj   /* This function, if defined, is called to write a note to a corefile.  */
1195*a9fa9459Szrj   char *(*elf_backend_write_core_note)
1196*a9fa9459Szrj     (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);
1197*a9fa9459Szrj 
1198*a9fa9459Szrj   /* This function, if defined, is called to convert target-specific
1199*a9fa9459Szrj      section flag names into hex values.  */
1200*a9fa9459Szrj   flagword (*elf_backend_lookup_section_flags_hook)
1201*a9fa9459Szrj     (char *);
1202*a9fa9459Szrj 
1203*a9fa9459Szrj   /* This function returns class of a reloc type.  */
1204*a9fa9459Szrj   enum elf_reloc_type_class (*elf_backend_reloc_type_class)
1205*a9fa9459Szrj   (const struct bfd_link_info *, const asection *, const Elf_Internal_Rela *);
1206*a9fa9459Szrj 
1207*a9fa9459Szrj   /* This function, if defined, removes information about discarded functions
1208*a9fa9459Szrj      from other sections which mention them.  */
1209*a9fa9459Szrj   bfd_boolean (*elf_backend_discard_info)
1210*a9fa9459Szrj     (bfd *, struct elf_reloc_cookie *, struct bfd_link_info *);
1211*a9fa9459Szrj 
1212*a9fa9459Szrj   /* This function, if defined, signals that the function above has removed
1213*a9fa9459Szrj      the discarded relocations for this section.  */
1214*a9fa9459Szrj   bfd_boolean (*elf_backend_ignore_discarded_relocs)
1215*a9fa9459Szrj     (asection *);
1216*a9fa9459Szrj 
1217*a9fa9459Szrj   /* What to do when ld finds relocations against symbols defined in
1218*a9fa9459Szrj      discarded sections.  */
1219*a9fa9459Szrj   unsigned int (*action_discarded)
1220*a9fa9459Szrj     (asection *);
1221*a9fa9459Szrj 
1222*a9fa9459Szrj   /* This function returns the width of FDE pointers in bytes, or 0 if
1223*a9fa9459Szrj      that can't be determined for some reason.  The default definition
1224*a9fa9459Szrj      goes by the bfd's EI_CLASS.  */
1225*a9fa9459Szrj   unsigned int (*elf_backend_eh_frame_address_size)
1226*a9fa9459Szrj     (bfd *, asection *);
1227*a9fa9459Szrj 
1228*a9fa9459Szrj   /* These functions tell elf-eh-frame whether to attempt to turn
1229*a9fa9459Szrj      absolute or lsda encodings into pc-relative ones.  The default
1230*a9fa9459Szrj      definition enables these transformations.  */
1231*a9fa9459Szrj   bfd_boolean (*elf_backend_can_make_relative_eh_frame)
1232*a9fa9459Szrj      (bfd *, struct bfd_link_info *, asection *);
1233*a9fa9459Szrj   bfd_boolean (*elf_backend_can_make_lsda_relative_eh_frame)
1234*a9fa9459Szrj      (bfd *, struct bfd_link_info *, asection *);
1235*a9fa9459Szrj 
1236*a9fa9459Szrj   /* This function returns an encoding after computing the encoded
1237*a9fa9459Szrj      value (and storing it in ENCODED) for the given OFFSET into OSEC,
1238*a9fa9459Szrj      to be stored in at LOC_OFFSET into the LOC_SEC input section.
1239*a9fa9459Szrj      The default definition chooses a 32-bit PC-relative encoding.  */
1240*a9fa9459Szrj   bfd_byte (*elf_backend_encode_eh_address)
1241*a9fa9459Szrj      (bfd *abfd, struct bfd_link_info *info,
1242*a9fa9459Szrj       asection *osec, bfd_vma offset,
1243*a9fa9459Szrj       asection *loc_sec, bfd_vma loc_offset,
1244*a9fa9459Szrj       bfd_vma *encoded);
1245*a9fa9459Szrj 
1246*a9fa9459Szrj   /* This function, if defined, may write out the given section.
1247*a9fa9459Szrj      Returns TRUE if it did so and FALSE if the caller should.  */
1248*a9fa9459Szrj   bfd_boolean (*elf_backend_write_section)
1249*a9fa9459Szrj     (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
1250*a9fa9459Szrj 
1251*a9fa9459Szrj   /* The level of IRIX compatibility we're striving for.
1252*a9fa9459Szrj      MIPS ELF specific function.  */
1253*a9fa9459Szrj   irix_compat_t (*elf_backend_mips_irix_compat)
1254*a9fa9459Szrj     (bfd *);
1255*a9fa9459Szrj 
1256*a9fa9459Szrj   reloc_howto_type *(*elf_backend_mips_rtype_to_howto)
1257*a9fa9459Szrj     (unsigned int, bfd_boolean);
1258*a9fa9459Szrj 
1259*a9fa9459Szrj   /* The swapping table to use when dealing with ECOFF information.
1260*a9fa9459Szrj      Used for the MIPS ELF .mdebug section.  */
1261*a9fa9459Szrj   const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
1262*a9fa9459Szrj 
1263*a9fa9459Szrj   /* This function implements `bfd_elf_bfd_from_remote_memory';
1264*a9fa9459Szrj      see elf.c, elfcode.h.  */
1265*a9fa9459Szrj   bfd *(*elf_backend_bfd_from_remote_memory)
1266*a9fa9459Szrj     (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
1267*a9fa9459Szrj      int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr,
1268*a9fa9459Szrj 				bfd_size_type len));
1269*a9fa9459Szrj 
1270*a9fa9459Szrj   /* This function is used by `_bfd_elf_get_synthetic_symtab';
1271*a9fa9459Szrj      see elf.c.  */
1272*a9fa9459Szrj   bfd_vma (*plt_sym_val) (bfd_vma, const asection *, const arelent *);
1273*a9fa9459Szrj 
1274*a9fa9459Szrj   /* Is symbol defined in common section?  */
1275*a9fa9459Szrj   bfd_boolean (*common_definition) (Elf_Internal_Sym *);
1276*a9fa9459Szrj 
1277*a9fa9459Szrj   /* Return a common section index for section.  */
1278*a9fa9459Szrj   unsigned int (*common_section_index) (asection *);
1279*a9fa9459Szrj 
1280*a9fa9459Szrj   /* Return a common section for section.  */
1281*a9fa9459Szrj   asection *(*common_section) (asection *);
1282*a9fa9459Szrj 
1283*a9fa9459Szrj   /* Return TRUE if we can merge 2 definitions.  */
1284*a9fa9459Szrj   bfd_boolean (*merge_symbol) (struct elf_link_hash_entry *,
1285*a9fa9459Szrj 			       const Elf_Internal_Sym *, asection **,
1286*a9fa9459Szrj 			       bfd_boolean, bfd_boolean,
1287*a9fa9459Szrj 			       bfd *, const asection *);
1288*a9fa9459Szrj 
1289*a9fa9459Szrj   /* Return TRUE if symbol should be hashed in the `.gnu.hash' section.  */
1290*a9fa9459Szrj   bfd_boolean (*elf_hash_symbol) (struct elf_link_hash_entry *);
1291*a9fa9459Szrj 
1292*a9fa9459Szrj   /* Return TRUE if type is a function symbol type.  */
1293*a9fa9459Szrj   bfd_boolean (*is_function_type) (unsigned int type);
1294*a9fa9459Szrj 
1295*a9fa9459Szrj   /* If the ELF symbol SYM might be a function in SEC, return the
1296*a9fa9459Szrj      function size and set *CODE_OFF to the function's entry point,
1297*a9fa9459Szrj      otherwise return zero.  */
1298*a9fa9459Szrj   bfd_size_type (*maybe_function_sym) (const asymbol *sym, asection *sec,
1299*a9fa9459Szrj 				       bfd_vma *code_off);
1300*a9fa9459Szrj 
1301*a9fa9459Szrj   /* Return the section which RELOC_SEC applies to.  */
1302*a9fa9459Szrj   asection *(*get_reloc_section) (asection *reloc_sec);
1303*a9fa9459Szrj 
1304*a9fa9459Szrj   /* Called to set the sh_flags, sh_link and sh_info fields of OSECTION which
1305*a9fa9459Szrj      has a type >= SHT_LOOS.  Returns TRUE if the fields were initialised,
1306*a9fa9459Szrj      FALSE otherwise.  Can be called multiple times for a given section,
1307*a9fa9459Szrj      until it returns TRUE.  Most of the times it is called ISECTION will be
1308*a9fa9459Szrj      set to an input section that might be associated with the output section.
1309*a9fa9459Szrj      The last time that it is called, ISECTION will be set to NULL.  */
1310*a9fa9459Szrj   bfd_boolean (*elf_backend_copy_special_section_fields)
1311*a9fa9459Szrj     (const bfd *ibfd, bfd *obfd, const Elf_Internal_Shdr *isection,
1312*a9fa9459Szrj      Elf_Internal_Shdr *osection);
1313*a9fa9459Szrj 
1314*a9fa9459Szrj   /* Used to handle bad SHF_LINK_ORDER input.  */
1315*a9fa9459Szrj   bfd_error_handler_type link_order_error_handler;
1316*a9fa9459Szrj 
1317*a9fa9459Szrj   /* Name of the PLT relocation section.  */
1318*a9fa9459Szrj   const char *relplt_name;
1319*a9fa9459Szrj 
1320*a9fa9459Szrj   /* Alternate EM_xxxx machine codes for this backend.  */
1321*a9fa9459Szrj   int elf_machine_alt1;
1322*a9fa9459Szrj   int elf_machine_alt2;
1323*a9fa9459Szrj 
1324*a9fa9459Szrj   const struct elf_size_info *s;
1325*a9fa9459Szrj 
1326*a9fa9459Szrj   /* An array of target specific special sections.  */
1327*a9fa9459Szrj   const struct bfd_elf_special_section *special_sections;
1328*a9fa9459Szrj 
1329*a9fa9459Szrj   /* The size in bytes of the header for the GOT.  This includes the
1330*a9fa9459Szrj      so-called reserved entries on some systems.  */
1331*a9fa9459Szrj   bfd_vma got_header_size;
1332*a9fa9459Szrj 
1333*a9fa9459Szrj   /* The size of the GOT entry for the symbol pointed to by H if non-NULL,
1334*a9fa9459Szrj      otherwise by the local symbol with index SYMNDX in IBFD.  */
1335*a9fa9459Szrj   bfd_vma (*got_elt_size) (bfd *, struct bfd_link_info *,
1336*a9fa9459Szrj 			   struct elf_link_hash_entry *h,
1337*a9fa9459Szrj 			   bfd *ibfd, unsigned long symndx);
1338*a9fa9459Szrj 
1339*a9fa9459Szrj   /* The vendor name to use for a processor-standard attributes section.  */
1340*a9fa9459Szrj   const char *obj_attrs_vendor;
1341*a9fa9459Szrj 
1342*a9fa9459Szrj   /* The section name to use for a processor-standard attributes section.  */
1343*a9fa9459Szrj   const char *obj_attrs_section;
1344*a9fa9459Szrj 
1345*a9fa9459Szrj   /* Return 1, 2 or 3 to indicate what type of arguments a
1346*a9fa9459Szrj      processor-specific tag takes.  */
1347*a9fa9459Szrj   int (*obj_attrs_arg_type) (int);
1348*a9fa9459Szrj 
1349*a9fa9459Szrj   /* The section type to use for an attributes section.  */
1350*a9fa9459Szrj   unsigned int obj_attrs_section_type;
1351*a9fa9459Szrj 
1352*a9fa9459Szrj   /* This function determines the order in which any attributes are
1353*a9fa9459Szrj      written.  It must be defined for input in the range
1354*a9fa9459Szrj      LEAST_KNOWN_OBJ_ATTRIBUTE..NUM_KNOWN_OBJ_ATTRIBUTES-1 (this range
1355*a9fa9459Szrj      is used in order to make unity easy).  The returned value is the
1356*a9fa9459Szrj      actual tag number to place in the input position.  */
1357*a9fa9459Szrj   int (*obj_attrs_order) (int);
1358*a9fa9459Szrj 
1359*a9fa9459Szrj   /* Handle merging unknown attributes; either warn and return TRUE,
1360*a9fa9459Szrj      or give an error and return FALSE.  */
1361*a9fa9459Szrj   bfd_boolean (*obj_attrs_handle_unknown) (bfd *, int);
1362*a9fa9459Szrj 
1363*a9fa9459Szrj   /* Encoding used for compact EH tables.  */
1364*a9fa9459Szrj   int (*compact_eh_encoding) (struct bfd_link_info *);
1365*a9fa9459Szrj 
1366*a9fa9459Szrj   /* Opcode representing no unwind.  */
1367*a9fa9459Szrj   int (*cant_unwind_opcode) (struct bfd_link_info *);
1368*a9fa9459Szrj 
1369*a9fa9459Szrj   /* This is non-zero if static TLS segments require a special alignment.  */
1370*a9fa9459Szrj   unsigned static_tls_alignment;
1371*a9fa9459Szrj 
1372*a9fa9459Szrj   /* Alignment for the PT_GNU_STACK segment. */
1373*a9fa9459Szrj   unsigned stack_align;
1374*a9fa9459Szrj 
1375*a9fa9459Szrj   /* Flag bits to assign to a section of type SHT_STRTAB.  */
1376*a9fa9459Szrj   unsigned long elf_strtab_flags;
1377*a9fa9459Szrj 
1378*a9fa9459Szrj   /* This is TRUE if the linker should act like collect and gather
1379*a9fa9459Szrj      global constructors and destructors by name.  This is TRUE for
1380*a9fa9459Szrj      MIPS ELF because the Irix 5 tools can not handle the .init
1381*a9fa9459Szrj      section.  */
1382*a9fa9459Szrj   unsigned collect : 1;
1383*a9fa9459Szrj 
1384*a9fa9459Szrj   /* This is TRUE if the linker should ignore changes to the type of a
1385*a9fa9459Szrj      symbol.  This is TRUE for MIPS ELF because some Irix 5 objects
1386*a9fa9459Szrj      record undefined functions as STT_OBJECT although the definitions
1387*a9fa9459Szrj      are STT_FUNC.  */
1388*a9fa9459Szrj   unsigned type_change_ok : 1;
1389*a9fa9459Szrj 
1390*a9fa9459Szrj   /* Whether the backend may use REL relocations.  (Some backends use
1391*a9fa9459Szrj      both REL and RELA relocations, and this flag is set for those
1392*a9fa9459Szrj      backends.)  */
1393*a9fa9459Szrj   unsigned may_use_rel_p : 1;
1394*a9fa9459Szrj 
1395*a9fa9459Szrj   /* Whether the backend may use RELA relocations.  (Some backends use
1396*a9fa9459Szrj      both REL and RELA relocations, and this flag is set for those
1397*a9fa9459Szrj      backends.)  */
1398*a9fa9459Szrj   unsigned may_use_rela_p : 1;
1399*a9fa9459Szrj 
1400*a9fa9459Szrj   /* Whether the default relocation type is RELA.  If a backend with
1401*a9fa9459Szrj      this flag set wants REL relocations for a particular section,
1402*a9fa9459Szrj      it must note that explicitly.  Similarly, if this flag is clear,
1403*a9fa9459Szrj      and the backend wants RELA relocations for a particular
1404*a9fa9459Szrj      section.  */
1405*a9fa9459Szrj   unsigned default_use_rela_p : 1;
1406*a9fa9459Szrj 
1407*a9fa9459Szrj   /* True if PLT and copy relocations should be RELA by default.  */
1408*a9fa9459Szrj   unsigned rela_plts_and_copies_p : 1;
1409*a9fa9459Szrj 
1410*a9fa9459Szrj   /* Set if RELA relocations for a relocatable link can be handled by
1411*a9fa9459Szrj      generic code.  Backends that set this flag need do nothing in the
1412*a9fa9459Szrj      backend relocate_section routine for relocatable linking.  */
1413*a9fa9459Szrj   unsigned rela_normal : 1;
1414*a9fa9459Szrj 
1415*a9fa9459Szrj   /* TRUE if addresses "naturally" sign extend.  This is used when
1416*a9fa9459Szrj      swapping in from Elf32 when BFD64.  */
1417*a9fa9459Szrj   unsigned sign_extend_vma : 1;
1418*a9fa9459Szrj 
1419*a9fa9459Szrj   unsigned want_got_plt : 1;
1420*a9fa9459Szrj   unsigned plt_readonly : 1;
1421*a9fa9459Szrj   unsigned want_plt_sym : 1;
1422*a9fa9459Szrj   unsigned plt_not_loaded : 1;
1423*a9fa9459Szrj   unsigned plt_alignment : 4;
1424*a9fa9459Szrj   unsigned can_gc_sections : 1;
1425*a9fa9459Szrj   unsigned can_refcount : 1;
1426*a9fa9459Szrj   unsigned want_got_sym : 1;
1427*a9fa9459Szrj   unsigned want_dynbss : 1;
1428*a9fa9459Szrj 
1429*a9fa9459Szrj   /* Targets which do not support physical addressing often require
1430*a9fa9459Szrj      that the p_paddr field in the section header to be set to zero.
1431*a9fa9459Szrj      This field indicates whether this behavior is required.  */
1432*a9fa9459Szrj   unsigned want_p_paddr_set_to_zero : 1;
1433*a9fa9459Szrj 
1434*a9fa9459Szrj   /* True if an object file lacking a .note.GNU-stack section
1435*a9fa9459Szrj      should be assumed to be requesting exec stack.  At least one
1436*a9fa9459Szrj      other file in the link needs to have a .note.GNU-stack section
1437*a9fa9459Szrj      for a PT_GNU_STACK segment to be created.  */
1438*a9fa9459Szrj   unsigned default_execstack : 1;
1439*a9fa9459Szrj 
1440*a9fa9459Szrj   /* True if elf_section_data(sec)->this_hdr.contents is sec->rawsize
1441*a9fa9459Szrj      in length rather than sec->size in length, if sec->rawsize is
1442*a9fa9459Szrj      non-zero and smaller than sec->size.  */
1443*a9fa9459Szrj   unsigned caches_rawsize : 1;
1444*a9fa9459Szrj 
1445*a9fa9459Szrj   /* Address of protected data defined in the shared library may be
1446*a9fa9459Szrj      external, i.e., due to copy relocation.   */
1447*a9fa9459Szrj   unsigned extern_protected_data : 1;
1448*a9fa9459Szrj };
1449*a9fa9459Szrj 
1450*a9fa9459Szrj /* Information about reloc sections associated with a bfd_elf_section_data
1451*a9fa9459Szrj    structure.  */
1452*a9fa9459Szrj struct bfd_elf_section_reloc_data
1453*a9fa9459Szrj {
1454*a9fa9459Szrj   /* The ELF header for the reloc section associated with this
1455*a9fa9459Szrj      section, if any.  */
1456*a9fa9459Szrj   Elf_Internal_Shdr *hdr;
1457*a9fa9459Szrj   /* The number of relocations currently assigned to HDR.  */
1458*a9fa9459Szrj   unsigned int count;
1459*a9fa9459Szrj   /* The ELF section number of the reloc section.  Only used for an
1460*a9fa9459Szrj      output file.  */
1461*a9fa9459Szrj   int idx;
1462*a9fa9459Szrj   /* Used by the backend linker to store the symbol hash table entries
1463*a9fa9459Szrj      associated with relocs against global symbols.  */
1464*a9fa9459Szrj   struct elf_link_hash_entry **hashes;
1465*a9fa9459Szrj };
1466*a9fa9459Szrj 
1467*a9fa9459Szrj /* Information stored for each BFD section in an ELF file.  This
1468*a9fa9459Szrj    structure is allocated by elf_new_section_hook.  */
1469*a9fa9459Szrj 
1470*a9fa9459Szrj struct bfd_elf_section_data
1471*a9fa9459Szrj {
1472*a9fa9459Szrj   /* The ELF header for this section.  */
1473*a9fa9459Szrj   Elf_Internal_Shdr this_hdr;
1474*a9fa9459Szrj 
1475*a9fa9459Szrj   /* INPUT_SECTION_FLAGS if specified in the linker script.  */
1476*a9fa9459Szrj   struct flag_info *section_flag_info;
1477*a9fa9459Szrj 
1478*a9fa9459Szrj   /* Information about the REL and RELA reloc sections associated
1479*a9fa9459Szrj      with this section, if any.  */
1480*a9fa9459Szrj   struct bfd_elf_section_reloc_data rel, rela;
1481*a9fa9459Szrj 
1482*a9fa9459Szrj   /* The ELF section number of this section.  */
1483*a9fa9459Szrj   int this_idx;
1484*a9fa9459Szrj 
1485*a9fa9459Szrj   /* Used by the backend linker when generating a shared library to
1486*a9fa9459Szrj      record the dynamic symbol index for a section symbol
1487*a9fa9459Szrj      corresponding to this section.  A value of 0 means that there is
1488*a9fa9459Szrj      no dynamic symbol for this section.  */
1489*a9fa9459Szrj   int dynindx;
1490*a9fa9459Szrj 
1491*a9fa9459Szrj   /* A pointer to the linked-to section for SHF_LINK_ORDER.  */
1492*a9fa9459Szrj   asection *linked_to;
1493*a9fa9459Szrj 
1494*a9fa9459Szrj   /* A pointer to the swapped relocs.  If the section uses REL relocs,
1495*a9fa9459Szrj      rather than RELA, all the r_addend fields will be zero.  This
1496*a9fa9459Szrj      pointer may be NULL.  It is used by the backend linker.  */
1497*a9fa9459Szrj   Elf_Internal_Rela *relocs;
1498*a9fa9459Szrj 
1499*a9fa9459Szrj   /* A pointer to a linked list tracking dynamic relocs copied for
1500*a9fa9459Szrj      local symbols.  */
1501*a9fa9459Szrj   void *local_dynrel;
1502*a9fa9459Szrj 
1503*a9fa9459Szrj   /* A pointer to the bfd section used for dynamic relocs.  */
1504*a9fa9459Szrj   asection *sreloc;
1505*a9fa9459Szrj 
1506*a9fa9459Szrj   union {
1507*a9fa9459Szrj     /* Group name, if this section is a member of a group.  */
1508*a9fa9459Szrj     const char *name;
1509*a9fa9459Szrj 
1510*a9fa9459Szrj     /* Group signature sym, if this is the SHT_GROUP section.  */
1511*a9fa9459Szrj     struct bfd_symbol *id;
1512*a9fa9459Szrj   } group;
1513*a9fa9459Szrj 
1514*a9fa9459Szrj   /* For a member of a group, points to the SHT_GROUP section.
1515*a9fa9459Szrj      NULL for the SHT_GROUP section itself and non-group sections.  */
1516*a9fa9459Szrj   asection *sec_group;
1517*a9fa9459Szrj 
1518*a9fa9459Szrj   /* A linked list of member sections in the group.  Circular when used by
1519*a9fa9459Szrj      the linker.  For the SHT_GROUP section, points at first member.  */
1520*a9fa9459Szrj   asection *next_in_group;
1521*a9fa9459Szrj 
1522*a9fa9459Szrj   /* The FDEs associated with this section.  The u.fde.next_in_section
1523*a9fa9459Szrj      field acts as a chain pointer.  */
1524*a9fa9459Szrj   struct eh_cie_fde *fde_list;
1525*a9fa9459Szrj 
1526*a9fa9459Szrj   /* Link from a text section to its .eh_frame_entry section.  */
1527*a9fa9459Szrj   asection *eh_frame_entry;
1528*a9fa9459Szrj 
1529*a9fa9459Szrj   /* A pointer used for various section optimizations.  */
1530*a9fa9459Szrj   void *sec_info;
1531*a9fa9459Szrj };
1532*a9fa9459Szrj 
1533*a9fa9459Szrj #define elf_section_data(sec) ((struct bfd_elf_section_data*)(sec)->used_by_bfd)
1534*a9fa9459Szrj #define elf_linked_to_section(sec) (elf_section_data(sec)->linked_to)
1535*a9fa9459Szrj #define elf_section_type(sec)	(elf_section_data(sec)->this_hdr.sh_type)
1536*a9fa9459Szrj #define elf_section_flags(sec)	(elf_section_data(sec)->this_hdr.sh_flags)
1537*a9fa9459Szrj #define elf_group_name(sec)	(elf_section_data(sec)->group.name)
1538*a9fa9459Szrj #define elf_group_id(sec)	(elf_section_data(sec)->group.id)
1539*a9fa9459Szrj #define elf_next_in_group(sec)	(elf_section_data(sec)->next_in_group)
1540*a9fa9459Szrj #define elf_fde_list(sec)	(elf_section_data(sec)->fde_list)
1541*a9fa9459Szrj #define elf_sec_group(sec)	(elf_section_data(sec)->sec_group)
1542*a9fa9459Szrj #define elf_section_eh_frame_entry(sec)	(elf_section_data(sec)->eh_frame_entry)
1543*a9fa9459Szrj 
1544*a9fa9459Szrj #define xvec_get_elf_backend_data(xvec) \
1545*a9fa9459Szrj   ((const struct elf_backend_data *) (xvec)->backend_data)
1546*a9fa9459Szrj 
1547*a9fa9459Szrj #define get_elf_backend_data(abfd) \
1548*a9fa9459Szrj    xvec_get_elf_backend_data ((abfd)->xvec)
1549*a9fa9459Szrj 
1550*a9fa9459Szrj /* The least object attributes (within an attributes subsection) known
1551*a9fa9459Szrj    for any target.  Some code assumes that the value 0 is not used and
1552*a9fa9459Szrj    the field for that attribute can instead be used as a marker to
1553*a9fa9459Szrj    indicate that attributes have been initialized.  */
1554*a9fa9459Szrj #define LEAST_KNOWN_OBJ_ATTRIBUTE 2
1555*a9fa9459Szrj 
1556*a9fa9459Szrj /* The maximum number of known object attributes for any target.  */
1557*a9fa9459Szrj #define NUM_KNOWN_OBJ_ATTRIBUTES 71
1558*a9fa9459Szrj 
1559*a9fa9459Szrj /* The value of an object attribute.  The type indicates whether the attribute
1560*a9fa9459Szrj    holds and integer, a string, or both.  It can also indicate that there can
1561*a9fa9459Szrj    be no default (i.e. all values must be written to file, even zero).  */
1562*a9fa9459Szrj 
1563*a9fa9459Szrj typedef struct obj_attribute
1564*a9fa9459Szrj {
1565*a9fa9459Szrj #define ATTR_TYPE_FLAG_INT_VAL    (1 << 0)
1566*a9fa9459Szrj #define ATTR_TYPE_FLAG_STR_VAL    (1 << 1)
1567*a9fa9459Szrj #define ATTR_TYPE_FLAG_NO_DEFAULT (1 << 2)
1568*a9fa9459Szrj 
1569*a9fa9459Szrj #define ATTR_TYPE_HAS_INT_VAL(TYPE)	((TYPE) & ATTR_TYPE_FLAG_INT_VAL)
1570*a9fa9459Szrj #define ATTR_TYPE_HAS_STR_VAL(TYPE)	((TYPE) & ATTR_TYPE_FLAG_STR_VAL)
1571*a9fa9459Szrj #define ATTR_TYPE_HAS_NO_DEFAULT(TYPE)	((TYPE) & ATTR_TYPE_FLAG_NO_DEFAULT)
1572*a9fa9459Szrj 
1573*a9fa9459Szrj   int type;
1574*a9fa9459Szrj   unsigned int i;
1575*a9fa9459Szrj   char *s;
1576*a9fa9459Szrj } obj_attribute;
1577*a9fa9459Szrj 
1578*a9fa9459Szrj typedef struct obj_attribute_list
1579*a9fa9459Szrj {
1580*a9fa9459Szrj   struct obj_attribute_list *next;
1581*a9fa9459Szrj   unsigned int tag;
1582*a9fa9459Szrj   obj_attribute attr;
1583*a9fa9459Szrj } obj_attribute_list;
1584*a9fa9459Szrj 
1585*a9fa9459Szrj /* Object attributes may either be defined by the processor ABI, index
1586*a9fa9459Szrj    OBJ_ATTR_PROC in the *_obj_attributes arrays, or be GNU-specific
1587*a9fa9459Szrj    (and possibly also processor-specific), index OBJ_ATTR_GNU.  */
1588*a9fa9459Szrj #define OBJ_ATTR_PROC 0
1589*a9fa9459Szrj #define OBJ_ATTR_GNU 1
1590*a9fa9459Szrj #define OBJ_ATTR_FIRST OBJ_ATTR_PROC
1591*a9fa9459Szrj #define OBJ_ATTR_LAST OBJ_ATTR_GNU
1592*a9fa9459Szrj 
1593*a9fa9459Szrj /* The following object attribute tags are taken as generic, for all
1594*a9fa9459Szrj    targets and for "gnu" where there is no target standard.  */
1595*a9fa9459Szrj enum
1596*a9fa9459Szrj {
1597*a9fa9459Szrj   Tag_NULL = 0,
1598*a9fa9459Szrj   Tag_File = 1,
1599*a9fa9459Szrj   Tag_Section = 2,
1600*a9fa9459Szrj   Tag_Symbol = 3,
1601*a9fa9459Szrj   Tag_compatibility = 32
1602*a9fa9459Szrj };
1603*a9fa9459Szrj 
1604*a9fa9459Szrj /* The following struct stores information about every SystemTap section
1605*a9fa9459Szrj    found in the object file.  */
1606*a9fa9459Szrj struct sdt_note
1607*a9fa9459Szrj {
1608*a9fa9459Szrj   struct sdt_note *next;
1609*a9fa9459Szrj   bfd_size_type size;
1610*a9fa9459Szrj   bfd_byte data[1];
1611*a9fa9459Szrj };
1612*a9fa9459Szrj 
1613*a9fa9459Szrj /* tdata information grabbed from an elf core file.  */
1614*a9fa9459Szrj struct core_elf_obj_tdata
1615*a9fa9459Szrj {
1616*a9fa9459Szrj   int signal;
1617*a9fa9459Szrj   int pid;
1618*a9fa9459Szrj   int lwpid;
1619*a9fa9459Szrj   char* program;
1620*a9fa9459Szrj   char* command;
1621*a9fa9459Szrj };
1622*a9fa9459Szrj 
1623*a9fa9459Szrj /* Extra tdata information held for output ELF BFDs.  */
1624*a9fa9459Szrj struct output_elf_obj_tdata
1625*a9fa9459Szrj {
1626*a9fa9459Szrj   struct elf_segment_map *seg_map;
1627*a9fa9459Szrj   struct elf_strtab_hash *strtab_ptr;
1628*a9fa9459Szrj 
1629*a9fa9459Szrj   /* STT_SECTION symbols for each section */
1630*a9fa9459Szrj   asymbol **section_syms;
1631*a9fa9459Szrj 
1632*a9fa9459Szrj   /* Used to determine if PT_GNU_EH_FRAME segment header should be
1633*a9fa9459Szrj      created.  */
1634*a9fa9459Szrj   asection *eh_frame_hdr;
1635*a9fa9459Szrj 
1636*a9fa9459Szrj   /* NT_GNU_BUILD_ID note type info.  */
1637*a9fa9459Szrj   struct
1638*a9fa9459Szrj   {
1639*a9fa9459Szrj     bfd_boolean (*after_write_object_contents) (bfd *);
1640*a9fa9459Szrj     const char *style;
1641*a9fa9459Szrj     asection *sec;
1642*a9fa9459Szrj   } build_id;
1643*a9fa9459Szrj 
1644*a9fa9459Szrj   /* Records the result of `get_program_header_size'.  */
1645*a9fa9459Szrj   bfd_size_type program_header_size;
1646*a9fa9459Szrj 
1647*a9fa9459Szrj   /* Used when laying out sections.  */
1648*a9fa9459Szrj   file_ptr next_file_pos;
1649*a9fa9459Szrj 
1650*a9fa9459Szrj   int num_section_syms;
1651*a9fa9459Szrj   unsigned int shstrtab_section, strtab_section;
1652*a9fa9459Szrj 
1653*a9fa9459Szrj   /* Segment flags for the PT_GNU_STACK segment.  */
1654*a9fa9459Szrj   unsigned int stack_flags;
1655*a9fa9459Szrj 
1656*a9fa9459Szrj   /* This is set to TRUE if the object was created by the backend
1657*a9fa9459Szrj      linker.  */
1658*a9fa9459Szrj   bfd_boolean linker;
1659*a9fa9459Szrj 
1660*a9fa9459Szrj   /* Used to determine if the e_flags field has been initialized */
1661*a9fa9459Szrj   bfd_boolean flags_init;
1662*a9fa9459Szrj };
1663*a9fa9459Szrj 
1664*a9fa9459Szrj /* Indicate if the bfd contains symbols that have the STT_GNU_IFUNC
1665*a9fa9459Szrj    symbol type or STB_GNU_UNIQUE binding.  Used to set the osabi
1666*a9fa9459Szrj    field in the ELF header structure.  */
1667*a9fa9459Szrj enum elf_gnu_symbols
1668*a9fa9459Szrj   {
1669*a9fa9459Szrj     elf_gnu_symbol_none = 0,
1670*a9fa9459Szrj     elf_gnu_symbol_any = 1 << 0,
1671*a9fa9459Szrj     elf_gnu_symbol_ifunc = (elf_gnu_symbol_any | 1 << 1),
1672*a9fa9459Szrj     elf_gnu_symbol_unique = (elf_gnu_symbol_any | 1 << 2),
1673*a9fa9459Szrj     elf_gnu_symbol_all = (elf_gnu_symbol_ifunc | elf_gnu_symbol_unique)
1674*a9fa9459Szrj   };
1675*a9fa9459Szrj 
1676*a9fa9459Szrj typedef struct elf_section_list
1677*a9fa9459Szrj {
1678*a9fa9459Szrj   Elf_Internal_Shdr          hdr;
1679*a9fa9459Szrj   unsigned int               ndx;
1680*a9fa9459Szrj   struct elf_section_list *  next;
1681*a9fa9459Szrj } elf_section_list;
1682*a9fa9459Szrj 
1683*a9fa9459Szrj 
1684*a9fa9459Szrj /* Some private data is stashed away for future use using the tdata pointer
1685*a9fa9459Szrj    in the bfd structure.  */
1686*a9fa9459Szrj 
1687*a9fa9459Szrj struct elf_obj_tdata
1688*a9fa9459Szrj {
1689*a9fa9459Szrj   Elf_Internal_Ehdr elf_header[1];	/* Actual data, but ref like ptr */
1690*a9fa9459Szrj   Elf_Internal_Shdr **elf_sect_ptr;
1691*a9fa9459Szrj   Elf_Internal_Phdr *phdr;
1692*a9fa9459Szrj   Elf_Internal_Shdr symtab_hdr;
1693*a9fa9459Szrj   Elf_Internal_Shdr shstrtab_hdr;
1694*a9fa9459Szrj   Elf_Internal_Shdr strtab_hdr;
1695*a9fa9459Szrj   Elf_Internal_Shdr dynsymtab_hdr;
1696*a9fa9459Szrj   Elf_Internal_Shdr dynstrtab_hdr;
1697*a9fa9459Szrj   Elf_Internal_Shdr dynversym_hdr;
1698*a9fa9459Szrj   Elf_Internal_Shdr dynverref_hdr;
1699*a9fa9459Szrj   Elf_Internal_Shdr dynverdef_hdr;
1700*a9fa9459Szrj   elf_section_list * symtab_shndx_list;
1701*a9fa9459Szrj   bfd_vma gp;				/* The gp value */
1702*a9fa9459Szrj   unsigned int gp_size;			/* The gp size */
1703*a9fa9459Szrj   unsigned int num_elf_sections;	/* elf_sect_ptr size */
1704*a9fa9459Szrj 
1705*a9fa9459Szrj   /* A mapping from external symbols to entries in the linker hash
1706*a9fa9459Szrj      table, used when linking.  This is indexed by the symbol index
1707*a9fa9459Szrj      minus the sh_info field of the symbol table header.  */
1708*a9fa9459Szrj   struct elf_link_hash_entry **sym_hashes;
1709*a9fa9459Szrj 
1710*a9fa9459Szrj   /* Track usage and final offsets of GOT entries for local symbols.
1711*a9fa9459Szrj      This array is indexed by symbol index.  Elements are used
1712*a9fa9459Szrj      identically to "got" in struct elf_link_hash_entry.  */
1713*a9fa9459Szrj   union
1714*a9fa9459Szrj     {
1715*a9fa9459Szrj       bfd_signed_vma *refcounts;
1716*a9fa9459Szrj       bfd_vma *offsets;
1717*a9fa9459Szrj       struct got_entry **ents;
1718*a9fa9459Szrj     } local_got;
1719*a9fa9459Szrj 
1720*a9fa9459Szrj   /* The linker ELF emulation code needs to let the backend ELF linker
1721*a9fa9459Szrj      know what filename should be used for a dynamic object if the
1722*a9fa9459Szrj      dynamic object is found using a search.  The emulation code then
1723*a9fa9459Szrj      sometimes needs to know what name was actually used.  Until the
1724*a9fa9459Szrj      file has been added to the linker symbol table, this field holds
1725*a9fa9459Szrj      the name the linker wants.  After it has been added, it holds the
1726*a9fa9459Szrj      name actually used, which will be the DT_SONAME entry if there is
1727*a9fa9459Szrj      one.  */
1728*a9fa9459Szrj   const char *dt_name;
1729*a9fa9459Szrj 
1730*a9fa9459Szrj   /* The linker emulation needs to know what audit libs
1731*a9fa9459Szrj      are used by a dynamic object.  */
1732*a9fa9459Szrj   const char *dt_audit;
1733*a9fa9459Szrj 
1734*a9fa9459Szrj   /* Used by find_nearest_line entry point.  */
1735*a9fa9459Szrj   void *line_info;
1736*a9fa9459Szrj 
1737*a9fa9459Szrj   /* A place to stash dwarf1 info for this bfd.  */
1738*a9fa9459Szrj   struct dwarf1_debug *dwarf1_find_line_info;
1739*a9fa9459Szrj 
1740*a9fa9459Szrj   /* A place to stash dwarf2 info for this bfd.  */
1741*a9fa9459Szrj   void *dwarf2_find_line_info;
1742*a9fa9459Szrj 
1743*a9fa9459Szrj   /* Stash away info for yet another find line/function variant.  */
1744*a9fa9459Szrj   void *elf_find_function_cache;
1745*a9fa9459Szrj 
1746*a9fa9459Szrj   /* Number of symbol version definitions we are about to emit.  */
1747*a9fa9459Szrj   unsigned int cverdefs;
1748*a9fa9459Szrj 
1749*a9fa9459Szrj   /* Number of symbol version references we are about to emit.  */
1750*a9fa9459Szrj   unsigned int cverrefs;
1751*a9fa9459Szrj 
1752*a9fa9459Szrj   /* Symbol version definitions in external objects.  */
1753*a9fa9459Szrj   Elf_Internal_Verdef *verdef;
1754*a9fa9459Szrj 
1755*a9fa9459Szrj   /* Symbol version references to external objects.  */
1756*a9fa9459Szrj   Elf_Internal_Verneed *verref;
1757*a9fa9459Szrj 
1758*a9fa9459Szrj   /* A pointer to the .eh_frame section.  */
1759*a9fa9459Szrj   asection *eh_frame_section;
1760*a9fa9459Szrj 
1761*a9fa9459Szrj   /* Symbol buffer.  */
1762*a9fa9459Szrj   void *symbuf;
1763*a9fa9459Szrj 
1764*a9fa9459Szrj   obj_attribute known_obj_attributes[2][NUM_KNOWN_OBJ_ATTRIBUTES];
1765*a9fa9459Szrj   obj_attribute_list *other_obj_attributes[2];
1766*a9fa9459Szrj 
1767*a9fa9459Szrj   /* Linked-list containing information about every Systemtap section
1768*a9fa9459Szrj      found in the object file.  Each section corresponds to one entry
1769*a9fa9459Szrj      in the list.  */
1770*a9fa9459Szrj   struct sdt_note *sdt_note_head;
1771*a9fa9459Szrj 
1772*a9fa9459Szrj   Elf_Internal_Shdr **group_sect_ptr;
1773*a9fa9459Szrj   int num_group;
1774*a9fa9459Szrj 
1775*a9fa9459Szrj   unsigned int symtab_section, dynsymtab_section;
1776*a9fa9459Szrj   unsigned int dynversym_section, dynverdef_section, dynverref_section;
1777*a9fa9459Szrj 
1778*a9fa9459Szrj   /* An identifier used to distinguish different target
1779*a9fa9459Szrj      specific extensions to this structure.  */
1780*a9fa9459Szrj   enum elf_target_id object_id;
1781*a9fa9459Szrj 
1782*a9fa9459Szrj   /* Whether a dyanmic object was specified normally on the linker
1783*a9fa9459Szrj      command line, or was specified when --as-needed was in effect,
1784*a9fa9459Szrj      or was found via a DT_NEEDED entry.  */
1785*a9fa9459Szrj   enum dynamic_lib_link_class dyn_lib_class;
1786*a9fa9459Szrj 
1787*a9fa9459Szrj   /* Irix 5 often screws up the symbol table, sorting local symbols
1788*a9fa9459Szrj      after global symbols.  This flag is set if the symbol table in
1789*a9fa9459Szrj      this BFD appears to be screwed up.  If it is, we ignore the
1790*a9fa9459Szrj      sh_info field in the symbol table header, and always read all the
1791*a9fa9459Szrj      symbols.  */
1792*a9fa9459Szrj   bfd_boolean bad_symtab;
1793*a9fa9459Szrj 
1794*a9fa9459Szrj   enum elf_gnu_symbols has_gnu_symbols;
1795*a9fa9459Szrj 
1796*a9fa9459Szrj   /* Information grabbed from an elf core file.  */
1797*a9fa9459Szrj   struct core_elf_obj_tdata *core;
1798*a9fa9459Szrj 
1799*a9fa9459Szrj   /* More information held for output ELF BFDs.  */
1800*a9fa9459Szrj   struct output_elf_obj_tdata *o;
1801*a9fa9459Szrj };
1802*a9fa9459Szrj 
1803*a9fa9459Szrj #define elf_tdata(bfd)		((bfd) -> tdata.elf_obj_data)
1804*a9fa9459Szrj 
1805*a9fa9459Szrj #define elf_object_id(bfd)	(elf_tdata(bfd) -> object_id)
1806*a9fa9459Szrj #define elf_program_header_size(bfd) (elf_tdata(bfd) -> o->program_header_size)
1807*a9fa9459Szrj #define elf_elfheader(bfd)	(elf_tdata(bfd) -> elf_header)
1808*a9fa9459Szrj #define elf_elfsections(bfd)	(elf_tdata(bfd) -> elf_sect_ptr)
1809*a9fa9459Szrj #define elf_numsections(bfd)	(elf_tdata(bfd) -> num_elf_sections)
1810*a9fa9459Szrj #define elf_seg_map(bfd)	(elf_tdata(bfd) -> o->seg_map)
1811*a9fa9459Szrj #define elf_next_file_pos(bfd)	(elf_tdata(bfd) -> o->next_file_pos)
1812*a9fa9459Szrj #define elf_eh_frame_hdr(bfd)	(elf_tdata(bfd) -> o->eh_frame_hdr)
1813*a9fa9459Szrj #define elf_linker(bfd)		(elf_tdata(bfd) -> o->linker)
1814*a9fa9459Szrj #define elf_stack_flags(bfd)	(elf_tdata(bfd) -> o->stack_flags)
1815*a9fa9459Szrj #define elf_shstrtab(bfd)	(elf_tdata(bfd) -> o->strtab_ptr)
1816*a9fa9459Szrj #define elf_onesymtab(bfd)	(elf_tdata(bfd) -> symtab_section)
1817*a9fa9459Szrj #define elf_symtab_shndx_list(bfd)	(elf_tdata(bfd) -> symtab_shndx_list)
1818*a9fa9459Szrj #define elf_strtab_sec(bfd)	(elf_tdata(bfd) -> o->strtab_section)
1819*a9fa9459Szrj #define elf_shstrtab_sec(bfd)	(elf_tdata(bfd) -> o->shstrtab_section)
1820*a9fa9459Szrj #define elf_symtab_hdr(bfd)	(elf_tdata(bfd) -> symtab_hdr)
1821*a9fa9459Szrj #define elf_dynsymtab(bfd)	(elf_tdata(bfd) -> dynsymtab_section)
1822*a9fa9459Szrj #define elf_dynversym(bfd)	(elf_tdata(bfd) -> dynversym_section)
1823*a9fa9459Szrj #define elf_dynverdef(bfd)	(elf_tdata(bfd) -> dynverdef_section)
1824*a9fa9459Szrj #define elf_dynverref(bfd)	(elf_tdata(bfd) -> dynverref_section)
1825*a9fa9459Szrj #define elf_eh_frame_section(bfd) \
1826*a9fa9459Szrj 				(elf_tdata(bfd) -> eh_frame_section)
1827*a9fa9459Szrj #define elf_section_syms(bfd)	(elf_tdata(bfd) -> o->section_syms)
1828*a9fa9459Szrj #define elf_num_section_syms(bfd) (elf_tdata(bfd) -> o->num_section_syms)
1829*a9fa9459Szrj #define core_prpsinfo(bfd)	(elf_tdata(bfd) -> prpsinfo)
1830*a9fa9459Szrj #define core_prstatus(bfd)	(elf_tdata(bfd) -> prstatus)
1831*a9fa9459Szrj #define elf_gp(bfd)		(elf_tdata(bfd) -> gp)
1832*a9fa9459Szrj #define elf_gp_size(bfd)	(elf_tdata(bfd) -> gp_size)
1833*a9fa9459Szrj #define elf_sym_hashes(bfd)	(elf_tdata(bfd) -> sym_hashes)
1834*a9fa9459Szrj #define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
1835*a9fa9459Szrj #define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
1836*a9fa9459Szrj #define elf_local_got_ents(bfd) (elf_tdata(bfd) -> local_got.ents)
1837*a9fa9459Szrj #define elf_dt_name(bfd)	(elf_tdata(bfd) -> dt_name)
1838*a9fa9459Szrj #define elf_dt_audit(bfd)	(elf_tdata(bfd) -> dt_audit)
1839*a9fa9459Szrj #define elf_dyn_lib_class(bfd)	(elf_tdata(bfd) -> dyn_lib_class)
1840*a9fa9459Szrj #define elf_bad_symtab(bfd)	(elf_tdata(bfd) -> bad_symtab)
1841*a9fa9459Szrj #define elf_flags_init(bfd)	(elf_tdata(bfd) -> o->flags_init)
1842*a9fa9459Szrj #define elf_known_obj_attributes(bfd) (elf_tdata (bfd) -> known_obj_attributes)
1843*a9fa9459Szrj #define elf_other_obj_attributes(bfd) (elf_tdata (bfd) -> other_obj_attributes)
1844*a9fa9459Szrj #define elf_known_obj_attributes_proc(bfd) \
1845*a9fa9459Szrj   (elf_known_obj_attributes (bfd) [OBJ_ATTR_PROC])
1846*a9fa9459Szrj #define elf_other_obj_attributes_proc(bfd) \
1847*a9fa9459Szrj   (elf_other_obj_attributes (bfd) [OBJ_ATTR_PROC])
1848*a9fa9459Szrj 
1849*a9fa9459Szrj extern void _bfd_elf_swap_verdef_in
1850*a9fa9459Szrj   (bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *);
1851*a9fa9459Szrj extern void _bfd_elf_swap_verdef_out
1852*a9fa9459Szrj   (bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *);
1853*a9fa9459Szrj extern void _bfd_elf_swap_verdaux_in
1854*a9fa9459Szrj   (bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *);
1855*a9fa9459Szrj extern void _bfd_elf_swap_verdaux_out
1856*a9fa9459Szrj   (bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *);
1857*a9fa9459Szrj extern void _bfd_elf_swap_verneed_in
1858*a9fa9459Szrj   (bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *);
1859*a9fa9459Szrj extern void _bfd_elf_swap_verneed_out
1860*a9fa9459Szrj   (bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *);
1861*a9fa9459Szrj extern void _bfd_elf_swap_vernaux_in
1862*a9fa9459Szrj   (bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *);
1863*a9fa9459Szrj extern void _bfd_elf_swap_vernaux_out
1864*a9fa9459Szrj   (bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *);
1865*a9fa9459Szrj extern void _bfd_elf_swap_versym_in
1866*a9fa9459Szrj   (bfd *, const Elf_External_Versym *, Elf_Internal_Versym *);
1867*a9fa9459Szrj extern void _bfd_elf_swap_versym_out
1868*a9fa9459Szrj   (bfd *, const Elf_Internal_Versym *, Elf_External_Versym *);
1869*a9fa9459Szrj 
1870*a9fa9459Szrj extern unsigned int _bfd_elf_section_from_bfd_section
1871*a9fa9459Szrj   (bfd *, asection *);
1872*a9fa9459Szrj extern char *bfd_elf_string_from_elf_section
1873*a9fa9459Szrj   (bfd *, unsigned, unsigned);
1874*a9fa9459Szrj extern Elf_Internal_Sym *bfd_elf_get_elf_syms
1875*a9fa9459Szrj   (bfd *, Elf_Internal_Shdr *, size_t, size_t, Elf_Internal_Sym *, void *,
1876*a9fa9459Szrj    Elf_External_Sym_Shndx *);
1877*a9fa9459Szrj extern const char *bfd_elf_sym_name
1878*a9fa9459Szrj   (bfd *, Elf_Internal_Shdr *, Elf_Internal_Sym *, asection *);
1879*a9fa9459Szrj 
1880*a9fa9459Szrj extern bfd_boolean _bfd_elf_copy_private_bfd_data
1881*a9fa9459Szrj   (bfd *, bfd *);
1882*a9fa9459Szrj extern bfd_boolean _bfd_elf_print_private_bfd_data
1883*a9fa9459Szrj   (bfd *, void *);
1884*a9fa9459Szrj const char * _bfd_elf_get_symbol_version_string
1885*a9fa9459Szrj   (bfd *, asymbol *, bfd_boolean *);
1886*a9fa9459Szrj extern void bfd_elf_print_symbol
1887*a9fa9459Szrj   (bfd *, void *, asymbol *, bfd_print_symbol_type);
1888*a9fa9459Szrj 
1889*a9fa9459Szrj extern unsigned int _bfd_elf_eh_frame_address_size
1890*a9fa9459Szrj   (bfd *, asection *);
1891*a9fa9459Szrj extern bfd_byte _bfd_elf_encode_eh_address
1892*a9fa9459Szrj   (bfd *abfd, struct bfd_link_info *info, asection *osec, bfd_vma offset,
1893*a9fa9459Szrj    asection *loc_sec, bfd_vma loc_offset, bfd_vma *encoded);
1894*a9fa9459Szrj extern bfd_boolean _bfd_elf_can_make_relative
1895*a9fa9459Szrj   (bfd *input_bfd, struct bfd_link_info *info, asection *eh_frame_section);
1896*a9fa9459Szrj 
1897*a9fa9459Szrj extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
1898*a9fa9459Szrj   (const struct bfd_link_info *, const asection *,
1899*a9fa9459Szrj    const Elf_Internal_Rela *);
1900*a9fa9459Szrj extern bfd_vma _bfd_elf_rela_local_sym
1901*a9fa9459Szrj   (bfd *, Elf_Internal_Sym *, asection **, Elf_Internal_Rela *);
1902*a9fa9459Szrj extern bfd_vma _bfd_elf_rel_local_sym
1903*a9fa9459Szrj   (bfd *, Elf_Internal_Sym *, asection **, bfd_vma);
1904*a9fa9459Szrj extern bfd_vma _bfd_elf_section_offset
1905*a9fa9459Szrj   (bfd *, struct bfd_link_info *, asection *, bfd_vma);
1906*a9fa9459Szrj 
1907*a9fa9459Szrj extern unsigned long bfd_elf_hash
1908*a9fa9459Szrj   (const char *);
1909*a9fa9459Szrj extern unsigned long bfd_elf_gnu_hash
1910*a9fa9459Szrj   (const char *);
1911*a9fa9459Szrj 
1912*a9fa9459Szrj extern bfd_reloc_status_type bfd_elf_generic_reloc
1913*a9fa9459Szrj   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
1914*a9fa9459Szrj extern bfd_boolean bfd_elf_allocate_object
1915*a9fa9459Szrj   (bfd *, size_t, enum elf_target_id);
1916*a9fa9459Szrj extern bfd_boolean bfd_elf_make_object
1917*a9fa9459Szrj   (bfd *);
1918*a9fa9459Szrj extern bfd_boolean bfd_elf_mkcorefile
1919*a9fa9459Szrj   (bfd *);
1920*a9fa9459Szrj extern bfd_boolean _bfd_elf_make_section_from_shdr
1921*a9fa9459Szrj   (bfd *, Elf_Internal_Shdr *, const char *, int);
1922*a9fa9459Szrj extern bfd_boolean _bfd_elf_make_section_from_phdr
1923*a9fa9459Szrj   (bfd *, Elf_Internal_Phdr *, int, const char *);
1924*a9fa9459Szrj extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
1925*a9fa9459Szrj   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
1926*a9fa9459Szrj extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
1927*a9fa9459Szrj   (bfd *);
1928*a9fa9459Szrj extern void _bfd_elf_link_hash_table_free
1929*a9fa9459Szrj   (bfd *);
1930*a9fa9459Szrj extern void _bfd_elf_link_hash_copy_indirect
1931*a9fa9459Szrj   (struct bfd_link_info *, struct elf_link_hash_entry *,
1932*a9fa9459Szrj    struct elf_link_hash_entry *);
1933*a9fa9459Szrj extern void _bfd_elf_link_hash_hide_symbol
1934*a9fa9459Szrj   (struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
1935*a9fa9459Szrj extern bfd_boolean _bfd_elf_link_hash_fixup_symbol
1936*a9fa9459Szrj   (struct bfd_link_info *, struct elf_link_hash_entry *);
1937*a9fa9459Szrj extern bfd_boolean _bfd_elf_link_hash_table_init
1938*a9fa9459Szrj   (struct elf_link_hash_table *, bfd *,
1939*a9fa9459Szrj    struct bfd_hash_entry *(*)
1940*a9fa9459Szrj      (struct bfd_hash_entry *, struct bfd_hash_table *, const char *),
1941*a9fa9459Szrj    unsigned int, enum elf_target_id);
1942*a9fa9459Szrj extern bfd_boolean _bfd_elf_slurp_version_tables
1943*a9fa9459Szrj   (bfd *, bfd_boolean);
1944*a9fa9459Szrj extern bfd_boolean _bfd_elf_merge_sections
1945*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
1946*a9fa9459Szrj extern bfd_boolean _bfd_elf_match_sections_by_type
1947*a9fa9459Szrj   (bfd *, const asection *, bfd *, const asection *);
1948*a9fa9459Szrj extern bfd_boolean bfd_elf_is_group_section
1949*a9fa9459Szrj   (bfd *, const struct bfd_section *);
1950*a9fa9459Szrj extern bfd_boolean _bfd_elf_section_already_linked
1951*a9fa9459Szrj   (bfd *, asection *, struct bfd_link_info *);
1952*a9fa9459Szrj extern void bfd_elf_set_group_contents
1953*a9fa9459Szrj   (bfd *, asection *, void *);
1954*a9fa9459Szrj extern asection *_bfd_elf_check_kept_section
1955*a9fa9459Szrj   (asection *, struct bfd_link_info *);
1956*a9fa9459Szrj #define _bfd_elf_link_just_syms _bfd_generic_link_just_syms
1957*a9fa9459Szrj extern void _bfd_elf_copy_link_hash_symbol_type
1958*a9fa9459Szrj   (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *);
1959*a9fa9459Szrj extern bfd_boolean _bfd_elf_size_group_sections
1960*a9fa9459Szrj   (struct bfd_link_info *);
1961*a9fa9459Szrj extern bfd_boolean _bfd_elf_fixup_group_sections
1962*a9fa9459Szrj (bfd *, asection *);
1963*a9fa9459Szrj extern bfd_boolean _bfd_elf_copy_private_header_data
1964*a9fa9459Szrj   (bfd *, bfd *);
1965*a9fa9459Szrj extern bfd_boolean _bfd_elf_copy_private_symbol_data
1966*a9fa9459Szrj   (bfd *, asymbol *, bfd *, asymbol *);
1967*a9fa9459Szrj #define _bfd_generic_init_private_section_data \
1968*a9fa9459Szrj   _bfd_elf_init_private_section_data
1969*a9fa9459Szrj extern bfd_boolean _bfd_elf_init_private_section_data
1970*a9fa9459Szrj   (bfd *, asection *, bfd *, asection *, struct bfd_link_info *);
1971*a9fa9459Szrj extern bfd_boolean _bfd_elf_copy_private_section_data
1972*a9fa9459Szrj   (bfd *, asection *, bfd *, asection *);
1973*a9fa9459Szrj extern bfd_boolean _bfd_elf_write_object_contents
1974*a9fa9459Szrj   (bfd *);
1975*a9fa9459Szrj extern bfd_boolean _bfd_elf_write_corefile_contents
1976*a9fa9459Szrj   (bfd *);
1977*a9fa9459Szrj extern bfd_boolean _bfd_elf_set_section_contents
1978*a9fa9459Szrj   (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type);
1979*a9fa9459Szrj extern long _bfd_elf_get_symtab_upper_bound
1980*a9fa9459Szrj   (bfd *);
1981*a9fa9459Szrj extern long _bfd_elf_canonicalize_symtab
1982*a9fa9459Szrj   (bfd *, asymbol **);
1983*a9fa9459Szrj extern long _bfd_elf_get_dynamic_symtab_upper_bound
1984*a9fa9459Szrj   (bfd *);
1985*a9fa9459Szrj extern long _bfd_elf_canonicalize_dynamic_symtab
1986*a9fa9459Szrj   (bfd *, asymbol **);
1987*a9fa9459Szrj extern long _bfd_elf_get_synthetic_symtab
1988*a9fa9459Szrj   (bfd *, long, asymbol **, long, asymbol **, asymbol **);
1989*a9fa9459Szrj extern long _bfd_elf_get_reloc_upper_bound
1990*a9fa9459Szrj   (bfd *, sec_ptr);
1991*a9fa9459Szrj extern long _bfd_elf_canonicalize_reloc
1992*a9fa9459Szrj   (bfd *, sec_ptr, arelent **, asymbol **);
1993*a9fa9459Szrj extern asection * _bfd_elf_get_dynamic_reloc_section
1994*a9fa9459Szrj   (bfd *, asection *, bfd_boolean);
1995*a9fa9459Szrj extern asection * _bfd_elf_make_dynamic_reloc_section
1996*a9fa9459Szrj   (asection *, bfd *, unsigned int, bfd *, bfd_boolean);
1997*a9fa9459Szrj extern long _bfd_elf_get_dynamic_reloc_upper_bound
1998*a9fa9459Szrj   (bfd *);
1999*a9fa9459Szrj extern long _bfd_elf_canonicalize_dynamic_reloc
2000*a9fa9459Szrj   (bfd *, arelent **, asymbol **);
2001*a9fa9459Szrj extern asymbol *_bfd_elf_make_empty_symbol
2002*a9fa9459Szrj   (bfd *);
2003*a9fa9459Szrj extern void _bfd_elf_get_symbol_info
2004*a9fa9459Szrj   (bfd *, asymbol *, symbol_info *);
2005*a9fa9459Szrj extern bfd_boolean _bfd_elf_is_local_label_name
2006*a9fa9459Szrj   (bfd *, const char *);
2007*a9fa9459Szrj extern alent *_bfd_elf_get_lineno
2008*a9fa9459Szrj   (bfd *, asymbol *);
2009*a9fa9459Szrj extern bfd_boolean _bfd_elf_set_arch_mach
2010*a9fa9459Szrj   (bfd *, enum bfd_architecture, unsigned long);
2011*a9fa9459Szrj extern bfd_boolean _bfd_elf_find_nearest_line
2012*a9fa9459Szrj   (bfd *, asymbol **, asection *, bfd_vma,
2013*a9fa9459Szrj    const char **, const char **, unsigned int *, unsigned int *);
2014*a9fa9459Szrj extern bfd_boolean _bfd_elf_find_line
2015*a9fa9459Szrj   (bfd *, asymbol **, asymbol *, const char **, unsigned int *);
2016*a9fa9459Szrj extern bfd_boolean _bfd_elf_find_inliner_info
2017*a9fa9459Szrj   (bfd *, const char **, const char **, unsigned int *);
2018*a9fa9459Szrj extern asymbol *_bfd_elf_find_function
2019*a9fa9459Szrj   (bfd *, asymbol **, asection *, bfd_vma, const char **, const char **);
2020*a9fa9459Szrj #define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
2021*a9fa9459Szrj #define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
2022*a9fa9459Szrj extern int _bfd_elf_sizeof_headers
2023*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2024*a9fa9459Szrj extern bfd_boolean _bfd_elf_new_section_hook
2025*a9fa9459Szrj   (bfd *, asection *);
2026*a9fa9459Szrj extern const struct bfd_elf_special_section *_bfd_elf_get_special_section
2027*a9fa9459Szrj   (const char *, const struct bfd_elf_special_section *, unsigned int);
2028*a9fa9459Szrj extern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr
2029*a9fa9459Szrj   (bfd *, asection *);
2030*a9fa9459Szrj 
2031*a9fa9459Szrj /* If the target doesn't have reloc handling written yet:  */
2032*a9fa9459Szrj extern void _bfd_elf_no_info_to_howto
2033*a9fa9459Szrj   (bfd *, arelent *, Elf_Internal_Rela *);
2034*a9fa9459Szrj 
2035*a9fa9459Szrj extern bfd_boolean bfd_section_from_shdr
2036*a9fa9459Szrj   (bfd *, unsigned int shindex);
2037*a9fa9459Szrj extern bfd_boolean bfd_section_from_phdr
2038*a9fa9459Szrj   (bfd *, Elf_Internal_Phdr *, int);
2039*a9fa9459Szrj 
2040*a9fa9459Szrj extern int _bfd_elf_symbol_from_bfd_symbol
2041*a9fa9459Szrj   (bfd *, asymbol **);
2042*a9fa9459Szrj 
2043*a9fa9459Szrj extern Elf_Internal_Sym *bfd_sym_from_r_symndx
2044*a9fa9459Szrj   (struct sym_cache *, bfd *, unsigned long);
2045*a9fa9459Szrj extern asection *bfd_section_from_elf_index
2046*a9fa9459Szrj   (bfd *, unsigned int);
2047*a9fa9459Szrj 
2048*a9fa9459Szrj extern struct elf_strtab_hash * _bfd_elf_strtab_init
2049*a9fa9459Szrj   (void);
2050*a9fa9459Szrj extern void _bfd_elf_strtab_free
2051*a9fa9459Szrj   (struct elf_strtab_hash *);
2052*a9fa9459Szrj extern size_t _bfd_elf_strtab_add
2053*a9fa9459Szrj   (struct elf_strtab_hash *, const char *, bfd_boolean);
2054*a9fa9459Szrj extern void _bfd_elf_strtab_addref
2055*a9fa9459Szrj   (struct elf_strtab_hash *, size_t);
2056*a9fa9459Szrj extern void _bfd_elf_strtab_delref
2057*a9fa9459Szrj   (struct elf_strtab_hash *, size_t);
2058*a9fa9459Szrj extern unsigned int _bfd_elf_strtab_refcount
2059*a9fa9459Szrj   (struct elf_strtab_hash *, size_t);
2060*a9fa9459Szrj extern void _bfd_elf_strtab_clear_all_refs
2061*a9fa9459Szrj   (struct elf_strtab_hash *);
2062*a9fa9459Szrj extern void *_bfd_elf_strtab_save
2063*a9fa9459Szrj   (struct elf_strtab_hash *);
2064*a9fa9459Szrj extern void _bfd_elf_strtab_restore
2065*a9fa9459Szrj   (struct elf_strtab_hash *, void *);
2066*a9fa9459Szrj extern bfd_size_type _bfd_elf_strtab_size
2067*a9fa9459Szrj   (struct elf_strtab_hash *);
2068*a9fa9459Szrj extern bfd_size_type _bfd_elf_strtab_offset
2069*a9fa9459Szrj   (struct elf_strtab_hash *, size_t);
2070*a9fa9459Szrj extern bfd_boolean _bfd_elf_strtab_emit
2071*a9fa9459Szrj   (bfd *, struct elf_strtab_hash *);
2072*a9fa9459Szrj extern void _bfd_elf_strtab_finalize
2073*a9fa9459Szrj   (struct elf_strtab_hash *);
2074*a9fa9459Szrj 
2075*a9fa9459Szrj extern bfd_boolean bfd_elf_parse_eh_frame_entries
2076*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2077*a9fa9459Szrj extern bfd_boolean _bfd_elf_parse_eh_frame_entry
2078*a9fa9459Szrj   (struct bfd_link_info *, asection *, struct elf_reloc_cookie *);
2079*a9fa9459Szrj extern void _bfd_elf_parse_eh_frame
2080*a9fa9459Szrj   (bfd *, struct bfd_link_info *, asection *, struct elf_reloc_cookie *);
2081*a9fa9459Szrj extern bfd_boolean _bfd_elf_end_eh_frame_parsing
2082*a9fa9459Szrj   (struct bfd_link_info *info);
2083*a9fa9459Szrj 
2084*a9fa9459Szrj extern bfd_boolean _bfd_elf_discard_section_eh_frame
2085*a9fa9459Szrj   (bfd *, struct bfd_link_info *, asection *,
2086*a9fa9459Szrj    bfd_boolean (*) (bfd_vma, void *), struct elf_reloc_cookie *);
2087*a9fa9459Szrj extern bfd_boolean _bfd_elf_discard_section_eh_frame_hdr
2088*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2089*a9fa9459Szrj extern bfd_vma _bfd_elf_eh_frame_section_offset
2090*a9fa9459Szrj   (bfd *, struct bfd_link_info *, asection *, bfd_vma);
2091*a9fa9459Szrj extern bfd_boolean _bfd_elf_write_section_eh_frame
2092*a9fa9459Szrj   (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
2093*a9fa9459Szrj bfd_boolean _bfd_elf_write_section_eh_frame_entry
2094*a9fa9459Szrj   (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
2095*a9fa9459Szrj extern bfd_boolean _bfd_elf_fixup_eh_frame_hdr (struct bfd_link_info *);
2096*a9fa9459Szrj extern bfd_boolean _bfd_elf_write_section_eh_frame_hdr
2097*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2098*a9fa9459Szrj extern bfd_boolean _bfd_elf_eh_frame_present
2099*a9fa9459Szrj   (struct bfd_link_info *);
2100*a9fa9459Szrj extern bfd_boolean _bfd_elf_eh_frame_entry_present
2101*a9fa9459Szrj   (struct bfd_link_info *);
2102*a9fa9459Szrj extern bfd_boolean _bfd_elf_maybe_strip_eh_frame_hdr
2103*a9fa9459Szrj   (struct bfd_link_info *);
2104*a9fa9459Szrj 
2105*a9fa9459Szrj extern bfd_boolean _bfd_elf_hash_symbol (struct elf_link_hash_entry *);
2106*a9fa9459Szrj 
2107*a9fa9459Szrj extern long _bfd_elf_link_lookup_local_dynindx
2108*a9fa9459Szrj   (struct bfd_link_info *, bfd *, long);
2109*a9fa9459Szrj extern bfd_boolean _bfd_elf_compute_section_file_positions
2110*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2111*a9fa9459Szrj extern file_ptr _bfd_elf_assign_file_position_for_section
2112*a9fa9459Szrj   (Elf_Internal_Shdr *, file_ptr, bfd_boolean);
2113*a9fa9459Szrj 
2114*a9fa9459Szrj extern bfd_boolean _bfd_elf_validate_reloc
2115*a9fa9459Szrj   (bfd *, arelent *);
2116*a9fa9459Szrj 
2117*a9fa9459Szrj extern bfd_boolean _bfd_elf_link_create_dynamic_sections
2118*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2119*a9fa9459Szrj extern bfd_boolean _bfd_elf_link_omit_section_dynsym
2120*a9fa9459Szrj   (bfd *, struct bfd_link_info *, asection *);
2121*a9fa9459Szrj extern bfd_boolean _bfd_elf_create_dynamic_sections
2122*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2123*a9fa9459Szrj extern bfd_boolean _bfd_elf_create_got_section
2124*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2125*a9fa9459Szrj extern asection *_bfd_elf_section_for_symbol
2126*a9fa9459Szrj   (struct elf_reloc_cookie *, unsigned long, bfd_boolean);
2127*a9fa9459Szrj extern struct elf_link_hash_entry *_bfd_elf_define_linkage_sym
2128*a9fa9459Szrj   (bfd *, struct bfd_link_info *, asection *, const char *);
2129*a9fa9459Szrj extern void _bfd_elf_init_1_index_section
2130*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2131*a9fa9459Szrj extern void _bfd_elf_init_2_index_sections
2132*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2133*a9fa9459Szrj 
2134*a9fa9459Szrj extern bfd_boolean _bfd_elfcore_make_pseudosection
2135*a9fa9459Szrj   (bfd *, char *, size_t, ufile_ptr);
2136*a9fa9459Szrj extern char *_bfd_elfcore_strndup
2137*a9fa9459Szrj   (bfd *, char *, size_t);
2138*a9fa9459Szrj 
2139*a9fa9459Szrj extern Elf_Internal_Rela *_bfd_elf_link_read_relocs
2140*a9fa9459Szrj   (bfd *, asection *, void *, Elf_Internal_Rela *, bfd_boolean);
2141*a9fa9459Szrj 
2142*a9fa9459Szrj extern bfd_boolean _bfd_elf_link_output_relocs
2143*a9fa9459Szrj   (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
2144*a9fa9459Szrj    struct elf_link_hash_entry **);
2145*a9fa9459Szrj 
2146*a9fa9459Szrj extern bfd_boolean _bfd_elf_adjust_dynamic_copy
2147*a9fa9459Szrj   (struct bfd_link_info *, struct elf_link_hash_entry *, asection *);
2148*a9fa9459Szrj 
2149*a9fa9459Szrj extern bfd_boolean _bfd_elf_dynamic_symbol_p
2150*a9fa9459Szrj   (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);
2151*a9fa9459Szrj 
2152*a9fa9459Szrj extern bfd_boolean _bfd_elf_symbol_refs_local_p
2153*a9fa9459Szrj   (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);
2154*a9fa9459Szrj 
2155*a9fa9459Szrj extern bfd_reloc_status_type bfd_elf_perform_complex_relocation
2156*a9fa9459Szrj   (bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, bfd_vma);
2157*a9fa9459Szrj 
2158*a9fa9459Szrj extern bfd_boolean _bfd_elf_setup_sections
2159*a9fa9459Szrj   (bfd *);
2160*a9fa9459Szrj 
2161*a9fa9459Szrj extern void _bfd_elf_post_process_headers (bfd * , struct bfd_link_info *);
2162*a9fa9459Szrj 
2163*a9fa9459Szrj extern const bfd_target *bfd_elf32_object_p
2164*a9fa9459Szrj   (bfd *);
2165*a9fa9459Szrj extern const bfd_target *bfd_elf32_core_file_p
2166*a9fa9459Szrj   (bfd *);
2167*a9fa9459Szrj extern char *bfd_elf32_core_file_failing_command
2168*a9fa9459Szrj   (bfd *);
2169*a9fa9459Szrj extern int bfd_elf32_core_file_failing_signal
2170*a9fa9459Szrj   (bfd *);
2171*a9fa9459Szrj extern bfd_boolean bfd_elf32_core_file_matches_executable_p
2172*a9fa9459Szrj   (bfd *, bfd *);
2173*a9fa9459Szrj extern int bfd_elf32_core_file_pid
2174*a9fa9459Szrj   (bfd *);
2175*a9fa9459Szrj 
2176*a9fa9459Szrj extern bfd_boolean bfd_elf32_swap_symbol_in
2177*a9fa9459Szrj   (bfd *, const void *, const void *, Elf_Internal_Sym *);
2178*a9fa9459Szrj extern void bfd_elf32_swap_symbol_out
2179*a9fa9459Szrj   (bfd *, const Elf_Internal_Sym *, void *, void *);
2180*a9fa9459Szrj extern void bfd_elf32_swap_reloc_in
2181*a9fa9459Szrj   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
2182*a9fa9459Szrj extern void bfd_elf32_swap_reloc_out
2183*a9fa9459Szrj   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
2184*a9fa9459Szrj extern void bfd_elf32_swap_reloca_in
2185*a9fa9459Szrj   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
2186*a9fa9459Szrj extern void bfd_elf32_swap_reloca_out
2187*a9fa9459Szrj   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
2188*a9fa9459Szrj extern void bfd_elf32_swap_phdr_in
2189*a9fa9459Szrj   (bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *);
2190*a9fa9459Szrj extern void bfd_elf32_swap_phdr_out
2191*a9fa9459Szrj   (bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *);
2192*a9fa9459Szrj extern void bfd_elf32_swap_dyn_in
2193*a9fa9459Szrj   (bfd *, const void *, Elf_Internal_Dyn *);
2194*a9fa9459Szrj extern void bfd_elf32_swap_dyn_out
2195*a9fa9459Szrj   (bfd *, const Elf_Internal_Dyn *, void *);
2196*a9fa9459Szrj extern long bfd_elf32_slurp_symbol_table
2197*a9fa9459Szrj   (bfd *, asymbol **, bfd_boolean);
2198*a9fa9459Szrj extern bfd_boolean bfd_elf32_write_shdrs_and_ehdr
2199*a9fa9459Szrj   (bfd *);
2200*a9fa9459Szrj extern int bfd_elf32_write_out_phdrs
2201*a9fa9459Szrj   (bfd *, const Elf_Internal_Phdr *, unsigned int);
2202*a9fa9459Szrj extern bfd_boolean bfd_elf32_checksum_contents
2203*a9fa9459Szrj   (bfd * , void (*) (const void *, size_t, void *), void *);
2204*a9fa9459Szrj extern void bfd_elf32_write_relocs
2205*a9fa9459Szrj   (bfd *, asection *, void *);
2206*a9fa9459Szrj extern bfd_boolean bfd_elf32_slurp_reloc_table
2207*a9fa9459Szrj   (bfd *, asection *, asymbol **, bfd_boolean);
2208*a9fa9459Szrj 
2209*a9fa9459Szrj extern const bfd_target *bfd_elf64_object_p
2210*a9fa9459Szrj   (bfd *);
2211*a9fa9459Szrj extern const bfd_target *bfd_elf64_core_file_p
2212*a9fa9459Szrj   (bfd *);
2213*a9fa9459Szrj extern char *bfd_elf64_core_file_failing_command
2214*a9fa9459Szrj   (bfd *);
2215*a9fa9459Szrj extern int bfd_elf64_core_file_failing_signal
2216*a9fa9459Szrj   (bfd *);
2217*a9fa9459Szrj extern bfd_boolean bfd_elf64_core_file_matches_executable_p
2218*a9fa9459Szrj   (bfd *, bfd *);
2219*a9fa9459Szrj extern int bfd_elf64_core_file_pid
2220*a9fa9459Szrj   (bfd *);
2221*a9fa9459Szrj 
2222*a9fa9459Szrj extern bfd_boolean bfd_elf64_swap_symbol_in
2223*a9fa9459Szrj   (bfd *, const void *, const void *, Elf_Internal_Sym *);
2224*a9fa9459Szrj extern void bfd_elf64_swap_symbol_out
2225*a9fa9459Szrj   (bfd *, const Elf_Internal_Sym *, void *, void *);
2226*a9fa9459Szrj extern void bfd_elf64_swap_reloc_in
2227*a9fa9459Szrj   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
2228*a9fa9459Szrj extern void bfd_elf64_swap_reloc_out
2229*a9fa9459Szrj   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
2230*a9fa9459Szrj extern void bfd_elf64_swap_reloca_in
2231*a9fa9459Szrj   (bfd *, const bfd_byte *, Elf_Internal_Rela *);
2232*a9fa9459Szrj extern void bfd_elf64_swap_reloca_out
2233*a9fa9459Szrj   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
2234*a9fa9459Szrj extern void bfd_elf64_swap_phdr_in
2235*a9fa9459Szrj   (bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *);
2236*a9fa9459Szrj extern void bfd_elf64_swap_phdr_out
2237*a9fa9459Szrj   (bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *);
2238*a9fa9459Szrj extern void bfd_elf64_swap_dyn_in
2239*a9fa9459Szrj   (bfd *, const void *, Elf_Internal_Dyn *);
2240*a9fa9459Szrj extern void bfd_elf64_swap_dyn_out
2241*a9fa9459Szrj   (bfd *, const Elf_Internal_Dyn *, void *);
2242*a9fa9459Szrj extern long bfd_elf64_slurp_symbol_table
2243*a9fa9459Szrj   (bfd *, asymbol **, bfd_boolean);
2244*a9fa9459Szrj extern bfd_boolean bfd_elf64_write_shdrs_and_ehdr
2245*a9fa9459Szrj   (bfd *);
2246*a9fa9459Szrj extern int bfd_elf64_write_out_phdrs
2247*a9fa9459Szrj   (bfd *, const Elf_Internal_Phdr *, unsigned int);
2248*a9fa9459Szrj extern bfd_boolean bfd_elf64_checksum_contents
2249*a9fa9459Szrj   (bfd * , void (*) (const void *, size_t, void *), void *);
2250*a9fa9459Szrj extern void bfd_elf64_write_relocs
2251*a9fa9459Szrj   (bfd *, asection *, void *);
2252*a9fa9459Szrj extern bfd_boolean bfd_elf64_slurp_reloc_table
2253*a9fa9459Szrj   (bfd *, asection *, asymbol **, bfd_boolean);
2254*a9fa9459Szrj 
2255*a9fa9459Szrj extern bfd_boolean _bfd_elf_default_relocs_compatible
2256*a9fa9459Szrj   (const bfd_target *, const bfd_target *);
2257*a9fa9459Szrj 
2258*a9fa9459Szrj extern bfd_boolean _bfd_elf_relocs_compatible
2259*a9fa9459Szrj   (const bfd_target *, const bfd_target *);
2260*a9fa9459Szrj extern bfd_boolean _bfd_elf_notice_as_needed
2261*a9fa9459Szrj   (bfd *, struct bfd_link_info *, enum notice_asneeded_action);
2262*a9fa9459Szrj 
2263*a9fa9459Szrj extern struct elf_link_hash_entry *_bfd_elf_archive_symbol_lookup
2264*a9fa9459Szrj   (bfd *, struct bfd_link_info *, const char *);
2265*a9fa9459Szrj extern bfd_boolean bfd_elf_link_add_symbols
2266*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2267*a9fa9459Szrj extern bfd_boolean _bfd_elf_add_dynamic_entry
2268*a9fa9459Szrj   (struct bfd_link_info *, bfd_vma, bfd_vma);
2269*a9fa9459Szrj extern bfd_boolean _bfd_elf_link_check_relocs
2270*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2271*a9fa9459Szrj 
2272*a9fa9459Szrj extern bfd_boolean bfd_elf_link_record_dynamic_symbol
2273*a9fa9459Szrj   (struct bfd_link_info *, struct elf_link_hash_entry *);
2274*a9fa9459Szrj 
2275*a9fa9459Szrj extern int bfd_elf_link_record_local_dynamic_symbol
2276*a9fa9459Szrj   (struct bfd_link_info *, bfd *, long);
2277*a9fa9459Szrj 
2278*a9fa9459Szrj extern bfd_boolean _bfd_elf_close_and_cleanup
2279*a9fa9459Szrj   (bfd *);
2280*a9fa9459Szrj 
2281*a9fa9459Szrj extern bfd_boolean _bfd_elf_common_definition
2282*a9fa9459Szrj   (Elf_Internal_Sym *);
2283*a9fa9459Szrj 
2284*a9fa9459Szrj extern unsigned int _bfd_elf_common_section_index
2285*a9fa9459Szrj   (asection *);
2286*a9fa9459Szrj 
2287*a9fa9459Szrj extern asection *_bfd_elf_common_section
2288*a9fa9459Szrj   (asection *);
2289*a9fa9459Szrj 
2290*a9fa9459Szrj extern bfd_vma _bfd_elf_default_got_elt_size
2291*a9fa9459Szrj (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, bfd *,
2292*a9fa9459Szrj  unsigned long);
2293*a9fa9459Szrj 
2294*a9fa9459Szrj extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
2295*a9fa9459Szrj   (bfd *, arelent *, struct bfd_symbol *, void *,
2296*a9fa9459Szrj    asection *, bfd *, char **);
2297*a9fa9459Szrj 
2298*a9fa9459Szrj extern bfd_boolean bfd_elf_final_link
2299*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2300*a9fa9459Szrj 
2301*a9fa9459Szrj extern void _bfd_elf_gc_keep
2302*a9fa9459Szrj   (struct bfd_link_info *info);
2303*a9fa9459Szrj 
2304*a9fa9459Szrj extern bfd_boolean bfd_elf_gc_mark_dynamic_ref_symbol
2305*a9fa9459Szrj   (struct elf_link_hash_entry *h, void *inf);
2306*a9fa9459Szrj 
2307*a9fa9459Szrj extern bfd_boolean bfd_elf_gc_sections
2308*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2309*a9fa9459Szrj 
2310*a9fa9459Szrj extern bfd_boolean bfd_elf_gc_record_vtinherit
2311*a9fa9459Szrj   (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
2312*a9fa9459Szrj 
2313*a9fa9459Szrj extern bfd_boolean bfd_elf_gc_record_vtentry
2314*a9fa9459Szrj   (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
2315*a9fa9459Szrj 
2316*a9fa9459Szrj extern asection *_bfd_elf_gc_mark_hook
2317*a9fa9459Szrj   (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
2318*a9fa9459Szrj    struct elf_link_hash_entry *, Elf_Internal_Sym *);
2319*a9fa9459Szrj 
2320*a9fa9459Szrj extern asection *_bfd_elf_gc_mark_rsec
2321*a9fa9459Szrj   (struct bfd_link_info *, asection *, elf_gc_mark_hook_fn,
2322*a9fa9459Szrj    struct elf_reloc_cookie *, bfd_boolean *);
2323*a9fa9459Szrj 
2324*a9fa9459Szrj extern bfd_boolean _bfd_elf_gc_mark_reloc
2325*a9fa9459Szrj   (struct bfd_link_info *, asection *, elf_gc_mark_hook_fn,
2326*a9fa9459Szrj    struct elf_reloc_cookie *);
2327*a9fa9459Szrj 
2328*a9fa9459Szrj extern bfd_boolean _bfd_elf_gc_mark_fdes
2329*a9fa9459Szrj   (struct bfd_link_info *, asection *, asection *, elf_gc_mark_hook_fn,
2330*a9fa9459Szrj    struct elf_reloc_cookie *);
2331*a9fa9459Szrj 
2332*a9fa9459Szrj extern bfd_boolean _bfd_elf_gc_mark
2333*a9fa9459Szrj   (struct bfd_link_info *, asection *, elf_gc_mark_hook_fn);
2334*a9fa9459Szrj 
2335*a9fa9459Szrj extern bfd_boolean _bfd_elf_gc_mark_extra_sections
2336*a9fa9459Szrj   (struct bfd_link_info *, elf_gc_mark_hook_fn);
2337*a9fa9459Szrj 
2338*a9fa9459Szrj extern bfd_boolean bfd_elf_gc_common_finalize_got_offsets
2339*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2340*a9fa9459Szrj 
2341*a9fa9459Szrj extern bfd_boolean bfd_elf_gc_common_final_link
2342*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2343*a9fa9459Szrj 
2344*a9fa9459Szrj extern asection *_bfd_elf_is_start_stop
2345*a9fa9459Szrj   (const struct bfd_link_info *, struct elf_link_hash_entry *);
2346*a9fa9459Szrj 
2347*a9fa9459Szrj extern bfd_boolean bfd_elf_reloc_symbol_deleted_p
2348*a9fa9459Szrj   (bfd_vma, void *);
2349*a9fa9459Szrj 
2350*a9fa9459Szrj extern struct elf_segment_map * _bfd_elf_make_dynamic_segment
2351*a9fa9459Szrj   (bfd *, asection *);
2352*a9fa9459Szrj 
2353*a9fa9459Szrj extern bfd_boolean _bfd_elf_map_sections_to_segments
2354*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2355*a9fa9459Szrj 
2356*a9fa9459Szrj extern bfd_boolean _bfd_elf_is_function_type (unsigned int);
2357*a9fa9459Szrj 
2358*a9fa9459Szrj extern bfd_size_type _bfd_elf_maybe_function_sym (const asymbol *, asection *,
2359*a9fa9459Szrj 						  bfd_vma *);
2360*a9fa9459Szrj 
2361*a9fa9459Szrj extern asection *_bfd_elf_get_reloc_section (asection *);
2362*a9fa9459Szrj 
2363*a9fa9459Szrj extern int bfd_elf_get_default_section_type (flagword);
2364*a9fa9459Szrj 
2365*a9fa9459Szrj extern bfd_boolean bfd_elf_lookup_section_flags
2366*a9fa9459Szrj   (struct bfd_link_info *, struct flag_info *, asection *);
2367*a9fa9459Szrj 
2368*a9fa9459Szrj extern Elf_Internal_Phdr * _bfd_elf_find_segment_containing_section
2369*a9fa9459Szrj   (bfd * abfd, asection * section);
2370*a9fa9459Szrj 
2371*a9fa9459Szrj /* PowerPC @tls opcode transform/validate.  */
2372*a9fa9459Szrj extern unsigned int _bfd_elf_ppc_at_tls_transform
2373*a9fa9459Szrj   (unsigned int, unsigned int);
2374*a9fa9459Szrj /* PowerPC @tprel opcode transform/validate.  */
2375*a9fa9459Szrj extern unsigned int _bfd_elf_ppc_at_tprel_transform
2376*a9fa9459Szrj   (unsigned int, unsigned int);
2377*a9fa9459Szrj /* PowerPC elf_object_p tweak.  */
2378*a9fa9459Szrj extern bfd_boolean _bfd_elf_ppc_set_arch (bfd *);
2379*a9fa9459Szrj 
2380*a9fa9459Szrj /* Exported interface for writing elf corefile notes. */
2381*a9fa9459Szrj extern char *elfcore_write_note
2382*a9fa9459Szrj   (bfd *, char *, int *, const char *, int, const void *, int);
2383*a9fa9459Szrj extern char *elfcore_write_prpsinfo
2384*a9fa9459Szrj   (bfd *, char *, int *, const char *, const char *);
2385*a9fa9459Szrj extern char *elfcore_write_prstatus
2386*a9fa9459Szrj   (bfd *, char *, int *, long, int, const void *);
2387*a9fa9459Szrj extern char * elfcore_write_pstatus
2388*a9fa9459Szrj   (bfd *, char *, int *, long, int, const void *);
2389*a9fa9459Szrj extern char *elfcore_write_prfpreg
2390*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2391*a9fa9459Szrj extern char *elfcore_write_prxfpreg
2392*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2393*a9fa9459Szrj extern char *elfcore_write_xstatereg
2394*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2395*a9fa9459Szrj extern char *elfcore_write_ppc_vmx
2396*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2397*a9fa9459Szrj extern char *elfcore_write_ppc_vsx
2398*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2399*a9fa9459Szrj extern char *elfcore_write_s390_timer
2400*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2401*a9fa9459Szrj extern char *elfcore_write_s390_todcmp
2402*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2403*a9fa9459Szrj extern char *elfcore_write_s390_todpreg
2404*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2405*a9fa9459Szrj extern char *elfcore_write_s390_ctrs
2406*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2407*a9fa9459Szrj extern char *elfcore_write_s390_prefix
2408*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2409*a9fa9459Szrj extern char *elfcore_write_s390_last_break
2410*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2411*a9fa9459Szrj extern char *elfcore_write_s390_system_call
2412*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2413*a9fa9459Szrj extern char *elfcore_write_s390_tdb
2414*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2415*a9fa9459Szrj extern char *elfcore_write_s390_vxrs_low
2416*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2417*a9fa9459Szrj extern char *elfcore_write_s390_vxrs_high
2418*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2419*a9fa9459Szrj extern char *elfcore_write_arm_vfp
2420*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2421*a9fa9459Szrj extern char *elfcore_write_aarch_tls
2422*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2423*a9fa9459Szrj extern char *elfcore_write_aarch_hw_break
2424*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2425*a9fa9459Szrj extern char *elfcore_write_aarch_hw_watch
2426*a9fa9459Szrj   (bfd *, char *, int *, const void *, int);
2427*a9fa9459Szrj extern char *elfcore_write_lwpstatus
2428*a9fa9459Szrj   (bfd *, char *, int *, long, int, const void *);
2429*a9fa9459Szrj extern char *elfcore_write_register_note
2430*a9fa9459Szrj   (bfd *, char *, int *, const char *, const void *, int);
2431*a9fa9459Szrj 
2432*a9fa9459Szrj /* Internal structure which holds information to be included in the
2433*a9fa9459Szrj    PRPSINFO section of Linux core files.
2434*a9fa9459Szrj 
2435*a9fa9459Szrj    This is an "internal" structure in the sense that it should be used
2436*a9fa9459Szrj    to pass information to BFD (via the `elfcore_write_linux_prpsinfo'
2437*a9fa9459Szrj    function), so things like endianess shouldn't be an issue.  This
2438*a9fa9459Szrj    structure will eventually be converted in one of the
2439*a9fa9459Szrj    `elf_external_linux_*' structures and written out to an output bfd
2440*a9fa9459Szrj    by one of the functions declared below.  */
2441*a9fa9459Szrj 
2442*a9fa9459Szrj struct elf_internal_linux_prpsinfo
2443*a9fa9459Szrj   {
2444*a9fa9459Szrj     char pr_state;			/* Numeric process state.  */
2445*a9fa9459Szrj     char pr_sname;			/* Char for pr_state.  */
2446*a9fa9459Szrj     char pr_zomb;			/* Zombie.  */
2447*a9fa9459Szrj     char pr_nice;			/* Nice val.  */
2448*a9fa9459Szrj     unsigned long pr_flag;		/* Flags.  */
2449*a9fa9459Szrj     unsigned int pr_uid;
2450*a9fa9459Szrj     unsigned int pr_gid;
2451*a9fa9459Szrj     int pr_pid, pr_ppid, pr_pgrp, pr_sid;
2452*a9fa9459Szrj     char pr_fname[16 + 1];		/* Filename of executable.  */
2453*a9fa9459Szrj     char pr_psargs[80 + 1];		/* Initial part of arg list.  */
2454*a9fa9459Szrj   };
2455*a9fa9459Szrj 
2456*a9fa9459Szrj /* Linux/most 32-bit archs.  */
2457*a9fa9459Szrj extern char *elfcore_write_linux_prpsinfo32
2458*a9fa9459Szrj   (bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *);
2459*a9fa9459Szrj 
2460*a9fa9459Szrj /* Linux/most 64-bit archs.  */
2461*a9fa9459Szrj extern char *elfcore_write_linux_prpsinfo64
2462*a9fa9459Szrj   (bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *);
2463*a9fa9459Szrj 
2464*a9fa9459Szrj /* Linux/PPC32 uses different layout compared to most archs.  */
2465*a9fa9459Szrj extern char *elfcore_write_ppc_linux_prpsinfo32
2466*a9fa9459Szrj   (bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *);
2467*a9fa9459Szrj 
2468*a9fa9459Szrj extern bfd *_bfd_elf32_bfd_from_remote_memory
2469*a9fa9459Szrj   (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
2470*a9fa9459Szrj    int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type));
2471*a9fa9459Szrj extern bfd *_bfd_elf64_bfd_from_remote_memory
2472*a9fa9459Szrj   (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
2473*a9fa9459Szrj    int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type));
2474*a9fa9459Szrj 
2475*a9fa9459Szrj extern bfd_vma bfd_elf_obj_attr_size (bfd *);
2476*a9fa9459Szrj extern void bfd_elf_set_obj_attr_contents (bfd *, bfd_byte *, bfd_vma);
2477*a9fa9459Szrj extern int bfd_elf_get_obj_attr_int (bfd *, int, unsigned int);
2478*a9fa9459Szrj extern void bfd_elf_add_obj_attr_int (bfd *, int, unsigned int, unsigned int);
2479*a9fa9459Szrj #define bfd_elf_add_proc_attr_int(BFD, TAG, VALUE) \
2480*a9fa9459Szrj   bfd_elf_add_obj_attr_int ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE))
2481*a9fa9459Szrj extern void bfd_elf_add_obj_attr_string (bfd *, int, unsigned int, const char *);
2482*a9fa9459Szrj #define bfd_elf_add_proc_attr_string(BFD, TAG, VALUE) \
2483*a9fa9459Szrj   bfd_elf_add_obj_attr_string ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE))
2484*a9fa9459Szrj extern void bfd_elf_add_obj_attr_int_string (bfd *, int, unsigned int,
2485*a9fa9459Szrj 					     unsigned int, const char *);
2486*a9fa9459Szrj #define bfd_elf_add_proc_attr_int_string(BFD, TAG, INTVAL, STRVAL) \
2487*a9fa9459Szrj   bfd_elf_add_obj_attr_int_string ((BFD), OBJ_ATTR_PROC, (TAG), \
2488*a9fa9459Szrj 				   (INTVAL), (STRVAL))
2489*a9fa9459Szrj 
2490*a9fa9459Szrj extern char *_bfd_elf_attr_strdup (bfd *, const char *);
2491*a9fa9459Szrj extern void _bfd_elf_copy_obj_attributes (bfd *, bfd *);
2492*a9fa9459Szrj extern int _bfd_elf_obj_attrs_arg_type (bfd *, int, unsigned int);
2493*a9fa9459Szrj extern void _bfd_elf_parse_attributes (bfd *, Elf_Internal_Shdr *);
2494*a9fa9459Szrj extern bfd_boolean _bfd_elf_merge_object_attributes (bfd *, bfd *);
2495*a9fa9459Szrj extern bfd_boolean _bfd_elf_merge_unknown_attribute_low (bfd *, bfd *, int);
2496*a9fa9459Szrj extern bfd_boolean _bfd_elf_merge_unknown_attribute_list (bfd *, bfd *);
2497*a9fa9459Szrj extern Elf_Internal_Shdr *_bfd_elf_single_rel_hdr (asection *sec);
2498*a9fa9459Szrj 
2499*a9fa9459Szrj /* The linker may need to keep track of the number of relocs that it
2500*a9fa9459Szrj    decides to copy as dynamic relocs in check_relocs for each symbol.
2501*a9fa9459Szrj    This is so that it can later discard them if they are found to be
2502*a9fa9459Szrj    unnecessary.  We can store the information in a field extending the
2503*a9fa9459Szrj    regular ELF linker hash table.  */
2504*a9fa9459Szrj 
2505*a9fa9459Szrj struct elf_dyn_relocs
2506*a9fa9459Szrj {
2507*a9fa9459Szrj   struct elf_dyn_relocs *next;
2508*a9fa9459Szrj 
2509*a9fa9459Szrj   /* The input section of the reloc.  */
2510*a9fa9459Szrj   asection *sec;
2511*a9fa9459Szrj 
2512*a9fa9459Szrj   /* Total number of relocs copied for the input section.  */
2513*a9fa9459Szrj   bfd_size_type count;
2514*a9fa9459Szrj 
2515*a9fa9459Szrj   /* Number of pc-relative relocs copied for the input section.  */
2516*a9fa9459Szrj   bfd_size_type pc_count;
2517*a9fa9459Szrj };
2518*a9fa9459Szrj 
2519*a9fa9459Szrj extern bfd_boolean _bfd_elf_create_ifunc_sections
2520*a9fa9459Szrj   (bfd *, struct bfd_link_info *);
2521*a9fa9459Szrj extern bfd_boolean _bfd_elf_allocate_ifunc_dyn_relocs
2522*a9fa9459Szrj   (struct bfd_link_info *, struct elf_link_hash_entry *,
2523*a9fa9459Szrj    struct elf_dyn_relocs **, bfd_boolean *, unsigned int,
2524*a9fa9459Szrj    unsigned int, unsigned int, bfd_boolean);
2525*a9fa9459Szrj extern long _bfd_elf_ifunc_get_synthetic_symtab
2526*a9fa9459Szrj   (bfd *, long, asymbol **, long, asymbol **, asymbol **, asection *,
2527*a9fa9459Szrj    bfd_vma *(*) (bfd *, asymbol **, asection *, asection *));
2528*a9fa9459Szrj 
2529*a9fa9459Szrj extern void elf_append_rela (bfd *, asection *, Elf_Internal_Rela *);
2530*a9fa9459Szrj extern void elf_append_rel (bfd *, asection *, Elf_Internal_Rela *);
2531*a9fa9459Szrj 
2532*a9fa9459Szrj extern bfd_vma elf64_r_info (bfd_vma, bfd_vma);
2533*a9fa9459Szrj extern bfd_vma elf64_r_sym (bfd_vma);
2534*a9fa9459Szrj extern bfd_vma elf32_r_info (bfd_vma, bfd_vma);
2535*a9fa9459Szrj extern bfd_vma elf32_r_sym (bfd_vma);
2536*a9fa9459Szrj 
2537*a9fa9459Szrj /* Large common section.  */
2538*a9fa9459Szrj extern asection _bfd_elf_large_com_section;
2539*a9fa9459Szrj 
2540*a9fa9459Szrj /* Hash for local symbol with the first section id, ID, in the input
2541*a9fa9459Szrj    file and the local symbol index, SYM.  */
2542*a9fa9459Szrj #define ELF_LOCAL_SYMBOL_HASH(ID, SYM) \
2543*a9fa9459Szrj   (((((ID) & 0xff) << 24) | (((ID) & 0xff00) << 8)) \
2544*a9fa9459Szrj    ^ (SYM) ^ ((ID) >> 16))
2545*a9fa9459Szrj 
2546*a9fa9459Szrj /* This is the condition under which finish_dynamic_symbol will be called.
2547*a9fa9459Szrj    If our finish_dynamic_symbol isn't called, we'll need to do something
2548*a9fa9459Szrj    about initializing any .plt and .got entries in relocate_section.  */
2549*a9fa9459Szrj #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \
2550*a9fa9459Szrj   ((DYN)								\
2551*a9fa9459Szrj    && ((SHARED) || !(H)->forced_local)					\
2552*a9fa9459Szrj    && ((H)->dynindx != -1 || (H)->forced_local))
2553*a9fa9459Szrj 
2554*a9fa9459Szrj /* This macro is to avoid lots of duplicated code in the body
2555*a9fa9459Szrj    of xxx_relocate_section() in the various elfxx-xxxx.c files.  */
2556*a9fa9459Szrj #define RELOC_FOR_GLOBAL_SYMBOL(info, input_bfd, input_section, rel,	\
2557*a9fa9459Szrj 				r_symndx, symtab_hdr, sym_hashes,	\
2558*a9fa9459Szrj 				h, sec, relocation,			\
2559*a9fa9459Szrj 				unresolved_reloc, warned, ignored)	\
2560*a9fa9459Szrj   do									\
2561*a9fa9459Szrj     {									\
2562*a9fa9459Szrj       /* It seems this can happen with erroneous or unsupported		\
2563*a9fa9459Szrj 	 input (mixing a.out and elf in an archive, for example.)  */	\
2564*a9fa9459Szrj       if (sym_hashes == NULL)						\
2565*a9fa9459Szrj 	return FALSE;							\
2566*a9fa9459Szrj 									\
2567*a9fa9459Szrj       h = sym_hashes[r_symndx - symtab_hdr->sh_info];			\
2568*a9fa9459Szrj 									\
2569*a9fa9459Szrj       if (info->wrap_hash != NULL					\
2570*a9fa9459Szrj 	  && (input_section->flags & SEC_DEBUGGING) != 0)		\
2571*a9fa9459Szrj 	h = ((struct elf_link_hash_entry *)				\
2572*a9fa9459Szrj 	     unwrap_hash_lookup (info, input_bfd, &h->root));		\
2573*a9fa9459Szrj 									\
2574*a9fa9459Szrj       while (h->root.type == bfd_link_hash_indirect			\
2575*a9fa9459Szrj 	     || h->root.type == bfd_link_hash_warning)			\
2576*a9fa9459Szrj 	h = (struct elf_link_hash_entry *) h->root.u.i.link;		\
2577*a9fa9459Szrj 									\
2578*a9fa9459Szrj       warned = FALSE;							\
2579*a9fa9459Szrj       ignored = FALSE;							\
2580*a9fa9459Szrj       unresolved_reloc = FALSE;						\
2581*a9fa9459Szrj       relocation = 0;							\
2582*a9fa9459Szrj       if (h->root.type == bfd_link_hash_defined				\
2583*a9fa9459Szrj 	  || h->root.type == bfd_link_hash_defweak)			\
2584*a9fa9459Szrj 	{								\
2585*a9fa9459Szrj 	  sec = h->root.u.def.section;					\
2586*a9fa9459Szrj 	  if (sec == NULL						\
2587*a9fa9459Szrj 	      || sec->output_section == NULL)				\
2588*a9fa9459Szrj 	    /* Set a flag that will be cleared later if we find a	\
2589*a9fa9459Szrj 	       relocation value for this symbol.  output_section	\
2590*a9fa9459Szrj 	       is typically NULL for symbols satisfied by a shared	\
2591*a9fa9459Szrj 	       library.  */						\
2592*a9fa9459Szrj 	    unresolved_reloc = TRUE;					\
2593*a9fa9459Szrj 	  else								\
2594*a9fa9459Szrj 	    relocation = (h->root.u.def.value				\
2595*a9fa9459Szrj 			  + sec->output_section->vma			\
2596*a9fa9459Szrj 			  + sec->output_offset);			\
2597*a9fa9459Szrj 	}								\
2598*a9fa9459Szrj       else if (h->root.type == bfd_link_hash_undefweak)			\
2599*a9fa9459Szrj 	;								\
2600*a9fa9459Szrj       else if (info->unresolved_syms_in_objects == RM_IGNORE		\
2601*a9fa9459Szrj 	       && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)		\
2602*a9fa9459Szrj 	ignored = TRUE;							\
2603*a9fa9459Szrj       else if (!bfd_link_relocatable (info))				\
2604*a9fa9459Szrj 	{								\
2605*a9fa9459Szrj 	  bfd_boolean err;						\
2606*a9fa9459Szrj 	  err = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR	\
2607*a9fa9459Szrj 		 || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT);	\
2608*a9fa9459Szrj 	  (*info->callbacks->undefined_symbol) (info,			\
2609*a9fa9459Szrj 						h->root.root.string,	\
2610*a9fa9459Szrj 						input_bfd,		\
2611*a9fa9459Szrj 						input_section,		\
2612*a9fa9459Szrj 						rel->r_offset, err);	\
2613*a9fa9459Szrj 	  warned = TRUE;						\
2614*a9fa9459Szrj 	}								\
2615*a9fa9459Szrj       (void) unresolved_reloc;						\
2616*a9fa9459Szrj       (void) warned;							\
2617*a9fa9459Szrj       (void) ignored;							\
2618*a9fa9459Szrj     }									\
2619*a9fa9459Szrj   while (0)
2620*a9fa9459Szrj 
2621*a9fa9459Szrj /* This macro is to avoid lots of duplicated code in the body of the
2622*a9fa9459Szrj    loop over relocations in xxx_relocate_section() in the various
2623*a9fa9459Szrj    elfxx-xxxx.c files.
2624*a9fa9459Szrj 
2625*a9fa9459Szrj    Handle relocations against symbols from removed linkonce sections,
2626*a9fa9459Szrj    or sections discarded by a linker script.  When doing a relocatable
2627*a9fa9459Szrj    link, we remove such relocations.  Otherwise, we just want the
2628*a9fa9459Szrj    section contents zeroed and avoid any special processing.  */
2629*a9fa9459Szrj #define RELOC_AGAINST_DISCARDED_SECTION(info, input_bfd, input_section,	\
2630*a9fa9459Szrj 					rel, count, relend,		\
2631*a9fa9459Szrj 					howto, index, contents)		\
2632*a9fa9459Szrj   {									\
2633*a9fa9459Szrj     int i_;								\
2634*a9fa9459Szrj     _bfd_clear_contents (howto, input_bfd, input_section,		\
2635*a9fa9459Szrj 			 contents + rel[index].r_offset);		\
2636*a9fa9459Szrj 									\
2637*a9fa9459Szrj     if (bfd_link_relocatable (info)					\
2638*a9fa9459Szrj 	&& (input_section->flags & SEC_DEBUGGING))			\
2639*a9fa9459Szrj       {									\
2640*a9fa9459Szrj 	/* Only remove relocations in debug sections since other	\
2641*a9fa9459Szrj 	   sections may require relocations.  */			\
2642*a9fa9459Szrj 	Elf_Internal_Shdr *rel_hdr;					\
2643*a9fa9459Szrj 									\
2644*a9fa9459Szrj 	rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); \
2645*a9fa9459Szrj 									\
2646*a9fa9459Szrj 	/* Avoid empty output section.  */				\
2647*a9fa9459Szrj 	if (rel_hdr->sh_size > rel_hdr->sh_entsize)			\
2648*a9fa9459Szrj 	  {								\
2649*a9fa9459Szrj 	    rel_hdr->sh_size -= rel_hdr->sh_entsize;			\
2650*a9fa9459Szrj 	    rel_hdr = _bfd_elf_single_rel_hdr (input_section);		\
2651*a9fa9459Szrj 	    rel_hdr->sh_size -= rel_hdr->sh_entsize;			\
2652*a9fa9459Szrj 									\
2653*a9fa9459Szrj 	    memmove (rel, rel + count,					\
2654*a9fa9459Szrj 		     (relend - rel - count) * sizeof (*rel));		\
2655*a9fa9459Szrj 									\
2656*a9fa9459Szrj 	    input_section->reloc_count--;				\
2657*a9fa9459Szrj 	    relend -= count;						\
2658*a9fa9459Szrj 	    rel--;							\
2659*a9fa9459Szrj 	    continue;							\
2660*a9fa9459Szrj 	  }								\
2661*a9fa9459Szrj       }									\
2662*a9fa9459Szrj 									\
2663*a9fa9459Szrj     for (i_ = 0; i_ < count; i_++)					\
2664*a9fa9459Szrj       {									\
2665*a9fa9459Szrj 	rel[i_].r_info = 0;						\
2666*a9fa9459Szrj 	rel[i_].r_addend = 0;						\
2667*a9fa9459Szrj       }									\
2668*a9fa9459Szrj     rel += count - 1;							\
2669*a9fa9459Szrj     continue;								\
2670*a9fa9459Szrj   }
2671*a9fa9459Szrj 
2672*a9fa9459Szrj /* Will a symbol be bound to the definition within the shared
2673*a9fa9459Szrj    library, if any.  A unique symbol can never be bound locally.  */
2674*a9fa9459Szrj #define SYMBOLIC_BIND(INFO, H) \
2675*a9fa9459Szrj     (!(H)->unique_global \
2676*a9fa9459Szrj      && ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic)))
2677*a9fa9459Szrj 
2678*a9fa9459Szrj #ifdef __cplusplus
2679*a9fa9459Szrj }
2680*a9fa9459Szrj #endif
2681*a9fa9459Szrj #endif /* _LIBELF_H_ */
2682