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