x86: move fetch error handling into a helper function
[binutils-gdb.git] / bfd / libcoff.h
blobb58ee8adedfa7a520ac15535fc55d2528554084c
1 /* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically
2 generated from "libcoff-in.h" and "coffcode.h".
3 Run "make headers" in your build bfd/ to regenerate. */
5 /* BFD COFF object file private structure.
6 Copyright (C) 1990-2023 Free Software Foundation, Inc.
7 Written by Cygnus Support.
9 This file is part of BFD, the Binary File Descriptor library.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
24 MA 02110-1301, USA. */
26 #ifndef _LIBCOFF_H
27 #define _LIBCOFF_H 1
29 #include "bfdlink.h"
30 #include "coff-bfd.h"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 /* Object file tdata; access macros. */
38 #define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
39 #define obj_pe(bfd) (coff_data (bfd)->pe)
40 #define obj_go32(bfd) (coff_data (bfd)->go32)
41 #define obj_symbols(bfd) (coff_data (bfd)->symbols)
42 #define obj_sym_filepos(bfd) (coff_data (bfd)->sym_filepos)
43 #define obj_relocbase(bfd) (coff_data (bfd)->relocbase)
44 #define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments)
45 #define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count)
46 #define obj_convert(bfd) (coff_data (bfd)->conversion_table)
47 #define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size)
48 #define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
49 #define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms)
50 #define obj_coff_strings(bfd) (coff_data (bfd)->strings)
51 #define obj_coff_strings_len(bfd) (coff_data (bfd)->strings_len)
52 #define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
53 #define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
54 #define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written)
55 #define obj_coff_local_toc_table(bfd) (coff_data (bfd)->local_toc_sym_map)
57 /* `Tdata' information kept for COFF files. */
59 typedef struct coff_tdata
61 struct coff_symbol_struct *symbols; /* Symtab for input bfd. */
62 unsigned int *conversion_table;
63 int conv_table_size;
64 file_ptr sym_filepos;
66 struct coff_ptr_struct *raw_syments;
67 unsigned long raw_syment_count;
69 /* These are only valid once writing has begun. */
70 unsigned long int relocbase;
72 /* These members communicate important constants about the symbol table
73 to GDB's symbol-reading code. These `constants' unfortunately vary
74 from coff implementation to implementation... */
75 unsigned local_n_btmask;
76 unsigned local_n_btshft;
77 unsigned local_n_tmask;
78 unsigned local_n_tshift;
79 unsigned local_symesz;
80 unsigned local_auxesz;
81 unsigned local_linesz;
83 /* The unswapped external symbols. May be NULL. Read by
84 _bfd_coff_get_external_symbols. */
85 void * external_syms;
87 /* The string table. May be NULL. Read by
88 _bfd_coff_read_string_table. */
89 char *strings;
90 /* The length of the strings table. For error checking. */
91 bfd_size_type strings_len;
93 /* Set if long section names are supported. A writable copy of the COFF
94 backend flag _bfd_coff_long_section_names. */
95 bool long_section_names;
97 /* If this is TRUE, the external_syms may not be freed. */
98 bool keep_syms;
99 /* If this is TRUE, the strings may not be freed. */
100 bool keep_strings;
101 /* If this is TRUE, the strings have been written out already. */
102 bool strings_written;
104 /* Is this a GO32 coff file? */
105 bool go32;
107 /* Is this a PE format coff file? */
108 bool pe;
110 /* Copy of some of the f_flags bits in the COFF filehdr structure,
111 used by ARM code. */
112 flagword flags;
114 /* Used by the COFF backend linker. */
115 struct coff_link_hash_entry **sym_hashes;
117 /* Used by the pe linker for PowerPC. */
118 int *local_toc_sym_map;
120 struct bfd_link_info *link_info;
122 /* Used by coff_find_nearest_line. */
123 void * line_info;
125 /* A place to stash dwarf2 info for this bfd. */
126 void * dwarf2_find_line_info;
128 /* The timestamp from the COFF file header. */
129 long timestamp;
131 /* A stub (extra data prepended before the COFF image) and its size.
132 Used by coff-go32-exe, it contains executable data that loads the
133 COFF object into memory. */
134 char * stub;
135 bfd_size_type stub_size;
136 } coff_data_type;
138 /* Tdata for pe image files. */
139 typedef struct pe_tdata
141 coff_data_type coff;
142 struct internal_extra_pe_aouthdr pe_opthdr;
143 int dll;
144 int has_reloc_section;
145 int dont_strip_reloc;
146 int dos_message[16];
147 /* The timestamp to insert into the output file.
148 If the timestamp is -1 then the current time is used. */
149 int timestamp;
150 bool (*in_reloc_p) (bfd *, reloc_howto_type *);
151 flagword real_flags;
153 /* Build-id info. */
154 struct
156 bool (*after_write_object_contents) (bfd *);
157 const char *style;
158 asection *sec;
159 } build_id;
160 } pe_data_type;
162 #define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
164 /* Tdata for XCOFF files. */
166 struct xcoff_tdata
168 /* Basic COFF information. */
169 coff_data_type coff;
171 /* TRUE if this is an XCOFF64 file. */
172 bool xcoff64;
174 /* TRUE if a large a.out header should be generated. */
175 bool full_aouthdr;
177 /* TOC value. */
178 bfd_vma toc;
180 /* Index of section holding TOC. */
181 int sntoc;
183 /* Index of section holding entry point. */
184 int snentry;
186 /* .text alignment from optional header. */
187 int text_align_power;
189 /* .data alignment from optional header. */
190 int data_align_power;
192 /* modtype from optional header. */
193 short modtype;
195 /* cputype from optional header. */
196 short cputype;
198 /* maxdata from optional header. */
199 bfd_vma maxdata;
201 /* maxstack from optional header. */
202 bfd_vma maxstack;
204 /* Used by the XCOFF backend linker. */
205 asection **csects;
206 long *debug_indices;
207 unsigned int *lineno_counts;
208 unsigned int import_file_id;
211 #define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
213 /* We take the address of the first element of an asymbol to ensure that the
214 macro is only ever applied to an asymbol. */
215 #define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
217 /* Tdata for sections in XCOFF files. This is used by the linker. */
219 struct xcoff_section_tdata
221 /* Used for XCOFF csects created by the linker; points to the real
222 XCOFF section which contains this csect. */
223 asection *enclosing;
224 /* The lineno_count field for the enclosing section, because we are
225 going to clobber it there. */
226 unsigned int lineno_count;
227 /* The first and last symbol indices for symbols used by this csect. */
228 unsigned long first_symndx;
229 unsigned long last_symndx;
232 /* An accessor macro the xcoff_section_tdata structure. */
233 #define xcoff_section_data(abfd, sec) \
234 ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
236 /* Tdata for sections in PE files. */
238 struct pei_section_tdata
240 /* The virtual size of the section. */
241 bfd_size_type virt_size;
242 /* The PE section flags. */
243 long pe_flags;
246 /* An accessor macro for the pei_section_tdata structure. */
247 #define pei_section_data(abfd, sec) \
248 ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
250 /* COFF linker hash table entries. */
252 struct coff_link_hash_entry
254 struct bfd_link_hash_entry root;
256 /* Symbol index in output file. This is initialized to -1. It is
257 set to -2 if the symbol is used by a reloc. It is set to -3 if
258 this symbol is defined in a discarded section. */
259 long indx;
261 /* Symbol type. */
262 unsigned short type;
264 /* Symbol class. */
265 unsigned char symbol_class;
267 /* Number of auxiliary entries. */
268 char numaux;
270 /* BFD to take auxiliary entries from. */
271 bfd *auxbfd;
273 /* Pointer to array of auxiliary entries, if any. */
274 union internal_auxent *aux;
276 /* Flag word; legal values follow. */
277 unsigned short coff_link_hash_flags;
278 /* Symbol is a PE section symbol. */
279 #define COFF_LINK_HASH_PE_SECTION_SYMBOL (01)
282 /* COFF linker hash table. */
284 struct coff_link_hash_table
286 struct bfd_link_hash_table root;
287 /* A pointer to information used to link stabs in sections. */
288 struct stab_info stab_info;
291 struct coff_reloc_cookie
293 struct internal_reloc * rels;
294 struct internal_reloc * rel;
295 struct internal_reloc * relend;
296 struct coff_symbol_struct * symbols; /* Symtab for input bfd. */
297 bfd * abfd;
298 struct coff_link_hash_entry ** sym_hashes;
301 /* Look up an entry in a COFF linker hash table. */
303 #define coff_link_hash_lookup(table, string, create, copy, follow) \
304 ((struct coff_link_hash_entry *) \
305 bfd_link_hash_lookup (&(table)->root, (string), (create), \
306 (copy), (follow)))
308 /* Traverse a COFF linker hash table. */
310 #define coff_link_hash_traverse(table, func, info) \
311 (bfd_link_hash_traverse \
312 (&(table)->root, \
313 (bool (*) (struct bfd_link_hash_entry *, void *)) (func), \
314 (info)))
316 /* Get the COFF linker hash table from a link_info structure. */
318 #define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
320 /* Functions in coffgen.c. */
321 extern bfd_cleanup coff_object_p
322 (bfd *);
323 extern struct bfd_section *coff_section_from_bfd_index
324 (bfd *, int);
325 extern long coff_get_symtab_upper_bound
326 (bfd *);
327 extern long coff_canonicalize_symtab
328 (bfd *, asymbol **);
329 extern int coff_count_linenumbers
330 (bfd *);
331 extern bool coff_renumber_symbols
332 (bfd *, int *);
333 extern void coff_mangle_symbols
334 (bfd *);
335 extern bool coff_write_symbols
336 (bfd *);
337 extern bool coff_write_alien_symbol
338 (bfd *, asymbol *, struct internal_syment *, bfd_vma *,
339 struct bfd_strtab_hash *, bool, asection **, bfd_size_type *);
340 extern bool coff_write_linenumbers
341 (bfd *);
342 extern alent *coff_get_lineno
343 (bfd *, asymbol *);
344 extern asymbol *coff_section_symbol
345 (bfd *, char *);
346 extern bool _bfd_coff_get_external_symbols
347 (bfd *);
348 extern const char *_bfd_coff_read_string_table
349 (bfd *);
350 extern bool _bfd_coff_free_symbols
351 (bfd *);
352 extern struct coff_ptr_struct *coff_get_normalized_symtab
353 (bfd *);
354 extern long coff_get_reloc_upper_bound
355 (bfd *, sec_ptr);
356 extern asymbol *coff_make_empty_symbol
357 (bfd *);
358 extern void coff_print_symbol
359 (bfd *, void * filep, asymbol *, bfd_print_symbol_type);
360 extern void coff_get_symbol_info
361 (bfd *, asymbol *, symbol_info *ret);
362 #define coff_get_symbol_version_string \
363 _bfd_nosymbols_get_symbol_version_string
364 extern bool _bfd_coff_is_local_label_name
365 (bfd *, const char *);
366 extern asymbol *coff_bfd_make_debug_symbol
367 (bfd *, void *, unsigned long);
368 extern bool coff_find_nearest_line
369 (bfd *, asymbol **, asection *, bfd_vma,
370 const char **, const char **, unsigned int *, unsigned int *);
371 #define coff_find_nearest_line_with_alt \
372 _bfd_nosymbols_find_nearest_line_with_alt
373 #define coff_find_line _bfd_nosymbols_find_line
374 struct dwarf_debug_section;
375 extern bool coff_find_nearest_line_with_names
376 (bfd *, asymbol **, asection *, bfd_vma, const char **, const char **,
377 unsigned int *, const struct dwarf_debug_section *);
378 extern bool coff_find_inliner_info
379 (bfd *, const char **, const char **, unsigned int *);
380 extern int coff_sizeof_headers
381 (bfd *, struct bfd_link_info *);
382 extern bool bfd_coff_reloc16_relax_section
383 (bfd *, asection *, struct bfd_link_info *, bool *);
384 extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
385 (bfd *, struct bfd_link_info *, struct bfd_link_order *,
386 bfd_byte *, bool, asymbol **);
387 extern bfd_vma bfd_coff_reloc16_get_value
388 (arelent *, struct bfd_link_info *, asection *);
389 extern void bfd_perform_slip
390 (bfd *, unsigned int, asection *, bfd_vma);
391 extern bool _bfd_coff_close_and_cleanup
392 (bfd *);
394 /* Functions and types in cofflink.c. */
396 #define STRING_SIZE_SIZE 4
398 /* We use a hash table to merge identical enum, struct, and union
399 definitions in the linker. */
401 /* Information we keep for a single element (an enum value, a
402 structure or union field) in the debug merge hash table. */
404 struct coff_debug_merge_element
406 /* Next element. */
407 struct coff_debug_merge_element *next;
409 /* Name. */
410 const char *name;
412 /* Type. */
413 unsigned int type;
415 /* Symbol index for complex type. */
416 long tagndx;
419 /* A linked list of debug merge entries for a given name. */
421 struct coff_debug_merge_type
423 /* Next type with the same name. */
424 struct coff_debug_merge_type *next;
426 /* Class of type. */
427 int type_class;
429 /* Symbol index where this type is defined. */
430 long indx;
432 /* List of elements. */
433 struct coff_debug_merge_element *elements;
436 /* Information we store in the debug merge hash table. */
438 struct coff_debug_merge_hash_entry
440 struct bfd_hash_entry root;
442 /* A list of types with this name. */
443 struct coff_debug_merge_type *types;
446 /* The debug merge hash table. */
448 struct coff_debug_merge_hash_table
450 struct bfd_hash_table root;
453 /* Initialize a COFF debug merge hash table. */
455 #define coff_debug_merge_hash_table_init(table) \
456 (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \
457 sizeof (struct coff_debug_merge_hash_entry)))
459 /* Free a COFF debug merge hash table. */
461 #define coff_debug_merge_hash_table_free(table) \
462 (bfd_hash_table_free (&(table)->root))
464 /* Look up an entry in a COFF debug merge hash table. */
466 #define coff_debug_merge_hash_lookup(table, string, create, copy) \
467 ((struct coff_debug_merge_hash_entry *) \
468 bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
470 /* Information we keep for each section in the output file when doing
471 a relocatable link. */
473 struct coff_link_section_info
475 /* The relocs to be output. */
476 struct internal_reloc *relocs;
477 /* For each reloc against a global symbol whose index was not known
478 when the reloc was handled, the global hash table entry. */
479 struct coff_link_hash_entry **rel_hashes;
482 /* Information that we pass around while doing the final link step. */
484 struct coff_final_link_info
486 /* General link information. */
487 struct bfd_link_info *info;
488 /* Output BFD. */
489 bfd *output_bfd;
490 /* Used to indicate failure in traversal routine. */
491 bool failed;
492 /* If doing "task linking" set only during the time when we want the
493 global symbol writer to convert the storage class of defined global
494 symbols from global to static. */
495 bool global_to_static;
496 /* Hash table for long symbol names. */
497 struct bfd_strtab_hash *strtab;
498 /* When doing a relocatable link, an array of information kept for
499 each output section, indexed by the target_index field. */
500 struct coff_link_section_info *section_info;
501 /* Symbol index of last C_FILE symbol (-1 if none). */
502 long last_file_index;
503 /* Contents of last C_FILE symbol. */
504 struct internal_syment last_file;
505 /* Symbol index of first aux entry of last .bf symbol with an empty
506 endndx field (-1 if none). */
507 long last_bf_index;
508 /* Contents of last_bf_index aux entry. */
509 union internal_auxent last_bf;
510 /* Hash table used to merge debug information. */
511 struct coff_debug_merge_hash_table debug_merge;
512 /* Buffer large enough to hold swapped symbols of any input file. */
513 struct internal_syment *internal_syms;
514 /* Buffer large enough to hold sections of symbols of any input file. */
515 asection **sec_ptrs;
516 /* Buffer large enough to hold output indices of symbols of any
517 input file. */
518 long *sym_indices;
519 /* Buffer large enough to hold output symbols for any input file. */
520 bfd_byte *outsyms;
521 /* Buffer large enough to hold external line numbers for any input
522 section. */
523 bfd_byte *linenos;
524 /* Buffer large enough to hold any input section. */
525 bfd_byte *contents;
526 /* Buffer large enough to hold external relocs of any input section. */
527 bfd_byte *external_relocs;
528 /* Buffer large enough to hold swapped relocs of any input section. */
529 struct internal_reloc *internal_relocs;
532 /* Most COFF variants have no way to record the alignment of a
533 section. This struct is used to set a specific alignment based on
534 the name of the section. */
536 struct coff_section_alignment_entry
538 /* The section name. */
539 const char *name;
541 /* This is either (unsigned int) -1, indicating that the section
542 name must match exactly, or it is the number of letters which
543 must match at the start of the name. */
544 unsigned int comparison_length;
546 /* These macros may be used to fill in the first two fields in a
547 structure initialization. */
548 #define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1)
549 #define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1)
551 /* Only use this entry if the default section alignment for this
552 target is at least that much (as a power of two). If this field
553 is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */
554 unsigned int default_alignment_min;
556 /* Only use this entry if the default section alignment for this
557 target is no greater than this (as a power of two). If this
558 field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */
559 unsigned int default_alignment_max;
561 #define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1)
563 /* The desired alignment for this section (as a power of two). */
564 unsigned int alignment_power;
567 extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
568 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
569 extern bool _bfd_coff_link_hash_table_init
570 (struct coff_link_hash_table *, bfd *,
571 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
572 struct bfd_hash_table *,
573 const char *),
574 unsigned int);
575 extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
576 (bfd *);
577 extern const char *_bfd_coff_internal_syment_name
578 (bfd *, const struct internal_syment *, char *);
579 extern bool _bfd_coff_section_already_linked
580 (bfd *, asection *, struct bfd_link_info *);
581 extern bool _bfd_coff_link_add_symbols
582 (bfd *, struct bfd_link_info *);
583 extern bool _bfd_coff_final_link
584 (bfd *, struct bfd_link_info *);
585 extern struct internal_reloc *_bfd_coff_read_internal_relocs
586 (bfd *, asection *, bool, bfd_byte *, bool,
587 struct internal_reloc *);
588 extern bool _bfd_coff_generic_relocate_section
589 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
590 struct internal_reloc *, struct internal_syment *, asection **);
591 extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
592 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
593 extern bool _bfd_coff_write_global_sym
594 (struct bfd_hash_entry *, void *);
595 extern bool _bfd_coff_write_task_globals
596 (struct coff_link_hash_entry *, void *);
597 extern bool _bfd_coff_link_input_bfd
598 (struct coff_final_link_info *, bfd *);
599 extern bool _bfd_coff_reloc_link_order
600 (bfd *, struct coff_final_link_info *, asection *,
601 struct bfd_link_order *);
602 extern bool bfd_coff_gc_sections
603 (bfd *, struct bfd_link_info *);
604 extern const char *bfd_coff_group_name
605 (bfd *, const asection *);
607 #define coff_get_section_contents_in_window \
608 _bfd_generic_get_section_contents_in_window
610 /* Functions in xcofflink.c. */
612 extern long _bfd_xcoff_get_dynamic_symtab_upper_bound
613 (bfd *);
614 extern long _bfd_xcoff_canonicalize_dynamic_symtab
615 (bfd *, asymbol **);
616 extern long _bfd_xcoff_get_dynamic_reloc_upper_bound
617 (bfd *);
618 extern long _bfd_xcoff_canonicalize_dynamic_reloc
619 (bfd *, arelent **, asymbol **);
620 extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
621 (bfd *);
622 extern bool _bfd_xcoff_bfd_link_add_symbols
623 (bfd *, struct bfd_link_info *);
624 extern bool _bfd_xcoff_bfd_final_link
625 (bfd *, struct bfd_link_info *);
626 extern bool _bfd_xcoff_define_common_symbol
627 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
628 extern bool _bfd_ppc_xcoff_relocate_section
629 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
630 struct internal_reloc *, struct internal_syment *, asection **);
631 /* Extracted from coffcode.h. */
633 typedef struct coff_ptr_struct
635 /* Remembers the offset from the first symbol in the file for
636 this symbol. Generated by coff_renumber_symbols. */
637 unsigned int offset;
639 /* Selects between the elements of the union below. */
640 unsigned int is_sym : 1;
642 /* Selects between the elements of the x_sym.x_tagndx union. If set,
643 p is valid and the field will be renumbered. */
644 unsigned int fix_tag : 1;
646 /* Selects between the elements of the x_sym.x_fcnary.x_fcn.x_endndx
647 union. If set, p is valid and the field will be renumbered. */
648 unsigned int fix_end : 1;
650 /* Selects between the elements of the x_csect.x_scnlen union. If set,
651 p is valid and the field will be renumbered. */
652 unsigned int fix_scnlen : 1;
654 /* If set, u.syment.n_value contains a pointer to a symbol. The final
655 value will be the offset field. Used for XCOFF C_BSTAT symbols. */
656 unsigned int fix_value : 1;
658 /* If set, u.syment.n_value is an index into the line number entries.
659 Used for XCOFF C_BINCL/C_EINCL symbols. */
660 unsigned int fix_line : 1;
662 /* The container for the symbol structure as read and translated
663 from the file. */
664 union
666 union internal_auxent auxent;
667 struct internal_syment syment;
668 } u;
670 /* An extra pointer which can used by format based on COFF (like XCOFF)
671 to provide extra information to their backend. */
672 void *extrap;
673 } combined_entry_type;
676 /* Each canonical asymbol really looks like this: */
678 typedef struct coff_symbol_struct
680 /* The actual symbol which the rest of BFD works with */
681 asymbol symbol;
683 /* A pointer to the hidden information for this symbol */
684 combined_entry_type *native;
686 /* A pointer to the linenumber information for this symbol */
687 struct lineno_cache_entry *lineno;
689 /* Have the line numbers been relocated yet ? */
690 bool done_lineno;
691 } coff_symbol_type;
692 /* COFF symbol classifications. */
694 enum coff_symbol_classification
696 /* Global symbol. */
697 COFF_SYMBOL_GLOBAL,
698 /* Common symbol. */
699 COFF_SYMBOL_COMMON,
700 /* Undefined symbol. */
701 COFF_SYMBOL_UNDEFINED,
702 /* Local symbol. */
703 COFF_SYMBOL_LOCAL,
704 /* PE section symbol. */
705 COFF_SYMBOL_PE_SECTION
708 typedef asection * (*coff_gc_mark_hook_fn)
709 (asection *, struct bfd_link_info *, struct internal_reloc *,
710 struct coff_link_hash_entry *, struct internal_syment *);
712 typedef struct
714 void (*_bfd_coff_swap_aux_in)
715 (bfd *, void *, int, int, int, int, void *);
717 void (*_bfd_coff_swap_sym_in)
718 (bfd *, void *, void *);
720 void (*_bfd_coff_swap_lineno_in)
721 (bfd *, void *, void *);
723 unsigned int (*_bfd_coff_swap_aux_out)
724 (bfd *, void *, int, int, int, int, void *);
726 unsigned int (*_bfd_coff_swap_sym_out)
727 (bfd *, void *, void *);
729 unsigned int (*_bfd_coff_swap_lineno_out)
730 (bfd *, void *, void *);
732 unsigned int (*_bfd_coff_swap_reloc_out)
733 (bfd *, void *, void *);
735 unsigned int (*_bfd_coff_swap_filehdr_out)
736 (bfd *, void *, void *);
738 unsigned int (*_bfd_coff_swap_aouthdr_out)
739 (bfd *, void *, void *);
741 unsigned int (*_bfd_coff_swap_scnhdr_out)
742 (bfd *, void *, void *);
744 unsigned int _bfd_filhsz;
745 unsigned int _bfd_aoutsz;
746 unsigned int _bfd_scnhsz;
747 unsigned int _bfd_symesz;
748 unsigned int _bfd_auxesz;
749 unsigned int _bfd_relsz;
750 unsigned int _bfd_linesz;
751 unsigned int _bfd_filnmlen;
752 bool _bfd_coff_long_filenames;
754 bool _bfd_coff_long_section_names;
755 bool (*_bfd_coff_set_long_section_names)
756 (bfd *, int);
758 unsigned int _bfd_coff_default_section_alignment_power;
759 bool _bfd_coff_force_symnames_in_strings;
760 unsigned int _bfd_coff_debug_string_prefix_length;
761 unsigned int _bfd_coff_max_nscns;
763 void (*_bfd_coff_swap_filehdr_in)
764 (bfd *, void *, void *);
766 void (*_bfd_coff_swap_aouthdr_in)
767 (bfd *, void *, void *);
769 void (*_bfd_coff_swap_scnhdr_in)
770 (bfd *, void *, void *);
772 void (*_bfd_coff_swap_reloc_in)
773 (bfd *abfd, void *, void *);
775 bool (*_bfd_coff_bad_format_hook)
776 (bfd *, void *);
778 bool (*_bfd_coff_set_arch_mach_hook)
779 (bfd *, void *);
781 void * (*_bfd_coff_mkobject_hook)
782 (bfd *, void *, void *);
784 bool (*_bfd_styp_to_sec_flags_hook)
785 (bfd *, void *, const char *, asection *, flagword *);
787 void (*_bfd_set_alignment_hook)
788 (bfd *, asection *, void *);
790 bool (*_bfd_coff_slurp_symbol_table)
791 (bfd *);
793 bool (*_bfd_coff_symname_in_debug)
794 (bfd *, struct internal_syment *);
796 bool (*_bfd_coff_pointerize_aux_hook)
797 (bfd *, combined_entry_type *, combined_entry_type *,
798 unsigned int, combined_entry_type *);
800 bool (*_bfd_coff_print_aux)
801 (bfd *, FILE *, combined_entry_type *, combined_entry_type *,
802 combined_entry_type *, unsigned int);
804 bool (*_bfd_coff_reloc16_extra_cases)
805 (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
806 bfd_byte *, size_t *, size_t *);
808 int (*_bfd_coff_reloc16_estimate)
809 (bfd *, asection *, arelent *, unsigned int,
810 struct bfd_link_info *);
812 enum coff_symbol_classification (*_bfd_coff_classify_symbol)
813 (bfd *, struct internal_syment *);
815 bool (*_bfd_coff_compute_section_file_positions)
816 (bfd *);
818 bool (*_bfd_coff_start_final_link)
819 (bfd *, struct bfd_link_info *);
821 bool (*_bfd_coff_relocate_section)
822 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
823 struct internal_reloc *, struct internal_syment *, asection **);
825 reloc_howto_type *(*_bfd_coff_rtype_to_howto)
826 (bfd *, asection *, struct internal_reloc *,
827 struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *);
829 bool (*_bfd_coff_adjust_symndx)
830 (bfd *, struct bfd_link_info *, bfd *, asection *,
831 struct internal_reloc *, bool *);
833 bool (*_bfd_coff_link_add_one_symbol)
834 (struct bfd_link_info *, bfd *, const char *, flagword,
835 asection *, bfd_vma, const char *, bool, bool,
836 struct bfd_link_hash_entry **);
838 bool (*_bfd_coff_link_output_has_begun)
839 (bfd *, struct coff_final_link_info *);
841 bool (*_bfd_coff_final_link_postscript)
842 (bfd *, struct coff_final_link_info *);
844 bool (*_bfd_coff_print_pdata)
845 (bfd *, void *);
847 } bfd_coff_backend_data;
849 #define coff_backend_info(abfd) \
850 ((const bfd_coff_backend_data *) (abfd)->xvec->backend_data)
852 #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
853 ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
855 #define bfd_coff_swap_sym_in(a,e,i) \
856 ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
858 #define bfd_coff_swap_lineno_in(a,e,i) \
859 ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
861 #define bfd_coff_swap_reloc_out(abfd, i, o) \
862 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
864 #define bfd_coff_swap_lineno_out(abfd, i, o) \
865 ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
867 #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
868 ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
870 #define bfd_coff_swap_sym_out(abfd, i,o) \
871 ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
873 #define bfd_coff_swap_scnhdr_out(abfd, i,o) \
874 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
876 #define bfd_coff_swap_filehdr_out(abfd, i,o) \
877 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
879 #define bfd_coff_swap_aouthdr_out(abfd, i,o) \
880 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
882 #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
883 #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
884 #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
885 #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
886 #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
887 #define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
888 #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
889 #define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
890 #define bfd_coff_long_filenames(abfd) \
891 (coff_backend_info (abfd)->_bfd_coff_long_filenames)
892 #define bfd_coff_long_section_names(abfd) \
893 (coff_data (abfd)->long_section_names)
894 #define bfd_coff_set_long_section_names(abfd, enable) \
895 ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable))
896 #define bfd_coff_default_section_alignment_power(abfd) \
897 (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
898 #define bfd_coff_max_nscns(abfd) \
899 (coff_backend_info (abfd)->_bfd_coff_max_nscns)
901 #define bfd_coff_swap_filehdr_in(abfd, i,o) \
902 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
904 #define bfd_coff_swap_aouthdr_in(abfd, i,o) \
905 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
907 #define bfd_coff_swap_scnhdr_in(abfd, i,o) \
908 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
910 #define bfd_coff_swap_reloc_in(abfd, i, o) \
911 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
913 #define bfd_coff_bad_format_hook(abfd, filehdr) \
914 ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
916 #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
917 ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
918 #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
919 ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\
920 (abfd, filehdr, aouthdr))
922 #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
923 ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
924 (abfd, scnhdr, name, section, flags_ptr))
926 #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
927 ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
929 #define bfd_coff_slurp_symbol_table(abfd)\
930 ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
932 #define bfd_coff_symname_in_debug(abfd, sym)\
933 ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
935 #define bfd_coff_force_symnames_in_strings(abfd)\
936 (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
938 #define bfd_coff_debug_string_prefix_length(abfd)\
939 (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
941 #define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
942 ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
943 (abfd, file, base, symbol, aux, indaux))
945 #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\
946 reloc, data, src_ptr, dst_ptr)\
947 ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
948 (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
950 #define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
951 ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
952 (abfd, section, reloc, shrink, link_info))
954 #define bfd_coff_classify_symbol(abfd, sym)\
955 ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
956 (abfd, sym))
958 #define bfd_coff_compute_section_file_positions(abfd)\
959 ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
960 (abfd))
962 #define bfd_coff_start_final_link(obfd, info)\
963 ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
964 (obfd, info))
965 #define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
966 ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
967 (obfd, info, ibfd, o, con, rel, isyms, secs))
968 #define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
969 ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
970 (abfd, sec, rel, h, sym, addendp))
971 #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
972 ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
973 (obfd, info, ibfd, sec, rel, adjustedp))
974 #define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
975 value, string, cp, coll, hashp)\
976 ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
977 (info, abfd, name, flags, section, value, string, cp, coll, hashp))
979 #define bfd_coff_link_output_has_begun(a,p) \
980 ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p))
981 #define bfd_coff_final_link_postscript(a,p) \
982 ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a, p))
984 #define bfd_coff_have_print_pdata(a) \
985 (coff_backend_info (a)->_bfd_coff_print_pdata)
986 #define bfd_coff_print_pdata(a,p) \
987 ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p))
989 /* Macro: Returns true if the bfd is a PE executable as opposed to a
990 PE object file. */
991 #define bfd_pei_p(abfd) \
992 (startswith ((abfd)->xvec->name, "pei-"))
993 #ifdef __cplusplus
995 #endif
996 #endif