* objcopy.c (use_alt_mach_code): New variable.
[deliverable/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))
276\f
277/* Constant information held for an ELF backend. */
278
279struct elf_size_info {
280 unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
281 unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
282
c7ac6ff8
MM
283 /* The size of entries in the .hash section. */
284 unsigned char sizeof_hash_entry;
285
286 /* The number of internal relocations to allocate per external
287 relocation entry. */
288 unsigned char int_rels_per_ext_rel;
289
252b5132
RH
290 unsigned char arch_size, file_align;
291 unsigned char elfclass, ev_current;
292 int (*write_out_phdrs) PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
293 boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *));
294 void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
295 void (*swap_symbol_out) PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
296 boolean (*slurp_reloc_table)
297 PARAMS ((bfd *, asection *, asymbol **, boolean));
298 long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean));
299 void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
c7ac6ff8
MM
300 void (*swap_dyn_out) PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
301
302 /* This function, if defined, is called to swap in a REL
303 relocation. If an external relocation corresponds to more than
304 one internal relocation, then all relocations are swapped in at
305 once. */
306 void (*swap_reloc_in)
307 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rel *));
308
309 /* This function, if defined, is called to swap out a REL
310 relocation. */
311 void (*swap_reloc_out)
312 PARAMS ((bfd *, const Elf_Internal_Rel *, bfd_byte *));
313
314 /* This function, if defined, is called to swap in a RELA
315 relocation. If an external relocation corresponds to more than
316 one internal relocation, then all relocations are swapped in at
317 once. */
318 void (*swap_reloca_in)
319 PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
320
321 /* This function, if defined, is called to swap out a RELA
322 relocation. */
323 void (*swap_reloca_out)
324 PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
325
252b5132
RH
326};
327
328#define elf_symbol_from(ABFD,S) \
329 (((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
330 && (S)->the_bfd->tdata.elf_obj_data != 0) \
331 ? (elf_symbol_type *) (S) \
332 : 0)
333
db6751f2
JJ
334enum elf_reloc_type_class {
335 reloc_class_normal,
336 reloc_class_relative,
337 reloc_class_plt,
338 reloc_class_copy
339};
340
252b5132
RH
341struct elf_backend_data
342{
252b5132
RH
343 /* The architecture for this backend. */
344 enum bfd_architecture arch;
345
346 /* The ELF machine code (EM_xxxx) for this backend. */
347 int elf_machine_code;
348
349 /* The maximum page size for this backend. */
350 bfd_vma maxpagesize;
351
252b5132
RH
352 /* A function to translate an ELF RELA relocation to a BFD arelent
353 structure. */
354 void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
355 Elf_Internal_Rela *));
356
357 /* A function to translate an ELF REL relocation to a BFD arelent
358 structure. */
359 void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
360 Elf_Internal_Rel *));
361
362 /* A function to determine whether a symbol is global when
363 partitioning the symbol table into local and global symbols.
364 This should be NULL for most targets, in which case the correct
365 thing will be done. MIPS ELF, at least on the Irix 5, has
366 special requirements. */
367 boolean (*elf_backend_sym_is_global) PARAMS ((bfd *, asymbol *));
368
369 /* The remaining functions are hooks which are called only if they
370 are not NULL. */
371
372 /* A function to permit a backend specific check on whether a
373 particular BFD format is relevant for an object file, and to
374 permit the backend to set any global information it wishes. When
375 this is called elf_elfheader is set, but anything else should be
376 used with caution. If this returns false, the check_format
377 routine will return a bfd_error_wrong_format error. */
378 boolean (*elf_backend_object_p) PARAMS ((bfd *));
379
380 /* A function to do additional symbol processing when reading the
381 ELF symbol table. This is where any processor-specific special
382 section indices are handled. */
383 void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *));
384
385 /* A function to do additional symbol processing after reading the
386 entire ELF symbol table. */
387 boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *,
388 elf_symbol_type *,
389 unsigned int));
390
391 /* A function to set the type of the info field. Processor-specific
3e932841 392 types should be handled here. */
60bcf0fa
NC
393 int (*elf_backend_get_symbol_type) PARAMS (( Elf_Internal_Sym *, int));
394
252b5132
RH
395 /* A function to do additional processing on the ELF section header
396 just before writing it out. This is used to set the flags and
397 type fields for some sections, or to actually write out data for
398 unusual sections. */
399 boolean (*elf_backend_section_processing) PARAMS ((bfd *,
400 Elf32_Internal_Shdr *));
401
402 /* A function to handle unusual section types when creating BFD
403 sections from ELF sections. */
404 boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *,
405 Elf32_Internal_Shdr *,
406 char *));
407
fa152c49
JW
408 /* A function to convert machine dependent section header flags to
409 BFD internal section header flags. */
410 boolean (*elf_backend_section_flags) PARAMS ((flagword *,
411 Elf32_Internal_Shdr *));
412
20cfcaae 413 /* A function to handle unusual program segment types when creating BFD
3e932841 414 sections from ELF program segments. */
20cfcaae
NC
415 boolean (*elf_backend_section_from_phdr) PARAMS ((bfd *,
416 Elf32_Internal_Phdr *,
417 int));
418
252b5132
RH
419 /* A function to set up the ELF section header for a BFD section in
420 preparation for writing it out. This is where the flags and type
421 fields are set for unusual sections. */
422 boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *,
423 asection *));
424
425 /* A function to get the ELF section index for a BFD section. If
426 this returns true, the section was found. If it is a normal ELF
427 section, *RETVAL should be left unchanged. If it is not a normal
428 ELF section *RETVAL should be set to the SHN_xxxx index. */
429 boolean (*elf_backend_section_from_bfd_section)
430 PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval));
431
432 /* If this field is not NULL, it is called by the add_symbols phase
433 of a link just before adding a symbol to the global linker hash
434 table. It may modify any of the fields as it wishes. If *NAME
435 is set to NULL, the symbol will be skipped rather than being
436 added to the hash table. This function is responsible for
437 handling all processor dependent symbol bindings and section
438 indices, and must set at least *FLAGS and *SEC for each processor
439 dependent case; failure to do so will cause a link error. */
440 boolean (*elf_add_symbol_hook)
441 PARAMS ((bfd *abfd, struct bfd_link_info *info,
442 const Elf_Internal_Sym *, const char **name,
443 flagword *flags, asection **sec, bfd_vma *value));
444
445 /* If this field is not NULL, it is called by the elf_link_output_sym
446 phase of a link for each symbol which will appear in the object file. */
447 boolean (*elf_backend_link_output_symbol_hook)
448 PARAMS ((bfd *, struct bfd_link_info *info, const char *,
449 Elf_Internal_Sym *, asection *));
450
451 /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
452 linker the first time it encounters a dynamic object in the link.
453 This function must create any sections required for dynamic
454 linking. The ABFD argument is a dynamic object. The .interp,
455 .dynamic, .dynsym, .dynstr, and .hash functions have already been
456 created, and this function may modify the section flags if
457 desired. This function will normally create the .got and .plt
458 sections, but different backends have different requirements. */
459 boolean (*elf_backend_create_dynamic_sections)
460 PARAMS ((bfd *abfd, struct bfd_link_info *info));
461
462 /* The CHECK_RELOCS function is called by the add_symbols phase of
463 the ELF backend linker. It is called once for each section with
464 relocs of an object file, just after the symbols for the object
465 file have been added to the global linker hash table. The
466 function must look through the relocs and do any special handling
467 required. This generally means allocating space in the global
468 offset table, and perhaps allocating space for a reloc. The
469 relocs are always passed as Rela structures; if the section
470 actually uses Rel structures, the r_addend field will always be
471 zero. */
472 boolean (*check_relocs)
473 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
474 const Elf_Internal_Rela *relocs));
475
476 /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
477 linker for every symbol which is defined by a dynamic object and
478 referenced by a regular object. This is called after all the
479 input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
480 function has been called. The hash table entry should be
481 bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
482 defined in a section from a dynamic object. Dynamic object
483 sections are not included in the final link, and this function is
484 responsible for changing the value to something which the rest of
485 the link can deal with. This will normally involve adding an
486 entry to the .plt or .got or some such section, and setting the
487 symbol to point to that. */
488 boolean (*elf_backend_adjust_dynamic_symbol)
489 PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
490
491 /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
492 after all the linker input files have been seen but before the
493 section sizes have been set. This is called after
494 ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */
495 boolean (*elf_backend_always_size_sections)
496 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
497
498 /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
499 linker after all the linker input files have been seen but before
500 the sections sizes have been set. This is called after
501 ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
502 It is only called when linking against a dynamic object. It must
503 set the sizes of the dynamic sections, and may fill in their
504 contents as well. The generic ELF linker can handle the .dynsym,
505 .dynstr and .hash sections. This function must handle the
506 .interp section and any sections created by the
507 CREATE_DYNAMIC_SECTIONS entry point. */
508 boolean (*elf_backend_size_dynamic_sections)
509 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
510
511 /* The RELOCATE_SECTION function is called by the ELF backend linker
512 to handle the relocations for a section.
513
514 The relocs are always passed as Rela structures; if the section
515 actually uses Rel structures, the r_addend field will always be
516 zero.
517
518 This function is responsible for adjust the section contents as
519 necessary, and (if using Rela relocs and generating a
520 relocateable output file) adjusting the reloc addend as
521 necessary.
522
523 This function does not have to worry about setting the reloc
524 address or the reloc symbol index.
525
526 LOCAL_SYMS is a pointer to the swapped in local symbols.
527
528 LOCAL_SECTIONS is an array giving the section in the input file
529 corresponding to the st_shndx field of each local symbol.
530
531 The global hash table entry for the global symbols can be found
532 via elf_sym_hashes (input_bfd).
533
534 When generating relocateable output, this function must handle
535 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
536 going to be the section symbol corresponding to the output
537 section, which means that the addend must be adjusted
538 accordingly. */
539 boolean (*elf_backend_relocate_section)
540 PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
541 bfd *input_bfd, asection *input_section, bfd_byte *contents,
542 Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
543 asection **local_sections));
544
545 /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
546 linker just before it writes a symbol out to the .dynsym section.
547 The processor backend may make any required adjustment to the
548 symbol. It may also take the opportunity to set contents of the
549 dynamic sections. Note that FINISH_DYNAMIC_SYMBOL is called on
550 all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
551 on those symbols which are defined by a dynamic object. */
552 boolean (*elf_backend_finish_dynamic_symbol)
553 PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
554 struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
555
556 /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
557 linker just before it writes all the dynamic sections out to the
558 output file. The FINISH_DYNAMIC_SYMBOL will have been called on
559 all dynamic symbols. */
560 boolean (*elf_backend_finish_dynamic_sections)
561 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
562
563 /* A function to do any beginning processing needed for the ELF file
564 before building the ELF headers and computing file positions. */
565 void (*elf_backend_begin_write_processing)
566 PARAMS ((bfd *, struct bfd_link_info *));
567
568 /* A function to do any final processing needed for the ELF file
569 before writing it out. The LINKER argument is true if this BFD
570 was created by the ELF backend linker. */
571 void (*elf_backend_final_write_processing)
572 PARAMS ((bfd *, boolean linker));
573
574 /* This function is called by get_program_header_size. It should
575 return the number of additional program segments which this BFD
576 will need. It should return -1 on error. */
577 int (*elf_backend_additional_program_headers) PARAMS ((bfd *));
578
579 /* This function is called to modify an existing segment map in a
580 backend specific fashion. */
581 boolean (*elf_backend_modify_segment_map) PARAMS ((bfd *));
582
583 /* This function is called during section gc to discover the section a
584 particular relocation refers to. It need not be defined for hosts
585 that have no queer relocation types. */
586 asection * (*gc_mark_hook)
587 PARAMS ((bfd *abfd, struct bfd_link_info *, Elf_Internal_Rela *,
588 struct elf_link_hash_entry *h, Elf_Internal_Sym *));
589
590 /* This function, if defined, is called during the sweep phase of gc
591 in order that a backend might update any data structures it might
592 be maintaining. */
593 boolean (*gc_sweep_hook)
594 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
595 const Elf_Internal_Rela *relocs));
596
e6c51ed4
NC
597 /* This function, if defined, is called after the ELF headers have
598 been created. This allows for things like the OS and ABI versions
599 to be changed. */
600 void (*elf_backend_post_process_headers)
601 PARAMS ((bfd *, struct bfd_link_info *));
602
587ff49e
RH
603 /* This function, if defined, prints a symbol to file and returns the
604 name of the symbol to be printed. It should return NULL to fall
605 back to default symbol printing. */
606 const char *(*elf_backend_print_symbol_all)
607 PARAMS ((bfd *, PTR, asymbol *));
608
609 /* This function, if defined, is called after all local symbols and
610 global symbols converted to locals are emited into the symtab
611 section. It allows the backend to emit special global symbols
612 not handled in the hash table. */
613 boolean (*elf_backend_output_arch_syms)
614 PARAMS ((bfd *, struct bfd_link_info *, PTR,
615 boolean (*) PARAMS ((PTR, const char *,
616 Elf_Internal_Sym *, asection *))));
617
c61b8717
RH
618 /* Copy any information related to dynamic linking from a pre-existing
619 symbol IND to a newly created symbol DIR. */
620 void (*elf_backend_copy_indirect_symbol)
621 PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
622
623 /* Modify any information related to dynamic linking such that the
624 symbol is not exported. */
625 void (*elf_backend_hide_symbol)
f41cbf03 626 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
c61b8717 627
9317eacc
CM
628 /* Emit relocations. Overrides default routine for emitting relocs,
629 except during a relocatable link, or if all relocs are being emitted. */
630 void (*elf_backend_emit_relocs)
631 PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *));
632
633 /* Count relocations. Not called for relocatable links
634 or if all relocs are being preserved in the output. */
635 unsigned int (*elf_backend_count_relocs)
636 PARAMS ((asection *, Elf_Internal_Rela *));
637
bb0082d6
AM
638 /* This function, if defined, is called when an NT_PRSTATUS note is found
639 in a core file. */
640 boolean (*elf_backend_grok_prstatus) PARAMS ((bfd *, Elf_Internal_Note *));
641
642 /* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
643 note is found in a core file. */
644 boolean (*elf_backend_grok_psinfo) PARAMS ((bfd *, Elf_Internal_Note *));
645
db6751f2 646 /* Functions to print VMAs. Special code to handle 64 bit ELF files. */
4e771d61
NC
647 void (* elf_backend_sprintf_vma) PARAMS ((bfd *, char *, bfd_vma));
648 void (* elf_backend_fprintf_vma) PARAMS ((bfd *, PTR, bfd_vma));
649
db6751f2
JJ
650 /* This function returns class of a reloc type. */
651 enum elf_reloc_type_class (* elf_backend_reloc_type_class) PARAMS ((int));
652
252b5132
RH
653 /* The swapping table to use when dealing with ECOFF information.
654 Used for the MIPS ELF .mdebug section. */
655 const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
656
657 /* Alternate EM_xxxx machine codes for this backend. */
658 int elf_machine_alt1;
659 int elf_machine_alt2;
660
661 const struct elf_size_info *s;
662
663 /* offset of the _GLOBAL_OFFSET_TABLE_ symbol from the start of the
664 .got section */
665 bfd_vma got_symbol_offset;
666
667 /* The size in bytes of the headers for the GOT and PLT. This includes
668 the so-called reserved entries on some systems. */
669 bfd_vma got_header_size;
670 bfd_vma plt_header_size;
671
86dc0f79
RH
672 /* This is true if the linker should act like collect and gather
673 global constructors and destructors by name. This is true for
674 MIPS ELF because the Irix 5 tools can not handle the .init
675 section. */
676 unsigned collect : 1;
677
678 /* This is true if the linker should ignore changes to the type of a
679 symbol. This is true for MIPS ELF because some Irix 5 objects
680 record undefined functions as STT_OBJECT although the definitions
681 are STT_FUNC. */
682 unsigned type_change_ok : 1;
683
bf572ba0
MM
684 /* Whether the backend may use REL relocations. (Some backends use
685 both REL and RELA relocations, and this flag is set for those
686 backends.) */
687 unsigned may_use_rel_p : 1;
60bcf0fa 688
bf572ba0
MM
689 /* Whether the backend may use RELA relocations. (Some backends use
690 both REL and RELA relocations, and this flag is set for those
691 backends.) */
692 unsigned may_use_rela_p : 1;
693
694 /* Whether the default relocation type is RELA. If a backend with
695 this flag set wants REL relocations for a particular section,
696 it must note that explicitly. Similarly, if this flag is clear,
60bcf0fa
NC
697 and the backend wants RELA relocations for a particular
698 section. */
bf572ba0
MM
699 unsigned default_use_rela_p : 1;
700
86dc0f79
RH
701 /* True if addresses "naturally" sign extend. This is used when
702 swapping in from Elf32 when BFD64. */
703 unsigned sign_extend_vma : 1;
704
252b5132
RH
705 unsigned want_got_plt : 1;
706 unsigned plt_readonly : 1;
707 unsigned want_plt_sym : 1;
708 unsigned plt_not_loaded : 1;
709 unsigned plt_alignment : 4;
710 unsigned can_gc_sections : 1;
2517a57f 711 unsigned want_got_sym : 1;
3018b441 712 unsigned want_dynbss : 1;
252b5132
RH
713};
714
715/* Information stored for each BFD section in an ELF file. This
716 structure is allocated by elf_new_section_hook. */
717
718struct bfd_elf_section_data
719{
720 /* The ELF header for this section. */
721 Elf_Internal_Shdr this_hdr;
722 /* The ELF header for the reloc section associated with this
723 section, if any. */
724 Elf_Internal_Shdr rel_hdr;
725 /* If there is a second reloc section associated with this section,
726 as can happen on Irix 6, this field points to the header. */
727 Elf_Internal_Shdr *rel_hdr2;
23bc299b
MM
728 /* The number of relocations currently assigned to REL_HDR. */
729 unsigned int rel_count;
730 /* The number of relocations currently assigned to REL_HDR2. */
731 unsigned int rel_count2;
252b5132
RH
732 /* The ELF section number of this section. Only used for an output
733 file. */
734 int this_idx;
23bc299b
MM
735 /* The ELF section number of the reloc section indicated by
736 REL_HDR if any. Only used for an output file. */
252b5132 737 int rel_idx;
23bc299b
MM
738 /* The ELF section number of the reloc section indicated by
739 REL_HDR2 if any. Only used for an output file. */
740 int rel_idx2;
252b5132
RH
741 /* Used by the backend linker to store the symbol hash table entries
742 associated with relocs against global symbols. */
743 struct elf_link_hash_entry **rel_hashes;
744 /* A pointer to the swapped relocs. If the section uses REL relocs,
745 rather than RELA, all the r_addend fields will be zero. This
746 pointer may be NULL. It is used by the backend linker. */
747 Elf_Internal_Rela *relocs;
748 /* Used by the backend linker when generating a shared library to
749 record the dynamic symbol index for a section symbol
75945f9f
ILT
750 corresponding to this section. A value of 0 means that there is
751 no dynamic symbol for this section. */
252b5132
RH
752 long dynindx;
753 /* A pointer used for .stab linking optimizations. */
754 PTR stab_info;
f5fa8ca2
JJ
755 /* A pointer used for SEC_MERGE optimizations. */
756 PTR merge_info;
252b5132
RH
757 /* A pointer available for the processor specific ELF backend. */
758 PTR tdata;
bf572ba0
MM
759 /* Nonzero if this section uses RELA relocations, rather than REL. */
760 unsigned int use_rela_p:1;
252b5132
RH
761};
762
763#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
764
765#define get_elf_backend_data(abfd) \
766 ((struct elf_backend_data *) (abfd)->xvec->backend_data)
767
768/* Enumeration to specify the special section. */
769typedef enum elf_linker_section_enum
770{
771 LINKER_SECTION_UNKNOWN, /* not used */
772 LINKER_SECTION_GOT, /* .got section for global offset pointers */
773 LINKER_SECTION_PLT, /* .plt section for generated procedure stubs */
774 LINKER_SECTION_SDATA, /* .sdata/.sbss section for PowerPC */
775 LINKER_SECTION_SDATA2, /* .sdata2/.sbss2 section for PowerPC */
776 LINKER_SECTION_MAX /* # of linker sections */
777} elf_linker_section_enum_t;
778
779/* Sections created by the linker. */
780
781typedef struct elf_linker_section
782{
783 char *name; /* name of the section */
784 char *rel_name; /* name of the associated .rel{,a}. section */
785 char *bss_name; /* name of a related .bss section */
786 char *sym_name; /* name of symbol to reference this section */
787 asection *section; /* pointer to the section */
788 asection *bss_section; /* pointer to the bss section associated with this */
789 asection *rel_section; /* pointer to the relocations needed for this section */
790 struct elf_link_hash_entry *sym_hash; /* pointer to the created symbol hash value */
791 bfd_vma initial_size; /* initial size before any linker generated allocations */
792 bfd_vma sym_offset; /* offset of symbol from beginning of section */
793 bfd_vma hole_size; /* size of reserved address hole in allocation */
794 bfd_vma hole_offset; /* current offset for the hole */
795 bfd_vma max_hole_offset; /* maximum offset for the hole */
796 elf_linker_section_enum_t which; /* which section this is */
797 boolean hole_written_p; /* whether the hole has been initialized */
798 unsigned int alignment; /* alignment for the section */
799 flagword flags; /* flags to use to create the section */
800} elf_linker_section_t;
801
802/* Linked list of allocated pointer entries. This hangs off of the symbol lists, and
803 provides allows us to return different pointers, based on different addend's. */
804
805typedef struct elf_linker_section_pointers
806{
807 struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */
808 bfd_vma offset; /* offset of pointer from beginning of section */
809 bfd_signed_vma addend; /* addend used */
810 elf_linker_section_enum_t which; /* which linker section this is */
811 boolean written_address_p; /* whether address was written yet */
812} elf_linker_section_pointers_t;
813
814/* Some private data is stashed away for future use using the tdata pointer
815 in the bfd structure. */
816
817struct elf_obj_tdata
818{
819 Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
820 Elf_Internal_Shdr **elf_sect_ptr;
821 Elf_Internal_Phdr *phdr;
822 struct elf_segment_map *segment_map;
823 struct bfd_strtab_hash *strtab_ptr;
824 int num_locals;
825 int num_globals;
4e89ac30 826 int num_section_syms;
252b5132
RH
827 asymbol **section_syms; /* STT_SECTION symbols for each section */
828 Elf_Internal_Shdr symtab_hdr;
829 Elf_Internal_Shdr shstrtab_hdr;
830 Elf_Internal_Shdr strtab_hdr;
831 Elf_Internal_Shdr dynsymtab_hdr;
832 Elf_Internal_Shdr dynstrtab_hdr;
833 Elf_Internal_Shdr dynversym_hdr;
834 Elf_Internal_Shdr dynverref_hdr;
835 Elf_Internal_Shdr dynverdef_hdr;
836 unsigned int symtab_section, shstrtab_section;
837 unsigned int strtab_section, dynsymtab_section;
838 unsigned int dynversym_section, dynverdef_section, dynverref_section;
839 file_ptr next_file_pos;
840#if 0
841 /* we don't need these inside bfd anymore, and I think
3e932841 842 these weren't used outside bfd. */
252b5132
RH
843 void *prstatus; /* The raw /proc prstatus structure */
844 void *prpsinfo; /* The raw /proc prpsinfo structure */
845#endif
846 bfd_vma gp; /* The gp value (MIPS only, for now) */
847 unsigned int gp_size; /* The gp size (MIPS only, for now) */
848
3e932841 849 /* Information grabbed from an elf core file. */
252b5132
RH
850 int core_signal;
851 int core_pid;
852 int core_lwpid;
853 char* core_program;
854 char* core_command;
855
856 /* This is set to true if the object was created by the backend
857 linker. */
858 boolean linker;
859
860 /* A mapping from external symbols to entries in the linker hash
861 table, used when linking. This is indexed by the symbol index
862 minus the sh_info field of the symbol table header. */
863 struct elf_link_hash_entry **sym_hashes;
864
865 /* A mapping from local symbols to offsets into the global offset
866 table, used when linking. This is indexed by the symbol index.
867 Like for the globals, we use a union and two names primarily to
868 document the intent of any particular piece of code. The field
869 should be used as a count until size_dynamic_sections, at which
870 point the contents of the .got is fixed. Afterward, if an entry
3e932841 871 is -1, then the symbol does not require a global offset table entry. */
252b5132
RH
872 union
873 {
874 bfd_signed_vma *refcounts;
875 bfd_vma *offsets;
876 } local_got;
877
878 /* A mapping from local symbols to offsets into the various linker
879 sections added. This is index by the symbol index. */
880 elf_linker_section_pointers_t **linker_section_pointers;
881
882 /* The linker ELF emulation code needs to let the backend ELF linker
883 know what filename should be used for a dynamic object if the
884 dynamic object is found using a search. The emulation code then
885 sometimes needs to know what name was actually used. Until the
886 file has been added to the linker symbol table, this field holds
887 the name the linker wants. After it has been added, it holds the
888 name actually used, which will be the DT_SONAME entry if there is
889 one. */
890 const char *dt_name;
891
74816898
L
892 /* When a reference in a regular object is resolved by a shared
893 object is loaded into via the DT_NEEDED entries by the linker
894 ELF emulation code, we need to add the shared object to the
895 DT_NEEDED list of the resulting binary to indicate the dependency
896 as if the -l option is passed to the linker. This field holds the
3e932841 897 name of the loaded shared object. */
74816898
L
898 const char *dt_soname;
899
252b5132
RH
900 /* Irix 5 often screws up the symbol table, sorting local symbols
901 after global symbols. This flag is set if the symbol table in
902 this BFD appears to be screwed up. If it is, we ignore the
903 sh_info field in the symbol table header, and always read all the
904 symbols. */
905 boolean bad_symtab;
906
907 /* Records the result of `get_program_header_size'. */
908 bfd_size_type program_header_size;
909
910 /* Used by find_nearest_line entry point. */
911 PTR line_info;
912
913 /* Used by MIPS ELF find_nearest_line entry point. The structure
914 could be included directly in this one, but there's no point to
915 wasting the memory just for the infrequently called
916 find_nearest_line. */
917 struct mips_elf_find_line *find_line_info;
918
3e932841 919 /* A place to stash dwarf1 info for this bfd. */
252b5132
RH
920 struct dwarf1_debug *dwarf1_find_line_info;
921
3e932841 922 /* A place to stash dwarf2 info for this bfd. */
51db3708 923 PTR dwarf2_find_line_info;
252b5132
RH
924
925 /* An array of stub sections indexed by symbol number, used by the
926 MIPS ELF linker. FIXME: We should figure out some way to only
927 include this field for a MIPS ELF target. */
928 asection **local_stubs;
929
930 /* Used to determine if the e_flags field has been initialized */
931 boolean flags_init;
932
933 /* Number of symbol version definitions we are about to emit. */
934 unsigned int cverdefs;
935
936 /* Number of symbol version references we are about to emit. */
937 unsigned int cverrefs;
938
939 /* Symbol version definitions in external objects. */
940 Elf_Internal_Verdef *verdef;
941
942 /* Symbol version references to external objects. */
943 Elf_Internal_Verneed *verref;
944
945 /* Linker sections that we are interested in. */
946 struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
b305ef96
UC
947
948 /* The Irix 5 support uses two virtual sections, which represent
949 text/data symbols defined in dynamic objects. */
950 asymbol *elf_data_symbol;
951 asymbol *elf_text_symbol;
952 asection *elf_data_section;
953 asection *elf_text_section;
252b5132
RH
954};
955
956#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
957#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
958#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
959#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
960#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
961#define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
962#define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section)
963#define elf_dynverdef(bfd) (elf_tdata(bfd) -> dynverdef_section)
964#define elf_dynverref(bfd) (elf_tdata(bfd) -> dynverref_section)
965#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
966#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
967#define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
4e89ac30 968#define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms)
252b5132
RH
969#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
970#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
971#define elf_gp(bfd) (elf_tdata(bfd) -> gp)
972#define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
973#define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
974#define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
975#define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
976#define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
977#define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)
74816898 978#define elf_dt_soname(bfd) (elf_tdata(bfd) -> dt_soname)
252b5132
RH
979#define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
980#define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)
981#define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
982\f
983extern void _bfd_elf_swap_verdef_in
984 PARAMS ((bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *));
985extern void _bfd_elf_swap_verdef_out
986 PARAMS ((bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *));
987extern void _bfd_elf_swap_verdaux_in
988 PARAMS ((bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *));
989extern void _bfd_elf_swap_verdaux_out
990 PARAMS ((bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *));
991extern void _bfd_elf_swap_verneed_in
992 PARAMS ((bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *));
993extern void _bfd_elf_swap_verneed_out
994 PARAMS ((bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *));
995extern void _bfd_elf_swap_vernaux_in
996 PARAMS ((bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *));
997extern void _bfd_elf_swap_vernaux_out
998 PARAMS ((bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *));
999extern void _bfd_elf_swap_versym_in
1000 PARAMS ((bfd *, const Elf_External_Versym *, Elf_Internal_Versym *));
1001extern void _bfd_elf_swap_versym_out
1002 PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *));
1003
1004extern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *));
1005extern char *bfd_elf_string_from_elf_section
1006 PARAMS ((bfd *, unsigned, unsigned));
1007extern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned));
1008
1009extern boolean _bfd_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
1010extern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *,
1011 bfd_print_symbol_type));
1012#define elf_string_from_elf_strtab(abfd,strindex) \
1013 bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)
1014
1015#define bfd_elf32_print_symbol bfd_elf_print_symbol
1016#define bfd_elf64_print_symbol bfd_elf_print_symbol
1017
4e771d61
NC
1018extern void _bfd_elf_sprintf_vma PARAMS ((bfd *, char *, bfd_vma));
1019extern void _bfd_elf_fprintf_vma PARAMS ((bfd *, PTR, bfd_vma));
d69bb69b 1020
db6751f2
JJ
1021extern enum elf_reloc_type_class _bfd_elf_reloc_type_class PARAMS ((int));
1022
3a99b017 1023extern unsigned long bfd_elf_hash PARAMS ((const char *));
252b5132
RH
1024
1025extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
1026 arelent *,
1027 asymbol *,
1028 PTR,
1029 asection *,
1030 bfd *,
1031 char **));
1032extern boolean bfd_elf_mkobject PARAMS ((bfd *));
1033extern boolean bfd_elf_mkcorefile PARAMS ((bfd *));
1034extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
1035extern boolean _bfd_elf_make_section_from_shdr
1036 PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));
20cfcaae
NC
1037extern boolean _bfd_elf_make_section_from_phdr
1038 PARAMS ((bfd *abfd, Elf_Internal_Phdr *hdr, int index, const char *typename));
252b5132
RH
1039extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
1040 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
1041extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
1042 PARAMS ((bfd *));
c61b8717
RH
1043extern void _bfd_elf_link_hash_copy_indirect
1044 PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
1045extern void _bfd_elf_link_hash_hide_symbol
f41cbf03 1046 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
252b5132
RH
1047extern boolean _bfd_elf_link_hash_table_init
1048 PARAMS ((struct elf_link_hash_table *, bfd *,
1049 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
1050 struct bfd_hash_table *,
1051 const char *)));
1052extern boolean _bfd_elf_slurp_version_tables PARAMS ((bfd *));
1053
8550eb6e
JJ
1054extern boolean _bfd_elf_merge_sections
1055 PARAMS ((bfd *, struct bfd_link_info *));
1056
252b5132
RH
1057extern boolean _bfd_elf_copy_private_symbol_data
1058 PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
1059extern boolean _bfd_elf_copy_private_section_data
1060 PARAMS ((bfd *, asection *, bfd *, asection *));
1061extern boolean _bfd_elf_write_object_contents PARAMS ((bfd *));
1062extern boolean _bfd_elf_write_corefile_contents PARAMS ((bfd *));
1063extern boolean _bfd_elf_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
1064 file_ptr,
1065 bfd_size_type));
1066extern long _bfd_elf_get_symtab_upper_bound PARAMS ((bfd *));
1067extern long _bfd_elf_get_symtab PARAMS ((bfd *, asymbol **));
1068extern long _bfd_elf_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
1069extern long _bfd_elf_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
1070extern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
1071extern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
1072 arelent **, asymbol **));
1073extern long _bfd_elf_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
1074extern long _bfd_elf_canonicalize_dynamic_reloc PARAMS ((bfd *, arelent **,
1075 asymbol **));
1076extern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *));
1077extern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *,
1078 symbol_info *));
1079extern boolean _bfd_elf_is_local_label_name PARAMS ((bfd *, const char *));
1080extern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *));
1081extern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
1082 unsigned long));
1083extern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
1084 asymbol **,
52b219b5
AM
1085 bfd_vma, const char **,
1086 const char **,
252b5132
RH
1087 unsigned int *));
1088#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
1089#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
1090extern int _bfd_elf_sizeof_headers PARAMS ((bfd *, boolean));
1091extern boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *));
60bcf0fa 1092extern boolean _bfd_elf_init_reloc_shdr
23bc299b 1093 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, boolean));
252b5132
RH
1094
1095/* If the target doesn't have reloc handling written yet: */
1096extern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *,
1097 Elf_Internal_Rela *));
1098
1099extern boolean bfd_section_from_shdr PARAMS ((bfd *, unsigned int shindex));
1100extern boolean bfd_section_from_phdr PARAMS ((bfd *, Elf_Internal_Phdr *, int));
1101
1102extern int _bfd_elf_symbol_from_bfd_symbol PARAMS ((bfd *, asymbol **));
1103
1104asection *bfd_section_from_elf_index PARAMS ((bfd *, unsigned int));
1105boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
1106 struct bfd_link_info *));
1107struct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
1108boolean
1109_bfd_elf_link_record_dynamic_symbol PARAMS ((struct bfd_link_info *,
1110 struct elf_link_hash_entry *));
30b30c21
RH
1111long
1112_bfd_elf_link_lookup_local_dynindx PARAMS ((struct bfd_link_info *,
1113 bfd *, long));
252b5132
RH
1114boolean
1115_bfd_elf_compute_section_file_positions PARAMS ((bfd *,
1116 struct bfd_link_info *));
1117void _bfd_elf_assign_file_positions_for_relocs PARAMS ((bfd *));
1118file_ptr _bfd_elf_assign_file_position_for_section PARAMS ((Elf_Internal_Shdr *,
1119 file_ptr,
1120 boolean));
1121
1122extern boolean _bfd_elf_validate_reloc PARAMS ((bfd *, arelent *));
1123
1124boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
1125 struct bfd_link_info *));
1126boolean _bfd_elf_create_got_section PARAMS ((bfd *,
1127 struct bfd_link_info *));
30b30c21
RH
1128unsigned long _bfd_elf_link_renumber_dynsyms PARAMS ((bfd *,
1129 struct bfd_link_info *));
252b5132 1130
bb0082d6
AM
1131boolean _bfd_elfcore_make_pseudosection PARAMS ((bfd *, char *, int, int));
1132char *_bfd_elfcore_strndup PARAMS ((bfd *, char *, int));
1133
252b5132
RH
1134elf_linker_section_t *_bfd_elf_create_linker_section
1135 PARAMS ((bfd *abfd,
1136 struct bfd_link_info *info,
1137 enum elf_linker_section_enum,
1138 elf_linker_section_t *defaults));
1139
1140elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
1141 PARAMS ((elf_linker_section_pointers_t *linker_pointers,
1142 bfd_signed_vma addend,
1143 elf_linker_section_enum_t which));
1144
1145boolean bfd_elf32_create_pointer_linker_section
1146 PARAMS ((bfd *abfd,
1147 struct bfd_link_info *info,
1148 elf_linker_section_t *lsect,
1149 struct elf_link_hash_entry *h,
1150 const Elf32_Internal_Rela *rel));
1151
1152bfd_vma bfd_elf32_finish_pointer_linker_section
1153 PARAMS ((bfd *output_abfd,
1154 bfd *input_bfd,
1155 struct bfd_link_info *info,
1156 elf_linker_section_t *lsect,
1157 struct elf_link_hash_entry *h,
1158 bfd_vma relocation,
1159 const Elf32_Internal_Rela *rel,
1160 int relative_reloc));
1161
1162boolean bfd_elf64_create_pointer_linker_section
1163 PARAMS ((bfd *abfd,
1164 struct bfd_link_info *info,
1165 elf_linker_section_t *lsect,
1166 struct elf_link_hash_entry *h,
1167 const Elf64_Internal_Rela *rel));
1168
1169bfd_vma bfd_elf64_finish_pointer_linker_section
1170 PARAMS ((bfd *output_abfd,
1171 bfd *input_bfd,
1172 struct bfd_link_info *info,
1173 elf_linker_section_t *lsect,
1174 struct elf_link_hash_entry *h,
1175 bfd_vma relocation,
1176 const Elf64_Internal_Rela *rel,
1177 int relative_reloc));
1178
1179boolean _bfd_elf_make_linker_section_rela
1180 PARAMS ((bfd *dynobj,
1181 elf_linker_section_t *lsect,
1182 int alignment));
1183
252b5132
RH
1184extern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
1185extern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
1186extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
1187extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
1188extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
1189 bfd *));
1190
1191extern boolean bfd_elf32_bfd_link_add_symbols
1192 PARAMS ((bfd *, struct bfd_link_info *));
1193extern boolean bfd_elf32_bfd_final_link
1194 PARAMS ((bfd *, struct bfd_link_info *));
1195
1196extern void bfd_elf32_swap_symbol_in
1197 PARAMS ((bfd *, const Elf32_External_Sym *, Elf_Internal_Sym *));
1198extern void bfd_elf32_swap_symbol_out
1199 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
1200extern void bfd_elf32_swap_reloc_in
1201 PARAMS ((bfd *, const Elf32_External_Rel *, Elf_Internal_Rel *));
1202extern void bfd_elf32_swap_reloc_out
1203 PARAMS ((bfd *, const Elf_Internal_Rel *, Elf32_External_Rel *));
1204extern void bfd_elf32_swap_reloca_in
1205 PARAMS ((bfd *, const Elf32_External_Rela *, Elf_Internal_Rela *));
1206extern void bfd_elf32_swap_reloca_out
1207 PARAMS ((bfd *, const Elf_Internal_Rela *, Elf32_External_Rela *));
1208extern void bfd_elf32_swap_phdr_in
1209 PARAMS ((bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *));
1210extern void bfd_elf32_swap_phdr_out
1211 PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *));
1212extern void bfd_elf32_swap_dyn_in
1213 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
1214extern void bfd_elf32_swap_dyn_out
c7ac6ff8 1215 PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
252b5132
RH
1216extern long bfd_elf32_slurp_symbol_table
1217 PARAMS ((bfd *, asymbol **, boolean));
1218extern boolean bfd_elf32_write_shdrs_and_ehdr PARAMS ((bfd *));
1219extern int bfd_elf32_write_out_phdrs
1220 PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
b9f66672
JL
1221extern void bfd_elf32_write_relocs
1222 PARAMS ((bfd *, asection *, PTR));
1223extern boolean bfd_elf32_slurp_reloc_table
1224 PARAMS ((bfd *, asection *, asymbol **, boolean));
252b5132
RH
1225extern boolean bfd_elf32_add_dynamic_entry
1226 PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
1227extern boolean bfd_elf32_link_create_dynamic_sections
1228 PARAMS ((bfd *, struct bfd_link_info *));
1229extern Elf_Internal_Rela *_bfd_elf32_link_read_relocs
1230 PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
1231
1232extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
1233extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
1234extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
1235extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
1236extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
1237 bfd *));
1238extern boolean bfd_elf64_bfd_link_add_symbols
1239 PARAMS ((bfd *, struct bfd_link_info *));
1240extern boolean bfd_elf64_bfd_final_link
1241 PARAMS ((bfd *, struct bfd_link_info *));
1242
1243extern void bfd_elf64_swap_symbol_in
1244 PARAMS ((bfd *, const Elf64_External_Sym *, Elf_Internal_Sym *));
1245extern void bfd_elf64_swap_symbol_out
1246 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
1247extern void bfd_elf64_swap_reloc_in
1248 PARAMS ((bfd *, const Elf64_External_Rel *, Elf_Internal_Rel *));
1249extern void bfd_elf64_swap_reloc_out
1250 PARAMS ((bfd *, const Elf_Internal_Rel *, Elf64_External_Rel *));
1251extern void bfd_elf64_swap_reloca_in
1252 PARAMS ((bfd *, const Elf64_External_Rela *, Elf_Internal_Rela *));
1253extern void bfd_elf64_swap_reloca_out
1254 PARAMS ((bfd *, const Elf_Internal_Rela *, Elf64_External_Rela *));
1255extern void bfd_elf64_swap_phdr_in
1256 PARAMS ((bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *));
1257extern void bfd_elf64_swap_phdr_out
1258 PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *));
1259extern void bfd_elf64_swap_dyn_in
1260 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
1261extern void bfd_elf64_swap_dyn_out
c7ac6ff8 1262 PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
252b5132
RH
1263extern long bfd_elf64_slurp_symbol_table
1264 PARAMS ((bfd *, asymbol **, boolean));
1265extern boolean bfd_elf64_write_shdrs_and_ehdr PARAMS ((bfd *));
1266extern int bfd_elf64_write_out_phdrs
1267 PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
b9f66672
JL
1268extern void bfd_elf64_write_relocs
1269 PARAMS ((bfd *, asection *, PTR));
1270extern boolean bfd_elf64_slurp_reloc_table
1271 PARAMS ((bfd *, asection *, asymbol **, boolean));
252b5132
RH
1272extern boolean bfd_elf64_add_dynamic_entry
1273 PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
1274extern boolean bfd_elf64_link_create_dynamic_sections
1275 PARAMS ((bfd *, struct bfd_link_info *));
1276extern Elf_Internal_Rela *_bfd_elf64_link_read_relocs
1277 PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
1278
30b30c21
RH
1279#define bfd_elf32_link_record_dynamic_symbol \
1280 _bfd_elf_link_record_dynamic_symbol
1281#define bfd_elf64_link_record_dynamic_symbol \
1282 _bfd_elf_link_record_dynamic_symbol
1283
1284boolean _bfd_elf32_link_record_local_dynamic_symbol
1285 PARAMS ((struct bfd_link_info *, bfd *, long));
1286boolean _bfd_elf64_link_record_local_dynamic_symbol
1287 PARAMS ((struct bfd_link_info *, bfd *, long));
252b5132
RH
1288
1289extern boolean _bfd_elf_close_and_cleanup PARAMS ((bfd *));
1290extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
1291 PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR,
1292 asection *, bfd *, char **));
1293
1294boolean _bfd_elf32_gc_sections
1295 PARAMS ((bfd *abfd, struct bfd_link_info *info));
1296boolean _bfd_elf32_gc_common_finalize_got_offsets
1297 PARAMS ((bfd *abfd, struct bfd_link_info *info));
1298boolean _bfd_elf32_gc_common_final_link
1299 PARAMS ((bfd *, struct bfd_link_info *));
1300boolean _bfd_elf32_gc_record_vtinherit
1301 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1302boolean _bfd_elf32_gc_record_vtentry
1303 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1304
1305boolean _bfd_elf64_gc_sections
1306 PARAMS ((bfd *abfd, struct bfd_link_info *info));
1307boolean _bfd_elf64_gc_common_finalize_got_offsets
1308 PARAMS ((bfd *abfd, struct bfd_link_info *info));
1309boolean _bfd_elf64_gc_common_final_link
1310 PARAMS ((bfd *, struct bfd_link_info *));
1311boolean _bfd_elf64_gc_record_vtinherit
1312 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1313boolean _bfd_elf64_gc_record_vtentry
1314 PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
1315
1316/* MIPS ELF specific routines. */
1317
1318extern boolean _bfd_mips_elf_object_p PARAMS ((bfd *));
1319extern boolean _bfd_mips_elf_section_from_shdr
103186c6 1320 PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
252b5132
RH
1321extern boolean _bfd_mips_elf_fake_sections
1322 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
1323extern boolean _bfd_mips_elf_section_from_bfd_section
1324 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, int *));
1325extern boolean _bfd_mips_elf_section_processing
1326 PARAMS ((bfd *, Elf_Internal_Shdr *));
1327extern void _bfd_mips_elf_symbol_processing PARAMS ((bfd *, asymbol *));
1328extern boolean _bfd_mips_elf_read_ecoff_info
1329 PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
1330extern void _bfd_mips_elf_final_write_processing PARAMS ((bfd *, boolean));
1331extern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc
1332 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1333extern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc
1334 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1335extern bfd_reloc_status_type _bfd_mips_elf_gprel16_reloc
1336 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1337extern bfd_reloc_status_type _bfd_mips_elf_got16_reloc
1338 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1339extern bfd_reloc_status_type _bfd_mips_elf_gprel32_reloc
1340 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
1341extern boolean _bfd_mips_elf_set_private_flags PARAMS ((bfd *, flagword));
1342extern boolean _bfd_mips_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
1343extern boolean _bfd_mips_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
1344extern boolean _bfd_mips_elf_find_nearest_line
1345 PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
1346 const char **, unsigned int *));
1347extern boolean _bfd_mips_elf_set_section_contents
1348 PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
103186c6
MM
1349extern boolean _bfd_mips_elf_create_dynamic_sections
1350 PARAMS ((bfd *, struct bfd_link_info *));
1351extern boolean _bfd_mips_elf_add_symbol_hook
1352 PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
1353 const char **, flagword *, asection **, bfd_vma *));
1354extern boolean _bfd_mips_elf_adjust_dynamic_symbol
1355 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
1356extern boolean _bfd_mips_elf_finish_dynamic_symbol
1357 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
1358 Elf_Internal_Sym *));
1359extern boolean _bfd_mips_elf_finish_dynamic_sections
1360 PARAMS ((bfd *, struct bfd_link_info *));
60bcf0fa 1361extern asection * _bfd_mips_elf_gc_mark_hook
103186c6
MM
1362 PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
1363 struct elf_link_hash_entry *, Elf_Internal_Sym *));
60bcf0fa
NC
1364extern boolean _bfd_mips_elf_gc_sweep_hook
1365 PARAMS ((bfd *, struct bfd_link_info *, asection *,
103186c6
MM
1366 const Elf_Internal_Rela *));
1367extern boolean _bfd_mips_elf_always_size_sections
1368 PARAMS ((bfd *, struct bfd_link_info *));
1369extern boolean _bfd_mips_elf_size_dynamic_sections
1370 PARAMS ((bfd *, struct bfd_link_info *));
1371extern boolean _bfd_mips_elf_check_relocs
1372 PARAMS ((bfd *, struct bfd_link_info *, asection *,
1373 const Elf_Internal_Rela *));
1374extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
1375 PARAMS ((bfd *));
60bcf0fa 1376extern boolean _bfd_mips_elf_print_private_bfd_data
103186c6
MM
1377 PARAMS ((bfd *, PTR));
1378extern boolean _bfd_mips_elf_link_output_symbol_hook
1379 PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
1380 asection *));
1381extern boolean _bfd_mips_elf_final_link
1382 PARAMS ((bfd *, struct bfd_link_info *));
1383extern int _bfd_mips_elf_additional_program_headers PARAMS ((bfd *));
1384extern boolean _bfd_mips_elf_modify_segment_map PARAMS ((bfd *));
1385extern boolean _bfd_mips_elf_relocate_section
1386 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
1387 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
252b5132 1388
d4845d57
JR
1389/* SH ELF specific routine. */
1390
1391extern boolean _sh_elf_set_mach_from_flags PARAMS ((bfd *));
1392
252b5132 1393#endif /* _LIBELF_H_ */
This page took 0.145614 seconds and 4 git commands to generate.