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