* elf64-mips.c: Extensive additions to provide better support for
[deliverable/binutils-gdb.git] / bfd / elf-bfd.h
1 /* BFD back-end data structures for ELF files.
2 Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
3 Written by Cygnus Support.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21 #ifndef _LIBELF_H_
22 #define _LIBELF_H_ 1
23
24 #include "elf/common.h"
25 #include "elf/internal.h"
26 #include "elf/external.h"
27 #include "bfdlink.h"
28
29 /* If size isn't specified as 64 or 32, NAME macro should fail. */
30 #ifndef NAME
31 #if ARCH_SIZE==64
32 #define NAME(x,y) CAT4(x,64,_,y)
33 #endif
34 #if ARCH_SIZE==32
35 #define NAME(x,y) CAT4(x,32,_,y)
36 #endif
37 #endif
38
39 #ifndef NAME
40 #define NAME(x,y) CAT4(x,NOSIZE,_,y)
41 #endif
42
43 #define ElfNAME(X) NAME(Elf,X)
44 #define elfNAME(X) NAME(elf,X)
45
46 /* Information held for an ELF symbol. The first field is the
47 corresponding asymbol. Every symbol is an ELF file is actually a
48 pointer to this structure, although it is often handled as a
49 pointer to an asymbol. */
50
51 typedef struct
52 {
53 /* The BFD symbol. */
54 asymbol symbol;
55 /* ELF symbol information. */
56 Elf_Internal_Sym internal_elf_sym;
57 /* Backend specific information. */
58 union
59 {
60 unsigned int hppa_arg_reloc;
61 PTR mips_extr;
62 PTR any;
63 }
64 tc_data;
65 } elf_symbol_type;
66 \f
67 /* ELF linker hash table entries. */
68
69 struct elf_link_hash_entry
70 {
71 struct bfd_link_hash_entry root;
72
73 /* Symbol index in output file. This is initialized to -1. It is
74 set to -2 if the symbol is used by a reloc. */
75 long indx;
76
77 /* Symbol size. */
78 bfd_size_type size;
79
80 /* Symbol index as a dynamic symbol. Initialized to -1, and remains
81 -1 if this is not a dynamic symbol. */
82 long dynindx;
83
84 /* String table index in .dynstr if this is a dynamic symbol. */
85 unsigned long dynstr_index;
86
87 /* If this is a weak defined symbol from a dynamic object, this
88 field points to a defined symbol with the same value, if there is
89 one. Otherwise it is NULL. */
90 struct elf_link_hash_entry *weakdef;
91
92 /* If this symbol requires an entry in the global offset table, the
93 processor specific backend uses this field to hold the offset
94 into the .got section. If this field is -1, then the symbol does
95 not require a global offset table entry. */
96 bfd_vma got_offset;
97
98 /* If this symbol requires an entry in the procedure linkage table,
99 the processor specific backend uses these two fields to hold the
100 offset into the procedure linkage section and the offset into the
101 .got section. If plt_offset is -1, then the symbol does not
102 require an entry in the procedure linkage table. */
103 bfd_vma plt_offset;
104
105 /* If this symbol is used in the linker created sections, the processor
106 specific backend uses this field to map the field into the offset
107 from the beginning of the section. */
108 struct elf_linker_section_pointers *linker_section_pointer;
109
110 /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */
111 char type;
112
113 /* Some flags; legal values follow. */
114 unsigned char elf_link_hash_flags;
115 /* Symbol is referenced by a non-shared object. */
116 #define ELF_LINK_HASH_REF_REGULAR 01
117 /* Symbol is defined by a non-shared object. */
118 #define ELF_LINK_HASH_DEF_REGULAR 02
119 /* Symbol is referenced by a shared object. */
120 #define ELF_LINK_HASH_REF_DYNAMIC 04
121 /* Symbol is defined by a shared object. */
122 #define ELF_LINK_HASH_DEF_DYNAMIC 010
123 /* Dynamic symbol has been adjustd. */
124 #define ELF_LINK_HASH_DYNAMIC_ADJUSTED 020
125 /* Symbol needs a copy reloc. */
126 #define ELF_LINK_HASH_NEEDS_COPY 040
127 /* Symbol needs a procedure linkage table entry. */
128 #define ELF_LINK_HASH_NEEDS_PLT 0100
129 /* Symbol appears in a non-ELF input file. */
130 #define ELF_LINK_NON_ELF 0200
131 /* Note: If you add more flags, you must change the type of
132 elf_link_hash_flags. */
133 };
134
135 /* ELF linker hash table. */
136
137 struct elf_link_hash_table
138 {
139 struct bfd_link_hash_table root;
140 /* Whether we have created the special dynamic sections required
141 when linking against or generating a shared object. */
142 boolean dynamic_sections_created;
143 /* The BFD used to hold special sections created by the linker.
144 This will be the first BFD found which requires these sections to
145 be created. */
146 bfd *dynobj;
147 /* The number of symbols found in the link which must be put into
148 the .dynsym section. */
149 bfd_size_type dynsymcount;
150 /* The string table of dynamic symbols, which becomes the .dynstr
151 section. */
152 struct bfd_strtab_hash *dynstr;
153 /* The number of buckets in the hash table in the .hash section.
154 This is based on the number of dynamic symbols. */
155 bfd_size_type bucketcount;
156 /* A linked list of DT_NEEDED names found in dynamic objects
157 included in the link. */
158 struct bfd_link_needed_list *needed;
159 /* The _GLOBAL_OFFSET_TABLE_ symbol. */
160 struct elf_link_hash_entry *hgot;
161 /* A pointer to information used to link stabs in sections. */
162 PTR stab_info;
163 };
164
165 /* Look up an entry in an ELF linker hash table. */
166
167 #define elf_link_hash_lookup(table, string, create, copy, follow) \
168 ((struct elf_link_hash_entry *) \
169 bfd_link_hash_lookup (&(table)->root, (string), (create), \
170 (copy), (follow)))
171
172 /* Traverse an ELF linker hash table. */
173
174 #define elf_link_hash_traverse(table, func, info) \
175 (bfd_link_hash_traverse \
176 (&(table)->root, \
177 (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
178 (info)))
179
180 /* Get the ELF linker hash table from a link_info structure. */
181
182 #define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
183 \f
184 /* Constant information held for an ELF backend. */
185
186 struct elf_size_info {
187 unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
188 unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
189
190 unsigned char arch_size, file_align;
191 unsigned char elfclass, ev_current;
192 int (*write_out_phdrs) PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
193 boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *));
194 void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
195 void (*swap_symbol_out) PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
196 boolean (*slurp_reloc_table) PARAMS ((bfd *, asection *, asymbol **));
197 long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean));
198 void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
199 };
200
201 #define elf_symbol_from(ABFD,S) \
202 (((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
203 && (S)->the_bfd->tdata.elf_obj_data != 0) \
204 ? (elf_symbol_type *) (S) \
205 : 0)
206
207 struct elf_backend_data
208 {
209 /* Whether the backend uses REL or RELA relocations. FIXME: some
210 ELF backends use both. When we need to support one, this whole
211 approach will need to be changed. */
212 int use_rela_p;
213
214 /* The architecture for this backend. */
215 enum bfd_architecture arch;
216
217 /* The ELF machine code (EM_xxxx) for this backend. */
218 int elf_machine_code;
219
220 /* The maximum page size for this backend. */
221 bfd_vma maxpagesize;
222
223 /* This is true if the linker should act like collect and gather
224 global constructors and destructors by name. This is true for
225 MIPS ELF because the Irix 5 tools can not handle the .init
226 section. */
227 boolean collect;
228
229 /* This is true if the linker should ignore changes to the type of a
230 symbol. This is true for MIPS ELF because some Irix 5 objects
231 record undefined functions as STT_OBJECT although the definitions
232 are STT_FUNC. */
233 boolean type_change_ok;
234
235 /* A function to translate an ELF RELA relocation to a BFD arelent
236 structure. */
237 void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
238 Elf_Internal_Rela *));
239
240 /* A function to translate an ELF REL relocation to a BFD arelent
241 structure. */
242 void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
243 Elf_Internal_Rel *));
244
245 /* A function to determine whether a symbol is global when
246 partitioning the symbol table into local and global symbols.
247 This should be NULL for most targets, in which case the correct
248 thing will be done. MIPS ELF, at least on the Irix 5, has
249 special requirements. */
250 boolean (*elf_backend_sym_is_global) PARAMS ((bfd *, asymbol *));
251
252 /* The remaining functions are hooks which are called only if they
253 are not NULL. */
254
255 /* A function to permit a backend specific check on whether a
256 particular BFD format is relevant for an object file, and to
257 permit the backend to set any global information it wishes. When
258 this is called elf_elfheader is set, but anything else should be
259 used with caution. If this returns false, the check_format
260 routine will return a bfd_error_wrong_format error. */
261 boolean (*elf_backend_object_p) PARAMS ((bfd *));
262
263 /* A function to do additional symbol processing when reading the
264 ELF symbol table. This is where any processor-specific special
265 section indices are handled. */
266 void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *));
267
268 /* A function to do additional symbol processing after reading the
269 entire ELF symbol table. */
270 boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *,
271 elf_symbol_type *,
272 unsigned int));
273
274 /* A function to do additional processing on the ELF section header
275 just before writing it out. This is used to set the flags and
276 type fields for some sections, or to actually write out data for
277 unusual sections. */
278 boolean (*elf_backend_section_processing) PARAMS ((bfd *,
279 Elf32_Internal_Shdr *));
280
281 /* A function to handle unusual section types when creating BFD
282 sections from ELF sections. */
283 boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *,
284 Elf32_Internal_Shdr *,
285 char *));
286
287 /* A function to set up the ELF section header for a BFD section in
288 preparation for writing it out. This is where the flags and type
289 fields are set for unusual sections. */
290 boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *,
291 asection *));
292
293 /* A function to get the ELF section index for a BFD section. If
294 this returns true, the section was found. If it is a normal ELF
295 section, *RETVAL should be left unchanged. If it is not a normal
296 ELF section *RETVAL should be set to the SHN_xxxx index. */
297 boolean (*elf_backend_section_from_bfd_section)
298 PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval));
299
300 /* If this field is not NULL, it is called by the add_symbols phase
301 of a link just before adding a symbol to the global linker hash
302 table. It may modify any of the fields as it wishes. If *NAME
303 is set to NULL, the symbol will be skipped rather than being
304 added to the hash table. This function is responsible for
305 handling all processor dependent symbol bindings and section
306 indices, and must set at least *FLAGS and *SEC for each processor
307 dependent case; failure to do so will cause a link error. */
308 boolean (*elf_add_symbol_hook)
309 PARAMS ((bfd *abfd, struct bfd_link_info *info,
310 const Elf_Internal_Sym *, const char **name,
311 flagword *flags, asection **sec, bfd_vma *value));
312
313 /* If this field is not NULL, it is called by the elf_link_output_sym
314 phase of a link for each symbol which will appear in the object file. */
315 boolean (*elf_backend_link_output_symbol_hook)
316 PARAMS ((bfd *, struct bfd_link_info *info, const char *,
317 Elf_Internal_Sym *, asection *));
318
319 /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
320 linker the first time it encounters a dynamic object in the link.
321 This function must create any sections required for dynamic
322 linking. The ABFD argument is a dynamic object. The .interp,
323 .dynamic, .dynsym, .dynstr, and .hash functions have already been
324 created, and this function may modify the section flags if
325 desired. This function will normally create the .got and .plt
326 sections, but different backends have different requirements. */
327 boolean (*elf_backend_create_dynamic_sections)
328 PARAMS ((bfd *abfd, struct bfd_link_info *info));
329
330 /* The CHECK_RELOCS function is called by the add_symbols phase of
331 the ELF backend linker. It is called once for each section with
332 relocs of an object file, just after the symbols for the object
333 file have been added to the global linker hash table. The
334 function must look through the relocs and do any special handling
335 required. This generally means allocating space in the global
336 offset table, and perhaps allocating space for a reloc. The
337 relocs are always passed as Rela structures; if the section
338 actually uses Rel structures, the r_addend field will always be
339 zero. */
340 boolean (*check_relocs)
341 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
342 const Elf_Internal_Rela *relocs));
343
344 /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
345 linker for every symbol which is defined by a dynamic object and
346 referenced by a regular object. This is called after all the
347 input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
348 function has been called. The hash table entry should be
349 bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
350 defined in a section from a dynamic object. Dynamic object
351 sections are not included in the final link, and this function is
352 responsible for changing the value to something which the rest of
353 the link can deal with. This will normally involve adding an
354 entry to the .plt or .got or some such section, and setting the
355 symbol to point to that. */
356 boolean (*elf_backend_adjust_dynamic_symbol)
357 PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
358
359 /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
360 linker after all the linker input files have been seen but before
361 the sections sizes have been set. This is called after
362 ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
363 It is only called when linking against a dynamic object. It must
364 set the sizes of the dynamic sections, and may fill in their
365 contents as well. The generic ELF linker can handle the .dynsym,
366 .dynstr and .hash sections. This function must handle the
367 .interp section and any sections created by the
368 CREATE_DYNAMIC_SECTIONS entry point. */
369 boolean (*elf_backend_size_dynamic_sections)
370 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
371
372 /* The RELOCATE_SECTION function is called by the ELF backend linker
373 to handle the relocations for a section.
374
375 The relocs are always passed as Rela structures; if the section
376 actually uses Rel structures, the r_addend field will always be
377 zero.
378
379 This function is responsible for adjust the section contents as
380 necessary, and (if using Rela relocs and generating a
381 relocateable output file) adjusting the reloc addend as
382 necessary.
383
384 This function does not have to worry about setting the reloc
385 address or the reloc symbol index.
386
387 LOCAL_SYMS is a pointer to the swapped in local symbols.
388
389 LOCAL_SECTIONS is an array giving the section in the input file
390 corresponding to the st_shndx field of each local symbol.
391
392 The global hash table entry for the global symbols can be found
393 via elf_sym_hashes (input_bfd).
394
395 When generating relocateable output, this function must handle
396 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
397 going to be the section symbol corresponding to the output
398 section, which means that the addend must be adjusted
399 accordingly. */
400 boolean (*elf_backend_relocate_section)
401 PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
402 bfd *input_bfd, asection *input_section, bfd_byte *contents,
403 Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
404 asection **local_sections));
405
406 /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
407 linker just before it writes a symbol out to the .dynsym section.
408 The processor backend may make any required adjustment to the
409 symbol. It may also take the opportunity to set contents of the
410 dynamic sections. Note that FINISH_DYNAMIC_SYMBOL is called on
411 all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
412 on those symbols which are defined by a dynamic object. */
413 boolean (*elf_backend_finish_dynamic_symbol)
414 PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
415 struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
416
417 /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
418 linker just before it writes all the dynamic sections out to the
419 output file. The FINISH_DYNAMIC_SYMBOL will have been called on
420 all dynamic symbols. */
421 boolean (*elf_backend_finish_dynamic_sections)
422 PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
423
424 /* A function to do any beginning processing needed for the ELF file
425 before building the ELF headers and computing file positions. */
426 void (*elf_backend_begin_write_processing)
427 PARAMS ((bfd *, struct bfd_link_info *));
428
429 /* A function to do any final processing needed for the ELF file
430 before writing it out. The LINKER argument is true if this BFD
431 was created by the ELF backend linker. */
432 void (*elf_backend_final_write_processing)
433 PARAMS ((bfd *, boolean linker));
434
435 /* This function is called by get_program_header_size. It should
436 return the number of additional program segments which this BFD
437 will need. It should return -1 on error. */
438 int (*elf_backend_additional_program_headers) PARAMS ((bfd *));
439
440 /* This function is called to modify an existing segment map in a
441 backend specific fashion. */
442 boolean (*elf_backend_modify_segment_map) PARAMS ((bfd *));
443
444 /* The swapping table to use when dealing with ECOFF information.
445 Used for the MIPS ELF .mdebug section. */
446 const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
447
448 /* Alternate EM_xxxx machine codes for this backend. */
449 int elf_machine_alt1;
450 int elf_machine_alt2;
451
452 const struct elf_size_info *s;
453
454 unsigned want_got_plt : 1;
455 unsigned plt_readonly : 1;
456 unsigned want_plt_sym : 1;
457 };
458
459 /* Information stored for each BFD section in an ELF file. This
460 structure is allocated by elf_new_section_hook. */
461
462 struct bfd_elf_section_data
463 {
464 /* The ELF header for this section. */
465 Elf_Internal_Shdr this_hdr;
466 /* The ELF header for the reloc section associated with this
467 section, if any. */
468 Elf_Internal_Shdr rel_hdr;
469 /* If there is a second reloc section associated with this section,
470 as can happen on Irix 6, this field points to the header. */
471 Elf_Internal_Shdr *rel_hdr2;
472 /* The ELF section number of this section. Only used for an output
473 file. */
474 int this_idx;
475 /* The ELF section number of the reloc section associated with this
476 section, if any. Only used for an output file. */
477 int rel_idx;
478 /* Used by the backend linker to store the symbol hash table entries
479 associated with relocs against global symbols. */
480 struct elf_link_hash_entry **rel_hashes;
481 /* A pointer to the swapped relocs. If the section uses REL relocs,
482 rather than RELA, all the r_addend fields will be zero. This
483 pointer may be NULL. It is used by the backend linker. */
484 Elf_Internal_Rela *relocs;
485 /* Used by the backend linker when generating a shared library to
486 record the dynamic symbol index for a section symbol
487 corresponding to this section. */
488 long dynindx;
489 /* A pointer used for .stab linking optimizations. */
490 PTR stab_info;
491 /* A pointer available for the processor specific ELF backend. */
492 PTR tdata;
493 };
494
495 #define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
496
497 #define get_elf_backend_data(abfd) \
498 ((struct elf_backend_data *) (abfd)->xvec->backend_data)
499
500 /* Enumeration to specify the special section. */
501 typedef enum elf_linker_section_enum
502 {
503 LINKER_SECTION_UNKNOWN, /* not used */
504 LINKER_SECTION_GOT, /* .got section for global offset pointers */
505 LINKER_SECTION_PLT, /* .plt section for generated procedure stubs */
506 LINKER_SECTION_SDATA, /* .sdata/.sbss section for PowerPC */
507 LINKER_SECTION_SDATA2, /* .sdata2/.sbss2 section for PowerPC */
508 LINKER_SECTION_MAX /* # of linker sections */
509 } elf_linker_section_enum_t;
510
511 /* Sections created by the linker. */
512
513 typedef struct elf_linker_section
514 {
515 char *name; /* name of the section */
516 char *rel_name; /* name of the associated .rel{,a}. section */
517 char *bss_name; /* name of a related .bss section */
518 char *sym_name; /* name of symbol to reference this section */
519 asection *section; /* pointer to the section */
520 asection *bss_section; /* pointer to the bss section associated with this */
521 asection *rel_section; /* pointer to the relocations needed for this section */
522 struct elf_link_hash_entry *sym_hash; /* pointer to the created symbol hash value */
523 bfd_vma initial_size; /* initial size before any linker generated allocations */
524 bfd_vma sym_offset; /* offset of symbol from beginning of section */
525 bfd_vma hole_size; /* size of reserved address hole in allocation */
526 bfd_vma hole_offset; /* current offset for the hole */
527 bfd_vma max_hole_offset; /* maximum offset for the hole */
528 elf_linker_section_enum_t which; /* which section this is */
529 boolean hole_written_p; /* whether the hole has been initialized */
530 int alignment; /* alignment for the section */
531 flagword flags; /* flags to use to create the section */
532 } elf_linker_section_t;
533
534 /* Linked list of allocated pointer entries. This hangs off of the symbol lists, and
535 provides allows us to return different pointers, based on different addend's. */
536
537 typedef struct elf_linker_section_pointers
538 {
539 struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */
540 bfd_vma offset; /* offset of pointer from beginning of section */
541 bfd_signed_vma addend; /* addend used */
542 elf_linker_section_enum_t which; /* which linker section this is */
543 boolean written_address_p; /* whether address was written yet */
544 } elf_linker_section_pointers_t;
545
546 /* Some private data is stashed away for future use using the tdata pointer
547 in the bfd structure. */
548
549 struct elf_obj_tdata
550 {
551 Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
552 Elf_Internal_Shdr **elf_sect_ptr;
553 Elf_Internal_Phdr *phdr;
554 struct elf_segment_map *segment_map;
555 struct bfd_strtab_hash *strtab_ptr;
556 int num_locals;
557 int num_globals;
558 asymbol **section_syms; /* STT_SECTION symbols for each section */
559 Elf_Internal_Shdr symtab_hdr;
560 Elf_Internal_Shdr shstrtab_hdr;
561 Elf_Internal_Shdr strtab_hdr;
562 Elf_Internal_Shdr dynsymtab_hdr;
563 Elf_Internal_Shdr dynstrtab_hdr;
564 unsigned int symtab_section, shstrtab_section;
565 unsigned int strtab_section, dynsymtab_section;
566 file_ptr next_file_pos;
567 void *prstatus; /* The raw /proc prstatus structure */
568 void *prpsinfo; /* The raw /proc prpsinfo structure */
569 bfd_vma gp; /* The gp value (MIPS only, for now) */
570 unsigned int gp_size; /* The gp size (MIPS only, for now) */
571
572 /* This is set to true if the object was created by the backend
573 linker. */
574 boolean linker;
575
576 /* A mapping from external symbols to entries in the linker hash
577 table, used when linking. This is indexed by the symbol index
578 minus the sh_info field of the symbol table header. */
579 struct elf_link_hash_entry **sym_hashes;
580
581 /* A mapping from local symbols to offsets into the global offset
582 table, used when linking. This is indexed by the symbol index. */
583 bfd_vma *local_got_offsets;
584
585 /* A mapping from local symbols to offsets into the various linker
586 sections added. This is index by the symbol index. */
587 elf_linker_section_pointers_t **linker_section_pointers;
588
589 /* The linker ELF emulation code needs to let the backend ELF linker
590 know what filename should be used for a dynamic object if the
591 dynamic object is found using a search. The emulation code then
592 sometimes needs to know what name was actually used. Until the
593 file has been added to the linker symbol table, this field holds
594 the name the linker wants. After it has been added, it holds the
595 name actually used, which will be the DT_SONAME entry if there is
596 one. */
597 const char *dt_name;
598
599 /* Irix 5 often screws up the symbol table, sorting local symbols
600 after global symbols. This flag is set if the symbol table in
601 this BFD appears to be screwed up. If it is, we ignore the
602 sh_info field in the symbol table header, and always read all the
603 symbols. */
604 boolean bad_symtab;
605
606 /* Records the result of `get_program_header_size'. */
607 bfd_size_type program_header_size;
608
609 /* Used by find_nearest_line entry point. */
610 PTR line_info;
611
612 /* Used by MIPS ELF find_nearest_line entry point. The structure
613 could be included directly in this one, but there's no point to
614 wasting the memory just for the infrequently called
615 find_nearest_line. */
616 struct mips_elf_find_line *find_line_info;
617
618 /* Used to determine if the e_flags field has been initialized */
619 boolean flags_init;
620
621 /* Linker sections that we are interested in. */
622 struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
623 };
624
625 #define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
626 #define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
627 #define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
628 #define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
629 #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
630 #define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
631 #define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
632 #define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
633 #define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
634 #define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
635 #define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
636 #define elf_gp(bfd) (elf_tdata(bfd) -> gp)
637 #define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
638 #define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
639 #define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got_offsets)
640 #define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
641 #define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)
642 #define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
643 #define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)
644 #define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
645 \f
646 extern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *));
647 extern char *bfd_elf_string_from_elf_section
648 PARAMS ((bfd *, unsigned, unsigned));
649 extern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned));
650
651 extern boolean _bfd_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
652 extern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *,
653 bfd_print_symbol_type));
654 #define elf_string_from_elf_strtab(abfd,strindex) \
655 bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)
656
657 #define bfd_elf32_print_symbol bfd_elf_print_symbol
658 #define bfd_elf64_print_symbol bfd_elf_print_symbol
659 #define bfd_elf32_mkobject bfd_elf_mkobject
660 #define bfd_elf64_mkobject bfd_elf_mkobject
661 #define elf_mkobject bfd_elf_mkobject
662
663 extern unsigned long bfd_elf_hash PARAMS ((CONST unsigned char *));
664
665 extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
666 arelent *,
667 asymbol *,
668 PTR,
669 asection *,
670 bfd *,
671 char **));
672 extern boolean bfd_elf_mkobject PARAMS ((bfd *));
673 extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
674 extern boolean _bfd_elf_make_section_from_shdr
675 PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));
676 extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
677 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
678 extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
679 PARAMS ((bfd *));
680 extern boolean _bfd_elf_link_hash_table_init
681 PARAMS ((struct elf_link_hash_table *, bfd *,
682 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
683 struct bfd_hash_table *,
684 const char *)));
685
686 extern boolean _bfd_elf_copy_private_symbol_data
687 PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
688 extern boolean _bfd_elf_copy_private_section_data
689 PARAMS ((bfd *, asection *, bfd *, asection *));
690 extern boolean _bfd_elf_write_object_contents PARAMS ((bfd *));
691 extern boolean _bfd_elf_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
692 file_ptr,
693 bfd_size_type));
694 extern long _bfd_elf_get_symtab_upper_bound PARAMS ((bfd *));
695 extern long _bfd_elf_get_symtab PARAMS ((bfd *, asymbol **));
696 extern long _bfd_elf_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
697 extern long _bfd_elf_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
698 extern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
699 extern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
700 arelent **, asymbol **));
701 extern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *));
702 extern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *,
703 symbol_info *));
704 extern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *));
705 extern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
706 unsigned long));
707 extern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
708 asymbol **,
709 bfd_vma, CONST char **,
710 CONST char **,
711 unsigned int *));
712 #define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
713 #define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
714 extern int _bfd_elf_sizeof_headers PARAMS ((bfd *, boolean));
715 extern boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *));
716
717 /* If the target doesn't have reloc handling written yet: */
718 extern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *,
719 Elf_Internal_Rela *));
720
721 extern boolean bfd_section_from_shdr PARAMS ((bfd *, unsigned int shindex));
722
723 extern int _bfd_elf_symbol_from_bfd_symbol PARAMS ((bfd *, asymbol **));
724
725 asection *bfd_section_from_elf_index PARAMS ((bfd *, unsigned int));
726 boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
727 struct bfd_link_info *));
728 struct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
729 boolean
730 _bfd_elf_link_record_dynamic_symbol PARAMS ((struct bfd_link_info *,
731 struct elf_link_hash_entry *));
732 boolean
733 _bfd_elf_compute_section_file_positions PARAMS ((bfd *,
734 struct bfd_link_info *));
735 void _bfd_elf_assign_file_positions_for_relocs PARAMS ((bfd *));
736 file_ptr _bfd_elf_assign_file_position_for_section PARAMS ((Elf_Internal_Shdr *,
737 file_ptr,
738 boolean));
739
740 extern boolean _bfd_elf_validate_reloc PARAMS ((bfd *, arelent *));
741
742 boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
743 struct bfd_link_info *));
744 boolean _bfd_elf_create_got_section PARAMS ((bfd *,
745 struct bfd_link_info *));
746
747 elf_linker_section_t *_bfd_elf_create_linker_section
748 PARAMS ((bfd *abfd,
749 struct bfd_link_info *info,
750 enum elf_linker_section_enum,
751 elf_linker_section_t *defaults));
752
753 elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
754 PARAMS ((elf_linker_section_pointers_t *linker_pointers,
755 bfd_signed_vma addend,
756 elf_linker_section_enum_t which));
757
758 boolean bfd_elf32_create_pointer_linker_section
759 PARAMS ((bfd *abfd,
760 struct bfd_link_info *info,
761 elf_linker_section_t *lsect,
762 struct elf_link_hash_entry *h,
763 const Elf32_Internal_Rela *rel));
764
765 bfd_vma bfd_elf32_finish_pointer_linker_section
766 PARAMS ((bfd *output_abfd,
767 bfd *input_bfd,
768 struct bfd_link_info *info,
769 elf_linker_section_t *lsect,
770 struct elf_link_hash_entry *h,
771 bfd_vma relocation,
772 const Elf32_Internal_Rela *rel,
773 int relative_reloc));
774
775 boolean bfd_elf64_create_pointer_linker_section
776 PARAMS ((bfd *abfd,
777 struct bfd_link_info *info,
778 elf_linker_section_t *lsect,
779 struct elf_link_hash_entry *h,
780 const Elf64_Internal_Rela *rel));
781
782 bfd_vma bfd_elf64_finish_pointer_linker_section
783 PARAMS ((bfd *output_abfd,
784 bfd *input_bfd,
785 struct bfd_link_info *info,
786 elf_linker_section_t *lsect,
787 struct elf_link_hash_entry *h,
788 bfd_vma relocation,
789 const Elf64_Internal_Rela *rel,
790 int relative_reloc));
791
792 boolean _bfd_elf_make_linker_section_rela
793 PARAMS ((bfd *dynobj,
794 elf_linker_section_t *lsect,
795 int alignment));
796
797 extern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
798 extern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
799 extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
800 extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
801 extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
802 bfd *));
803
804 extern boolean bfd_elf32_bfd_link_add_symbols
805 PARAMS ((bfd *, struct bfd_link_info *));
806 extern boolean bfd_elf32_bfd_final_link
807 PARAMS ((bfd *, struct bfd_link_info *));
808
809 extern void bfd_elf32_swap_symbol_in
810 PARAMS ((bfd *, const Elf32_External_Sym *, Elf_Internal_Sym *));
811 extern void bfd_elf32_swap_symbol_out
812 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
813 extern void bfd_elf32_swap_reloc_in
814 PARAMS ((bfd *, const Elf32_External_Rel *, Elf_Internal_Rel *));
815 extern void bfd_elf32_swap_reloc_out
816 PARAMS ((bfd *, const Elf_Internal_Rel *, Elf32_External_Rel *));
817 extern void bfd_elf32_swap_reloca_in
818 PARAMS ((bfd *, const Elf32_External_Rela *, Elf_Internal_Rela *));
819 extern void bfd_elf32_swap_reloca_out
820 PARAMS ((bfd *, const Elf_Internal_Rela *, Elf32_External_Rela *));
821 extern void bfd_elf32_swap_phdr_in
822 PARAMS ((bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *));
823 extern void bfd_elf32_swap_phdr_out
824 PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *));
825 extern void bfd_elf32_swap_dyn_in
826 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
827 extern void bfd_elf32_swap_dyn_out
828 PARAMS ((bfd *, const Elf_Internal_Dyn *, Elf32_External_Dyn *));
829 extern long bfd_elf32_slurp_symbol_table
830 PARAMS ((bfd *, asymbol **, boolean));
831 extern boolean bfd_elf32_write_shdrs_and_ehdr PARAMS ((bfd *));
832 extern int bfd_elf32_write_out_phdrs
833 PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
834 extern boolean bfd_elf32_add_dynamic_entry
835 PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
836 extern boolean bfd_elf32_link_create_dynamic_sections
837 PARAMS ((bfd *, struct bfd_link_info *));
838
839 extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
840 extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
841 extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
842 extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
843 extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
844 bfd *));
845 extern boolean bfd_elf64_bfd_link_add_symbols
846 PARAMS ((bfd *, struct bfd_link_info *));
847 extern boolean bfd_elf64_bfd_final_link
848 PARAMS ((bfd *, struct bfd_link_info *));
849
850 extern void bfd_elf64_swap_symbol_in
851 PARAMS ((bfd *, const Elf64_External_Sym *, Elf_Internal_Sym *));
852 extern void bfd_elf64_swap_symbol_out
853 PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
854 extern void bfd_elf64_swap_reloc_in
855 PARAMS ((bfd *, const Elf64_External_Rel *, Elf_Internal_Rel *));
856 extern void bfd_elf64_swap_reloc_out
857 PARAMS ((bfd *, const Elf_Internal_Rel *, Elf64_External_Rel *));
858 extern void bfd_elf64_swap_reloca_in
859 PARAMS ((bfd *, const Elf64_External_Rela *, Elf_Internal_Rela *));
860 extern void bfd_elf64_swap_reloca_out
861 PARAMS ((bfd *, const Elf_Internal_Rela *, Elf64_External_Rela *));
862 extern void bfd_elf64_swap_phdr_in
863 PARAMS ((bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *));
864 extern void bfd_elf64_swap_phdr_out
865 PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *));
866 extern void bfd_elf64_swap_dyn_in
867 PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
868 extern void bfd_elf64_swap_dyn_out
869 PARAMS ((bfd *, const Elf_Internal_Dyn *, Elf64_External_Dyn *));
870 extern long bfd_elf64_slurp_symbol_table
871 PARAMS ((bfd *, asymbol **, boolean));
872 extern boolean bfd_elf64_write_shdrs_and_ehdr PARAMS ((bfd *));
873 extern int bfd_elf64_write_out_phdrs
874 PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
875 extern boolean bfd_elf64_add_dynamic_entry
876 PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
877 extern boolean bfd_elf64_link_create_dynamic_sections
878 PARAMS ((bfd *, struct bfd_link_info *));
879
880 #define bfd_elf32_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
881 #define bfd_elf64_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
882
883 /* MIPS ELF specific routines. */
884
885 extern boolean _bfd_mips_elf_object_p PARAMS ((bfd *));
886 extern boolean _bfd_mips_elf_section_from_shdr
887 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
888 extern boolean _bfd_mips_elf_fake_sections
889 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
890 extern boolean _bfd_mips_elf_section_from_bfd_section
891 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, int *));
892 extern boolean _bfd_mips_elf_section_processing
893 PARAMS ((bfd *, Elf_Internal_Shdr *));
894 extern void _bfd_mips_elf_symbol_processing PARAMS ((bfd *, asymbol *));
895 extern boolean _bfd_mips_elf_read_ecoff_info
896 PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
897 extern void _bfd_mips_elf_final_write_processing PARAMS ((bfd *, boolean));
898
899 #endif /* _LIBELF_H_ */
This page took 0.049503 seconds and 5 git commands to generate.