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