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