]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/elf-bfd.h
*** empty log message ***
[thirdparty/binutils-gdb.git] / bfd / elf-bfd.h
CommitLineData
252b5132 1/* BFD back-end data structures for ELF files.
7898deda
NC
2 Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
252b5132
RH
4 Written by Cygnus Support.
5
6This file is part of BFD, the Binary File Descriptor library.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
22#ifndef _LIBELF_H_
23#define _LIBELF_H_ 1
24
25#include "elf/common.h"
26#include "elf/internal.h"
27#include "elf/external.h"
28#include "bfdlink.h"
29
d9bc7a44
NC
30/* The number of entries in a section is its size divided by the size
31 of a single entry. This is normally only applicaable to reloc and
32 symbol table sections. */
33#define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_size / (shdr)->sh_entsize)
34
252b5132
RH
35/* If size isn't specified as 64 or 32, NAME macro should fail. */
36#ifndef NAME
37#if ARCH_SIZE==64
38#define NAME(x,y) CAT4(x,64,_,y)
39#endif
40#if ARCH_SIZE==32
41#define NAME(x,y) CAT4(x,32,_,y)
42#endif
43#endif
44
45#ifndef NAME
46#define NAME(x,y) CAT4(x,NOSIZE,_,y)
47#endif
48
49#define ElfNAME(X) NAME(Elf,X)
50#define elfNAME(X) NAME(elf,X)
51
52/* Information held for an ELF symbol. The first field is the
53 corresponding asymbol. Every symbol is an ELF file is actually a
54 pointer to this structure, although it is often handled as a
55 pointer to an asymbol. */
56
57typedef struct
58{
59 /* The BFD symbol. */
60 asymbol symbol;
61 /* ELF symbol information. */
62 Elf_Internal_Sym internal_elf_sym;
63 /* Backend specific information. */
64 union
65 {
66 unsigned int hppa_arg_reloc;
67 PTR mips_extr;
68 PTR any;
69 }
70 tc_data;
71
72 /* Version information. This is from an Elf_Internal_Versym
73 structure in a SHT_GNU_versym section. It is zero if there is no
74 version information. */
75 unsigned short version;
76
77} elf_symbol_type;
78\f
79/* ELF linker hash table entries. */
80
81struct elf_link_hash_entry
82{
83 struct bfd_link_hash_entry root;
84
85 /* Symbol index in output file. This is initialized to -1. It is
86 set to -2 if the symbol is used by a reloc. */
87 long indx;
88
89 /* Symbol size. */
90 bfd_size_type size;
91
92 /* Symbol index as a dynamic symbol. Initialized to -1, and remains
93 -1 if this is not a dynamic symbol. */
30b30c21
RH
94 /* ??? Note that this is consistently used as a synonym for tests
95 against whether we can perform various simplifying transformations
96 to the code. (E.g. changing a pc-relative jump to a PLT entry
97 into a pc-relative jump to the target function.) That test, which
98 is often relatively complex, and someplaces wrong or incomplete,
99 should really be replaced by a predicate in elflink.c.
100
101 End result: this field -1 does not indicate that the symbol is
102 not in the dynamic symbol table, but rather that the symbol is
103 not visible outside this DSO. */
252b5132
RH
104 long dynindx;
105
106 /* String table index in .dynstr if this is a dynamic symbol. */
107 unsigned long dynstr_index;
108
109 /* If this is a weak defined symbol from a dynamic object, this
110 field points to a defined symbol with the same value, if there is
111 one. Otherwise it is NULL. */
112 struct elf_link_hash_entry *weakdef;
113
114 /* If this symbol requires an entry in the global offset table, the
115 processor specific backend uses this field to track usage and
116 final offset. We use a union and two names primarily to document
117 the intent of any particular piece of code. The field should be
118 used as a count until size_dynamic_sections, at which point the
119 contents of the .got is fixed. Afterward, if this field is -1,
120 then the symbol does not require a global offset table entry. */
121 union
122 {
123 bfd_signed_vma refcount;
124 bfd_vma offset;
125 } got;
126
127 /* Same, but tracks a procedure linkage table entry. */
128 union
129 {
130 bfd_signed_vma refcount;
131 bfd_vma offset;
132 } plt;
133
134 /* If this symbol is used in the linker created sections, the processor
135 specific backend uses this field to map the field into the offset
136 from the beginning of the section. */
137 struct elf_linker_section_pointers *linker_section_pointer;
138
139 /* Version information. */
140 union
141 {
142 /* This field is used for a symbol which is not defined in a
143 regular object. It points to the version information read in
144 from the dynamic object. */
145 Elf_Internal_Verdef *verdef;
146 /* This field is used for a symbol which is defined in a regular
147 object. It is set up in size_dynamic_sections. It points to
148 the version information we should write out for this symbol. */
149 struct bfd_elf_version_tree *vertree;
150 } verinfo;
151
152 /* Virtual table entry use information. This array is nominally of size
153 size/sizeof(target_void_pointer), though we have to be able to assume
154 and track a size while the symbol is still undefined. It is indexed
155 via offset/sizeof(target_void_pointer). */
156 size_t vtable_entries_size;
157 boolean *vtable_entries_used;
158
159 /* Virtual table derivation info. */
160 struct elf_link_hash_entry *vtable_parent;
161
162 /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */
163 char type;
164
9b234ee9 165 /* Symbol st_other value, symbol visibility. */
252b5132
RH
166 unsigned char other;
167
168 /* Hash value of the name computed using the ELF hash function. */
169 unsigned long elf_hash_value;
170
171 /* Some flags; legal values follow. */
172 unsigned short elf_link_hash_flags;
173 /* Symbol is referenced by a non-shared object. */
174#define ELF_LINK_HASH_REF_REGULAR 01
175 /* Symbol is defined by a non-shared object. */
176#define ELF_LINK_HASH_DEF_REGULAR 02
177 /* Symbol is referenced by a shared object. */
178#define ELF_LINK_HASH_REF_DYNAMIC 04
179 /* Symbol is defined by a shared object. */
180#define ELF_LINK_HASH_DEF_DYNAMIC 010
181 /* Symbol has a non-weak reference from a non-shared object. */
182#define ELF_LINK_HASH_REF_REGULAR_NONWEAK 020
183 /* Dynamic symbol has been adjustd. */
184#define ELF_LINK_HASH_DYNAMIC_ADJUSTED 040
185 /* Symbol needs a copy reloc. */
186#define ELF_LINK_HASH_NEEDS_COPY 0100
187 /* Symbol needs a procedure linkage table entry. */
188#define ELF_LINK_HASH_NEEDS_PLT 0200
189 /* Symbol appears in a non-ELF input file. */
190#define ELF_LINK_NON_ELF 0400
191 /* Symbol should be marked as hidden in the version information. */
192#define ELF_LINK_HIDDEN 01000
193 /* Symbol was forced to local scope due to a version script file. */
194#define ELF_LINK_FORCED_LOCAL 02000
195 /* Symbol was marked during garbage collection. */
196#define ELF_LINK_HASH_MARK 04000
7843f00e
ILT
197 /* Symbol is referenced by a non-GOT/non-PLT relocation. This is
198 not currently set by all the backends. */
199#define ELF_LINK_NON_GOT_REF 010000
252b5132
RH
200};
201
30b30c21
RH
202/* Records local symbols to be emitted in the dynamic symbol table. */
203
204struct elf_link_local_dynamic_entry
205{
206 struct elf_link_local_dynamic_entry *next;
207
208 /* The input bfd this symbol came from. */
209 bfd *input_bfd;
210
211 /* The index of the local symbol being copied. */
212 long input_indx;
213
214 /* The index in the outgoing dynamic symbol table. */
215 long dynindx;
3e932841 216
30b30c21
RH
217 /* A copy of the input symbol. */
218 Elf_Internal_Sym isym;
219};
220
252b5132
RH
221/* ELF linker hash table. */
222
223struct elf_link_hash_table
224{
225 struct bfd_link_hash_table root;
226 /* Whether we have created the special dynamic sections required
227 when linking against or generating a shared object. */
228 boolean dynamic_sections_created;
229 /* The BFD used to hold special sections created by the linker.
230 This will be the first BFD found which requires these sections to
231 be created. */
232 bfd *dynobj;
233 /* The number of symbols found in the link which must be put into
234 the .dynsym section. */
235 bfd_size_type dynsymcount;
236 /* The string table of dynamic symbols, which becomes the .dynstr
237 section. */
238 struct bfd_strtab_hash *dynstr;
239 /* The number of buckets in the hash table in the .hash section.
240 This is based on the number of dynamic symbols. */
241 bfd_size_type bucketcount;
242 /* A linked list of DT_NEEDED names found in dynamic objects
243 included in the link. */
244 struct bfd_link_needed_list *needed;
245 /* The _GLOBAL_OFFSET_TABLE_ symbol. */
246 struct elf_link_hash_entry *hgot;
247 /* A pointer to information used to link stabs in sections. */
248 PTR stab_info;
f5fa8ca2
JJ
249 /* A pointer to information used to merge SEC_MERGE sections. */
250 PTR merge_info;
30b30c21
RH
251 /* A linked list of local symbols to be added to .dynsym. */
252 struct elf_link_local_dynamic_entry *dynlocal;
a963dc6a
L
253 /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
254 objects included in the link. */
255 struct bfd_link_needed_list *runpath;
252b5132
RH
256};
257
258/* Look up an entry in an ELF linker hash table. */
259
260#define elf_link_hash_lookup(table, string, create, copy, follow) \
261 ((struct elf_link_hash_entry *) \
262 bfd_link_hash_lookup (&(table)->root, (string), (create), \
263 (copy), (follow)))
264
265/* Traverse an ELF linker hash table. */
266
267#define elf_link_hash_traverse(table, func, info) \
268 (bfd_link_hash_traverse \
269 (&(table)->root, \
270 (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
271 (info)))
272
273/* Get the ELF linker hash table from a link_info structure. */
274
275#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
8ea2e4bd
NC
276
277/* Returns true if the hash table is a struct elf_link_hash_table. */
278#define is_elf_hash_table(p) \
279 ((p)->hash->type == bfd_link_elf_hash_table)
252b5132
RH
280\f
281/* Constant information held for an ELF backend. */
282
283struct elf_size_info {
284 unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
285 unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
286
c7ac6ff8
MM
287 /* The size of entries in the .hash section. */
288 unsigned char sizeof_hash_entry;
289
290 /* The number of internal relocations to allocate per external
291 relocation entry. */
292 unsigned char int_rels_per_ext_rel;
293
252b5132
RH
294 unsigned char arch_size, file_align;
295 unsigned char elfclass, ev_current;
dc810e39
AM
296 int (*write_out_phdrs)
297 PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
298 boolean (*write_shdrs_and_ehdr)
299 PARAMS ((bfd *));
300 void (*write_relocs)
301 PARAMS ((bfd *, asection *, PTR));
302 void (*swap_symbol_out)
303 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
252b5132
RH
304 boolean (*slurp_reloc_table)
305 PARAMS ((bfd *, asection *, asymbol **, boolean));
dc810e39
AM
306 long (*slurp_symbol_table)
307 PARAMS ((bfd *, asymbol **, boolean));
308 void (*swap_dyn_in)
309 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
310 void (*swap_dyn_out)
311 PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
c7ac6ff8
MM
312
313 /* This function, if defined, is called to swap in a REL
314 relocation. If an external relocation corresponds to more than
315 one internal relocation, then all relocations are swapped in at
316 once. */
317 void (*swap_reloc_in)
318 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rel *));
319
320 /* This function, if defined, is called to swap out a REL
321 relocation. */
322 void (*swap_reloc_out)
323 PARAMS ((bfd *, const Elf_Internal_Rel *, bfd_byte *));
324
325 /* This function, if defined, is called to swap in a RELA
326 relocation. If an external relocation corresponds to more than
327 one internal relocation, then all relocations are swapped in at
328 once. */
329 void (*swap_reloca_in)
330 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
331
332 /* This function, if defined, is called to swap out a RELA
333 relocation. */
334 void (*swap_reloca_out)
335 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
336
252b5132
RH
337};
338
339#define elf_symbol_from(ABFD,S) \
340 (((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
341 && (S)->the_bfd->tdata.elf_obj_data != 0) \
342 ? (elf_symbol_type *) (S) \
343 : 0)
344
db6751f2
JJ
345enum elf_reloc_type_class {
346 reloc_class_normal,
347 reloc_class_relative,
348 reloc_class_plt,
349 reloc_class_copy
350};
351
252b5132
RH
352struct elf_backend_data
353{
252b5132
RH
354 /* The architecture for this backend. */
355 enum bfd_architecture arch;
356
357 /* The ELF machine code (EM_xxxx) for this backend. */
358 int elf_machine_code;
359
360 /* The maximum page size for this backend. */
361 bfd_vma maxpagesize;
362
252b5132
RH
363 /* A function to translate an ELF RELA relocation to a BFD arelent
364 structure. */
dc810e39
AM
365 void (*elf_info_to_howto)
366 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
252b5132
RH
367
368 /* A function to translate an ELF REL relocation to a BFD arelent
369 structure. */
dc810e39
AM
370 void (*elf_info_to_howto_rel)
371 PARAMS ((bfd *, arelent *, Elf_Internal_Rel *));
252b5132
RH
372
373 /* A function to determine whether a symbol is global when
374 partitioning the symbol table into local and global symbols.
375 This should be NULL for most targets, in which case the correct
376 thing will be done. MIPS ELF, at least on the Irix 5, has
377 special requirements. */
dc810e39
AM
378 boolean (*elf_backend_sym_is_global)
379 PARAMS ((bfd *, asymbol *));
252b5132
RH
380
381 /* The remaining functions are hooks which are called only if they
382 are not NULL. */
383
384 /* A function to permit a backend specific check on whether a
385 particular BFD format is relevant for an object file, and to
386 permit the backend to set any global information it wishes. When
387 this is called elf_elfheader is set, but anything else should be
388 used with caution. If this returns false, the check_format
389 routine will return a bfd_error_wrong_format error. */
dc810e39
AM
390 boolean (*elf_backend_object_p)
391 PARAMS ((bfd *));
252b5132
RH
392
393 /* A function to do additional symbol processing when reading the
394 ELF symbol table. This is where any processor-specific special
395 section indices are handled. */
dc810e39
AM
396 void (*elf_backend_symbol_processing)
397 PARAMS ((bfd *, asymbol *));
252b5132
RH
398
399 /* A function to do additional symbol processing after reading the
400 entire ELF symbol table. */
dc810e39
AM
401 boolean (*elf_backend_symbol_table_processing)
402 PARAMS ((bfd *, elf_symbol_type *, unsigned int));
252b5132
RH
403
404 /* A function to set the type of the info field. Processor-specific
3e932841 405 types should be handled here. */
dc810e39
AM
406 int (*elf_backend_get_symbol_type)
407 PARAMS (( Elf_Internal_Sym *, int));
60bcf0fa 408
252b5132
RH
409 /* A function to do additional processing on the ELF section header
410 just before writing it out. This is used to set the flags and
411 type fields for some sections, or to actually write out data for
412 unusual sections. */
dc810e39
AM
413 boolean (*elf_backend_section_processing)
414 PARAMS ((bfd *, Elf32_Internal_Shdr *));
252b5132
RH
415
416 /* A function to handle unusual section types when creating BFD
417 sections from ELF sections. */
dc810e39
AM
418 boolean (*elf_backend_section_from_shdr)
419 PARAMS ((bfd *, Elf32_Internal_Shdr *, char *));
252b5132 420
fa152c49
JW
421 /* A function to convert machine dependent section header flags to
422 BFD internal section header flags. */
dc810e39
AM
423 boolean (*elf_backend_section_flags)
424 PARAMS ((flagword *, Elf32_Internal_Shdr *));
fa152c49 425
20cfcaae 426 /* A function to handle unusual program segment types when creating BFD
3e932841 427 sections from ELF program segments. */
dc810e39
AM
428 boolean (*elf_backend_section_from_phdr)
429 PARAMS ((bfd *, Elf32_Internal_Phdr *, int));
20cfcaae 430
252b5132
RH
431 /* A function to set up the ELF section header for a BFD section in
432 preparation for writing it out. This is where the flags and type
433 fields are set for unusual sections. */
dc810e39
AM
434 boolean (*elf_backend_fake_sections)
435 PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
252b5132
RH
436
437 /* A function to get the ELF section index for a BFD section. If
438 this returns true, the section was found. If it is a normal ELF
439 section, *RETVAL should be left unchanged. If it is not a normal
440 ELF section *RETVAL should be set to the SHN_xxxx index. */
441 boolean (*elf_backend_section_from_bfd_section)
442 PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval));
443
444 /* If this field is not NULL, it is called by the add_symbols phase
445 of a link just before adding a symbol to the global linker hash
446 table. It may modify any of the fields as it wishes. If *NAME
447 is set to NULL, the symbol will be skipped rather than being
448 added to the hash table. This function is responsible for
449 handling all processor dependent symbol bindings and section
450 indices, and must set at least *FLAGS and *SEC for each processor
451 dependent case; failure to do so will cause a link error. */
452 boolean (*elf_add_symbol_hook)
453 PARAMS ((bfd *abfd, struct bfd_link_info *info,
454 const Elf_Internal_Sym *, const char **name,
455 flagword *flags, asection **sec, bfd_vma *value));
456
457 /* If this field is not NULL, it is called by the elf_link_output_sym
458 phase of a link for each symbol which will appear in the object file. */
459 boolean (*elf_backend_link_output_symbol_hook)
460 PARAMS ((bfd *, struct bfd_link_info *info, const char *,
461 Elf_Internal_Sym *, asection *));
462
463 /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
464 linker the first time it encounters a dynamic object in the link.
465 This function must create any sections required for dynamic
466 linking. The ABFD argument is a dynamic object. The .interp,
467 .dynamic, .dynsym, .dynstr, and .hash functions have already been
468 created, and this function may modify the section flags if
469 desired. This function will normally create the .got and .plt
470 sections, but different backends have different requirements. */
471 boolean (*elf_backend_create_dynamic_sections)
472 PARAMS ((bfd *abfd, struct bfd_link_info *info));
473
474 /* The CHECK_RELOCS function is called by the add_symbols phase of
475 the ELF backend linker. It is called once for each section with
476 relocs of an object file, just after the symbols for the object
477 file have been added to the global linker hash table. The
478 function must look through the relocs and do any special handling
479 required. This generally means allocating space in the global
480 offset table, and perhaps allocating space for a reloc. The
481 relocs are always passed as Rela structures; if the section
482 actually uses Rel structures, the r_addend field will always be
483 zero. */
484 boolean (*check_relocs)
485 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
486 const Elf_Internal_Rela *relocs));
487
488 /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
489 linker for every symbol which is defined by a dynamic object and
490 referenced by a regular object. This is called after all the
491 input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
492 function has been called. The hash table entry should be
493 bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
494 defined in a section from a dynamic object. Dynamic object
495 sections are not included in the final link, and this function is
496 responsible for changing the value to something which the rest of
497 the link can deal with. This will normally involve adding an
498 entry to the .plt or .got or some such section, and setting the
499 symbol to point to that. */
500 boolean (*elf_backend_adjust_dynamic_symbol)
501 PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
502
503 /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
504 after all the linker input files have been seen but before the
505 section sizes have been set. This is called after
506 ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */
507 boolean (*elf_backend_always_size_sections)
508 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
509
510 /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
511 linker after all the linker input files have been seen but before
512 the sections sizes have been set. This is called after
513 ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
514 It is only called when linking against a dynamic object. It must
515 set the sizes of the dynamic sections, and may fill in their
516 contents as well. The generic ELF linker can handle the .dynsym,
517 .dynstr and .hash sections. This function must handle the
518 .interp section and any sections created by the
519 CREATE_DYNAMIC_SECTIONS entry point. */
520 boolean (*elf_backend_size_dynamic_sections)
521 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
522
523 /* The RELOCATE_SECTION function is called by the ELF backend linker
524 to handle the relocations for a section.
525
526 The relocs are always passed as Rela structures; if the section
527 actually uses Rel structures, the r_addend field will always be
528 zero.
529
530 This function is responsible for adjust the section contents as
531 necessary, and (if using Rela relocs and generating a
532 relocateable output file) adjusting the reloc addend as
533 necessary.
534
535 This function does not have to worry about setting the reloc
536 address or the reloc symbol index.
537
538 LOCAL_SYMS is a pointer to the swapped in local symbols.
539
540 LOCAL_SECTIONS is an array giving the section in the input file
541 corresponding to the st_shndx field of each local symbol.
542
543 The global hash table entry for the global symbols can be found
544 via elf_sym_hashes (input_bfd).
545
546 When generating relocateable output, this function must handle
547 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
548 going to be the section symbol corresponding to the output
549 section, which means that the addend must be adjusted
550 accordingly. */
551 boolean (*elf_backend_relocate_section)
552 PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
553 bfd *input_bfd, asection *input_section, bfd_byte *contents,
554 Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
555 asection **local_sections));
556
557 /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
558 linker just before it writes a symbol out to the .dynsym section.
559 The processor backend may make any required adjustment to the
560 symbol. It may also take the opportunity to set contents of the
561 dynamic sections. Note that FINISH_DYNAMIC_SYMBOL is called on
562 all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
563 on those symbols which are defined by a dynamic object. */
564 boolean (*elf_backend_finish_dynamic_symbol)
565 PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
566 struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
567
568 /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
569 linker just before it writes all the dynamic sections out to the
570 output file. The FINISH_DYNAMIC_SYMBOL will have been called on
571 all dynamic symbols. */
572 boolean (*elf_backend_finish_dynamic_sections)
573 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
574
575 /* A function to do any beginning processing needed for the ELF file
576 before building the ELF headers and computing file positions. */
577 void (*elf_backend_begin_write_processing)
578 PARAMS ((bfd *, struct bfd_link_info *));
579
580 /* A function to do any final processing needed for the ELF file
581 before writing it out. The LINKER argument is true if this BFD
582 was created by the ELF backend linker. */
583 void (*elf_backend_final_write_processing)
584 PARAMS ((bfd *, boolean linker));
585
586 /* This function is called by get_program_header_size. It should
587 return the number of additional program segments which this BFD
588 will need. It should return -1 on error. */
dc810e39
AM
589 int (*elf_backend_additional_program_headers)
590 PARAMS ((bfd *));
252b5132
RH
591
592 /* This function is called to modify an existing segment map in a
593 backend specific fashion. */
dc810e39
AM
594 boolean (*elf_backend_modify_segment_map)
595 PARAMS ((bfd *));
252b5132
RH
596
597 /* This function is called during section gc to discover the section a
598 particular relocation refers to. It need not be defined for hosts
599 that have no queer relocation types. */
600 asection * (*gc_mark_hook)
601 PARAMS ((bfd *abfd, struct bfd_link_info *, Elf_Internal_Rela *,
602 struct elf_link_hash_entry *h, Elf_Internal_Sym *));
603
604 /* This function, if defined, is called during the sweep phase of gc
605 in order that a backend might update any data structures it might
606 be maintaining. */
607 boolean (*gc_sweep_hook)
608 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
609 const Elf_Internal_Rela *relocs));
610
e6c51ed4
NC
611 /* This function, if defined, is called after the ELF headers have
612 been created. This allows for things like the OS and ABI versions
613 to be changed. */
614 void (*elf_backend_post_process_headers)
615 PARAMS ((bfd *, struct bfd_link_info *));
616
587ff49e
RH
617 /* This function, if defined, prints a symbol to file and returns the
618 name of the symbol to be printed. It should return NULL to fall
619 back to default symbol printing. */
620 const char *(*elf_backend_print_symbol_all)
621 PARAMS ((bfd *, PTR, asymbol *));
622
623 /* This function, if defined, is called after all local symbols and
624 global symbols converted to locals are emited into the symtab
625 section. It allows the backend to emit special global symbols
626 not handled in the hash table. */
627 boolean (*elf_backend_output_arch_syms)
628 PARAMS ((bfd *, struct bfd_link_info *, PTR,
dc810e39 629 boolean (*) (PTR, const char *, Elf_Internal_Sym *, asection *)));
587ff49e 630
c61b8717
RH
631 /* Copy any information related to dynamic linking from a pre-existing
632 symbol IND to a newly created symbol DIR. */
633 void (*elf_backend_copy_indirect_symbol)
634 PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
635
636 /* Modify any information related to dynamic linking such that the
637 symbol is not exported. */
638 void (*elf_backend_hide_symbol)
f41cbf03 639 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
c61b8717 640
9317eacc
CM
641 /* Emit relocations. Overrides default routine for emitting relocs,
642 except during a relocatable link, or if all relocs are being emitted. */
643 void (*elf_backend_emit_relocs)
644 PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *));
645
646 /* Count relocations. Not called for relocatable links
647 or if all relocs are being preserved in the output. */
648 unsigned int (*elf_backend_count_relocs)
649 PARAMS ((asection *, Elf_Internal_Rela *));
650
bb0082d6
AM
651 /* This function, if defined, is called when an NT_PRSTATUS note is found
652 in a core file. */
dc810e39
AM
653 boolean (*elf_backend_grok_prstatus)
654 PARAMS ((bfd *, Elf_Internal_Note *));
bb0082d6
AM
655
656 /* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
657 note is found in a core file. */
dc810e39
AM
658 boolean (*elf_backend_grok_psinfo)
659 PARAMS ((bfd *, Elf_Internal_Note *));
bb0082d6 660
db6751f2 661 /* Functions to print VMAs. Special code to handle 64 bit ELF files. */
dc810e39
AM
662 void (* elf_backend_sprintf_vma)
663 PARAMS ((bfd *, char *, bfd_vma));
664 void (* elf_backend_fprintf_vma)
665 PARAMS ((bfd *, PTR, bfd_vma));
4e771d61 666
db6751f2 667 /* This function returns class of a reloc type. */
dc810e39
AM
668 enum elf_reloc_type_class (* elf_backend_reloc_type_class)
669 PARAMS ((int));
db6751f2 670
252b5132
RH
671 /* The swapping table to use when dealing with ECOFF information.
672 Used for the MIPS ELF .mdebug section. */
673 const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
674
675 /* Alternate EM_xxxx machine codes for this backend. */
676 int elf_machine_alt1;
677 int elf_machine_alt2;
678
679 const struct elf_size_info *s;
680
681 /* offset of the _GLOBAL_OFFSET_TABLE_ symbol from the start of the
682 .got section */
683 bfd_vma got_symbol_offset;
684
685 /* The size in bytes of the headers for the GOT and PLT. This includes
686 the so-called reserved entries on some systems. */
687 bfd_vma got_header_size;
688 bfd_vma plt_header_size;
689
86dc0f79
RH
690 /* This is true if the linker should act like collect and gather
691 global constructors and destructors by name. This is true for
692 MIPS ELF because the Irix 5 tools can not handle the .init
693 section. */
694 unsigned collect : 1;
695
696 /* This is true if the linker should ignore changes to the type of a
697 symbol. This is true for MIPS ELF because some Irix 5 objects
698 record undefined functions as STT_OBJECT although the definitions
699 are STT_FUNC. */
700 unsigned type_change_ok : 1;
701
bf572ba0
MM
702 /* Whether the backend may use REL relocations. (Some backends use
703 both REL and RELA relocations, and this flag is set for those
704 backends.) */
705 unsigned may_use_rel_p : 1;
60bcf0fa 706
bf572ba0
MM
707 /* Whether the backend may use RELA relocations. (Some backends use
708 both REL and RELA relocations, and this flag is set for those
709 backends.) */
710 unsigned may_use_rela_p : 1;
711
712 /* Whether the default relocation type is RELA. If a backend with
713 this flag set wants REL relocations for a particular section,
714 it must note that explicitly. Similarly, if this flag is clear,
60bcf0fa
NC
715 and the backend wants RELA relocations for a particular
716 section. */
bf572ba0
MM
717 unsigned default_use_rela_p : 1;
718
86dc0f79
RH
719 /* True if addresses "naturally" sign extend. This is used when
720 swapping in from Elf32 when BFD64. */
721 unsigned sign_extend_vma : 1;
722
252b5132
RH
723 unsigned want_got_plt : 1;
724 unsigned plt_readonly : 1;
725 unsigned want_plt_sym : 1;
726 unsigned plt_not_loaded : 1;
727 unsigned plt_alignment : 4;
728 unsigned can_gc_sections : 1;
2517a57f 729 unsigned want_got_sym : 1;
3018b441 730 unsigned want_dynbss : 1;
252b5132
RH
731};
732
733/* Information stored for each BFD section in an ELF file. This
734 structure is allocated by elf_new_section_hook. */
735
736struct bfd_elf_section_data
737{
738 /* The ELF header for this section. */
739 Elf_Internal_Shdr this_hdr;
740 /* The ELF header for the reloc section associated with this
741 section, if any. */
742 Elf_Internal_Shdr rel_hdr;
743 /* If there is a second reloc section associated with this section,
744 as can happen on Irix 6, this field points to the header. */
745 Elf_Internal_Shdr *rel_hdr2;
23bc299b
MM
746 /* The number of relocations currently assigned to REL_HDR. */
747 unsigned int rel_count;
748 /* The number of relocations currently assigned to REL_HDR2. */
749 unsigned int rel_count2;
252b5132
RH
750 /* The ELF section number of this section. Only used for an output
751 file. */
752 int this_idx;
23bc299b
MM
753 /* The ELF section number of the reloc section indicated by
754 REL_HDR if any. Only used for an output file. */
252b5132 755 int rel_idx;
23bc299b
MM
756 /* The ELF section number of the reloc section indicated by
757 REL_HDR2 if any. Only used for an output file. */
758 int rel_idx2;
252b5132
RH
759 /* Used by the backend linker to store the symbol hash table entries
760 associated with relocs against global symbols. */
761 struct elf_link_hash_entry **rel_hashes;
762 /* A pointer to the swapped relocs. If the section uses REL relocs,
763 rather than RELA, all the r_addend fields will be zero. This
764 pointer may be NULL. It is used by the backend linker. */
765 Elf_Internal_Rela *relocs;
766 /* Used by the backend linker when generating a shared library to
767 record the dynamic symbol index for a section symbol
75945f9f
ILT
768 corresponding to this section. A value of 0 means that there is
769 no dynamic symbol for this section. */
252b5132
RH
770 long dynindx;
771 /* A pointer used for .stab linking optimizations. */
772 PTR stab_info;
f5fa8ca2
JJ
773 /* A pointer used for SEC_MERGE optimizations. */
774 PTR merge_info;
252b5132
RH
775 /* A pointer available for the processor specific ELF backend. */
776 PTR tdata;
bf572ba0
MM
777 /* Nonzero if this section uses RELA relocations, rather than REL. */
778 unsigned int use_rela_p:1;
252b5132
RH
779};
780
781#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
782
783#define get_elf_backend_data(abfd) \
784 ((struct elf_backend_data *) (abfd)->xvec->backend_data)
785
786/* Enumeration to specify the special section. */
787typedef enum elf_linker_section_enum
788{
789 LINKER_SECTION_UNKNOWN, /* not used */
790 LINKER_SECTION_GOT, /* .got section for global offset pointers */
791 LINKER_SECTION_PLT, /* .plt section for generated procedure stubs */
792 LINKER_SECTION_SDATA, /* .sdata/.sbss section for PowerPC */
793 LINKER_SECTION_SDATA2, /* .sdata2/.sbss2 section for PowerPC */
794 LINKER_SECTION_MAX /* # of linker sections */
795} elf_linker_section_enum_t;
796
797/* Sections created by the linker. */
798
799typedef struct elf_linker_section
800{
801 char *name; /* name of the section */
802 char *rel_name; /* name of the associated .rel{,a}. section */
803 char *bss_name; /* name of a related .bss section */
804 char *sym_name; /* name of symbol to reference this section */
805 asection *section; /* pointer to the section */
806 asection *bss_section; /* pointer to the bss section associated with this */
807 asection *rel_section; /* pointer to the relocations needed for this section */
808 struct elf_link_hash_entry *sym_hash; /* pointer to the created symbol hash value */
809 bfd_vma initial_size; /* initial size before any linker generated allocations */
810 bfd_vma sym_offset; /* offset of symbol from beginning of section */
811 bfd_vma hole_size; /* size of reserved address hole in allocation */
812 bfd_vma hole_offset; /* current offset for the hole */
813 bfd_vma max_hole_offset; /* maximum offset for the hole */
814 elf_linker_section_enum_t which; /* which section this is */
815 boolean hole_written_p; /* whether the hole has been initialized */
816 unsigned int alignment; /* alignment for the section */
817 flagword flags; /* flags to use to create the section */
818} elf_linker_section_t;
819
820/* Linked list of allocated pointer entries. This hangs off of the symbol lists, and
821 provides allows us to return different pointers, based on different addend's. */
822
823typedef struct elf_linker_section_pointers
824{
825 struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */
826 bfd_vma offset; /* offset of pointer from beginning of section */
dc810e39 827 bfd_vma addend; /* addend used */
252b5132
RH
828 elf_linker_section_enum_t which; /* which linker section this is */
829 boolean written_address_p; /* whether address was written yet */
830} elf_linker_section_pointers_t;
831
832/* Some private data is stashed away for future use using the tdata pointer
833 in the bfd structure. */
834
835struct elf_obj_tdata
836{
837 Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
838 Elf_Internal_Shdr **elf_sect_ptr;
839 Elf_Internal_Phdr *phdr;
840 struct elf_segment_map *segment_map;
841 struct bfd_strtab_hash *strtab_ptr;
842 int num_locals;
843 int num_globals;
4e89ac30 844 int num_section_syms;
252b5132
RH
845 asymbol **section_syms; /* STT_SECTION symbols for each section */
846 Elf_Internal_Shdr symtab_hdr;
847 Elf_Internal_Shdr shstrtab_hdr;
848 Elf_Internal_Shdr strtab_hdr;
849 Elf_Internal_Shdr dynsymtab_hdr;
850 Elf_Internal_Shdr dynstrtab_hdr;
851 Elf_Internal_Shdr dynversym_hdr;
852 Elf_Internal_Shdr dynverref_hdr;
853 Elf_Internal_Shdr dynverdef_hdr;
854 unsigned int symtab_section, shstrtab_section;
855 unsigned int strtab_section, dynsymtab_section;
856 unsigned int dynversym_section, dynverdef_section, dynverref_section;
857 file_ptr next_file_pos;
858#if 0
859 /* we don't need these inside bfd anymore, and I think
3e932841 860 these weren't used outside bfd. */
252b5132
RH
861 void *prstatus; /* The raw /proc prstatus structure */
862 void *prpsinfo; /* The raw /proc prpsinfo structure */
863#endif
864 bfd_vma gp; /* The gp value (MIPS only, for now) */
865 unsigned int gp_size; /* The gp size (MIPS only, for now) */
866
3e932841 867 /* Information grabbed from an elf core file. */
252b5132
RH
868 int core_signal;
869 int core_pid;
870 int core_lwpid;
871 char* core_program;
872 char* core_command;
873
874 /* This is set to true if the object was created by the backend
875 linker. */
876 boolean linker;
877
878 /* A mapping from external symbols to entries in the linker hash
879 table, used when linking. This is indexed by the symbol index
880 minus the sh_info field of the symbol table header. */
881 struct elf_link_hash_entry **sym_hashes;
882
883 /* A mapping from local symbols to offsets into the global offset
884 table, used when linking. This is indexed by the symbol index.
885 Like for the globals, we use a union and two names primarily to
886 document the intent of any particular piece of code. The field
887 should be used as a count until size_dynamic_sections, at which
888 point the contents of the .got is fixed. Afterward, if an entry
3e932841 889 is -1, then the symbol does not require a global offset table entry. */
252b5132
RH
890 union
891 {
892 bfd_signed_vma *refcounts;
893 bfd_vma *offsets;
894 } local_got;
895
896 /* A mapping from local symbols to offsets into the various linker
897 sections added. This is index by the symbol index. */
898 elf_linker_section_pointers_t **linker_section_pointers;
899
900 /* The linker ELF emulation code needs to let the backend ELF linker
901 know what filename should be used for a dynamic object if the
902 dynamic object is found using a search. The emulation code then
903 sometimes needs to know what name was actually used. Until the
904 file has been added to the linker symbol table, this field holds
905 the name the linker wants. After it has been added, it holds the
906 name actually used, which will be the DT_SONAME entry if there is
907 one. */
908 const char *dt_name;
909
74816898
L
910 /* When a reference in a regular object is resolved by a shared
911 object is loaded into via the DT_NEEDED entries by the linker
912 ELF emulation code, we need to add the shared object to the
913 DT_NEEDED list of the resulting binary to indicate the dependency
914 as if the -l option is passed to the linker. This field holds the
3e932841 915 name of the loaded shared object. */
74816898
L
916 const char *dt_soname;
917
252b5132
RH
918 /* Irix 5 often screws up the symbol table, sorting local symbols
919 after global symbols. This flag is set if the symbol table in
920 this BFD appears to be screwed up. If it is, we ignore the
921 sh_info field in the symbol table header, and always read all the
922 symbols. */
923 boolean bad_symtab;
924
925 /* Records the result of `get_program_header_size'. */
926 bfd_size_type program_header_size;
927
928 /* Used by find_nearest_line entry point. */
929 PTR line_info;
930
931 /* Used by MIPS ELF find_nearest_line entry point. The structure
932 could be included directly in this one, but there's no point to
933 wasting the memory just for the infrequently called
934 find_nearest_line. */
935 struct mips_elf_find_line *find_line_info;
936
3e932841 937 /* A place to stash dwarf1 info for this bfd. */
252b5132
RH
938 struct dwarf1_debug *dwarf1_find_line_info;
939
3e932841 940 /* A place to stash dwarf2 info for this bfd. */
51db3708 941 PTR dwarf2_find_line_info;
252b5132
RH
942
943 /* An array of stub sections indexed by symbol number, used by the
944 MIPS ELF linker. FIXME: We should figure out some way to only
945 include this field for a MIPS ELF target. */
946 asection **local_stubs;
947
948 /* Used to determine if the e_flags field has been initialized */
949 boolean flags_init;
950
951 /* Number of symbol version definitions we are about to emit. */
952 unsigned int cverdefs;
953
954 /* Number of symbol version references we are about to emit. */
955 unsigned int cverrefs;
956
957 /* Symbol version definitions in external objects. */
958 Elf_Internal_Verdef *verdef;
959
960 /* Symbol version references to external objects. */
961 Elf_Internal_Verneed *verref;
962
963 /* Linker sections that we are interested in. */
964 struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
b305ef96
UC
965
966 /* The Irix 5 support uses two virtual sections, which represent
967 text/data symbols defined in dynamic objects. */
968 asymbol *elf_data_symbol;
969 asymbol *elf_text_symbol;
970 asection *elf_data_section;
971 asection *elf_text_section;
252b5132
RH
972};
973
974#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
975#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
976#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
977#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
978#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
979#define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
980#define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section)
981#define elf_dynverdef(bfd) (elf_tdata(bfd) -> dynverdef_section)
982#define elf_dynverref(bfd) (elf_tdata(bfd) -> dynverref_section)
983#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
984#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
985#define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
4e89ac30 986#define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms)
252b5132
RH
987#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
988#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
989#define elf_gp(bfd) (elf_tdata(bfd) -> gp)
990#define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
991#define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
992#define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
993#define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
994#define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
995#define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)
74816898 996#define elf_dt_soname(bfd) (elf_tdata(bfd) -> dt_soname)
252b5132
RH
997#define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
998#define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)
999#define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
1000\f
1001extern void _bfd_elf_swap_verdef_in
1002 PARAMS ((bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *));
1003extern void _bfd_elf_swap_verdef_out
1004 PARAMS ((bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *));
1005extern void _bfd_elf_swap_verdaux_in
1006 PARAMS ((bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *));
1007extern void _bfd_elf_swap_verdaux_out
1008 PARAMS ((bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *));
1009extern void _bfd_elf_swap_verneed_in
1010 PARAMS ((bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *));
1011extern void _bfd_elf_swap_verneed_out
1012 PARAMS ((bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *));
1013extern void _bfd_elf_swap_vernaux_in
1014 PARAMS ((bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *));
1015extern void _bfd_elf_swap_vernaux_out
1016 PARAMS ((bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *));
1017extern void _bfd_elf_swap_versym_in
1018 PARAMS ((bfd *, const Elf_External_Versym *, Elf_Internal_Versym *));
1019extern void _bfd_elf_swap_versym_out
1020 PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *));
1021
dc810e39
AM
1022extern int _bfd_elf_section_from_bfd_section
1023 PARAMS ((bfd *, asection *));
252b5132
RH
1024extern char *bfd_elf_string_from_elf_section
1025 PARAMS ((bfd *, unsigned, unsigned));
dc810e39
AM
1026extern char *bfd_elf_get_str_section
1027 PARAMS ((bfd *, unsigned));
252b5132 1028
dc810e39
AM
1029extern boolean _bfd_elf_print_private_bfd_data
1030 PARAMS ((bfd *, PTR));
1031extern void bfd_elf_print_symbol
1032 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
1033
1034#define elf_string_from_elf_strtab(abfd, strindex) \
1035 bfd_elf_string_from_elf_section(abfd, elf_elfheader(abfd)->e_shstrndx, \
1036 strindex)
252b5132
RH
1037
1038#define bfd_elf32_print_symbol bfd_elf_print_symbol
1039#define bfd_elf64_print_symbol bfd_elf_print_symbol
1040
dc810e39
AM
1041extern void _bfd_elf_sprintf_vma
1042 PARAMS ((bfd *, char *, bfd_vma));
1043extern void _bfd_elf_fprintf_vma
1044 PARAMS ((bfd *, PTR, bfd_vma));
d69bb69b 1045
dc810e39
AM
1046extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
1047 PARAMS ((int));
db6751f2 1048
dc810e39
AM
1049extern unsigned long bfd_elf_hash
1050 PARAMS ((const char *));
252b5132 1051
dc810e39
AM
1052extern bfd_reloc_status_type bfd_elf_generic_reloc
1053 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1054extern boolean bfd_elf_mkobject
1055 PARAMS ((bfd *));
1056extern boolean bfd_elf_mkcorefile
1057 PARAMS ((bfd *));
1058extern Elf_Internal_Shdr *bfd_elf_find_section
1059 PARAMS ((bfd *, char *));
252b5132 1060extern boolean _bfd_elf_make_section_from_shdr
dc810e39 1061 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
20cfcaae 1062extern boolean _bfd_elf_make_section_from_phdr
dc810e39 1063 PARAMS ((bfd *, Elf_Internal_Phdr *, int, const char *));
252b5132
RH
1064extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
1065 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
1066extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
1067 PARAMS ((bfd *));
c61b8717
RH
1068extern void _bfd_elf_link_hash_copy_indirect
1069 PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
1070extern void _bfd_elf_link_hash_hide_symbol
f41cbf03 1071 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
252b5132
RH
1072extern boolean _bfd_elf_link_hash_table_init
1073 PARAMS ((struct elf_link_hash_table *, bfd *,
1074 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
1075 struct bfd_hash_table *,
1076 const char *)));
dc810e39
AM
1077extern boolean _bfd_elf_slurp_version_tables
1078 PARAMS ((bfd *));
252b5132 1079
8550eb6e
JJ
1080extern boolean _bfd_elf_merge_sections
1081 PARAMS ((bfd *, struct bfd_link_info *));
1082
252b5132
RH
1083extern boolean _bfd_elf_copy_private_symbol_data
1084 PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
1085extern boolean _bfd_elf_copy_private_section_data
1086 PARAMS ((bfd *, asection *, bfd *, asection *));
dc810e39
AM
1087extern boolean _bfd_elf_write_object_contents
1088 PARAMS ((bfd *));
1089extern boolean _bfd_elf_write_corefile_contents
1090 PARAMS ((bfd *));
1091extern boolean _bfd_elf_set_section_contents
1092 PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
1093extern long _bfd_elf_get_symtab_upper_bound
1094 PARAMS ((bfd *));
1095extern long _bfd_elf_get_symtab
1096 PARAMS ((bfd *, asymbol **));
1097extern long _bfd_elf_get_dynamic_symtab_upper_bound
1098 PARAMS ((bfd *));
1099extern long _bfd_elf_canonicalize_dynamic_symtab
1100 PARAMS ((bfd *, asymbol **));
1101extern long _bfd_elf_get_reloc_upper_bound
1102 PARAMS ((bfd *, sec_ptr));
1103extern long _bfd_elf_canonicalize_reloc
1104 PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
1105extern long _bfd_elf_get_dynamic_reloc_upper_bound
1106 PARAMS ((bfd *));
1107extern long _bfd_elf_canonicalize_dynamic_reloc
1108 PARAMS ((bfd *, arelent **, asymbol **));
1109extern asymbol *_bfd_elf_make_empty_symbol
1110 PARAMS ((bfd *));
1111extern void _bfd_elf_get_symbol_info
1112 PARAMS ((bfd *, asymbol *, symbol_info *));
1113extern boolean _bfd_elf_is_local_label_name
1114 PARAMS ((bfd *, const char *));
1115extern alent *_bfd_elf_get_lineno
1116 PARAMS ((bfd *, asymbol *));
1117extern boolean _bfd_elf_set_arch_mach
1118 PARAMS ((bfd *, enum bfd_architecture, unsigned long));
1119extern boolean _bfd_elf_find_nearest_line
1120 PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
1121 const char **, unsigned int *));
252b5132
RH
1122#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
1123#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
dc810e39
AM
1124extern int _bfd_elf_sizeof_headers
1125 PARAMS ((bfd *, boolean));
1126extern boolean _bfd_elf_new_section_hook
1127 PARAMS ((bfd *, asection *));
60bcf0fa 1128extern boolean _bfd_elf_init_reloc_shdr
23bc299b 1129 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, boolean));
252b5132
RH
1130
1131/* If the target doesn't have reloc handling written yet: */
dc810e39
AM
1132extern void _bfd_elf_no_info_to_howto
1133 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
1134
1135extern boolean bfd_section_from_shdr
1136 PARAMS ((bfd *, unsigned int shindex));
1137extern boolean bfd_section_from_phdr
1138 PARAMS ((bfd *, Elf_Internal_Phdr *, int));
1139
1140extern int _bfd_elf_symbol_from_bfd_symbol
1141 PARAMS ((bfd *, asymbol **));
1142
1143extern asection *bfd_section_from_elf_index
1144 PARAMS ((bfd *, unsigned int));
1145extern boolean _bfd_elf_create_dynamic_sections
1146 PARAMS ((bfd *, struct bfd_link_info *));
1147extern struct bfd_strtab_hash *_bfd_elf_stringtab_init
1148 PARAMS ((void));
1149extern boolean _bfd_elf_link_record_dynamic_symbol
1150 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
1151extern long _bfd_elf_link_lookup_local_dynindx
1152 PARAMS ((struct bfd_link_info *, bfd *, long));
1153extern boolean _bfd_elf_compute_section_file_positions
1154 PARAMS ((bfd *, struct bfd_link_info *));
1155extern void _bfd_elf_assign_file_positions_for_relocs
1156 PARAMS ((bfd *));
1157extern file_ptr _bfd_elf_assign_file_position_for_section
1158 PARAMS ((Elf_Internal_Shdr *, file_ptr, boolean));
1159
1160extern boolean _bfd_elf_validate_reloc
1161 PARAMS ((bfd *, arelent *));
1162
1163extern boolean _bfd_elf_create_dynamic_sections
1164 PARAMS ((bfd *, struct bfd_link_info *));
1165extern boolean _bfd_elf_create_got_section
1166 PARAMS ((bfd *, struct bfd_link_info *));
1167extern unsigned long _bfd_elf_link_renumber_dynsyms
1168 PARAMS ((bfd *, struct bfd_link_info *));
1169
1170extern boolean _bfd_elfcore_make_pseudosection
1171 PARAMS ((bfd *, char *, size_t, ufile_ptr));
1172extern char *_bfd_elfcore_strndup
1173 PARAMS ((bfd *, char *, size_t));
1174
1175extern elf_linker_section_t *_bfd_elf_create_linker_section
1176 PARAMS ((bfd *, struct bfd_link_info *, enum elf_linker_section_enum,
1177 elf_linker_section_t *));
1178
1179extern elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
1180 PARAMS ((elf_linker_section_pointers_t *, bfd_vma,
1181 elf_linker_section_enum_t));
1182
1183extern boolean bfd_elf32_create_pointer_linker_section
1184 PARAMS ((bfd *, struct bfd_link_info *, elf_linker_section_t *,
1185 struct elf_link_hash_entry *, const Elf32_Internal_Rela *));
1186
1187extern bfd_vma bfd_elf32_finish_pointer_linker_section
1188 PARAMS ((bfd *, bfd *, struct bfd_link_info *, elf_linker_section_t *,
1189 struct elf_link_hash_entry *, bfd_vma,
1190 const Elf32_Internal_Rela *, int));
1191
1192extern boolean bfd_elf64_create_pointer_linker_section
1193 PARAMS ((bfd *, struct bfd_link_info *, elf_linker_section_t *,
1194 struct elf_link_hash_entry *, const Elf64_Internal_Rela *));
1195
1196extern bfd_vma bfd_elf64_finish_pointer_linker_section
1197 PARAMS ((bfd *, bfd *, struct bfd_link_info *, elf_linker_section_t *,
1198 struct elf_link_hash_entry *, bfd_vma,
1199 const Elf64_Internal_Rela *, int));
1200
1201extern boolean _bfd_elf_make_linker_section_rela
1202 PARAMS ((bfd *, elf_linker_section_t *, int));
1203
1204extern const bfd_target *bfd_elf32_object_p
1205 PARAMS ((bfd *));
1206extern const bfd_target *bfd_elf32_core_file_p
1207 PARAMS ((bfd *));
1208extern char *bfd_elf32_core_file_failing_command
1209 PARAMS ((bfd *));
1210extern int bfd_elf32_core_file_failing_signal
1211 PARAMS ((bfd *));
1212extern boolean bfd_elf32_core_file_matches_executable_p
1213 PARAMS ((bfd *, bfd *));
252b5132
RH
1214
1215extern boolean bfd_elf32_bfd_link_add_symbols
1216 PARAMS ((bfd *, struct bfd_link_info *));
1217extern boolean bfd_elf32_bfd_final_link
1218 PARAMS ((bfd *, struct bfd_link_info *));
1219
1220extern void bfd_elf32_swap_symbol_in
1221 PARAMS ((bfd *, const Elf32_External_Sym *, Elf_Internal_Sym *));
1222extern void bfd_elf32_swap_symbol_out
1223 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
1224extern void bfd_elf32_swap_reloc_in
1225 PARAMS ((bfd *, const Elf32_External_Rel *, Elf_Internal_Rel *));
1226extern void bfd_elf32_swap_reloc_out
1227 PARAMS ((bfd *, const Elf_Internal_Rel *, Elf32_External_Rel *));
1228extern void bfd_elf32_swap_reloca_in
1229 PARAMS ((bfd *, const Elf32_External_Rela *, Elf_Internal_Rela *));
1230extern void bfd_elf32_swap_reloca_out
1231 PARAMS ((bfd *, const Elf_Internal_Rela *, Elf32_External_Rela *));
1232extern void bfd_elf32_swap_phdr_in
1233 PARAMS ((bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *));
1234extern void bfd_elf32_swap_phdr_out
1235 PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *));
1236extern void bfd_elf32_swap_dyn_in
1237 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
1238extern void bfd_elf32_swap_dyn_out
c7ac6ff8 1239 PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
252b5132
RH
1240extern long bfd_elf32_slurp_symbol_table
1241 PARAMS ((bfd *, asymbol **, boolean));
dc810e39
AM
1242extern boolean bfd_elf32_write_shdrs_and_ehdr
1243 PARAMS ((bfd *));
252b5132 1244extern int bfd_elf32_write_out_phdrs
dc810e39 1245 PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
b9f66672
JL
1246extern void bfd_elf32_write_relocs
1247 PARAMS ((bfd *, asection *, PTR));
1248extern boolean bfd_elf32_slurp_reloc_table
1249 PARAMS ((bfd *, asection *, asymbol **, boolean));
252b5132
RH
1250extern boolean bfd_elf32_add_dynamic_entry
1251 PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
1252extern boolean bfd_elf32_link_create_dynamic_sections
1253 PARAMS ((bfd *, struct bfd_link_info *));
1254extern Elf_Internal_Rela *_bfd_elf32_link_read_relocs
1255 PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
1256
dc810e39
AM
1257extern const bfd_target *bfd_elf64_object_p
1258 PARAMS ((bfd *));
1259extern const bfd_target *bfd_elf64_core_file_p
1260 PARAMS ((bfd *));
1261extern char *bfd_elf64_core_file_failing_command
1262 PARAMS ((bfd *));
1263extern int bfd_elf64_core_file_failing_signal
1264 PARAMS ((bfd *));
1265extern boolean bfd_elf64_core_file_matches_executable_p
1266 PARAMS ((bfd *, bfd *));
252b5132
RH
1267extern boolean bfd_elf64_bfd_link_add_symbols
1268 PARAMS ((bfd *, struct bfd_link_info *));
1269extern boolean bfd_elf64_bfd_final_link
1270 PARAMS ((bfd *, struct bfd_link_info *));
1271
1272extern void bfd_elf64_swap_symbol_in
1273 PARAMS ((bfd *, const Elf64_External_Sym *, Elf_Internal_Sym *));
1274extern void bfd_elf64_swap_symbol_out
1275 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
1276extern void bfd_elf64_swap_reloc_in
1277 PARAMS ((bfd *, const Elf64_External_Rel *, Elf_Internal_Rel *));
1278extern void bfd_elf64_swap_reloc_out
1279 PARAMS ((bfd *, const Elf_Internal_Rel *, Elf64_External_Rel *));
1280extern void bfd_elf64_swap_reloca_in
1281 PARAMS ((bfd *, const Elf64_External_Rela *, Elf_Internal_Rela *));
1282extern void bfd_elf64_swap_reloca_out
1283 PARAMS ((bfd *, const Elf_Internal_Rela *, Elf64_External_Rela *));
1284extern void bfd_elf64_swap_phdr_in
1285 PARAMS ((bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *));
1286extern void bfd_elf64_swap_phdr_out
1287 PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *));
1288extern void bfd_elf64_swap_dyn_in
1289 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
1290extern void bfd_elf64_swap_dyn_out
c7ac6ff8 1291 PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
252b5132
RH
1292extern long bfd_elf64_slurp_symbol_table
1293 PARAMS ((bfd *, asymbol **, boolean));
dc810e39
AM
1294extern boolean bfd_elf64_write_shdrs_and_ehdr
1295 PARAMS ((bfd *));
252b5132 1296extern int bfd_elf64_write_out_phdrs
dc810e39 1297 PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
b9f66672
JL
1298extern void bfd_elf64_write_relocs
1299 PARAMS ((bfd *, asection *, PTR));
1300extern boolean bfd_elf64_slurp_reloc_table
1301 PARAMS ((bfd *, asection *, asymbol **, boolean));
252b5132
RH
1302extern boolean bfd_elf64_add_dynamic_entry
1303 PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
1304extern boolean bfd_elf64_link_create_dynamic_sections
1305 PARAMS ((bfd *, struct bfd_link_info *));
1306extern Elf_Internal_Rela *_bfd_elf64_link_read_relocs
1307 PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
1308
30b30c21
RH
1309#define bfd_elf32_link_record_dynamic_symbol \
1310 _bfd_elf_link_record_dynamic_symbol
1311#define bfd_elf64_link_record_dynamic_symbol \
1312 _bfd_elf_link_record_dynamic_symbol
1313
dc810e39 1314extern boolean _bfd_elf32_link_record_local_dynamic_symbol
30b30c21 1315 PARAMS ((struct bfd_link_info *, bfd *, long));
dc810e39 1316extern boolean _bfd_elf64_link_record_local_dynamic_symbol
30b30c21 1317 PARAMS ((struct bfd_link_info *, bfd *, long));
252b5132 1318
dc810e39
AM
1319extern boolean _bfd_elf_close_and_cleanup
1320 PARAMS ((bfd *));
252b5132
RH
1321extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
1322 PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR,
1323 asection *, bfd *, char **));
1324
dc810e39
AM
1325extern boolean _bfd_elf32_gc_sections
1326 PARAMS ((bfd *, struct bfd_link_info *));
1327extern boolean _bfd_elf32_gc_common_finalize_got_offsets
1328 PARAMS ((bfd *, struct bfd_link_info *));
1329extern boolean _bfd_elf32_gc_common_final_link
252b5132 1330 PARAMS ((bfd *, struct bfd_link_info *));
dc810e39 1331extern boolean _bfd_elf32_gc_record_vtinherit
252b5132 1332 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
dc810e39 1333extern boolean _bfd_elf32_gc_record_vtentry
252b5132
RH
1334 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1335
dc810e39 1336extern boolean _bfd_elf64_gc_sections
252b5132 1337 PARAMS ((bfd *, struct bfd_link_info *));
dc810e39
AM
1338extern boolean _bfd_elf64_gc_common_finalize_got_offsets
1339 PARAMS ((bfd *, struct bfd_link_info *));
1340extern boolean _bfd_elf64_gc_common_final_link
1341 PARAMS ((bfd *, struct bfd_link_info *));
1342extern boolean _bfd_elf64_gc_record_vtinherit
252b5132 1343 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
dc810e39 1344extern boolean _bfd_elf64_gc_record_vtentry
252b5132
RH
1345 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1346
1347/* MIPS ELF specific routines. */
1348
dc810e39
AM
1349extern boolean _bfd_mips_elf_object_p
1350 PARAMS ((bfd *));
252b5132 1351extern boolean _bfd_mips_elf_section_from_shdr
103186c6 1352 PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
252b5132
RH
1353extern boolean _bfd_mips_elf_fake_sections
1354 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
1355extern boolean _bfd_mips_elf_section_from_bfd_section
1356 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, int *));
1357extern boolean _bfd_mips_elf_section_processing
1358 PARAMS ((bfd *, Elf_Internal_Shdr *));
dc810e39
AM
1359extern void _bfd_mips_elf_symbol_processing
1360 PARAMS ((bfd *, asymbol *));
252b5132
RH
1361extern boolean _bfd_mips_elf_read_ecoff_info
1362 PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
dc810e39
AM
1363extern void _bfd_mips_elf_final_write_processing
1364 PARAMS ((bfd *, boolean));
252b5132
RH
1365extern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc
1366 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1367extern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc
1368 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1369extern bfd_reloc_status_type _bfd_mips_elf_gprel16_reloc
1370 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1371extern bfd_reloc_status_type _bfd_mips_elf_got16_reloc
1372 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1373extern bfd_reloc_status_type _bfd_mips_elf_gprel32_reloc
1374 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
dc810e39
AM
1375extern boolean _bfd_mips_elf_set_private_flags
1376 PARAMS ((bfd *, flagword));
1377extern boolean _bfd_mips_elf_copy_private_bfd_data
1378 PARAMS ((bfd *, bfd *));
1379extern boolean _bfd_mips_elf_merge_private_bfd_data
1380 PARAMS ((bfd *, bfd *));
252b5132
RH
1381extern boolean _bfd_mips_elf_find_nearest_line
1382 PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
1383 const char **, unsigned int *));
1384extern boolean _bfd_mips_elf_set_section_contents
1385 PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
103186c6
MM
1386extern boolean _bfd_mips_elf_create_dynamic_sections
1387 PARAMS ((bfd *, struct bfd_link_info *));
1388extern boolean _bfd_mips_elf_add_symbol_hook
1389 PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
1390 const char **, flagword *, asection **, bfd_vma *));
1391extern boolean _bfd_mips_elf_adjust_dynamic_symbol
1392 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
1393extern boolean _bfd_mips_elf_finish_dynamic_symbol
1394 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
1395 Elf_Internal_Sym *));
1396extern boolean _bfd_mips_elf_finish_dynamic_sections
1397 PARAMS ((bfd *, struct bfd_link_info *));
60bcf0fa 1398extern asection * _bfd_mips_elf_gc_mark_hook
103186c6
MM
1399 PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
1400 struct elf_link_hash_entry *, Elf_Internal_Sym *));
60bcf0fa
NC
1401extern boolean _bfd_mips_elf_gc_sweep_hook
1402 PARAMS ((bfd *, struct bfd_link_info *, asection *,
103186c6
MM
1403 const Elf_Internal_Rela *));
1404extern boolean _bfd_mips_elf_always_size_sections
1405 PARAMS ((bfd *, struct bfd_link_info *));
1406extern boolean _bfd_mips_elf_size_dynamic_sections
1407 PARAMS ((bfd *, struct bfd_link_info *));
1408extern boolean _bfd_mips_elf_check_relocs
1409 PARAMS ((bfd *, struct bfd_link_info *, asection *,
1410 const Elf_Internal_Rela *));
1411extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
1412 PARAMS ((bfd *));
60bcf0fa 1413extern boolean _bfd_mips_elf_print_private_bfd_data
103186c6
MM
1414 PARAMS ((bfd *, PTR));
1415extern boolean _bfd_mips_elf_link_output_symbol_hook
1416 PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
1417 asection *));
1418extern boolean _bfd_mips_elf_final_link
1419 PARAMS ((bfd *, struct bfd_link_info *));
dc810e39
AM
1420extern int _bfd_mips_elf_additional_program_headers
1421 PARAMS ((bfd *));
1422extern boolean _bfd_mips_elf_modify_segment_map
1423 PARAMS ((bfd *));
103186c6
MM
1424extern boolean _bfd_mips_elf_relocate_section
1425 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
1426 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
252b5132 1427
d4845d57
JR
1428/* SH ELF specific routine. */
1429
dc810e39
AM
1430extern boolean _sh_elf_set_mach_from_flags
1431 PARAMS ((bfd *));
d4845d57 1432
252b5132 1433#endif /* _LIBELF_H_ */