]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/libcoff.h
Remove unused args from bfd_make_debug_symbol
[thirdparty/binutils-gdb.git] / bfd / libcoff.h
CommitLineData
07d6d2b8 1/* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically
59bc061d 2 generated from "libcoff-in.h" and "coffcode.h".
4eef72c7
AM
3 Run "make headers" in your build bfd/ to regenerate. */
4
252b5132 5/* BFD COFF object file private structure.
d87bef3a 6 Copyright (C) 1990-2023 Free Software Foundation, Inc.
252b5132
RH
7 Written by Cygnus Support.
8
7920ce38 9 This file is part of BFD, the Binary File Descriptor library.
252b5132 10
7920ce38
NC
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
cd123cb7 13 the Free Software Foundation; either version 3 of the License, or
7920ce38 14 (at your option) any later version.
252b5132 15
7920ce38
NC
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.
252b5132 20
7920ce38
NC
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
cd123cb7
NC
23 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
24 MA 02110-1301, USA. */
252b5132 25
0b439543
AM
26#ifndef _LIBCOFF_H
27#define _LIBCOFF_H 1
28
252b5132 29#include "bfdlink.h"
f4943d82 30#include "coff-bfd.h"
252b5132 31
55172d69
PA
32#ifdef __cplusplus
33extern "C" {
34#endif
35
7920ce38
NC
36/* Object file tdata; access macros. */
37
38#define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
07d6d2b8 39#define obj_pe(bfd) (coff_data (bfd)->pe)
f717994f 40#define obj_go32(bfd) (coff_data (bfd)->go32)
7920ce38 41#define obj_symbols(bfd) (coff_data (bfd)->symbols)
f717994f 42#define obj_sym_filepos(bfd) (coff_data (bfd)->sym_filepos)
7920ce38
NC
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)
5a3f568b 51#define obj_coff_strings_len(bfd) (coff_data (bfd)->strings_len)
7920ce38
NC
52#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
53#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
d71f672e 54#define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written)
7920ce38 55#define obj_coff_local_toc_table(bfd) (coff_data (bfd)->local_toc_sym_map)
252b5132
RH
56
57/* `Tdata' information kept for COFF files. */
58
59typedef struct coff_tdata
60{
7920ce38 61 struct coff_symbol_struct *symbols; /* Symtab for input bfd. */
252b5132
RH
62 unsigned int *conversion_table;
63 int conv_table_size;
64 file_ptr sym_filepos;
65
66 struct coff_ptr_struct *raw_syments;
00692651 67 unsigned long raw_syment_count;
252b5132 68
7920ce38 69 /* These are only valid once writing has begun. */
bad1a9f7 70 unsigned long int relocbase;
252b5132
RH
71
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;
82
83 /* The unswapped external symbols. May be NULL. Read by
84 _bfd_coff_get_external_symbols. */
7920ce38 85 void * external_syms;
252b5132
RH
86
87 /* The string table. May be NULL. Read by
88 _bfd_coff_read_string_table. */
89 char *strings;
5a3f568b
NC
90 /* The length of the strings table. For error checking. */
91 bfd_size_type strings_len;
22a95e1a
AM
92
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;
96
97 /* If this is TRUE, the external_syms may not be freed. */
98 bool keep_syms;
b34976b6 99 /* If this is TRUE, the strings may not be freed. */
0a1b45a2 100 bool keep_strings;
b34976b6 101 /* If this is TRUE, the strings have been written out already. */
0a1b45a2 102 bool strings_written;
252b5132 103
22a95e1a
AM
104 /* Is this a GO32 coff file? */
105 bool go32;
106
7920ce38 107 /* Is this a PE format coff file? */
10df41b1 108 bool pe;
22a95e1a
AM
109
110 /* Copy of some of the f_flags bits in the COFF filehdr structure,
111 used by ARM code. */
112 flagword flags;
113
252b5132
RH
114 /* Used by the COFF backend linker. */
115 struct coff_link_hash_entry **sym_hashes;
116
7920ce38 117 /* Used by the pe linker for PowerPC. */
252b5132
RH
118 int *local_toc_sym_map;
119
120 struct bfd_link_info *link_info;
121
122 /* Used by coff_find_nearest_line. */
7920ce38 123 void * line_info;
252b5132 124
7920ce38
NC
125 /* A place to stash dwarf2 info for this bfd. */
126 void * dwarf2_find_line_info;
51db3708 127
00692651
ILT
128 /* The timestamp from the COFF file header. */
129 long timestamp;
130
4d095f5b
JJ
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;
252b5132
RH
136} coff_data_type;
137
7920ce38 138/* Tdata for pe image files. */
252b5132
RH
139typedef struct pe_tdata
140{
141 coff_data_type coff;
142 struct internal_extra_pe_aouthdr pe_opthdr;
143 int dll;
144 int has_reloc_section;
441f34fa 145 int dont_strip_reloc;
70cf6834 146 int dos_message[16];
00386881
NC
147 /* The timestamp to insert into the output file.
148 If the timestamp is -1 then the current time is used. */
149 int timestamp;
0a1b45a2 150 bool (*in_reloc_p) (bfd *, reloc_howto_type *);
252b5132 151 flagword real_flags;
61e2488c 152
e30d16e9 153 /* Build-id info. */
61e2488c
JT
154 struct
155 {
0a1b45a2 156 bool (*after_write_object_contents) (bfd *);
61e2488c
JT
157 const char *style;
158 asection *sec;
159 } build_id;
252b5132
RH
160} pe_data_type;
161
162#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
163
164/* Tdata for XCOFF files. */
165
166struct xcoff_tdata
167{
168 /* Basic COFF information. */
169 coff_data_type coff;
170
b34976b6 171 /* TRUE if this is an XCOFF64 file. */
0a1b45a2 172 bool xcoff64;
a2fdf270 173
b34976b6 174 /* TRUE if a large a.out header should be generated. */
0a1b45a2 175 bool full_aouthdr;
252b5132
RH
176
177 /* TOC value. */
178 bfd_vma toc;
179
180 /* Index of section holding TOC. */
181 int sntoc;
182
183 /* Index of section holding entry point. */
184 int snentry;
185
186 /* .text alignment from optional header. */
187 int text_align_power;
188
189 /* .data alignment from optional header. */
190 int data_align_power;
191
192 /* modtype from optional header. */
193 short modtype;
194
195 /* cputype from optional header. */
196 short cputype;
197
198 /* maxdata from optional header. */
f34d8777 199 bfd_vma maxdata;
252b5132
RH
200
201 /* maxstack from optional header. */
f34d8777 202 bfd_vma maxstack;
252b5132
RH
203
204 /* Used by the XCOFF backend linker. */
205 asection **csects;
e450936a 206 long *debug_indices;
3df13c4a 207 unsigned int *lineno_counts;
252b5132
RH
208 unsigned int import_file_id;
209};
210
211#define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
212
08da05b0 213/* We take the address of the first element of an asymbol to ensure that the
7920ce38 214 macro is only ever applied to an asymbol. */
252b5132
RH
215#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
216
252b5132
RH
217/* Tdata for sections in XCOFF files. This is used by the linker. */
218
219struct xcoff_section_tdata
220{
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;
4cc02a02 227 /* The first and last symbol indices for symbols used by this csect. */
252b5132
RH
228 unsigned long first_symndx;
229 unsigned long last_symndx;
230};
231
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)
235
8d3ad4e1 236/* Tdata for sections in PE files. */
252b5132
RH
237
238struct pei_section_tdata
239{
240 /* The virtual size of the section. */
241 bfd_size_type virt_size;
8d3ad4e1
ILT
242 /* The PE section flags. */
243 long pe_flags;
252b5132
RH
244};
245
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)
249
250/* COFF linker hash table entries. */
251
252struct coff_link_hash_entry
253{
254 struct bfd_link_hash_entry root;
255
75cfe082
AM
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. */
252b5132
RH
259 long indx;
260
261 /* Symbol type. */
262 unsigned short type;
263
264 /* Symbol class. */
96d56e9f 265 unsigned char symbol_class;
252b5132
RH
266
267 /* Number of auxiliary entries. */
268 char numaux;
269
270 /* BFD to take auxiliary entries from. */
271 bfd *auxbfd;
272
273 /* Pointer to array of auxiliary entries, if any. */
274 union internal_auxent *aux;
7fd9c191
ILT
275
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)
252b5132
RH
280};
281
282/* COFF linker hash table. */
283
284struct coff_link_hash_table
285{
286 struct bfd_link_hash_table root;
287 /* A pointer to information used to link stabs in sections. */
3722b82f 288 struct stab_info stab_info;
252b5132
RH
289};
290
0f088b2a
KT
291struct coff_reloc_cookie
292{
07d6d2b8
AM
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;
0f088b2a
KT
298 struct coff_link_hash_entry ** sym_hashes;
299};
300
252b5132
RH
301/* Look up an entry in a COFF linker hash table. */
302
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)))
307
308/* Traverse a COFF linker hash table. */
309
310#define coff_link_hash_traverse(table, func, info) \
311 (bfd_link_hash_traverse \
312 (&(table)->root, \
0a1b45a2 313 (bool (*) (struct bfd_link_hash_entry *, void *)) (func), \
252b5132
RH
314 (info)))
315
316/* Get the COFF linker hash table from a link_info structure. */
317
318#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
319
320/* Functions in coffgen.c. */
cb001c0d 321extern bfd_cleanup coff_object_p
7920ce38 322 (bfd *);
198beae2 323extern struct bfd_section *coff_section_from_bfd_index
7920ce38 324 (bfd *, int);
dc810e39 325extern long coff_get_symtab_upper_bound
7920ce38 326 (bfd *);
6cee3f79 327extern long coff_canonicalize_symtab
7920ce38 328 (bfd *, asymbol **);
dc810e39 329extern int coff_count_linenumbers
7920ce38 330 (bfd *);
0a1b45a2 331extern bool coff_renumber_symbols
7920ce38 332 (bfd *, int *);
dc810e39 333extern void coff_mangle_symbols
7920ce38 334 (bfd *);
0a1b45a2 335extern bool coff_write_symbols
7920ce38 336 (bfd *);
0a1b45a2 337extern bool coff_write_alien_symbol
20bed3bb
JB
338 (bfd *, asymbol *, struct internal_syment *, bfd_vma *,
339 struct bfd_strtab_hash *, bool, asection **, bfd_size_type *);
0a1b45a2 340extern bool coff_write_linenumbers
7920ce38 341 (bfd *);
dc810e39 342extern alent *coff_get_lineno
7920ce38 343 (bfd *, asymbol *);
dc810e39 344extern asymbol *coff_section_symbol
7920ce38 345 (bfd *, char *);
0a1b45a2 346extern bool _bfd_coff_get_external_symbols
7920ce38 347 (bfd *);
dc810e39 348extern const char *_bfd_coff_read_string_table
7920ce38 349 (bfd *);
0a1b45a2 350extern bool _bfd_coff_free_symbols
7920ce38 351 (bfd *);
dc810e39 352extern struct coff_ptr_struct *coff_get_normalized_symtab
7920ce38 353 (bfd *);
dc810e39 354extern long coff_get_reloc_upper_bound
7920ce38 355 (bfd *, sec_ptr);
dc810e39 356extern asymbol *coff_make_empty_symbol
7920ce38 357 (bfd *);
dc810e39 358extern void coff_print_symbol
7920ce38 359 (bfd *, void * filep, asymbol *, bfd_print_symbol_type);
dc810e39 360extern void coff_get_symbol_info
7920ce38 361 (bfd *, asymbol *, symbol_info *ret);
60bb06bc
L
362#define coff_get_symbol_version_string \
363 _bfd_nosymbols_get_symbol_version_string
0a1b45a2 364extern bool _bfd_coff_is_local_label_name
7920ce38 365 (bfd *, const char *);
dc810e39 366extern asymbol *coff_bfd_make_debug_symbol
a0722319 367 (bfd *);
0a1b45a2 368extern bool coff_find_nearest_line
fb167eb2
AM
369 (bfd *, asymbol **, asection *, bfd_vma,
370 const char **, const char **, unsigned int *, unsigned int *);
6e7a29c7
AM
371#define coff_find_nearest_line_with_alt \
372 _bfd_nosymbols_find_nearest_line_with_alt
9c461f7d 373#define coff_find_line _bfd_nosymbols_find_line
fc28f9aa 374struct dwarf_debug_section;
0a1b45a2 375extern bool coff_find_nearest_line_with_names
fb167eb2
AM
376 (bfd *, asymbol **, asection *, bfd_vma, const char **, const char **,
377 unsigned int *, const struct dwarf_debug_section *);
0a1b45a2 378extern bool coff_find_inliner_info
4ab527b0 379 (bfd *, const char **, const char **, unsigned int *);
dc810e39 380extern int coff_sizeof_headers
a6b96beb 381 (bfd *, struct bfd_link_info *);
0a1b45a2
AM
382extern bool bfd_coff_reloc16_relax_section
383 (bfd *, asection *, struct bfd_link_info *, bool *);
252b5132 384extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
7920ce38 385 (bfd *, struct bfd_link_info *, struct bfd_link_order *,
0a1b45a2 386 bfd_byte *, bool, asymbol **);
dc810e39 387extern bfd_vma bfd_coff_reloc16_get_value
7920ce38 388 (arelent *, struct bfd_link_info *, asection *);
dc810e39 389extern void bfd_perform_slip
7920ce38 390 (bfd *, unsigned int, asection *, bfd_vma);
0a1b45a2 391extern bool _bfd_coff_close_and_cleanup
f5d35bb7 392 (bfd *);
252b5132
RH
393
394/* Functions and types in cofflink.c. */
395
ceae3e33 396#define STRING_SIZE_SIZE 4
252b5132
RH
397
398/* We use a hash table to merge identical enum, struct, and union
399 definitions in the linker. */
400
401/* Information we keep for a single element (an enum value, a
402 structure or union field) in the debug merge hash table. */
403
404struct coff_debug_merge_element
405{
406 /* Next element. */
407 struct coff_debug_merge_element *next;
408
409 /* Name. */
410 const char *name;
411
412 /* Type. */
413 unsigned int type;
414
415 /* Symbol index for complex type. */
416 long tagndx;
417};
418
419/* A linked list of debug merge entries for a given name. */
420
421struct coff_debug_merge_type
422{
423 /* Next type with the same name. */
424 struct coff_debug_merge_type *next;
425
426 /* Class of type. */
96d56e9f 427 int type_class;
252b5132
RH
428
429 /* Symbol index where this type is defined. */
430 long indx;
431
432 /* List of elements. */
433 struct coff_debug_merge_element *elements;
434};
435
436/* Information we store in the debug merge hash table. */
437
438struct coff_debug_merge_hash_entry
439{
440 struct bfd_hash_entry root;
441
442 /* A list of types with this name. */
443 struct coff_debug_merge_type *types;
444};
445
446/* The debug merge hash table. */
447
448struct coff_debug_merge_hash_table
449{
450 struct bfd_hash_table root;
451};
452
453/* Initialize a COFF debug merge hash table. */
454
455#define coff_debug_merge_hash_table_init(table) \
66eb6687
AM
456 (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \
457 sizeof (struct coff_debug_merge_hash_entry)))
252b5132
RH
458
459/* Free a COFF debug merge hash table. */
460
461#define coff_debug_merge_hash_table_free(table) \
462 (bfd_hash_table_free (&(table)->root))
463
464/* Look up an entry in a COFF debug merge hash table. */
465
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)))
469
470/* Information we keep for each section in the output file when doing
1049f94e 471 a relocatable link. */
252b5132
RH
472
473struct coff_link_section_info
474{
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;
480};
481
482/* Information that we pass around while doing the final link step. */
483
484struct coff_final_link_info
485{
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. */
0a1b45a2 491 bool failed;
252b5132
RH
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. */
0a1b45a2 495 bool global_to_static;
252b5132
RH
496 /* Hash table for long symbol names. */
497 struct bfd_strtab_hash *strtab;
1049f94e 498 /* When doing a relocatable link, an array of information kept for
252b5132
RH
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;
530};
531
5dccc1dd
ILT
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. */
535
536struct coff_section_alignment_entry
537{
538 /* The section name. */
539 const char *name;
540
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;
545
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)
550
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;
555
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;
560
561#define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1)
562
563 /* The desired alignment for this section (as a power of two). */
564 unsigned int alignment_power;
565};
566
252b5132 567extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
7920ce38 568 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
0a1b45a2 569extern bool _bfd_coff_link_hash_table_init
7920ce38
NC
570 (struct coff_link_hash_table *, bfd *,
571 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
572 struct bfd_hash_table *,
66eb6687
AM
573 const char *),
574 unsigned int);
252b5132 575extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
7920ce38 576 (bfd *);
252b5132 577extern const char *_bfd_coff_internal_syment_name
7920ce38 578 (bfd *, const struct internal_syment *, char *);
0a1b45a2 579extern bool _bfd_coff_section_already_linked
c77ec726 580 (bfd *, asection *, struct bfd_link_info *);
0a1b45a2 581extern bool _bfd_coff_link_add_symbols
7920ce38 582 (bfd *, struct bfd_link_info *);
0a1b45a2 583extern bool _bfd_coff_final_link
7920ce38 584 (bfd *, struct bfd_link_info *);
252b5132 585extern struct internal_reloc *_bfd_coff_read_internal_relocs
0a1b45a2 586 (bfd *, asection *, bool, bfd_byte *, bool,
7920ce38 587 struct internal_reloc *);
0a1b45a2 588extern bool _bfd_coff_generic_relocate_section
7920ce38
NC
589 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
590 struct internal_reloc *, struct internal_syment *, asection **);
252b5132 591extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
7920ce38 592 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
0a1b45a2 593extern bool _bfd_coff_write_global_sym
7686d77d 594 (struct bfd_hash_entry *, void *);
0a1b45a2 595extern bool _bfd_coff_write_task_globals
7920ce38 596 (struct coff_link_hash_entry *, void *);
0a1b45a2 597extern bool _bfd_coff_link_input_bfd
7920ce38 598 (struct coff_final_link_info *, bfd *);
0a1b45a2 599extern bool _bfd_coff_reloc_link_order
7920ce38
NC
600 (bfd *, struct coff_final_link_info *, asection *,
601 struct bfd_link_order *);
0a1b45a2 602extern bool bfd_coff_gc_sections
0f088b2a 603 (bfd *, struct bfd_link_info *);
cb7f4b29
AM
604extern const char *bfd_coff_group_name
605 (bfd *, const asection *);
252b5132
RH
606
607#define coff_get_section_contents_in_window \
608 _bfd_generic_get_section_contents_in_window
609
f34d8777
L
610/* Functions in xcofflink.c. */
611
dc810e39 612extern long _bfd_xcoff_get_dynamic_symtab_upper_bound
7920ce38 613 (bfd *);
f34d8777 614extern long _bfd_xcoff_canonicalize_dynamic_symtab
7920ce38 615 (bfd *, asymbol **);
dc810e39 616extern long _bfd_xcoff_get_dynamic_reloc_upper_bound
7920ce38 617 (bfd *);
f34d8777 618extern long _bfd_xcoff_canonicalize_dynamic_reloc
7920ce38 619 (bfd *, arelent **, asymbol **);
f34d8777 620extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
7920ce38 621 (bfd *);
0a1b45a2 622extern bool _bfd_xcoff_bfd_link_add_symbols
7920ce38 623 (bfd *, struct bfd_link_info *);
0a1b45a2 624extern bool _bfd_xcoff_bfd_final_link
7920ce38 625 (bfd *, struct bfd_link_info *);
0a1b45a2 626extern bool _bfd_xcoff_define_common_symbol
3023e3f6 627 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
0a1b45a2 628extern bool _bfd_ppc_xcoff_relocate_section
7920ce38
NC
629 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
630 struct internal_reloc *, struct internal_syment *, asection **);
e61463e1 631/* Extracted from coffcode.h. */
252b5132
RH
632typedef struct coff_ptr_struct
633{
dc810e39 634 /* Remembers the offset from the first symbol in the file for
695c3228 635 this symbol. Generated by coff_renumber_symbols. */
dc810e39
AM
636 unsigned int offset;
637
695c3228
AM
638 /* Selects between the elements of the union below. */
639 unsigned int is_sym : 1;
dc810e39 640
695c3228
AM
641 /* Selects between the elements of the x_sym.x_tagndx union. If set,
642 p is valid and the field will be renumbered. */
dc810e39
AM
643 unsigned int fix_tag : 1;
644
695c3228
AM
645 /* Selects between the elements of the x_sym.x_fcnary.x_fcn.x_endndx
646 union. If set, p is valid and the field will be renumbered. */
dc810e39
AM
647 unsigned int fix_end : 1;
648
695c3228
AM
649 /* Selects between the elements of the x_csect.x_scnlen union. If set,
650 p is valid and the field will be renumbered. */
dc810e39
AM
651 unsigned int fix_scnlen : 1;
652
695c3228
AM
653 /* If set, u.syment.n_value contains a pointer to a symbol. The final
654 value will be the offset field. Used for XCOFF C_BSTAT symbols. */
655 unsigned int fix_value : 1;
656
657 /* If set, u.syment.n_value is an index into the line number entries.
658 Used for XCOFF C_BINCL/C_EINCL symbols. */
dc810e39
AM
659 unsigned int fix_line : 1;
660
661 /* The container for the symbol structure as read and translated
a5c71af8 662 from the file. */
dc810e39
AM
663 union
664 {
665 union internal_auxent auxent;
666 struct internal_syment syment;
667 } u;
a5c71af8 668
e86fc4a5
CC
669 /* An extra pointer which can used by format based on COFF (like XCOFF)
670 to provide extra information to their backend. */
671 void *extrap;
252b5132
RH
672} combined_entry_type;
673
52b219b5 674/* Each canonical asymbol really looks like this: */
252b5132
RH
675
676typedef struct coff_symbol_struct
677{
dc810e39
AM
678 /* The actual symbol which the rest of BFD works with */
679 asymbol symbol;
252b5132 680
dc810e39
AM
681 /* A pointer to the hidden information for this symbol */
682 combined_entry_type *native;
252b5132 683
dc810e39
AM
684 /* A pointer to the linenumber information for this symbol */
685 struct lineno_cache_entry *lineno;
252b5132 686
dc810e39 687 /* Have the line numbers been relocated yet ? */
0a1b45a2 688 bool done_lineno;
252b5132 689} coff_symbol_type;
717d4bd6 690
52b219b5 691/* COFF symbol classifications. */
5d54c628
ILT
692
693enum coff_symbol_classification
694{
52b219b5 695 /* Global symbol. */
5d54c628 696 COFF_SYMBOL_GLOBAL,
52b219b5 697 /* Common symbol. */
5d54c628 698 COFF_SYMBOL_COMMON,
52b219b5 699 /* Undefined symbol. */
5d54c628 700 COFF_SYMBOL_UNDEFINED,
52b219b5 701 /* Local symbol. */
5d54c628 702 COFF_SYMBOL_LOCAL,
52b219b5 703 /* PE section symbol. */
5d54c628
ILT
704 COFF_SYMBOL_PE_SECTION
705};
706
0f088b2a
KT
707typedef asection * (*coff_gc_mark_hook_fn)
708 (asection *, struct bfd_link_info *, struct internal_reloc *,
709 struct coff_link_hash_entry *, struct internal_syment *);
710
252b5132
RH
711typedef struct
712{
dc810e39 713 void (*_bfd_coff_swap_aux_in)
7920ce38 714 (bfd *, void *, int, int, int, int, void *);
dc810e39
AM
715
716 void (*_bfd_coff_swap_sym_in)
7920ce38 717 (bfd *, void *, void *);
dc810e39
AM
718
719 void (*_bfd_coff_swap_lineno_in)
7920ce38 720 (bfd *, void *, void *);
dc810e39
AM
721
722 unsigned int (*_bfd_coff_swap_aux_out)
7920ce38 723 (bfd *, void *, int, int, int, int, void *);
dc810e39
AM
724
725 unsigned int (*_bfd_coff_swap_sym_out)
7920ce38 726 (bfd *, void *, void *);
dc810e39
AM
727
728 unsigned int (*_bfd_coff_swap_lineno_out)
7920ce38 729 (bfd *, void *, void *);
dc810e39
AM
730
731 unsigned int (*_bfd_coff_swap_reloc_out)
7920ce38 732 (bfd *, void *, void *);
dc810e39
AM
733
734 unsigned int (*_bfd_coff_swap_filehdr_out)
7920ce38 735 (bfd *, void *, void *);
dc810e39
AM
736
737 unsigned int (*_bfd_coff_swap_aouthdr_out)
7920ce38 738 (bfd *, void *, void *);
dc810e39
AM
739
740 unsigned int (*_bfd_coff_swap_scnhdr_out)
7920ce38 741 (bfd *, void *, void *);
dc810e39
AM
742
743 unsigned int _bfd_filhsz;
744 unsigned int _bfd_aoutsz;
745 unsigned int _bfd_scnhsz;
746 unsigned int _bfd_symesz;
747 unsigned int _bfd_auxesz;
748 unsigned int _bfd_relsz;
749 unsigned int _bfd_linesz;
750 unsigned int _bfd_filnmlen;
0a1b45a2 751 bool _bfd_coff_long_filenames;
88183869 752
0a1b45a2
AM
753 bool _bfd_coff_long_section_names;
754 bool (*_bfd_coff_set_long_section_names)
88183869 755 (bfd *, int);
68ffbac6 756
dc810e39 757 unsigned int _bfd_coff_default_section_alignment_power;
0a1b45a2 758 bool _bfd_coff_force_symnames_in_strings;
dc810e39 759 unsigned int _bfd_coff_debug_string_prefix_length;
167ad85b 760 unsigned int _bfd_coff_max_nscns;
dc810e39
AM
761
762 void (*_bfd_coff_swap_filehdr_in)
7920ce38 763 (bfd *, void *, void *);
dc810e39
AM
764
765 void (*_bfd_coff_swap_aouthdr_in)
7920ce38 766 (bfd *, void *, void *);
dc810e39
AM
767
768 void (*_bfd_coff_swap_scnhdr_in)
7920ce38 769 (bfd *, void *, void *);
dc810e39
AM
770
771 void (*_bfd_coff_swap_reloc_in)
7920ce38 772 (bfd *abfd, void *, void *);
dc810e39 773
0a1b45a2 774 bool (*_bfd_coff_bad_format_hook)
7920ce38 775 (bfd *, void *);
dc810e39 776
0a1b45a2 777 bool (*_bfd_coff_set_arch_mach_hook)
7920ce38 778 (bfd *, void *);
dc810e39 779
7920ce38
NC
780 void * (*_bfd_coff_mkobject_hook)
781 (bfd *, void *, void *);
dc810e39 782
0a1b45a2 783 bool (*_bfd_styp_to_sec_flags_hook)
7920ce38 784 (bfd *, void *, const char *, asection *, flagword *);
dc810e39
AM
785
786 void (*_bfd_set_alignment_hook)
7920ce38 787 (bfd *, asection *, void *);
dc810e39 788
0a1b45a2 789 bool (*_bfd_coff_slurp_symbol_table)
7920ce38 790 (bfd *);
dc810e39 791
0a1b45a2 792 bool (*_bfd_coff_symname_in_debug)
7920ce38 793 (bfd *, struct internal_syment *);
dc810e39 794
0a1b45a2 795 bool (*_bfd_coff_pointerize_aux_hook)
7920ce38 796 (bfd *, combined_entry_type *, combined_entry_type *,
07d6d2b8 797 unsigned int, combined_entry_type *);
dc810e39 798
0a1b45a2 799 bool (*_bfd_coff_print_aux)
7920ce38 800 (bfd *, FILE *, combined_entry_type *, combined_entry_type *,
07d6d2b8 801 combined_entry_type *, unsigned int);
dc810e39 802
d64c8f71 803 bool (*_bfd_coff_reloc16_extra_cases)
7920ce38 804 (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
d64c8f71 805 bfd_byte *, size_t *, size_t *);
dc810e39
AM
806
807 int (*_bfd_coff_reloc16_estimate)
7920ce38 808 (bfd *, asection *, arelent *, unsigned int,
07d6d2b8 809 struct bfd_link_info *);
dc810e39
AM
810
811 enum coff_symbol_classification (*_bfd_coff_classify_symbol)
7920ce38 812 (bfd *, struct internal_syment *);
dc810e39 813
0a1b45a2 814 bool (*_bfd_coff_compute_section_file_positions)
7920ce38 815 (bfd *);
dc810e39 816
0a1b45a2 817 bool (*_bfd_coff_start_final_link)
7920ce38 818 (bfd *, struct bfd_link_info *);
dc810e39 819
0a1b45a2 820 bool (*_bfd_coff_relocate_section)
7920ce38 821 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
07d6d2b8 822 struct internal_reloc *, struct internal_syment *, asection **);
dc810e39
AM
823
824 reloc_howto_type *(*_bfd_coff_rtype_to_howto)
7920ce38 825 (bfd *, asection *, struct internal_reloc *,
07d6d2b8 826 struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *);
dc810e39 827
0a1b45a2 828 bool (*_bfd_coff_adjust_symndx)
7920ce38 829 (bfd *, struct bfd_link_info *, bfd *, asection *,
0a1b45a2 830 struct internal_reloc *, bool *);
dc810e39 831
0a1b45a2 832 bool (*_bfd_coff_link_add_one_symbol)
7920ce38 833 (struct bfd_link_info *, bfd *, const char *, flagword,
0a1b45a2 834 asection *, bfd_vma, const char *, bool, bool,
07d6d2b8 835 struct bfd_link_hash_entry **);
dc810e39 836
0a1b45a2 837 bool (*_bfd_coff_link_output_has_begun)
7920ce38 838 (bfd *, struct coff_final_link_info *);
dc810e39 839
0a1b45a2 840 bool (*_bfd_coff_final_link_postscript)
7920ce38 841 (bfd *, struct coff_final_link_info *);
252b5132 842
0a1b45a2 843 bool (*_bfd_coff_print_pdata)
2b5c217d
NC
844 (bfd *, void *);
845
252b5132
RH
846} bfd_coff_backend_data;
847
dc810e39 848#define coff_backend_info(abfd) \
22a95e1a 849 ((const bfd_coff_backend_data *) (abfd)->xvec->backend_data)
252b5132
RH
850
851#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
dc810e39 852 ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
252b5132
RH
853
854#define bfd_coff_swap_sym_in(a,e,i) \
dc810e39 855 ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
252b5132
RH
856
857#define bfd_coff_swap_lineno_in(a,e,i) \
dc810e39 858 ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
252b5132
RH
859
860#define bfd_coff_swap_reloc_out(abfd, i, o) \
dc810e39 861 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
252b5132
RH
862
863#define bfd_coff_swap_lineno_out(abfd, i, o) \
dc810e39 864 ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
252b5132
RH
865
866#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
dc810e39 867 ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
252b5132
RH
868
869#define bfd_coff_swap_sym_out(abfd, i,o) \
dc810e39 870 ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
252b5132
RH
871
872#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
dc810e39 873 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
252b5132
RH
874
875#define bfd_coff_swap_filehdr_out(abfd, i,o) \
dc810e39 876 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
252b5132
RH
877
878#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
dc810e39 879 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
252b5132
RH
880
881#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
882#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
883#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
884#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
885#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
886#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
887#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
692b7d62 888#define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
dc810e39
AM
889#define bfd_coff_long_filenames(abfd) \
890 (coff_backend_info (abfd)->_bfd_coff_long_filenames)
252b5132 891#define bfd_coff_long_section_names(abfd) \
22a95e1a 892 (coff_data (abfd)->long_section_names)
88183869
DK
893#define bfd_coff_set_long_section_names(abfd, enable) \
894 ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable))
252b5132 895#define bfd_coff_default_section_alignment_power(abfd) \
dc810e39 896 (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
167ad85b
TG
897#define bfd_coff_max_nscns(abfd) \
898 (coff_backend_info (abfd)->_bfd_coff_max_nscns)
899
252b5132 900#define bfd_coff_swap_filehdr_in(abfd, i,o) \
dc810e39 901 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
252b5132
RH
902
903#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
dc810e39 904 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
252b5132
RH
905
906#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
dc810e39 907 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
252b5132
RH
908
909#define bfd_coff_swap_reloc_in(abfd, i, o) \
dc810e39 910 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
252b5132
RH
911
912#define bfd_coff_bad_format_hook(abfd, filehdr) \
dc810e39 913 ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
252b5132
RH
914
915#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
dc810e39 916 ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
252b5132 917#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
ed781d5d
NC
918 ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\
919 (abfd, filehdr, aouthdr))
252b5132 920
7c8ca0e4 921#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
dc810e39
AM
922 ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
923 (abfd, scnhdr, name, section, flags_ptr))
252b5132
RH
924
925#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
dc810e39 926 ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
252b5132
RH
927
928#define bfd_coff_slurp_symbol_table(abfd)\
dc810e39 929 ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
252b5132
RH
930
931#define bfd_coff_symname_in_debug(abfd, sym)\
dc810e39 932 ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
252b5132 933
7f6d05e8 934#define bfd_coff_force_symnames_in_strings(abfd)\
dc810e39 935 (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
7f6d05e8
CP
936
937#define bfd_coff_debug_string_prefix_length(abfd)\
dc810e39 938 (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
7f6d05e8 939
252b5132 940#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
dc810e39
AM
941 ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
942 (abfd, file, base, symbol, aux, indaux))
252b5132 943
ed781d5d 944#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\
717d4bd6 945 reloc, data, src_ptr, dst_ptr)\
dc810e39
AM
946 ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
947 (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
252b5132
RH
948
949#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
dc810e39
AM
950 ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
951 (abfd, section, reloc, shrink, link_info))
252b5132 952
5d54c628 953#define bfd_coff_classify_symbol(abfd, sym)\
dc810e39
AM
954 ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
955 (abfd, sym))
252b5132
RH
956
957#define bfd_coff_compute_section_file_positions(abfd)\
dc810e39
AM
958 ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
959 (abfd))
252b5132
RH
960
961#define bfd_coff_start_final_link(obfd, info)\
dc810e39
AM
962 ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
963 (obfd, info))
252b5132 964#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
dc810e39
AM
965 ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
966 (obfd, info, ibfd, o, con, rel, isyms, secs))
252b5132 967#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
dc810e39
AM
968 ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
969 (abfd, sec, rel, h, sym, addendp))
252b5132 970#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
dc810e39
AM
971 ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
972 (obfd, info, ibfd, sec, rel, adjustedp))
ed781d5d 973#define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
717d4bd6 974 value, string, cp, coll, hashp)\
dc810e39
AM
975 ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
976 (info, abfd, name, flags, section, value, string, cp, coll, hashp))
252b5132
RH
977
978#define bfd_coff_link_output_has_begun(a,p) \
7920ce38 979 ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p))
252b5132 980#define bfd_coff_final_link_postscript(a,p) \
7920ce38 981 ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a, p))
252b5132 982
2b5c217d
NC
983#define bfd_coff_have_print_pdata(a) \
984 (coff_backend_info (a)->_bfd_coff_print_pdata)
985#define bfd_coff_print_pdata(a,p) \
986 ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p))
987
92dd4511
L
988/* Macro: Returns true if the bfd is a PE executable as opposed to a
989 PE object file. */
990#define bfd_pei_p(abfd) \
08dedd66 991 (startswith ((abfd)->xvec->name, "pei-"))
55172d69
PA
992#ifdef __cplusplus
993}
994#endif
0b439543 995#endif