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