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