[PATCH] ld: Improve documentation of -rpath-link search paths
[binutils-gdb.git] / bfd / libcoff.h
blob50b3959234afa26018b4a16206151ff9d93f80e5
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-2024 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"
31 #include "hashtab.h"
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 /* Object file tdata; access macros. */
39 #define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
40 #define obj_pe(bfd) (coff_data (bfd)->pe)
41 #define obj_go32(bfd) (coff_data (bfd)->go32)
42 #define obj_symbols(bfd) (coff_data (bfd)->symbols)
43 #define obj_sym_filepos(bfd) (coff_data (bfd)->sym_filepos)
44 #define obj_relocbase(bfd) (coff_data (bfd)->relocbase)
45 #define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments)
46 #define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count)
47 #define obj_convert(bfd) (coff_data (bfd)->conversion_table)
48 #define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size)
49 #define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
50 #define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms)
51 #define obj_coff_strings(bfd) (coff_data (bfd)->strings)
52 #define obj_coff_strings_len(bfd) (coff_data (bfd)->strings_len)
53 #define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
54 #define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
55 #define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written)
56 #define obj_coff_local_toc_table(bfd) (coff_data (bfd)->local_toc_sym_map)
58 /* `Tdata' information kept for COFF files. */
60 typedef struct coff_tdata
62 struct coff_symbol_struct *symbols; /* Symtab for input bfd. */
63 unsigned int *conversion_table;
64 int conv_table_size;
65 file_ptr sym_filepos;
67 struct coff_ptr_struct *raw_syments;
68 unsigned long raw_syment_count;
70 /* These are only valid once writing has begun. */
71 unsigned long int relocbase;
73 /* These members communicate important constants about the symbol table
74 to GDB's symbol-reading code. These `constants' unfortunately vary
75 from coff implementation to implementation... */
76 unsigned local_n_btmask;
77 unsigned local_n_btshft;
78 unsigned local_n_tmask;
79 unsigned local_n_tshift;
80 unsigned local_symesz;
81 unsigned local_auxesz;
82 unsigned local_linesz;
84 /* The unswapped external symbols. May be NULL. Read by
85 _bfd_coff_get_external_symbols. */
86 void * external_syms;
88 /* The string table. May be NULL. Read by
89 _bfd_coff_read_string_table. */
90 char *strings;
91 /* The length of the strings table. For error checking. */
92 bfd_size_type strings_len;
94 /* Set if long section names are supported. A writable copy of the COFF
95 backend flag _bfd_coff_long_section_names. */
96 bool long_section_names;
98 /* If this is TRUE, the external_syms may not be freed. */
99 bool keep_syms;
100 /* If this is TRUE, the strings may not be freed. */
101 bool keep_strings;
102 /* If this is TRUE, the strings have been written out already. */
103 bool strings_written;
105 /* Is this a GO32 coff file? */
106 bool go32;
108 /* Is this a PE format coff file? */
109 bool pe;
111 /* Copy of some of the f_flags bits in the COFF filehdr structure,
112 used by ARM code. */
113 flagword flags;
115 /* Used by the COFF backend linker. */
116 struct coff_link_hash_entry **sym_hashes;
118 /* Used by the pe linker for PowerPC. */
119 int *local_toc_sym_map;
121 struct bfd_link_info *link_info;
123 /* Used by coff_find_nearest_line. */
124 void * line_info;
126 /* A place to stash dwarf2 info for this bfd. */
127 void * dwarf2_find_line_info;
129 /* The timestamp from the COFF file header. */
130 long timestamp;
132 /* A stub (extra data prepended before the COFF image) and its size.
133 Used by coff-go32-exe, it contains executable data that loads the
134 COFF object into memory. */
135 char * stub;
136 bfd_size_type stub_size;
138 /* Hash table containing sections by target index. */
139 htab_t section_by_target_index;
141 /* Hash table containing sections by index. */
142 htab_t section_by_index;
144 } coff_data_type;
146 /* Tdata for pe image files. */
147 typedef struct pe_tdata
149 coff_data_type coff;
150 struct internal_extra_pe_aouthdr pe_opthdr;
151 int dll;
152 int has_reloc_section;
153 int dont_strip_reloc;
154 char dos_message[64];
155 /* The timestamp to insert into the output file.
156 If the timestamp is -1 then the current time is used. */
157 int timestamp;
158 bool (*in_reloc_p) (bfd *, reloc_howto_type *);
159 flagword real_flags;
161 /* Build-id info. */
162 struct
164 bool (*after_write_object_contents) (bfd *);
165 const char *style;
166 asection *sec;
167 } build_id;
169 htab_t comdat_hash;
170 } pe_data_type;
172 #define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
174 struct comdat_hash_entry
176 int target_index;
177 struct internal_syment isym;
178 char *symname;
179 flagword sec_flags;
180 char *comdat_name;
181 long comdat_symbol;
184 /* Tdata for XCOFF files. */
186 struct xcoff_tdata
188 /* Basic COFF information. */
189 coff_data_type coff;
191 /* TRUE if this is an XCOFF64 file. */
192 bool xcoff64;
194 /* TRUE if a large a.out header should be generated. */
195 bool full_aouthdr;
197 /* TOC value. */
198 bfd_vma toc;
200 /* Index of section holding TOC. */
201 int sntoc;
203 /* Index of section holding entry point. */
204 int snentry;
206 /* .text alignment from optional header. */
207 int text_align_power;
209 /* .data alignment from optional header. */
210 int data_align_power;
212 /* modtype from optional header. */
213 short modtype;
215 /* cputype from optional header. */
216 short cputype;
218 /* maxdata from optional header. */
219 bfd_vma maxdata;
221 /* maxstack from optional header. */
222 bfd_vma maxstack;
224 /* Used by the XCOFF backend linker. */
225 asection **csects;
226 long *debug_indices;
227 unsigned int *lineno_counts;
228 unsigned int import_file_id;
231 #define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
233 /* We take the address of the first element of an asymbol to ensure that the
234 macro is only ever applied to an asymbol. */
235 #define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
237 /* Tdata for sections in XCOFF files. This is used by the linker. */
239 struct xcoff_section_tdata
241 /* Used for XCOFF csects created by the linker; points to the real
242 XCOFF section which contains this csect. */
243 asection *enclosing;
244 /* The lineno_count field for the enclosing section, because we are
245 going to clobber it there. */
246 unsigned int lineno_count;
247 /* The first and last symbol indices for symbols used by this csect. */
248 unsigned long first_symndx;
249 unsigned long last_symndx;
252 /* An accessor macro the xcoff_section_tdata structure. */
253 #define xcoff_section_data(abfd, sec) \
254 ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
256 /* Tdata for sections in PE files. */
258 struct pei_section_tdata
260 /* The virtual size of the section. */
261 bfd_size_type virt_size;
262 /* The PE section flags. */
263 long pe_flags;
266 /* An accessor macro for the pei_section_tdata structure. */
267 #define pei_section_data(abfd, sec) \
268 ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
270 /* COFF linker hash table entries. */
272 struct coff_link_hash_entry
274 struct bfd_link_hash_entry root;
276 /* Symbol index in output file. This is initialized to -1. It is
277 set to -2 if the symbol is used by a reloc. It is set to -3 if
278 this symbol is defined in a discarded section. */
279 long indx;
281 /* Symbol type. */
282 unsigned short type;
284 /* Symbol class. */
285 unsigned char symbol_class;
287 /* Number of auxiliary entries. */
288 char numaux;
290 /* BFD to take auxiliary entries from. */
291 bfd *auxbfd;
293 /* Pointer to array of auxiliary entries, if any. */
294 union internal_auxent *aux;
296 /* Flag word; legal values follow. */
297 unsigned short coff_link_hash_flags;
298 /* Symbol is a PE section symbol. */
299 #define COFF_LINK_HASH_PE_SECTION_SYMBOL (01)
302 /* COFF linker hash table. */
304 struct coff_link_hash_table
306 struct bfd_link_hash_table root;
307 /* A pointer to information used to link stabs in sections. */
308 struct stab_info stab_info;
309 /* Hash table that maps undecorated names to their respective
310 * decorated coff_link_hash_entry as found in fixup_stdcalls */
311 struct bfd_hash_table decoration_hash;
314 struct coff_reloc_cookie
316 struct internal_reloc * rels;
317 struct internal_reloc * rel;
318 struct internal_reloc * relend;
319 struct coff_symbol_struct * symbols; /* Symtab for input bfd. */
320 bfd * abfd;
321 struct coff_link_hash_entry ** sym_hashes;
324 /* Look up an entry in a COFF linker hash table. */
326 #define coff_link_hash_lookup(table, string, create, copy, follow) \
327 ((struct coff_link_hash_entry *) \
328 bfd_link_hash_lookup (&(table)->root, (string), (create), \
329 (copy), (follow)))
331 /* Traverse a COFF linker hash table. */
333 #define coff_link_hash_traverse(table, func, info) \
334 (bfd_link_hash_traverse \
335 (&(table)->root, \
336 (bool (*) (struct bfd_link_hash_entry *, void *)) (func), \
337 (info)))
339 /* Get the COFF linker hash table from a link_info structure. */
341 #define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
343 struct decoration_hash_entry
345 struct bfd_hash_entry root;
346 struct bfd_link_hash_entry *decorated_link;
349 /* Functions in coffgen.c. */
350 extern void coff_object_cleanup
351 (bfd *);
352 extern bfd_cleanup coff_real_object_p
353 (bfd *, unsigned, struct internal_filehdr *, struct internal_aouthdr *);
354 extern bfd_cleanup coff_object_p
355 (bfd *);
356 extern struct bfd_section *coff_section_from_bfd_index
357 (bfd *, int);
358 extern long coff_get_symtab_upper_bound
359 (bfd *);
360 extern long coff_canonicalize_symtab
361 (bfd *, asymbol **);
362 extern int coff_count_linenumbers
363 (bfd *);
364 extern bool coff_renumber_symbols
365 (bfd *, int *);
366 extern void coff_mangle_symbols
367 (bfd *);
368 extern bool coff_write_symbols
369 (bfd *);
370 extern bool coff_write_alien_symbol
371 (bfd *, asymbol *, struct internal_syment *, bfd_vma *,
372 struct bfd_strtab_hash *, bool, asection **, bfd_size_type *);
373 extern bool coff_write_linenumbers
374 (bfd *);
375 extern alent *coff_get_lineno
376 (bfd *, asymbol *);
377 extern asymbol *coff_section_symbol
378 (bfd *, char *);
379 extern bool _bfd_coff_get_external_symbols
380 (bfd *);
381 extern const char *_bfd_coff_read_string_table
382 (bfd *);
383 extern bool _bfd_coff_free_symbols
384 (bfd *);
385 extern struct coff_ptr_struct *coff_get_normalized_symtab
386 (bfd *);
387 extern long coff_get_reloc_upper_bound
388 (bfd *, sec_ptr);
389 extern asymbol *coff_make_empty_symbol
390 (bfd *);
391 extern void coff_print_symbol
392 (bfd *, void * filep, asymbol *, bfd_print_symbol_type);
393 extern void coff_get_symbol_info
394 (bfd *, asymbol *, symbol_info *ret);
395 #define coff_get_symbol_version_string \
396 _bfd_nosymbols_get_symbol_version_string
397 extern bool _bfd_coff_is_local_label_name
398 (bfd *, const char *);
399 extern asymbol *coff_bfd_make_debug_symbol
400 (bfd *);
401 extern bool coff_find_nearest_line
402 (bfd *, asymbol **, asection *, bfd_vma,
403 const char **, const char **, unsigned int *, unsigned int *);
404 #define coff_find_nearest_line_with_alt \
405 _bfd_nosymbols_find_nearest_line_with_alt
406 #define coff_find_line _bfd_nosymbols_find_line
407 struct dwarf_debug_section;
408 extern bool coff_find_nearest_line_with_names
409 (bfd *, asymbol **, asection *, bfd_vma, const char **, const char **,
410 unsigned int *, const struct dwarf_debug_section *);
411 extern bool coff_find_inliner_info
412 (bfd *, const char **, const char **, unsigned int *);
413 extern int coff_sizeof_headers
414 (bfd *, struct bfd_link_info *);
415 extern bool bfd_coff_reloc16_relax_section
416 (bfd *, asection *, struct bfd_link_info *, bool *);
417 extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
418 (bfd *, struct bfd_link_info *, struct bfd_link_order *,
419 bfd_byte *, bool, asymbol **);
420 extern bfd_vma bfd_coff_reloc16_get_value
421 (arelent *, struct bfd_link_info *, asection *);
422 extern void bfd_perform_slip
423 (bfd *, unsigned int, asection *, bfd_vma);
424 extern bool _bfd_coff_free_cached_info
425 (bfd *);
427 /* Functions and types in cofflink.c. */
429 #define STRING_SIZE_SIZE 4
431 /* We use a hash table to merge identical enum, struct, and union
432 definitions in the linker. */
434 /* Information we keep for a single element (an enum value, a
435 structure or union field) in the debug merge hash table. */
437 struct coff_debug_merge_element
439 /* Next element. */
440 struct coff_debug_merge_element *next;
442 /* Name. */
443 const char *name;
445 /* Type. */
446 unsigned int type;
448 /* Symbol index for complex type. */
449 long tagndx;
452 /* A linked list of debug merge entries for a given name. */
454 struct coff_debug_merge_type
456 /* Next type with the same name. */
457 struct coff_debug_merge_type *next;
459 /* Class of type. */
460 int type_class;
462 /* Symbol index where this type is defined. */
463 long indx;
465 /* List of elements. */
466 struct coff_debug_merge_element *elements;
469 /* Information we store in the debug merge hash table. */
471 struct coff_debug_merge_hash_entry
473 struct bfd_hash_entry root;
475 /* A list of types with this name. */
476 struct coff_debug_merge_type *types;
479 /* The debug merge hash table. */
481 struct coff_debug_merge_hash_table
483 struct bfd_hash_table root;
486 /* Initialize a COFF debug merge hash table. */
488 #define coff_debug_merge_hash_table_init(table) \
489 (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \
490 sizeof (struct coff_debug_merge_hash_entry)))
492 /* Free a COFF debug merge hash table. */
494 #define coff_debug_merge_hash_table_free(table) \
495 (bfd_hash_table_free (&(table)->root))
497 /* Look up an entry in a COFF debug merge hash table. */
499 #define coff_debug_merge_hash_lookup(table, string, create, copy) \
500 ((struct coff_debug_merge_hash_entry *) \
501 bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
503 /* Information we keep for each section in the output file when doing
504 a relocatable link. */
506 struct coff_link_section_info
508 /* The relocs to be output. */
509 struct internal_reloc *relocs;
510 /* For each reloc against a global symbol whose index was not known
511 when the reloc was handled, the global hash table entry. */
512 struct coff_link_hash_entry **rel_hashes;
515 /* Information that we pass around while doing the final link step. */
517 struct coff_final_link_info
519 /* General link information. */
520 struct bfd_link_info *info;
521 /* Output BFD. */
522 bfd *output_bfd;
523 /* Used to indicate failure in traversal routine. */
524 bool failed;
525 /* If doing "task linking" set only during the time when we want the
526 global symbol writer to convert the storage class of defined global
527 symbols from global to static. */
528 bool global_to_static;
529 /* Hash table for long symbol names. */
530 struct bfd_strtab_hash *strtab;
531 /* When doing a relocatable link, an array of information kept for
532 each output section, indexed by the target_index field. */
533 struct coff_link_section_info *section_info;
534 /* Symbol index of last C_FILE symbol (-1 if none). */
535 long last_file_index;
536 /* Contents of last C_FILE symbol. */
537 struct internal_syment last_file;
538 /* Symbol index of first aux entry of last .bf symbol with an empty
539 endndx field (-1 if none). */
540 long last_bf_index;
541 /* Contents of last_bf_index aux entry. */
542 union internal_auxent last_bf;
543 /* Hash table used to merge debug information. */
544 struct coff_debug_merge_hash_table debug_merge;
545 /* Buffer large enough to hold swapped symbols of any input file. */
546 struct internal_syment *internal_syms;
547 /* Buffer large enough to hold sections of symbols of any input file. */
548 asection **sec_ptrs;
549 /* Buffer large enough to hold output indices of symbols of any
550 input file. */
551 long *sym_indices;
552 /* Buffer large enough to hold output symbols for any input file. */
553 bfd_byte *outsyms;
554 /* Buffer large enough to hold external line numbers for any input
555 section. */
556 bfd_byte *linenos;
557 /* Buffer large enough to hold any input section. */
558 bfd_byte *contents;
559 /* Buffer large enough to hold external relocs of any input section. */
560 bfd_byte *external_relocs;
561 /* Buffer large enough to hold swapped relocs of any input section. */
562 struct internal_reloc *internal_relocs;
565 /* Most COFF variants have no way to record the alignment of a
566 section. This struct is used to set a specific alignment based on
567 the name of the section. */
569 struct coff_section_alignment_entry
571 /* The section name. */
572 const char *name;
574 /* This is either (unsigned int) -1, indicating that the section
575 name must match exactly, or it is the number of letters which
576 must match at the start of the name. */
577 unsigned int comparison_length;
579 /* These macros may be used to fill in the first two fields in a
580 structure initialization. */
581 #define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1)
582 #define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1)
584 /* Only use this entry if the default section alignment for this
585 target is at least that much (as a power of two). If this field
586 is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */
587 unsigned int default_alignment_min;
589 /* Only use this entry if the default section alignment for this
590 target is no greater than this (as a power of two). If this
591 field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */
592 unsigned int default_alignment_max;
594 #define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1)
596 /* The desired alignment for this section (as a power of two). */
597 unsigned int alignment_power;
600 extern struct bfd_hash_entry *_decoration_hash_newfunc
601 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
602 extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
603 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
604 extern bool _bfd_coff_link_hash_table_init
605 (struct coff_link_hash_table *, bfd *,
606 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
607 struct bfd_hash_table *,
608 const char *),
609 unsigned int);
610 extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
611 (bfd *);
612 extern const char *_bfd_coff_internal_syment_name
613 (bfd *, const struct internal_syment *, char *);
614 extern bool _bfd_coff_section_already_linked
615 (bfd *, asection *, struct bfd_link_info *);
616 extern bool _bfd_coff_link_add_symbols
617 (bfd *, struct bfd_link_info *);
618 extern bool _bfd_coff_final_link
619 (bfd *, struct bfd_link_info *);
620 extern struct internal_reloc *_bfd_coff_read_internal_relocs
621 (bfd *, asection *, bool, bfd_byte *, bool,
622 struct internal_reloc *);
623 extern bool _bfd_coff_generic_relocate_section
624 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
625 struct internal_reloc *, struct internal_syment *, asection **);
626 extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
627 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
628 extern bool _bfd_coff_write_global_sym
629 (struct bfd_hash_entry *, void *);
630 extern bool _bfd_coff_write_task_globals
631 (struct coff_link_hash_entry *, void *);
632 extern bool _bfd_coff_link_input_bfd
633 (struct coff_final_link_info *, bfd *);
634 extern bool _bfd_coff_reloc_link_order
635 (bfd *, struct coff_final_link_info *, asection *,
636 struct bfd_link_order *);
637 extern bool bfd_coff_gc_sections
638 (bfd *, struct bfd_link_info *);
639 extern const char *bfd_coff_group_name
640 (bfd *, const asection *);
642 #define coff_get_section_contents_in_window \
643 _bfd_generic_get_section_contents_in_window
645 /* Functions in xcofflink.c. */
647 extern long _bfd_xcoff_get_dynamic_symtab_upper_bound
648 (bfd *);
649 extern long _bfd_xcoff_canonicalize_dynamic_symtab
650 (bfd *, asymbol **);
651 extern long _bfd_xcoff_get_dynamic_reloc_upper_bound
652 (bfd *);
653 extern long _bfd_xcoff_canonicalize_dynamic_reloc
654 (bfd *, arelent **, asymbol **);
655 extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
656 (bfd *);
657 extern bool _bfd_xcoff_bfd_link_add_symbols
658 (bfd *, struct bfd_link_info *);
659 extern bool _bfd_xcoff_bfd_final_link
660 (bfd *, struct bfd_link_info *);
661 extern bool _bfd_xcoff_define_common_symbol
662 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
663 extern bool _bfd_ppc_xcoff_relocate_section
664 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
665 struct internal_reloc *, struct internal_syment *, asection **);
666 /* Extracted from coffcode.h. */
667 typedef struct coff_ptr_struct
669 /* Remembers the offset from the first symbol in the file for
670 this symbol. Generated by coff_renumber_symbols. */
671 unsigned int offset;
673 /* Selects between the elements of the union below. */
674 unsigned int is_sym : 1;
676 /* Selects between the elements of the x_sym.x_tagndx union. If set,
677 p is valid and the field will be renumbered. */
678 unsigned int fix_tag : 1;
680 /* Selects between the elements of the x_sym.x_fcnary.x_fcn.x_endndx
681 union. If set, p is valid and the field will be renumbered. */
682 unsigned int fix_end : 1;
684 /* Selects between the elements of the x_csect.x_scnlen union. If set,
685 p is valid and the field will be renumbered. */
686 unsigned int fix_scnlen : 1;
688 /* If set, u.syment.n_value contains a pointer to a symbol. The final
689 value will be the offset field. Used for XCOFF C_BSTAT symbols. */
690 unsigned int fix_value : 1;
692 /* If set, u.syment.n_value is an index into the line number entries.
693 Used for XCOFF C_BINCL/C_EINCL symbols. */
694 unsigned int fix_line : 1;
696 /* The container for the symbol structure as read and translated
697 from the file. */
698 union
700 union internal_auxent auxent;
701 struct internal_syment syment;
702 } u;
704 /* An extra pointer which can used by format based on COFF (like XCOFF)
705 to provide extra information to their backend. */
706 void *extrap;
707 } combined_entry_type;
709 /* Each canonical asymbol really looks like this: */
711 typedef struct coff_symbol_struct
713 /* The actual symbol which the rest of BFD works with */
714 asymbol symbol;
716 /* A pointer to the hidden information for this symbol */
717 combined_entry_type *native;
719 /* A pointer to the linenumber information for this symbol */
720 struct lineno_cache_entry *lineno;
722 /* Have the line numbers been relocated yet ? */
723 bool done_lineno;
724 } coff_symbol_type;
726 /* COFF symbol classifications. */
728 enum coff_symbol_classification
730 /* Global symbol. */
731 COFF_SYMBOL_GLOBAL,
732 /* Common symbol. */
733 COFF_SYMBOL_COMMON,
734 /* Undefined symbol. */
735 COFF_SYMBOL_UNDEFINED,
736 /* Local symbol. */
737 COFF_SYMBOL_LOCAL,
738 /* PE section symbol. */
739 COFF_SYMBOL_PE_SECTION
742 typedef asection * (*coff_gc_mark_hook_fn)
743 (asection *, struct bfd_link_info *, struct internal_reloc *,
744 struct coff_link_hash_entry *, struct internal_syment *);
746 typedef struct
748 void (*_bfd_coff_swap_aux_in)
749 (bfd *, void *, int, int, int, int, void *);
751 void (*_bfd_coff_swap_sym_in)
752 (bfd *, void *, void *);
754 void (*_bfd_coff_swap_lineno_in)
755 (bfd *, void *, void *);
757 unsigned int (*_bfd_coff_swap_aux_out)
758 (bfd *, void *, int, int, int, int, void *);
760 unsigned int (*_bfd_coff_swap_sym_out)
761 (bfd *, void *, void *);
763 unsigned int (*_bfd_coff_swap_lineno_out)
764 (bfd *, void *, void *);
766 unsigned int (*_bfd_coff_swap_reloc_out)
767 (bfd *, void *, void *);
769 unsigned int (*_bfd_coff_swap_filehdr_out)
770 (bfd *, void *, void *);
772 unsigned int (*_bfd_coff_swap_aouthdr_out)
773 (bfd *, void *, void *);
775 unsigned int (*_bfd_coff_swap_scnhdr_out)
776 (bfd *, void *, void *);
778 unsigned int _bfd_filhsz;
779 unsigned int _bfd_aoutsz;
780 unsigned int _bfd_scnhsz;
781 unsigned int _bfd_symesz;
782 unsigned int _bfd_auxesz;
783 unsigned int _bfd_relsz;
784 unsigned int _bfd_linesz;
785 unsigned int _bfd_filnmlen;
786 bool _bfd_coff_long_filenames;
788 bool _bfd_coff_long_section_names;
789 bool (*_bfd_coff_set_long_section_names)
790 (bfd *, int);
792 unsigned int _bfd_coff_default_section_alignment_power;
793 bool _bfd_coff_force_symnames_in_strings;
794 unsigned int _bfd_coff_debug_string_prefix_length;
795 unsigned int _bfd_coff_max_nscns;
797 void (*_bfd_coff_swap_filehdr_in)
798 (bfd *, void *, void *);
800 void (*_bfd_coff_swap_aouthdr_in)
801 (bfd *, void *, void *);
803 void (*_bfd_coff_swap_scnhdr_in)
804 (bfd *, void *, void *);
806 void (*_bfd_coff_swap_reloc_in)
807 (bfd *abfd, void *, void *);
809 bool (*_bfd_coff_bad_format_hook)
810 (bfd *, void *);
812 bool (*_bfd_coff_set_arch_mach_hook)
813 (bfd *, void *);
815 void * (*_bfd_coff_mkobject_hook)
816 (bfd *, void *, void *);
818 bool (*_bfd_styp_to_sec_flags_hook)
819 (bfd *, void *, const char *, asection *, flagword *);
821 void (*_bfd_set_alignment_hook)
822 (bfd *, asection *, void *);
824 bool (*_bfd_coff_slurp_symbol_table)
825 (bfd *);
827 bool (*_bfd_coff_symname_in_debug)
828 (bfd *, struct internal_syment *);
830 bool (*_bfd_coff_pointerize_aux_hook)
831 (bfd *, combined_entry_type *, combined_entry_type *,
832 unsigned int, combined_entry_type *);
834 bool (*_bfd_coff_print_aux)
835 (bfd *, FILE *, combined_entry_type *, combined_entry_type *,
836 combined_entry_type *, unsigned int);
838 bool (*_bfd_coff_reloc16_extra_cases)
839 (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
840 bfd_byte *, size_t *, size_t *);
842 int (*_bfd_coff_reloc16_estimate)
843 (bfd *, asection *, arelent *, unsigned int,
844 struct bfd_link_info *);
846 enum coff_symbol_classification (*_bfd_coff_classify_symbol)
847 (bfd *, struct internal_syment *);
849 bool (*_bfd_coff_compute_section_file_positions)
850 (bfd *);
852 bool (*_bfd_coff_start_final_link)
853 (bfd *, struct bfd_link_info *);
855 bool (*_bfd_coff_relocate_section)
856 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
857 struct internal_reloc *, struct internal_syment *, asection **);
859 reloc_howto_type *(*_bfd_coff_rtype_to_howto)
860 (bfd *, asection *, struct internal_reloc *,
861 struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *);
863 bool (*_bfd_coff_adjust_symndx)
864 (bfd *, struct bfd_link_info *, bfd *, asection *,
865 struct internal_reloc *, bool *);
867 bool (*_bfd_coff_link_add_one_symbol)
868 (struct bfd_link_info *, bfd *, const char *, flagword,
869 asection *, bfd_vma, const char *, bool, bool,
870 struct bfd_link_hash_entry **);
872 bool (*_bfd_coff_link_output_has_begun)
873 (bfd *, struct coff_final_link_info *);
875 bool (*_bfd_coff_final_link_postscript)
876 (bfd *, struct coff_final_link_info *);
878 bool (*_bfd_coff_print_pdata)
879 (bfd *, void *);
881 } bfd_coff_backend_data;
883 #define coff_backend_info(abfd) \
884 ((const bfd_coff_backend_data *) (abfd)->xvec->backend_data)
886 #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
887 ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
889 #define bfd_coff_swap_sym_in(a,e,i) \
890 ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
892 #define bfd_coff_swap_lineno_in(a,e,i) \
893 ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
895 #define bfd_coff_swap_reloc_out(abfd, i, o) \
896 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
898 #define bfd_coff_swap_lineno_out(abfd, i, o) \
899 ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
901 #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
902 ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
904 #define bfd_coff_swap_sym_out(abfd, i,o) \
905 ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
907 #define bfd_coff_swap_scnhdr_out(abfd, i,o) \
908 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
910 #define bfd_coff_swap_filehdr_out(abfd, i,o) \
911 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
913 #define bfd_coff_swap_aouthdr_out(abfd, i,o) \
914 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
916 #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
917 #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
918 #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
919 #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
920 #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
921 #define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
922 #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
923 #define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
924 #define bfd_coff_long_filenames(abfd) \
925 (coff_backend_info (abfd)->_bfd_coff_long_filenames)
926 #define bfd_coff_long_section_names(abfd) \
927 (coff_data (abfd)->long_section_names)
928 #define bfd_coff_set_long_section_names(abfd, enable) \
929 ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable))
930 #define bfd_coff_default_section_alignment_power(abfd) \
931 (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
932 #define bfd_coff_max_nscns(abfd) \
933 (coff_backend_info (abfd)->_bfd_coff_max_nscns)
935 #define bfd_coff_swap_filehdr_in(abfd, i,o) \
936 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
938 #define bfd_coff_swap_aouthdr_in(abfd, i,o) \
939 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
941 #define bfd_coff_swap_scnhdr_in(abfd, i,o) \
942 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
944 #define bfd_coff_swap_reloc_in(abfd, i, o) \
945 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
947 #define bfd_coff_bad_format_hook(abfd, filehdr) \
948 ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
950 #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
951 ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
952 #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
953 ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\
954 (abfd, filehdr, aouthdr))
956 #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
957 ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
958 (abfd, scnhdr, name, section, flags_ptr))
960 #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
961 ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
963 #define bfd_coff_slurp_symbol_table(abfd)\
964 ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
966 #define bfd_coff_symname_in_debug(abfd, sym)\
967 ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
969 #define bfd_coff_force_symnames_in_strings(abfd)\
970 (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
972 #define bfd_coff_debug_string_prefix_length(abfd)\
973 (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
975 #define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
976 ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
977 (abfd, file, base, symbol, aux, indaux))
979 #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\
980 reloc, data, src_ptr, dst_ptr)\
981 ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
982 (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
984 #define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
985 ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
986 (abfd, section, reloc, shrink, link_info))
988 #define bfd_coff_classify_symbol(abfd, sym)\
989 ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
990 (abfd, sym))
992 #define bfd_coff_compute_section_file_positions(abfd)\
993 ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
994 (abfd))
996 #define bfd_coff_start_final_link(obfd, info)\
997 ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
998 (obfd, info))
999 #define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
1000 ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
1001 (obfd, info, ibfd, o, con, rel, isyms, secs))
1002 #define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
1003 ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
1004 (abfd, sec, rel, h, sym, addendp))
1005 #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
1006 ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
1007 (obfd, info, ibfd, sec, rel, adjustedp))
1008 #define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
1009 value, string, cp, coll, hashp)\
1010 ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
1011 (info, abfd, name, flags, section, value, string, cp, coll, hashp))
1013 #define bfd_coff_link_output_has_begun(a,p) \
1014 ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p))
1015 #define bfd_coff_final_link_postscript(a,p) \
1016 ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a, p))
1018 #define bfd_coff_have_print_pdata(a) \
1019 (coff_backend_info (a)->_bfd_coff_print_pdata)
1020 #define bfd_coff_print_pdata(a,p) \
1021 ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p))
1023 /* Macro: Returns true if the bfd is a PE executable as opposed to a
1024 PE object file. */
1025 #define bfd_pei_p(abfd) \
1026 (startswith ((abfd)->xvec->name, "pei-"))
1027 #ifdef __cplusplus
1029 #endif
1030 #endif