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. */
4
5 /* BFD COFF object file private structure.
6 Copyright (C) 1990-2023 Free Software Foundation, Inc.
7 Written by Cygnus Support.
8
9 This file is part of BFD, the Binary File Descriptor library.
10
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.
15
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.
20
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. */
25
26 #ifndef _LIBCOFF_H
27 #define _LIBCOFF_H 1
28
29 #include "bfdlink.h"
30 #include "coff-bfd.h"
31 #include "hashtab.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 /* Object file tdata; access macros. */
38
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)
57
58 /* `Tdata' information kept for COFF files. */
59
60 typedef struct coff_tdata
61 {
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;
66
67 struct coff_ptr_struct *raw_syments;
68 unsigned long raw_syment_count;
69
70 /* These are only valid once writing has begun. */
71 unsigned long int relocbase;
72
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;
83
84 /* The unswapped external symbols. May be NULL. Read by
85 _bfd_coff_get_external_symbols. */
86 void * external_syms;
87
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;
93
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;
97
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;
104
105 /* Is this a GO32 coff file? */
106 bool go32;
107
108 /* Is this a PE format coff file? */
109 bool pe;
110
111 /* Copy of some of the f_flags bits in the COFF filehdr structure,
112 used by ARM code. */
113 flagword flags;
114
115 /* Used by the COFF backend linker. */
116 struct coff_link_hash_entry **sym_hashes;
117
118 /* Used by the pe linker for PowerPC. */
119 int *local_toc_sym_map;
120
121 struct bfd_link_info *link_info;
122
123 /* Used by coff_find_nearest_line. */
124 void * line_info;
125
126 /* A place to stash dwarf2 info for this bfd. */
127 void * dwarf2_find_line_info;
128
129 /* The timestamp from the COFF file header. */
130 long timestamp;
131
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;
137
138 /* Hash table containing sections by target index. */
139 htab_t section_by_target_index;
140
141 /* Hash table containing sections by index. */
142 htab_t section_by_index;
143
144 } coff_data_type;
145
146 /* Tdata for pe image files. */
147 typedef struct pe_tdata
148 {
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 int dos_message[16];
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;
160
161 /* Build-id info. */
162 struct
163 {
164 bool (*after_write_object_contents) (bfd *);
165 const char *style;
166 asection *sec;
167 } build_id;
168 } pe_data_type;
169
170 #define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
171
172 /* Tdata for XCOFF files. */
173
174 struct xcoff_tdata
175 {
176 /* Basic COFF information. */
177 coff_data_type coff;
178
179 /* TRUE if this is an XCOFF64 file. */
180 bool xcoff64;
181
182 /* TRUE if a large a.out header should be generated. */
183 bool full_aouthdr;
184
185 /* TOC value. */
186 bfd_vma toc;
187
188 /* Index of section holding TOC. */
189 int sntoc;
190
191 /* Index of section holding entry point. */
192 int snentry;
193
194 /* .text alignment from optional header. */
195 int text_align_power;
196
197 /* .data alignment from optional header. */
198 int data_align_power;
199
200 /* modtype from optional header. */
201 short modtype;
202
203 /* cputype from optional header. */
204 short cputype;
205
206 /* maxdata from optional header. */
207 bfd_vma maxdata;
208
209 /* maxstack from optional header. */
210 bfd_vma maxstack;
211
212 /* Used by the XCOFF backend linker. */
213 asection **csects;
214 long *debug_indices;
215 unsigned int *lineno_counts;
216 unsigned int import_file_id;
217 };
218
219 #define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
220
221 /* We take the address of the first element of an asymbol to ensure that the
222 macro is only ever applied to an asymbol. */
223 #define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
224
225 /* Tdata for sections in XCOFF files. This is used by the linker. */
226
227 struct xcoff_section_tdata
228 {
229 /* Used for XCOFF csects created by the linker; points to the real
230 XCOFF section which contains this csect. */
231 asection *enclosing;
232 /* The lineno_count field for the enclosing section, because we are
233 going to clobber it there. */
234 unsigned int lineno_count;
235 /* The first and last symbol indices for symbols used by this csect. */
236 unsigned long first_symndx;
237 unsigned long last_symndx;
238 };
239
240 /* An accessor macro the xcoff_section_tdata structure. */
241 #define xcoff_section_data(abfd, sec) \
242 ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
243
244 /* Tdata for sections in PE files. */
245
246 struct pei_section_tdata
247 {
248 /* The virtual size of the section. */
249 bfd_size_type virt_size;
250 /* The PE section flags. */
251 long pe_flags;
252 };
253
254 /* An accessor macro for the pei_section_tdata structure. */
255 #define pei_section_data(abfd, sec) \
256 ((struct pei_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
257
258 /* COFF linker hash table entries. */
259
260 struct coff_link_hash_entry
261 {
262 struct bfd_link_hash_entry root;
263
264 /* Symbol index in output file. This is initialized to -1. It is
265 set to -2 if the symbol is used by a reloc. It is set to -3 if
266 this symbol is defined in a discarded section. */
267 long indx;
268
269 /* Symbol type. */
270 unsigned short type;
271
272 /* Symbol class. */
273 unsigned char symbol_class;
274
275 /* Number of auxiliary entries. */
276 char numaux;
277
278 /* BFD to take auxiliary entries from. */
279 bfd *auxbfd;
280
281 /* Pointer to array of auxiliary entries, if any. */
282 union internal_auxent *aux;
283
284 /* Flag word; legal values follow. */
285 unsigned short coff_link_hash_flags;
286 /* Symbol is a PE section symbol. */
287 #define COFF_LINK_HASH_PE_SECTION_SYMBOL (01)
288 };
289
290 /* COFF linker hash table. */
291
292 struct coff_link_hash_table
293 {
294 struct bfd_link_hash_table root;
295 /* A pointer to information used to link stabs in sections. */
296 struct stab_info stab_info;
297 /* Hash table that maps undecorated names to their respective
298 * decorated coff_link_hash_entry as found in fixup_stdcalls */
299 struct bfd_hash_table decoration_hash;
300 };
301
302 struct coff_reloc_cookie
303 {
304 struct internal_reloc * rels;
305 struct internal_reloc * rel;
306 struct internal_reloc * relend;
307 struct coff_symbol_struct * symbols; /* Symtab for input bfd. */
308 bfd * abfd;
309 struct coff_link_hash_entry ** sym_hashes;
310 };
311
312 /* Look up an entry in a COFF linker hash table. */
313
314 #define coff_link_hash_lookup(table, string, create, copy, follow) \
315 ((struct coff_link_hash_entry *) \
316 bfd_link_hash_lookup (&(table)->root, (string), (create), \
317 (copy), (follow)))
318
319 /* Traverse a COFF linker hash table. */
320
321 #define coff_link_hash_traverse(table, func, info) \
322 (bfd_link_hash_traverse \
323 (&(table)->root, \
324 (bool (*) (struct bfd_link_hash_entry *, void *)) (func), \
325 (info)))
326
327 /* Get the COFF linker hash table from a link_info structure. */
328
329 #define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
330
331 struct decoration_hash_entry
332 {
333 struct bfd_hash_entry root;
334 struct bfd_link_hash_entry *decorated_link;
335 };
336
337 /* Functions in coffgen.c. */
338 extern void coff_object_cleanup
339 (bfd *);
340 extern bfd_cleanup coff_real_object_p
341 (bfd *, unsigned, struct internal_filehdr *, struct internal_aouthdr *);
342 extern bfd_cleanup coff_object_p
343 (bfd *);
344 extern struct bfd_section *coff_section_from_bfd_index
345 (bfd *, int);
346 extern long coff_get_symtab_upper_bound
347 (bfd *);
348 extern long coff_canonicalize_symtab
349 (bfd *, asymbol **);
350 extern int coff_count_linenumbers
351 (bfd *);
352 extern bool coff_renumber_symbols
353 (bfd *, int *);
354 extern void coff_mangle_symbols
355 (bfd *);
356 extern bool coff_write_symbols
357 (bfd *);
358 extern bool coff_write_alien_symbol
359 (bfd *, asymbol *, struct internal_syment *, bfd_vma *,
360 struct bfd_strtab_hash *, bool, asection **, bfd_size_type *);
361 extern bool coff_write_linenumbers
362 (bfd *);
363 extern alent *coff_get_lineno
364 (bfd *, asymbol *);
365 extern asymbol *coff_section_symbol
366 (bfd *, char *);
367 extern bool _bfd_coff_get_external_symbols
368 (bfd *);
369 extern const char *_bfd_coff_read_string_table
370 (bfd *);
371 extern bool _bfd_coff_free_symbols
372 (bfd *);
373 extern struct coff_ptr_struct *coff_get_normalized_symtab
374 (bfd *);
375 extern long coff_get_reloc_upper_bound
376 (bfd *, sec_ptr);
377 extern asymbol *coff_make_empty_symbol
378 (bfd *);
379 extern void coff_print_symbol
380 (bfd *, void * filep, asymbol *, bfd_print_symbol_type);
381 extern void coff_get_symbol_info
382 (bfd *, asymbol *, symbol_info *ret);
383 #define coff_get_symbol_version_string \
384 _bfd_nosymbols_get_symbol_version_string
385 extern bool _bfd_coff_is_local_label_name
386 (bfd *, const char *);
387 extern asymbol *coff_bfd_make_debug_symbol
388 (bfd *);
389 extern bool coff_find_nearest_line
390 (bfd *, asymbol **, asection *, bfd_vma,
391 const char **, const char **, unsigned int *, unsigned int *);
392 #define coff_find_nearest_line_with_alt \
393 _bfd_nosymbols_find_nearest_line_with_alt
394 #define coff_find_line _bfd_nosymbols_find_line
395 struct dwarf_debug_section;
396 extern bool coff_find_nearest_line_with_names
397 (bfd *, asymbol **, asection *, bfd_vma, const char **, const char **,
398 unsigned int *, const struct dwarf_debug_section *);
399 extern bool coff_find_inliner_info
400 (bfd *, const char **, const char **, unsigned int *);
401 extern int coff_sizeof_headers
402 (bfd *, struct bfd_link_info *);
403 extern bool bfd_coff_reloc16_relax_section
404 (bfd *, asection *, struct bfd_link_info *, bool *);
405 extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
406 (bfd *, struct bfd_link_info *, struct bfd_link_order *,
407 bfd_byte *, bool, asymbol **);
408 extern bfd_vma bfd_coff_reloc16_get_value
409 (arelent *, struct bfd_link_info *, asection *);
410 extern void bfd_perform_slip
411 (bfd *, unsigned int, asection *, bfd_vma);
412 extern bool _bfd_coff_free_cached_info
413 (bfd *);
414
415 /* Functions and types in cofflink.c. */
416
417 #define STRING_SIZE_SIZE 4
418
419 /* We use a hash table to merge identical enum, struct, and union
420 definitions in the linker. */
421
422 /* Information we keep for a single element (an enum value, a
423 structure or union field) in the debug merge hash table. */
424
425 struct coff_debug_merge_element
426 {
427 /* Next element. */
428 struct coff_debug_merge_element *next;
429
430 /* Name. */
431 const char *name;
432
433 /* Type. */
434 unsigned int type;
435
436 /* Symbol index for complex type. */
437 long tagndx;
438 };
439
440 /* A linked list of debug merge entries for a given name. */
441
442 struct coff_debug_merge_type
443 {
444 /* Next type with the same name. */
445 struct coff_debug_merge_type *next;
446
447 /* Class of type. */
448 int type_class;
449
450 /* Symbol index where this type is defined. */
451 long indx;
452
453 /* List of elements. */
454 struct coff_debug_merge_element *elements;
455 };
456
457 /* Information we store in the debug merge hash table. */
458
459 struct coff_debug_merge_hash_entry
460 {
461 struct bfd_hash_entry root;
462
463 /* A list of types with this name. */
464 struct coff_debug_merge_type *types;
465 };
466
467 /* The debug merge hash table. */
468
469 struct coff_debug_merge_hash_table
470 {
471 struct bfd_hash_table root;
472 };
473
474 /* Initialize a COFF debug merge hash table. */
475
476 #define coff_debug_merge_hash_table_init(table) \
477 (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \
478 sizeof (struct coff_debug_merge_hash_entry)))
479
480 /* Free a COFF debug merge hash table. */
481
482 #define coff_debug_merge_hash_table_free(table) \
483 (bfd_hash_table_free (&(table)->root))
484
485 /* Look up an entry in a COFF debug merge hash table. */
486
487 #define coff_debug_merge_hash_lookup(table, string, create, copy) \
488 ((struct coff_debug_merge_hash_entry *) \
489 bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
490
491 /* Information we keep for each section in the output file when doing
492 a relocatable link. */
493
494 struct coff_link_section_info
495 {
496 /* The relocs to be output. */
497 struct internal_reloc *relocs;
498 /* For each reloc against a global symbol whose index was not known
499 when the reloc was handled, the global hash table entry. */
500 struct coff_link_hash_entry **rel_hashes;
501 };
502
503 /* Information that we pass around while doing the final link step. */
504
505 struct coff_final_link_info
506 {
507 /* General link information. */
508 struct bfd_link_info *info;
509 /* Output BFD. */
510 bfd *output_bfd;
511 /* Used to indicate failure in traversal routine. */
512 bool failed;
513 /* If doing "task linking" set only during the time when we want the
514 global symbol writer to convert the storage class of defined global
515 symbols from global to static. */
516 bool global_to_static;
517 /* Hash table for long symbol names. */
518 struct bfd_strtab_hash *strtab;
519 /* When doing a relocatable link, an array of information kept for
520 each output section, indexed by the target_index field. */
521 struct coff_link_section_info *section_info;
522 /* Symbol index of last C_FILE symbol (-1 if none). */
523 long last_file_index;
524 /* Contents of last C_FILE symbol. */
525 struct internal_syment last_file;
526 /* Symbol index of first aux entry of last .bf symbol with an empty
527 endndx field (-1 if none). */
528 long last_bf_index;
529 /* Contents of last_bf_index aux entry. */
530 union internal_auxent last_bf;
531 /* Hash table used to merge debug information. */
532 struct coff_debug_merge_hash_table debug_merge;
533 /* Buffer large enough to hold swapped symbols of any input file. */
534 struct internal_syment *internal_syms;
535 /* Buffer large enough to hold sections of symbols of any input file. */
536 asection **sec_ptrs;
537 /* Buffer large enough to hold output indices of symbols of any
538 input file. */
539 long *sym_indices;
540 /* Buffer large enough to hold output symbols for any input file. */
541 bfd_byte *outsyms;
542 /* Buffer large enough to hold external line numbers for any input
543 section. */
544 bfd_byte *linenos;
545 /* Buffer large enough to hold any input section. */
546 bfd_byte *contents;
547 /* Buffer large enough to hold external relocs of any input section. */
548 bfd_byte *external_relocs;
549 /* Buffer large enough to hold swapped relocs of any input section. */
550 struct internal_reloc *internal_relocs;
551 };
552
553 /* Most COFF variants have no way to record the alignment of a
554 section. This struct is used to set a specific alignment based on
555 the name of the section. */
556
557 struct coff_section_alignment_entry
558 {
559 /* The section name. */
560 const char *name;
561
562 /* This is either (unsigned int) -1, indicating that the section
563 name must match exactly, or it is the number of letters which
564 must match at the start of the name. */
565 unsigned int comparison_length;
566
567 /* These macros may be used to fill in the first two fields in a
568 structure initialization. */
569 #define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1)
570 #define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1)
571
572 /* Only use this entry if the default section alignment for this
573 target is at least that much (as a power of two). If this field
574 is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */
575 unsigned int default_alignment_min;
576
577 /* Only use this entry if the default section alignment for this
578 target is no greater than this (as a power of two). If this
579 field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored. */
580 unsigned int default_alignment_max;
581
582 #define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1)
583
584 /* The desired alignment for this section (as a power of two). */
585 unsigned int alignment_power;
586 };
587
588 extern struct bfd_hash_entry *_decoration_hash_newfunc
589 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
590 extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
591 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
592 extern bool _bfd_coff_link_hash_table_init
593 (struct coff_link_hash_table *, bfd *,
594 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
595 struct bfd_hash_table *,
596 const char *),
597 unsigned int);
598 extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
599 (bfd *);
600 extern const char *_bfd_coff_internal_syment_name
601 (bfd *, const struct internal_syment *, char *);
602 extern bool _bfd_coff_section_already_linked
603 (bfd *, asection *, struct bfd_link_info *);
604 extern bool _bfd_coff_link_add_symbols
605 (bfd *, struct bfd_link_info *);
606 extern bool _bfd_coff_final_link
607 (bfd *, struct bfd_link_info *);
608 extern struct internal_reloc *_bfd_coff_read_internal_relocs
609 (bfd *, asection *, bool, bfd_byte *, bool,
610 struct internal_reloc *);
611 extern bool _bfd_coff_generic_relocate_section
612 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
613 struct internal_reloc *, struct internal_syment *, asection **);
614 extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
615 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
616 extern bool _bfd_coff_write_global_sym
617 (struct bfd_hash_entry *, void *);
618 extern bool _bfd_coff_write_task_globals
619 (struct coff_link_hash_entry *, void *);
620 extern bool _bfd_coff_link_input_bfd
621 (struct coff_final_link_info *, bfd *);
622 extern bool _bfd_coff_reloc_link_order
623 (bfd *, struct coff_final_link_info *, asection *,
624 struct bfd_link_order *);
625 extern bool bfd_coff_gc_sections
626 (bfd *, struct bfd_link_info *);
627 extern const char *bfd_coff_group_name
628 (bfd *, const asection *);
629
630 #define coff_get_section_contents_in_window \
631 _bfd_generic_get_section_contents_in_window
632
633 /* Functions in xcofflink.c. */
634
635 extern long _bfd_xcoff_get_dynamic_symtab_upper_bound
636 (bfd *);
637 extern long _bfd_xcoff_canonicalize_dynamic_symtab
638 (bfd *, asymbol **);
639 extern long _bfd_xcoff_get_dynamic_reloc_upper_bound
640 (bfd *);
641 extern long _bfd_xcoff_canonicalize_dynamic_reloc
642 (bfd *, arelent **, asymbol **);
643 extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
644 (bfd *);
645 extern bool _bfd_xcoff_bfd_link_add_symbols
646 (bfd *, struct bfd_link_info *);
647 extern bool _bfd_xcoff_bfd_final_link
648 (bfd *, struct bfd_link_info *);
649 extern bool _bfd_xcoff_define_common_symbol
650 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
651 extern bool _bfd_ppc_xcoff_relocate_section
652 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
653 struct internal_reloc *, struct internal_syment *, asection **);
654 /* Extracted from coffcode.h. */
655 typedef struct coff_ptr_struct
656 {
657 /* Remembers the offset from the first symbol in the file for
658 this symbol. Generated by coff_renumber_symbols. */
659 unsigned int offset;
660
661 /* Selects between the elements of the union below. */
662 unsigned int is_sym : 1;
663
664 /* Selects between the elements of the x_sym.x_tagndx union. If set,
665 p is valid and the field will be renumbered. */
666 unsigned int fix_tag : 1;
667
668 /* Selects between the elements of the x_sym.x_fcnary.x_fcn.x_endndx
669 union. If set, p is valid and the field will be renumbered. */
670 unsigned int fix_end : 1;
671
672 /* Selects between the elements of the x_csect.x_scnlen union. If set,
673 p is valid and the field will be renumbered. */
674 unsigned int fix_scnlen : 1;
675
676 /* If set, u.syment.n_value contains a pointer to a symbol. The final
677 value will be the offset field. Used for XCOFF C_BSTAT symbols. */
678 unsigned int fix_value : 1;
679
680 /* If set, u.syment.n_value is an index into the line number entries.
681 Used for XCOFF C_BINCL/C_EINCL symbols. */
682 unsigned int fix_line : 1;
683
684 /* The container for the symbol structure as read and translated
685 from the file. */
686 union
687 {
688 union internal_auxent auxent;
689 struct internal_syment syment;
690 } u;
691
692 /* An extra pointer which can used by format based on COFF (like XCOFF)
693 to provide extra information to their backend. */
694 void *extrap;
695 } combined_entry_type;
696
697 /* Each canonical asymbol really looks like this: */
698
699 typedef struct coff_symbol_struct
700 {
701 /* The actual symbol which the rest of BFD works with */
702 asymbol symbol;
703
704 /* A pointer to the hidden information for this symbol */
705 combined_entry_type *native;
706
707 /* A pointer to the linenumber information for this symbol */
708 struct lineno_cache_entry *lineno;
709
710 /* Have the line numbers been relocated yet ? */
711 bool done_lineno;
712 } coff_symbol_type;
713
714 /* COFF symbol classifications. */
715
716 enum coff_symbol_classification
717 {
718 /* Global symbol. */
719 COFF_SYMBOL_GLOBAL,
720 /* Common symbol. */
721 COFF_SYMBOL_COMMON,
722 /* Undefined symbol. */
723 COFF_SYMBOL_UNDEFINED,
724 /* Local symbol. */
725 COFF_SYMBOL_LOCAL,
726 /* PE section symbol. */
727 COFF_SYMBOL_PE_SECTION
728 };
729
730 typedef asection * (*coff_gc_mark_hook_fn)
731 (asection *, struct bfd_link_info *, struct internal_reloc *,
732 struct coff_link_hash_entry *, struct internal_syment *);
733
734 typedef struct
735 {
736 void (*_bfd_coff_swap_aux_in)
737 (bfd *, void *, int, int, int, int, void *);
738
739 void (*_bfd_coff_swap_sym_in)
740 (bfd *, void *, void *);
741
742 void (*_bfd_coff_swap_lineno_in)
743 (bfd *, void *, void *);
744
745 unsigned int (*_bfd_coff_swap_aux_out)
746 (bfd *, void *, int, int, int, int, void *);
747
748 unsigned int (*_bfd_coff_swap_sym_out)
749 (bfd *, void *, void *);
750
751 unsigned int (*_bfd_coff_swap_lineno_out)
752 (bfd *, void *, void *);
753
754 unsigned int (*_bfd_coff_swap_reloc_out)
755 (bfd *, void *, void *);
756
757 unsigned int (*_bfd_coff_swap_filehdr_out)
758 (bfd *, void *, void *);
759
760 unsigned int (*_bfd_coff_swap_aouthdr_out)
761 (bfd *, void *, void *);
762
763 unsigned int (*_bfd_coff_swap_scnhdr_out)
764 (bfd *, void *, void *);
765
766 unsigned int _bfd_filhsz;
767 unsigned int _bfd_aoutsz;
768 unsigned int _bfd_scnhsz;
769 unsigned int _bfd_symesz;
770 unsigned int _bfd_auxesz;
771 unsigned int _bfd_relsz;
772 unsigned int _bfd_linesz;
773 unsigned int _bfd_filnmlen;
774 bool _bfd_coff_long_filenames;
775
776 bool _bfd_coff_long_section_names;
777 bool (*_bfd_coff_set_long_section_names)
778 (bfd *, int);
779
780 unsigned int _bfd_coff_default_section_alignment_power;
781 bool _bfd_coff_force_symnames_in_strings;
782 unsigned int _bfd_coff_debug_string_prefix_length;
783 unsigned int _bfd_coff_max_nscns;
784
785 void (*_bfd_coff_swap_filehdr_in)
786 (bfd *, void *, void *);
787
788 void (*_bfd_coff_swap_aouthdr_in)
789 (bfd *, void *, void *);
790
791 void (*_bfd_coff_swap_scnhdr_in)
792 (bfd *, void *, void *);
793
794 void (*_bfd_coff_swap_reloc_in)
795 (bfd *abfd, void *, void *);
796
797 bool (*_bfd_coff_bad_format_hook)
798 (bfd *, void *);
799
800 bool (*_bfd_coff_set_arch_mach_hook)
801 (bfd *, void *);
802
803 void * (*_bfd_coff_mkobject_hook)
804 (bfd *, void *, void *);
805
806 bool (*_bfd_styp_to_sec_flags_hook)
807 (bfd *, void *, const char *, asection *, flagword *);
808
809 void (*_bfd_set_alignment_hook)
810 (bfd *, asection *, void *);
811
812 bool (*_bfd_coff_slurp_symbol_table)
813 (bfd *);
814
815 bool (*_bfd_coff_symname_in_debug)
816 (bfd *, struct internal_syment *);
817
818 bool (*_bfd_coff_pointerize_aux_hook)
819 (bfd *, combined_entry_type *, combined_entry_type *,
820 unsigned int, combined_entry_type *);
821
822 bool (*_bfd_coff_print_aux)
823 (bfd *, FILE *, combined_entry_type *, combined_entry_type *,
824 combined_entry_type *, unsigned int);
825
826 bool (*_bfd_coff_reloc16_extra_cases)
827 (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
828 bfd_byte *, size_t *, size_t *);
829
830 int (*_bfd_coff_reloc16_estimate)
831 (bfd *, asection *, arelent *, unsigned int,
832 struct bfd_link_info *);
833
834 enum coff_symbol_classification (*_bfd_coff_classify_symbol)
835 (bfd *, struct internal_syment *);
836
837 bool (*_bfd_coff_compute_section_file_positions)
838 (bfd *);
839
840 bool (*_bfd_coff_start_final_link)
841 (bfd *, struct bfd_link_info *);
842
843 bool (*_bfd_coff_relocate_section)
844 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
845 struct internal_reloc *, struct internal_syment *, asection **);
846
847 reloc_howto_type *(*_bfd_coff_rtype_to_howto)
848 (bfd *, asection *, struct internal_reloc *,
849 struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *);
850
851 bool (*_bfd_coff_adjust_symndx)
852 (bfd *, struct bfd_link_info *, bfd *, asection *,
853 struct internal_reloc *, bool *);
854
855 bool (*_bfd_coff_link_add_one_symbol)
856 (struct bfd_link_info *, bfd *, const char *, flagword,
857 asection *, bfd_vma, const char *, bool, bool,
858 struct bfd_link_hash_entry **);
859
860 bool (*_bfd_coff_link_output_has_begun)
861 (bfd *, struct coff_final_link_info *);
862
863 bool (*_bfd_coff_final_link_postscript)
864 (bfd *, struct coff_final_link_info *);
865
866 bool (*_bfd_coff_print_pdata)
867 (bfd *, void *);
868
869 } bfd_coff_backend_data;
870
871 #define coff_backend_info(abfd) \
872 ((const bfd_coff_backend_data *) (abfd)->xvec->backend_data)
873
874 #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
875 ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
876
877 #define bfd_coff_swap_sym_in(a,e,i) \
878 ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
879
880 #define bfd_coff_swap_lineno_in(a,e,i) \
881 ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
882
883 #define bfd_coff_swap_reloc_out(abfd, i, o) \
884 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
885
886 #define bfd_coff_swap_lineno_out(abfd, i, o) \
887 ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
888
889 #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
890 ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
891
892 #define bfd_coff_swap_sym_out(abfd, i,o) \
893 ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
894
895 #define bfd_coff_swap_scnhdr_out(abfd, i,o) \
896 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
897
898 #define bfd_coff_swap_filehdr_out(abfd, i,o) \
899 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
900
901 #define bfd_coff_swap_aouthdr_out(abfd, i,o) \
902 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
903
904 #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
905 #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
906 #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
907 #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
908 #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
909 #define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
910 #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
911 #define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
912 #define bfd_coff_long_filenames(abfd) \
913 (coff_backend_info (abfd)->_bfd_coff_long_filenames)
914 #define bfd_coff_long_section_names(abfd) \
915 (coff_data (abfd)->long_section_names)
916 #define bfd_coff_set_long_section_names(abfd, enable) \
917 ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable))
918 #define bfd_coff_default_section_alignment_power(abfd) \
919 (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
920 #define bfd_coff_max_nscns(abfd) \
921 (coff_backend_info (abfd)->_bfd_coff_max_nscns)
922
923 #define bfd_coff_swap_filehdr_in(abfd, i,o) \
924 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
925
926 #define bfd_coff_swap_aouthdr_in(abfd, i,o) \
927 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
928
929 #define bfd_coff_swap_scnhdr_in(abfd, i,o) \
930 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
931
932 #define bfd_coff_swap_reloc_in(abfd, i, o) \
933 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
934
935 #define bfd_coff_bad_format_hook(abfd, filehdr) \
936 ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
937
938 #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
939 ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
940 #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
941 ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\
942 (abfd, filehdr, aouthdr))
943
944 #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
945 ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
946 (abfd, scnhdr, name, section, flags_ptr))
947
948 #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
949 ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
950
951 #define bfd_coff_slurp_symbol_table(abfd)\
952 ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
953
954 #define bfd_coff_symname_in_debug(abfd, sym)\
955 ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
956
957 #define bfd_coff_force_symnames_in_strings(abfd)\
958 (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
959
960 #define bfd_coff_debug_string_prefix_length(abfd)\
961 (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
962
963 #define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
964 ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
965 (abfd, file, base, symbol, aux, indaux))
966
967 #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\
968 reloc, data, src_ptr, dst_ptr)\
969 ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
970 (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
971
972 #define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
973 ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
974 (abfd, section, reloc, shrink, link_info))
975
976 #define bfd_coff_classify_symbol(abfd, sym)\
977 ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
978 (abfd, sym))
979
980 #define bfd_coff_compute_section_file_positions(abfd)\
981 ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
982 (abfd))
983
984 #define bfd_coff_start_final_link(obfd, info)\
985 ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
986 (obfd, info))
987 #define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
988 ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
989 (obfd, info, ibfd, o, con, rel, isyms, secs))
990 #define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
991 ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
992 (abfd, sec, rel, h, sym, addendp))
993 #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
994 ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
995 (obfd, info, ibfd, sec, rel, adjustedp))
996 #define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
997 value, string, cp, coll, hashp)\
998 ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
999 (info, abfd, name, flags, section, value, string, cp, coll, hashp))
1000
1001 #define bfd_coff_link_output_has_begun(a,p) \
1002 ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p))
1003 #define bfd_coff_final_link_postscript(a,p) \
1004 ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a, p))
1005
1006 #define bfd_coff_have_print_pdata(a) \
1007 (coff_backend_info (a)->_bfd_coff_print_pdata)
1008 #define bfd_coff_print_pdata(a,p) \
1009 ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p))
1010
1011 /* Macro: Returns true if the bfd is a PE executable as opposed to a
1012 PE object file. */
1013 #define bfd_pei_p(abfd) \
1014 (startswith ((abfd)->xvec->name, "pei-"))
1015 #ifdef __cplusplus
1016 }
1017 #endif
1018 #endif