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