]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/libecoff.h
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / bfd / libecoff.h
CommitLineData
252b5132 1/* BFD ECOFF object file private structure.
fd67aa11 2 Copyright (C) 1993-2024 Free Software Foundation, Inc.
252b5132
RH
3 Written by Ian Lance Taylor, Cygnus Support.
4
7920ce38 5 This file is part of BFD, the Binary File Descriptor library.
252b5132 6
7920ce38
NC
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
cd123cb7 9 the Free Software Foundation; either version 3 of the License, or
7920ce38 10 (at your option) any later version.
252b5132 11
7920ce38
NC
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
252b5132 16
7920ce38
NC
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
cd123cb7
NC
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
252b5132
RH
21
22#include "bfdlink.h"
23
24#ifndef ECOFF_H
25#include "coff/ecoff.h"
26#endif
27
28/* This is the backend information kept for ECOFF files. This
29 structure is constant for a particular backend. The first element
30 is the COFF backend data structure, so that ECOFF targets can use
31 the generic COFF code. */
32
33#define ecoff_backend(abfd) \
34 ((struct ecoff_backend_data *) (abfd)->xvec->backend_data)
35
36struct ecoff_backend_data
37{
38 /* COFF backend information. This must be the first field. */
39 bfd_coff_backend_data coff;
40 /* Supported architecture. */
41 enum bfd_architecture arch;
42 /* Initial portion of armap string. */
43 const char *armap_start;
44 /* The page boundary used to align sections in a demand-paged
45 executable file. E.g., 0x1000. */
46 bfd_vma round;
b34976b6
AM
47 /* TRUE if the .rdata section is part of the text segment, as on the
48 Alpha. FALSE if .rdata is part of the data segment, as on the
252b5132 49 MIPS. */
0a1b45a2 50 bool rdata_in_text;
252b5132
RH
51 /* Bitsize of constructor entries. */
52 unsigned int constructor_bitsize;
53 /* Reloc to use for constructor entries. */
54 reloc_howto_type *constructor_reloc;
55 /* How to swap debugging information. */
56 struct ecoff_debug_swap debug_swap;
57 /* External reloc size. */
58 bfd_size_type external_reloc_size;
59 /* Reloc swapping functions. */
7920ce38
NC
60 void (*swap_reloc_in) (bfd *, void *, struct internal_reloc *);
61 void (*swap_reloc_out) (bfd *, const struct internal_reloc *, void *);
252b5132 62 /* Backend reloc tweaking. */
b34976b6 63 void (*adjust_reloc_in)
7920ce38 64 (bfd *, const struct internal_reloc *, arelent *);
b34976b6 65 void (*adjust_reloc_out)
7920ce38 66 (bfd *, const arelent *, struct internal_reloc *);
252b5132 67 /* Relocate section contents while linking. */
0a1b45a2 68 bool (*relocate_section)
7920ce38 69 (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, void *);
252b5132 70 /* Do final adjustments to filehdr and aouthdr. */
0a1b45a2 71 bool (*adjust_headers)
7920ce38 72 (bfd *, struct internal_filehdr *, struct internal_aouthdr *);
252b5132
RH
73 /* Read an element from an archive at a given file position. This
74 is needed because OSF/1 3.2 uses a weird archive format. */
6395a102 75 bfd *(*get_elt_at_filepos) (bfd *, file_ptr, struct bfd_link_info *);
252b5132
RH
76};
77
88183869
DK
78/* ECOFF targets don't support COFF long section names, so this
79 macro is provided to use as an initialiser for the related
80 members of the embedded bfd_coff_backend_data struct. */
0a1b45a2 81#define ECOFF_NO_LONG_SECTION_NAMES (false), _bfd_ecoff_no_long_sections
88183869 82
5a671d7a
AM
83struct mips_hi
84{
85 struct mips_hi *next;
86 bfd_byte *addr;
87 bfd_vma addend;
88};
89
252b5132
RH
90/* This is the target specific information kept for ECOFF files. */
91
92#define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
93
94typedef struct ecoff_tdata
95{
96 /* The reloc file position, set by
97 ecoff_compute_section_file_positions. */
98 file_ptr reloc_filepos;
99
100 /* The symbol table file position, set by _bfd_ecoff_mkobject_hook. */
101 file_ptr sym_filepos;
102
103 /* The start and end of the text segment. Only valid for an
104 existing file, not for one we are creating. */
105 unsigned long text_start;
106 unsigned long text_end;
107
108 /* The cached gp value. This is used when relocating. */
109 bfd_vma gp;
110
111 /* The maximum size of objects to optimize using gp. This is
112 typically set by the -G option to the compiler, assembler or
113 linker. */
114 unsigned int gp_size;
115
116 /* The register masks. When linking, all the masks found in the
117 input files are combined into the masks of the output file.
118 These are not all used for all targets, but that's OK, because
119 the relevant ones are the only ones swapped in and out. */
120 unsigned long gprmask;
121 unsigned long fprmask;
122 unsigned long cprmask[4];
123
124 /* The ECOFF symbolic debugging information. */
125 struct ecoff_debug_info debug_info;
126
252b5132
RH
127 /* The canonical BFD symbols. */
128 struct ecoff_symbol_struct *canonical_symbols;
129
130 /* A mapping from external symbol numbers to entries in the linker
131 hash table, used when linking. */
132 struct ecoff_link_hash_entry **sym_hashes;
133
134 /* A mapping from reloc symbol indices to sections, used when
135 linking. */
136 asection **symndx_to_section;
137
b34976b6 138 /* TRUE if this BFD was written by the backend linker. */
0a1b45a2 139 bool linker;
252b5132 140
b34976b6 141 /* TRUE if a warning that multiple global pointer values are
252b5132 142 needed in the output binary was issued already. */
0a1b45a2 143 bool issued_multiple_gp_warning;
252b5132
RH
144
145 /* Used by find_nearest_line entry point. The structure could be
146 included directly in this one, but there's no point to wasting
147 the memory just for the infrequently called find_nearest_line. */
148 struct ecoff_find_line *find_line_info;
149
150 /* Whether the .rdata section is in the text segment for this
151 particular ECOFF file. This is not valid until
152 ecoff_compute_section_file_positions is called. */
0a1b45a2 153 bool rdata_in_text;
252b5132 154
5a671d7a
AM
155 /* Used by coff-mips.c to track REFHI relocs for pairing with REFLO. */
156 struct mips_hi *mips_refhi_list;
252b5132
RH
157} ecoff_data_type;
158
159/* Each canonical asymbol really looks like this. */
160
161typedef struct ecoff_symbol_struct
162{
163 /* The actual symbol which the rest of BFD works with */
164 asymbol symbol;
165
166 /* The fdr for this symbol. */
167 FDR *fdr;
168
b34976b6 169 /* TRUE if this is a local symbol rather than an external one. */
0a1b45a2 170 bool local;
252b5132
RH
171
172 /* A pointer to the unswapped hidden information for this symbol.
173 This is either a struct sym_ext or a struct ext_ext, depending on
174 the value of the local field above. */
7920ce38 175 void * native;
252b5132
RH
176} ecoff_symbol_type;
177
08da05b0 178/* We take the address of the first element of an asymbol to ensure that the
252b5132
RH
179 macro is only ever applied to an asymbol. */
180#define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
181
182/* We need to save the index of an external symbol when we write it
183 out so that can set the symbol index correctly when we write out
184 the relocs. */
185#define ecoff_get_sym_index(symbol) ((symbol)->udata.i)
186#define ecoff_set_sym_index(symbol, idx) ((symbol)->udata.i = (idx))
187
3e27568f
CD
188/* A pointer to this structure is put in the used_by_bfd pointer of
189 a section to keep track of any per-section data.
190 The user_by_bfd pointer will be NULL if the information was not
191 needed. */
252b5132
RH
192
193struct ecoff_section_tdata
194{
252b5132
RH
195 /* When producing an executable (i.e., final, non-relocatable link)
196 on the Alpha, we may need to use multiple global pointer values
197 to span the entire .lita section. In essence, we allow each
198 input .lita section to have its own gp value. To support this,
199 we need to keep track of the gp values that we picked for each
200 input .lita section . */
201 bfd_vma gp;
202};
203
204/* An accessor macro for the ecoff_section_tdata structure. */
205#define ecoff_section_data(abfd, sec) \
206 ((struct ecoff_section_tdata *) (sec)->used_by_bfd)
207
208/* ECOFF linker hash table entries. */
209
210struct ecoff_link_hash_entry
211{
212 struct bfd_link_hash_entry root;
213 /* Symbol index in output file. */
214 long indx;
215 /* BFD that ext field value came from. */
216 bfd *abfd;
217 /* ECOFF external symbol information. */
218 EXTR esym;
219 /* Nonzero if this symbol has been written out. */
220 char written;
221 /* Nonzero if this symbol was referred to as small undefined. */
222 char small;
223};
224
225/* ECOFF linker hash table. */
226
227struct ecoff_link_hash_table
228{
229 struct bfd_link_hash_table root;
230};
231
232/* Make an ECOFF object. */
0a1b45a2 233extern bool _bfd_ecoff_mkobject (bfd *);
252b5132
RH
234
235/* Read in the ECOFF symbolic debugging information. */
0a1b45a2 236extern bool _bfd_ecoff_slurp_symbolic_info
7920ce38 237 (bfd *, asection *, struct ecoff_debug_info *);
252b5132
RH
238
239/* Generic ECOFF BFD backend vectors. */
240
0a1b45a2 241extern bool _bfd_ecoff_write_object_contents (bfd *);
252b5132 242
ba75d1c5
AM
243#define _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup
244extern bool _bfd_ecoff_bfd_free_cached_info (bfd *);
0a1b45a2 245extern bool _bfd_ecoff_new_section_hook
7920ce38 246 (bfd *, asection *);
0a1b45a2 247extern bool _bfd_ecoff_get_section_contents
7920ce38 248 (bfd *, asection *, void * location, file_ptr, bfd_size_type);
252b5132
RH
249
250#define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section
4f3b23b3 251#define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs
252b5132 252
433b4f8a
L
253#define _bfd_ecoff_init_private_section_data \
254 _bfd_generic_init_private_section_data
255
0a1b45a2 256extern bool _bfd_ecoff_bfd_copy_private_bfd_data
7920ce38 257 (bfd *, bfd *);
252b5132
RH
258#define _bfd_ecoff_bfd_copy_private_section_data \
259 _bfd_generic_bfd_copy_private_section_data
260
261#define _bfd_ecoff_bfd_copy_private_symbol_data \
262 _bfd_generic_bfd_copy_private_symbol_data
263
80fccad2
BW
264#define _bfd_ecoff_bfd_copy_private_header_data \
265 _bfd_generic_bfd_copy_private_header_data
266
252b5132
RH
267#define _bfd_ecoff_bfd_print_private_bfd_data \
268 _bfd_generic_bfd_print_private_bfd_data
269
270#define _bfd_ecoff_bfd_merge_private_bfd_data \
271 _bfd_generic_bfd_merge_private_bfd_data
272
273#define _bfd_ecoff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
0a1b45a2 274extern bool _bfd_ecoff_slurp_armap (bfd *);
252b5132
RH
275#define _bfd_ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
276#define _bfd_ecoff_construct_extended_name_table \
277 _bfd_archive_bsd_construct_extended_name_table
278#define _bfd_ecoff_truncate_arname bfd_dont_truncate_arname
0a1b45a2 279extern bool _bfd_ecoff_write_armap
7920ce38 280 (bfd *, unsigned int, struct orl *, unsigned int, int);
252b5132 281#define _bfd_ecoff_read_ar_hdr _bfd_generic_read_ar_hdr
8f95b6e4 282#define _bfd_ecoff_write_ar_hdr _bfd_generic_write_ar_hdr
252b5132
RH
283#define _bfd_ecoff_openr_next_archived_file \
284 bfd_generic_openr_next_archived_file
285#define _bfd_ecoff_get_elt_at_index _bfd_generic_get_elt_at_index
286#define _bfd_ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
d00dd7dc
AM
287#define _bfd_ecoff_update_armap_timestamp _bfd_bool_bfd_true
288#define _bfd_ecoff_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
252b5132 289
7920ce38
NC
290extern long _bfd_ecoff_get_symtab_upper_bound (bfd *);
291extern long _bfd_ecoff_canonicalize_symtab (bfd *, asymbol **);
292extern asymbol *_bfd_ecoff_make_empty_symbol (bfd *);
252b5132 293extern void _bfd_ecoff_print_symbol
7920ce38 294 (bfd *, void *, asymbol *, bfd_print_symbol_type);
252b5132 295extern void _bfd_ecoff_get_symbol_info
7920ce38 296 (bfd *, asymbol *, symbol_info *);
60bb06bc
L
297#define _bfd_ecoff_get_symbol_version_string \
298 _bfd_nosymbols_get_symbol_version_string
0a1b45a2 299extern bool _bfd_ecoff_bfd_is_local_label_name
7920ce38 300 (bfd *, const char *);
252b5132 301#define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno
0a1b45a2 302extern bool _bfd_ecoff_find_nearest_line
fb167eb2
AM
303 (bfd *, asymbol **, asection *, bfd_vma,
304 const char **, const char **, unsigned int *, unsigned int *);
6e7a29c7
AM
305#define _bfd_ecoff_find_nearest_line_with_alt \
306 _bfd_nosymbols_find_nearest_line_with_alt
9c461f7d 307#define _bfd_ecoff_find_line _bfd_nosymbols_find_line
252b5132
RH
308#define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
309#define _bfd_ecoff_read_minisymbols _bfd_generic_read_minisymbols
310#define _bfd_ecoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
4ab527b0 311#define _bfd_ecoff_find_inliner_info _bfd_nosymbols_find_inliner_info
252b5132
RH
312
313#define _bfd_ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
314extern long _bfd_ecoff_canonicalize_reloc
68d20676 315 (bfd *, asection *, arelent **, asymbol **);
252b5132
RH
316/* ecoff_bfd_reloc_type_lookup defined by backend. */
317
0a1b45a2 318extern bool _bfd_ecoff_set_arch_mach
7920ce38 319 (bfd *, enum bfd_architecture, unsigned long);
0a1b45a2 320extern bool _bfd_ecoff_set_section_contents
7920ce38 321 (bfd *, asection *, const void * location, file_ptr, bfd_size_type);
252b5132 322
a6b96beb 323extern int _bfd_ecoff_sizeof_headers (bfd *, struct bfd_link_info *);
252b5132
RH
324/* ecoff_bfd_get_relocated_section_contents defined by backend. */
325/* ecoff_bfd_relax_section defined by backend. */
326extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create
7920ce38 327 (bfd *);
0a1b45a2 328extern bool _bfd_ecoff_bfd_link_add_symbols
7920ce38 329 (bfd *, struct bfd_link_info *);
2d653fc7 330#define _bfd_ecoff_bfd_link_just_syms _bfd_generic_link_just_syms
1338dd10
PB
331#define _bfd_ecoff_bfd_copy_link_hash_symbol_type \
332 _bfd_generic_copy_link_hash_symbol_type
0a1b45a2 333extern bool _bfd_ecoff_bfd_final_link
7920ce38 334 (bfd *, struct bfd_link_info *);
252b5132
RH
335
336/* Hook functions for the generic COFF section reading code. */
337
7920ce38 338extern void * _bfd_ecoff_mkobject_hook (bfd *, void *, void *);
d00dd7dc
AM
339extern void _bfd_ecoff_set_alignment_hook
340 (bfd *, asection *, void *);
0a1b45a2 341extern bool _bfd_ecoff_set_arch_mach_hook
7920ce38 342 (bfd *, void *);
0a1b45a2 343extern bool _bfd_ecoff_no_long_sections
88183869 344 (bfd *abfd, int enable);
0a1b45a2 345extern bool _bfd_ecoff_styp_to_sec_flags
7920ce38 346 (bfd *, void *, const char *, asection *, flagword *);
0a1b45a2 347extern bool _bfd_ecoff_slurp_symbol_table (bfd *);
252b5132
RH
348
349/* ECOFF auxiliary information swapping routines. These are the same
350 for all ECOFF targets, so they are defined in ecofflink.c. */
351
352extern void _bfd_ecoff_swap_tir_in
7920ce38 353 (int, const struct tir_ext *, TIR *);
252b5132 354extern void _bfd_ecoff_swap_tir_out
7920ce38 355 (int, const TIR *, struct tir_ext *);
252b5132 356extern void _bfd_ecoff_swap_rndx_in
7920ce38 357 (int, const struct rndx_ext *, RNDXR *);
252b5132 358extern void _bfd_ecoff_swap_rndx_out
7920ce38 359 (int, const RNDXR *, struct rndx_ext *);