libecoff.h revision 1.1.1.5 1 1.1 skrll /* BFD ECOFF object file private structure.
2 1.1.1.5 christos Copyright (C) 1993-2018 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 skrll bfd_boolean 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 skrll bfd_boolean (*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 skrll bfd_boolean (*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 skrll bfd *(*get_elt_at_filepos) (bfd *, file_ptr);
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.2 christos #define ECOFF_NO_LONG_SECTION_NAMES (FALSE), _bfd_ecoff_no_long_sections
82 1.1.1.2 christos
83 1.1 skrll /* This is the target specific information kept for ECOFF files. */
84 1.1 skrll
85 1.1 skrll #define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
86 1.1 skrll
87 1.1 skrll typedef struct ecoff_tdata
88 1.1 skrll {
89 1.1 skrll /* The reloc file position, set by
90 1.1 skrll ecoff_compute_section_file_positions. */
91 1.1 skrll file_ptr reloc_filepos;
92 1.1 skrll
93 1.1 skrll /* The symbol table file position, set by _bfd_ecoff_mkobject_hook. */
94 1.1 skrll file_ptr sym_filepos;
95 1.1 skrll
96 1.1 skrll /* The start and end of the text segment. Only valid for an
97 1.1 skrll existing file, not for one we are creating. */
98 1.1 skrll unsigned long text_start;
99 1.1 skrll unsigned long text_end;
100 1.1 skrll
101 1.1 skrll /* The cached gp value. This is used when relocating. */
102 1.1 skrll bfd_vma gp;
103 1.1 skrll
104 1.1 skrll /* The maximum size of objects to optimize using gp. This is
105 1.1 skrll typically set by the -G option to the compiler, assembler or
106 1.1 skrll linker. */
107 1.1 skrll unsigned int gp_size;
108 1.1 skrll
109 1.1 skrll /* The register masks. When linking, all the masks found in the
110 1.1 skrll input files are combined into the masks of the output file.
111 1.1 skrll These are not all used for all targets, but that's OK, because
112 1.1 skrll the relevant ones are the only ones swapped in and out. */
113 1.1 skrll unsigned long gprmask;
114 1.1 skrll unsigned long fprmask;
115 1.1 skrll unsigned long cprmask[4];
116 1.1 skrll
117 1.1 skrll /* The ECOFF symbolic debugging information. */
118 1.1 skrll struct ecoff_debug_info debug_info;
119 1.1 skrll
120 1.1 skrll /* The unswapped ECOFF symbolic information. */
121 1.1 skrll void * raw_syments;
122 1.1 skrll
123 1.1 skrll /* The canonical BFD symbols. */
124 1.1 skrll struct ecoff_symbol_struct *canonical_symbols;
125 1.1 skrll
126 1.1 skrll /* A mapping from external symbol numbers to entries in the linker
127 1.1 skrll hash table, used when linking. */
128 1.1 skrll struct ecoff_link_hash_entry **sym_hashes;
129 1.1 skrll
130 1.1 skrll /* A mapping from reloc symbol indices to sections, used when
131 1.1 skrll linking. */
132 1.1 skrll asection **symndx_to_section;
133 1.1 skrll
134 1.1 skrll /* TRUE if this BFD was written by the backend linker. */
135 1.1 skrll bfd_boolean linker;
136 1.1 skrll
137 1.1 skrll /* TRUE if a warning that multiple global pointer values are
138 1.1 skrll needed in the output binary was issued already. */
139 1.1 skrll bfd_boolean issued_multiple_gp_warning;
140 1.1 skrll
141 1.1 skrll /* Used by find_nearest_line entry point. The structure could be
142 1.1 skrll included directly in this one, but there's no point to wasting
143 1.1 skrll the memory just for the infrequently called find_nearest_line. */
144 1.1 skrll struct ecoff_find_line *find_line_info;
145 1.1 skrll
146 1.1 skrll /* Whether the .rdata section is in the text segment for this
147 1.1 skrll particular ECOFF file. This is not valid until
148 1.1 skrll ecoff_compute_section_file_positions is called. */
149 1.1 skrll bfd_boolean rdata_in_text;
150 1.1 skrll
151 1.1 skrll } ecoff_data_type;
152 1.1 skrll
153 1.1 skrll /* Each canonical asymbol really looks like this. */
154 1.1 skrll
155 1.1 skrll typedef struct ecoff_symbol_struct
156 1.1 skrll {
157 1.1 skrll /* The actual symbol which the rest of BFD works with */
158 1.1 skrll asymbol symbol;
159 1.1 skrll
160 1.1 skrll /* The fdr for this symbol. */
161 1.1 skrll FDR *fdr;
162 1.1 skrll
163 1.1 skrll /* TRUE if this is a local symbol rather than an external one. */
164 1.1 skrll bfd_boolean local;
165 1.1 skrll
166 1.1 skrll /* A pointer to the unswapped hidden information for this symbol.
167 1.1 skrll This is either a struct sym_ext or a struct ext_ext, depending on
168 1.1 skrll the value of the local field above. */
169 1.1 skrll void * native;
170 1.1 skrll } ecoff_symbol_type;
171 1.1 skrll
172 1.1 skrll /* We take the address of the first element of an asymbol to ensure that the
173 1.1 skrll macro is only ever applied to an asymbol. */
174 1.1 skrll #define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
175 1.1 skrll
176 1.1 skrll /* We need to save the index of an external symbol when we write it
177 1.1 skrll out so that can set the symbol index correctly when we write out
178 1.1 skrll the relocs. */
179 1.1 skrll #define ecoff_get_sym_index(symbol) ((symbol)->udata.i)
180 1.1 skrll #define ecoff_set_sym_index(symbol, idx) ((symbol)->udata.i = (idx))
181 1.1 skrll
182 1.1 skrll /* A pointer to this structure is put in the used_by_bfd pointer of
183 1.1 skrll a section to keep track of any per-section data.
184 1.1 skrll The user_by_bfd pointer will be NULL if the information was not
185 1.1 skrll needed. */
186 1.1 skrll
187 1.1 skrll struct ecoff_section_tdata
188 1.1 skrll {
189 1.1 skrll /* When producing an executable (i.e., final, non-relocatable link)
190 1.1 skrll on the Alpha, we may need to use multiple global pointer values
191 1.1 skrll to span the entire .lita section. In essence, we allow each
192 1.1 skrll input .lita section to have its own gp value. To support this,
193 1.1 skrll we need to keep track of the gp values that we picked for each
194 1.1 skrll input .lita section . */
195 1.1 skrll bfd_vma gp;
196 1.1 skrll };
197 1.1 skrll
198 1.1 skrll /* An accessor macro for the ecoff_section_tdata structure. */
199 1.1 skrll #define ecoff_section_data(abfd, sec) \
200 1.1 skrll ((struct ecoff_section_tdata *) (sec)->used_by_bfd)
201 1.1 skrll
202 1.1 skrll /* ECOFF linker hash table entries. */
203 1.1 skrll
204 1.1 skrll struct ecoff_link_hash_entry
205 1.1 skrll {
206 1.1 skrll struct bfd_link_hash_entry root;
207 1.1 skrll /* Symbol index in output file. */
208 1.1 skrll long indx;
209 1.1 skrll /* BFD that ext field value came from. */
210 1.1 skrll bfd *abfd;
211 1.1 skrll /* ECOFF external symbol information. */
212 1.1 skrll EXTR esym;
213 1.1 skrll /* Nonzero if this symbol has been written out. */
214 1.1 skrll char written;
215 1.1 skrll /* Nonzero if this symbol was referred to as small undefined. */
216 1.1 skrll char small;
217 1.1 skrll };
218 1.1 skrll
219 1.1 skrll /* ECOFF linker hash table. */
220 1.1 skrll
221 1.1 skrll struct ecoff_link_hash_table
222 1.1 skrll {
223 1.1 skrll struct bfd_link_hash_table root;
224 1.1 skrll };
225 1.1 skrll
226 1.1 skrll /* Make an ECOFF object. */
227 1.1 skrll extern bfd_boolean _bfd_ecoff_mkobject (bfd *);
228 1.1 skrll
229 1.1 skrll /* Read in the ECOFF symbolic debugging information. */
230 1.1 skrll extern bfd_boolean _bfd_ecoff_slurp_symbolic_info
231 1.1 skrll (bfd *, asection *, struct ecoff_debug_info *);
232 1.1 skrll
233 1.1 skrll /* Generic ECOFF BFD backend vectors. */
234 1.1 skrll
235 1.1 skrll extern bfd_boolean _bfd_ecoff_write_object_contents (bfd *);
236 1.1 skrll
237 1.1 skrll #define _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup
238 1.1 skrll #define _bfd_ecoff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
239 1.1 skrll extern bfd_boolean _bfd_ecoff_new_section_hook
240 1.1 skrll (bfd *, asection *);
241 1.1 skrll extern bfd_boolean _bfd_ecoff_get_section_contents
242 1.1 skrll (bfd *, asection *, void * location, file_ptr, bfd_size_type);
243 1.1 skrll
244 1.1 skrll #define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section
245 1.1.1.4 christos #define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs
246 1.1 skrll
247 1.1 skrll extern bfd_boolean _bfd_ecoff_bfd_copy_private_bfd_data
248 1.1 skrll (bfd *, bfd *);
249 1.1 skrll #define _bfd_ecoff_bfd_copy_private_section_data \
250 1.1 skrll _bfd_generic_bfd_copy_private_section_data
251 1.1 skrll
252 1.1 skrll #define _bfd_ecoff_bfd_copy_private_symbol_data \
253 1.1 skrll _bfd_generic_bfd_copy_private_symbol_data
254 1.1 skrll
255 1.1 skrll #define _bfd_ecoff_bfd_copy_private_header_data \
256 1.1 skrll _bfd_generic_bfd_copy_private_header_data
257 1.1 skrll
258 1.1 skrll #define _bfd_ecoff_bfd_print_private_bfd_data \
259 1.1 skrll _bfd_generic_bfd_print_private_bfd_data
260 1.1 skrll
261 1.1 skrll #define _bfd_ecoff_bfd_merge_private_bfd_data \
262 1.1 skrll _bfd_generic_bfd_merge_private_bfd_data
263 1.1 skrll
264 1.1 skrll #define _bfd_ecoff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
265 1.1 skrll extern bfd_boolean _bfd_ecoff_slurp_armap (bfd *);
266 1.1 skrll #define _bfd_ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
267 1.1 skrll #define _bfd_ecoff_construct_extended_name_table \
268 1.1 skrll _bfd_archive_bsd_construct_extended_name_table
269 1.1 skrll #define _bfd_ecoff_truncate_arname bfd_dont_truncate_arname
270 1.1 skrll extern bfd_boolean _bfd_ecoff_write_armap
271 1.1 skrll (bfd *, unsigned int, struct orl *, unsigned int, int);
272 1.1 skrll #define _bfd_ecoff_read_ar_hdr _bfd_generic_read_ar_hdr
273 1.1.1.2 christos #define _bfd_ecoff_write_ar_hdr _bfd_generic_write_ar_hdr
274 1.1 skrll #define _bfd_ecoff_openr_next_archived_file \
275 1.1 skrll bfd_generic_openr_next_archived_file
276 1.1 skrll #define _bfd_ecoff_get_elt_at_index _bfd_generic_get_elt_at_index
277 1.1 skrll #define _bfd_ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
278 1.1 skrll #define _bfd_ecoff_update_armap_timestamp bfd_true
279 1.1 skrll #define _bfd_ecoff_bfd_is_target_special_symbol \
280 1.1 skrll ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
281 1.1 skrll
282 1.1 skrll extern long _bfd_ecoff_get_symtab_upper_bound (bfd *);
283 1.1 skrll extern long _bfd_ecoff_canonicalize_symtab (bfd *, asymbol **);
284 1.1 skrll extern asymbol *_bfd_ecoff_make_empty_symbol (bfd *);
285 1.1 skrll extern void _bfd_ecoff_print_symbol
286 1.1 skrll (bfd *, void *, asymbol *, bfd_print_symbol_type);
287 1.1 skrll extern void _bfd_ecoff_get_symbol_info
288 1.1 skrll (bfd *, asymbol *, symbol_info *);
289 1.1.1.3 christos #define _bfd_ecoff_get_symbol_version_string \
290 1.1.1.3 christos _bfd_nosymbols_get_symbol_version_string
291 1.1 skrll extern bfd_boolean _bfd_ecoff_bfd_is_local_label_name
292 1.1 skrll (bfd *, const char *);
293 1.1 skrll #define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno
294 1.1 skrll extern bfd_boolean _bfd_ecoff_find_nearest_line
295 1.1.1.3 christos (bfd *, asymbol **, asection *, bfd_vma,
296 1.1.1.3 christos const char **, const char **, unsigned int *, unsigned int *);
297 1.1.1.3 christos #define _bfd_ecoff_find_line _bfd_nosymbols_find_line
298 1.1 skrll #define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
299 1.1 skrll #define _bfd_ecoff_read_minisymbols _bfd_generic_read_minisymbols
300 1.1 skrll #define _bfd_ecoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
301 1.1 skrll #define _bfd_ecoff_find_inliner_info _bfd_nosymbols_find_inliner_info
302 1.1 skrll
303 1.1 skrll #define _bfd_ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
304 1.1 skrll extern long _bfd_ecoff_canonicalize_reloc
305 1.1 skrll (bfd *, asection *, arelent **, asymbol **symbols);
306 1.1 skrll /* ecoff_bfd_reloc_type_lookup defined by backend. */
307 1.1 skrll
308 1.1 skrll extern bfd_boolean _bfd_ecoff_set_arch_mach
309 1.1 skrll (bfd *, enum bfd_architecture, unsigned long);
310 1.1 skrll extern bfd_boolean _bfd_ecoff_set_section_contents
311 1.1 skrll (bfd *, asection *, const void * location, file_ptr, bfd_size_type);
312 1.1 skrll
313 1.1 skrll extern int _bfd_ecoff_sizeof_headers (bfd *, struct bfd_link_info *);
314 1.1 skrll /* ecoff_bfd_get_relocated_section_contents defined by backend. */
315 1.1 skrll /* ecoff_bfd_relax_section defined by backend. */
316 1.1 skrll extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create
317 1.1 skrll (bfd *);
318 1.1 skrll extern bfd_boolean _bfd_ecoff_bfd_link_add_symbols
319 1.1 skrll (bfd *, struct bfd_link_info *);
320 1.1 skrll #define _bfd_ecoff_bfd_link_just_syms _bfd_generic_link_just_syms
321 1.1.1.2 christos #define _bfd_ecoff_bfd_copy_link_hash_symbol_type \
322 1.1.1.2 christos _bfd_generic_copy_link_hash_symbol_type
323 1.1 skrll extern bfd_boolean _bfd_ecoff_bfd_final_link
324 1.1 skrll (bfd *, struct bfd_link_info *);
325 1.1 skrll
326 1.1 skrll /* Hook functions for the generic COFF section reading code. */
327 1.1 skrll
328 1.1 skrll extern void * _bfd_ecoff_mkobject_hook (bfd *, void *, void *);
329 1.1 skrll #define _bfd_ecoff_set_alignment_hook \
330 1.1 skrll ((void (*) (bfd *, asection *, void *)) bfd_void)
331 1.1 skrll extern bfd_boolean _bfd_ecoff_set_arch_mach_hook
332 1.1 skrll (bfd *, void *);
333 1.1.1.2 christos extern bfd_boolean _bfd_ecoff_no_long_sections
334 1.1.1.2 christos (bfd *abfd, int enable);
335 1.1 skrll extern bfd_boolean _bfd_ecoff_styp_to_sec_flags
336 1.1 skrll (bfd *, void *, const char *, asection *, flagword *);
337 1.1 skrll extern bfd_boolean _bfd_ecoff_slurp_symbol_table (bfd *);
338 1.1 skrll
339 1.1 skrll /* ECOFF auxiliary information swapping routines. These are the same
340 1.1 skrll for all ECOFF targets, so they are defined in ecofflink.c. */
341 1.1 skrll
342 1.1 skrll extern void _bfd_ecoff_swap_tir_in
343 1.1 skrll (int, const struct tir_ext *, TIR *);
344 1.1 skrll extern void _bfd_ecoff_swap_tir_out
345 1.1 skrll (int, const TIR *, struct tir_ext *);
346 1.1 skrll extern void _bfd_ecoff_swap_rndx_in
347 1.1 skrll (int, const struct rndx_ext *, RNDXR *);
348 1.1 skrll extern void _bfd_ecoff_swap_rndx_out
349 1.1 skrll (int, const RNDXR *, struct rndx_ext *);
350