~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to binutils/bfd/libecoff.h

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* BFD ECOFF object file private structure.
 
2
   Copyright 1993, 1994, 1995, 1996, 1999, 2001, 2002
 
3
   Free Software Foundation, Inc.
 
4
   Written by Ian Lance Taylor, Cygnus Support.
 
5
 
 
6
This file is part of BFD, the Binary File Descriptor library.
 
7
 
 
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 2 of the License, or
 
11
(at your option) any later version.
 
12
 
 
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.
 
17
 
 
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
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
 
 
36
struct 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;
 
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
 
49
     MIPS.  */
 
50
  boolean rdata_in_text;
 
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.  */
 
60
  void (*swap_reloc_in) PARAMS ((bfd *, PTR, struct internal_reloc *));
 
61
  void (*swap_reloc_out) PARAMS ((bfd *, const struct internal_reloc *, PTR));
 
62
  /* Backend reloc tweaking.  */
 
63
  void (*adjust_reloc_in) PARAMS ((bfd *, const struct internal_reloc *,
 
64
                                   arelent *));
 
65
  void (*adjust_reloc_out) PARAMS ((bfd *, const arelent *,
 
66
                                    struct internal_reloc *));
 
67
  /* Relocate section contents while linking.  */
 
68
  boolean (*relocate_section) PARAMS ((bfd *output_bfd, struct bfd_link_info *,
 
69
                                       bfd *input_bfd, asection *input_section,
 
70
                                       bfd_byte *contents,
 
71
                                       PTR external_relocs));
 
72
  /* Do final adjustments to filehdr and aouthdr.  */
 
73
  boolean (*adjust_headers) PARAMS ((bfd *, struct internal_filehdr *,
 
74
                                     struct internal_aouthdr *));
 
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.  */
 
77
  bfd *(*get_elt_at_filepos) PARAMS ((bfd *, file_ptr));
 
78
};
 
79
 
 
80
/* This is the target specific information kept for ECOFF files.  */
 
81
 
 
82
#define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
 
83
 
 
84
typedef struct ecoff_tdata
 
85
{
 
86
  /* The reloc file position, set by
 
87
     ecoff_compute_section_file_positions.  */
 
88
  file_ptr reloc_filepos;
 
89
 
 
90
  /* The symbol table file position, set by _bfd_ecoff_mkobject_hook.  */
 
91
  file_ptr sym_filepos;
 
92
 
 
93
  /* The start and end of the text segment.  Only valid for an
 
94
     existing file, not for one we are creating.  */
 
95
  unsigned long text_start;
 
96
  unsigned long text_end;
 
97
 
 
98
  /* The cached gp value.  This is used when relocating.  */
 
99
  bfd_vma gp;
 
100
 
 
101
  /* The maximum size of objects to optimize using gp.  This is
 
102
     typically set by the -G option to the compiler, assembler or
 
103
     linker.  */
 
104
  unsigned int gp_size;
 
105
 
 
106
  /* The register masks.  When linking, all the masks found in the
 
107
     input files are combined into the masks of the output file.
 
108
     These are not all used for all targets, but that's OK, because
 
109
     the relevant ones are the only ones swapped in and out.  */
 
110
  unsigned long gprmask;
 
111
  unsigned long fprmask;
 
112
  unsigned long cprmask[4];
 
113
 
 
114
  /* The ECOFF symbolic debugging information.  */
 
115
  struct ecoff_debug_info debug_info;
 
116
 
 
117
  /* The unswapped ECOFF symbolic information.  */
 
118
  PTR raw_syments;
 
119
 
 
120
  /* The canonical BFD symbols.  */
 
121
  struct ecoff_symbol_struct *canonical_symbols;
 
122
 
 
123
  /* A mapping from external symbol numbers to entries in the linker
 
124
     hash table, used when linking.  */
 
125
  struct ecoff_link_hash_entry **sym_hashes;
 
126
 
 
127
  /* A mapping from reloc symbol indices to sections, used when
 
128
     linking.  */
 
129
  asection **symndx_to_section;
 
130
 
 
131
  /* True if this BFD was written by the backend linker.  */
 
132
  boolean linker;
 
133
 
 
134
  /* True if a warning that multiple global pointer values are
 
135
     needed in the output binary was issued already.  */
 
136
  boolean issued_multiple_gp_warning;
 
137
 
 
138
  /* Used by find_nearest_line entry point.  The structure could be
 
139
     included directly in this one, but there's no point to wasting
 
140
     the memory just for the infrequently called find_nearest_line.  */
 
141
  struct ecoff_find_line *find_line_info;
 
142
 
 
143
  /* Whether the .rdata section is in the text segment for this
 
144
     particular ECOFF file.  This is not valid until
 
145
     ecoff_compute_section_file_positions is called.  */
 
146
  boolean rdata_in_text;
 
147
 
 
148
} ecoff_data_type;
 
149
 
 
150
/* Each canonical asymbol really looks like this.  */
 
151
 
 
152
typedef struct ecoff_symbol_struct
 
153
{
 
154
  /* The actual symbol which the rest of BFD works with */
 
155
  asymbol symbol;
 
156
 
 
157
  /* The fdr for this symbol.  */
 
158
  FDR *fdr;
 
159
 
 
160
  /* true if this is a local symbol rather than an external one.  */
 
161
  boolean local;
 
162
 
 
163
  /* A pointer to the unswapped hidden information for this symbol.
 
164
     This is either a struct sym_ext or a struct ext_ext, depending on
 
165
     the value of the local field above.  */
 
166
  PTR native;
 
167
} ecoff_symbol_type;
 
168
 
 
169
/* We take the address of the first element of an asymbol to ensure that the
 
170
   macro is only ever applied to an asymbol.  */
 
171
#define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
 
172
 
 
173
/* We need to save the index of an external symbol when we write it
 
174
   out so that can set the symbol index correctly when we write out
 
175
   the relocs.  */
 
176
#define ecoff_get_sym_index(symbol) ((symbol)->udata.i)
 
177
#define ecoff_set_sym_index(symbol, idx) ((symbol)->udata.i = (idx))
 
178
 
 
179
/* When generating MIPS embedded PIC code, the linker relaxes the code
 
180
   to turn PC relative branches into longer code sequences when the PC
 
181
   relative branch is out of range.  This involves reading the relocs
 
182
   in bfd_relax_section as well as in bfd_final_link, and requires the
 
183
   code to keep track of which relocs have been expanded.  A pointer
 
184
   to this structure is put in the used_by_bfd pointer of a section to
 
185
   keep track of this information.  The user_by_bfd pointer will be
 
186
   NULL if the information was not needed.  */
 
187
 
 
188
struct ecoff_section_tdata
 
189
{
 
190
  /* The unswapped relocs for this section.  These are stored in
 
191
     memory so the input file does not have to be read twice.  */
 
192
  PTR external_relocs;
 
193
 
 
194
  /* The contents of the section.  These bytes may or may not be saved
 
195
     in memory, but if it is this is a pointer to them.  */
 
196
  bfd_byte *contents;
 
197
 
 
198
  /* Offset adjustments for PC relative branches.  A number other than
 
199
     1 is an addend for a PC relative branch, or a switch table entry
 
200
     which is the difference of two .text locations; this addend
 
201
     arises because the branch or difference crosses one or more
 
202
     branches which were expanded into a larger code sequence.  A 1
 
203
     means that this branch was itself expanded into a larger code
 
204
     sequence.  1 is not a possible offset, since all offsets must be
 
205
     multiples of the instruction size, which is 4; also, the only
 
206
     relocs with non-zero offsets will be PC relative branches or
 
207
     switch table entries within the same object file.  If this field
 
208
     is NULL, no branches were expanded and no offsets are required.
 
209
     Otherwise there are as many entries as there are relocs in the
 
210
     section, and the entry for any reloc that is not PC relative is
 
211
     zero.  */
 
212
  long *offsets;
 
213
 
 
214
  /* When producing an executable (i.e., final, non-relocatable link)
 
215
     on the Alpha, we may need to use multiple global pointer values
 
216
     to span the entire .lita section.  In essence, we allow each
 
217
     input .lita section to have its own gp value.  To support this,
 
218
     we need to keep track of the gp values that we picked for each
 
219
     input .lita section . */
 
220
  bfd_vma gp;
 
221
};
 
222
 
 
223
/* An accessor macro for the ecoff_section_tdata structure.  */
 
224
#define ecoff_section_data(abfd, sec) \
 
225
  ((struct ecoff_section_tdata *) (sec)->used_by_bfd)
 
226
 
 
227
/* ECOFF linker hash table entries.  */
 
228
 
 
229
struct ecoff_link_hash_entry
 
230
{
 
231
  struct bfd_link_hash_entry root;
 
232
  /* Symbol index in output file.  */
 
233
  long indx;
 
234
  /* BFD that ext field value came from.  */
 
235
  bfd *abfd;
 
236
  /* ECOFF external symbol information.  */
 
237
  EXTR esym;
 
238
  /* Nonzero if this symbol has been written out.  */
 
239
  char written;
 
240
  /* Nonzero if this symbol was referred to as small undefined.  */
 
241
  char small;
 
242
};
 
243
 
 
244
/* ECOFF linker hash table.  */
 
245
 
 
246
struct ecoff_link_hash_table
 
247
{
 
248
  struct bfd_link_hash_table root;
 
249
};
 
250
 
 
251
/* Make an ECOFF object.  */
 
252
extern boolean _bfd_ecoff_mkobject PARAMS ((bfd *));
 
253
 
 
254
/* Read in the ECOFF symbolic debugging information.  */
 
255
extern boolean _bfd_ecoff_slurp_symbolic_info
 
256
  PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
 
257
 
 
258
/* Generic ECOFF BFD backend vectors.  */
 
259
 
 
260
extern boolean _bfd_ecoff_write_object_contents PARAMS ((bfd *abfd));
 
261
extern const bfd_target *_bfd_ecoff_archive_p PARAMS ((bfd *abfd));
 
262
 
 
263
#define _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup
 
264
#define _bfd_ecoff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
 
265
extern boolean _bfd_ecoff_new_section_hook
 
266
  PARAMS ((bfd *, asection *));
 
267
extern boolean _bfd_ecoff_get_section_contents
 
268
  PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
 
269
 
 
270
#define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section
 
271
 
 
272
extern boolean _bfd_ecoff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
 
273
#define _bfd_ecoff_bfd_copy_private_section_data \
 
274
  _bfd_generic_bfd_copy_private_section_data
 
275
 
 
276
#define _bfd_ecoff_bfd_copy_private_symbol_data \
 
277
  _bfd_generic_bfd_copy_private_symbol_data
 
278
 
 
279
#define _bfd_ecoff_bfd_print_private_bfd_data \
 
280
  _bfd_generic_bfd_print_private_bfd_data
 
281
 
 
282
#define _bfd_ecoff_bfd_merge_private_bfd_data \
 
283
  _bfd_generic_bfd_merge_private_bfd_data
 
284
 
 
285
#define _bfd_ecoff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
 
286
extern boolean _bfd_ecoff_slurp_armap PARAMS ((bfd *abfd));
 
287
#define _bfd_ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
 
288
#define _bfd_ecoff_construct_extended_name_table \
 
289
  _bfd_archive_bsd_construct_extended_name_table
 
290
#define _bfd_ecoff_truncate_arname bfd_dont_truncate_arname
 
291
extern boolean _bfd_ecoff_write_armap
 
292
  PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
 
293
#define _bfd_ecoff_read_ar_hdr _bfd_generic_read_ar_hdr
 
294
#define _bfd_ecoff_openr_next_archived_file \
 
295
  bfd_generic_openr_next_archived_file
 
296
#define _bfd_ecoff_get_elt_at_index _bfd_generic_get_elt_at_index
 
297
#define _bfd_ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
 
298
#define _bfd_ecoff_update_armap_timestamp bfd_true
 
299
 
 
300
extern long _bfd_ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd));
 
301
extern long _bfd_ecoff_get_symtab PARAMS ((bfd *abfd, asymbol **alocation));
 
302
extern asymbol *_bfd_ecoff_make_empty_symbol PARAMS ((bfd *abfd));
 
303
extern void _bfd_ecoff_print_symbol
 
304
  PARAMS ((bfd *, PTR filep, asymbol *, bfd_print_symbol_type));
 
305
extern void _bfd_ecoff_get_symbol_info
 
306
  PARAMS ((bfd *, asymbol *, symbol_info *));
 
307
extern boolean _bfd_ecoff_bfd_is_local_label_name
 
308
  PARAMS ((bfd *, const char *));
 
309
#define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno
 
310
extern boolean _bfd_ecoff_find_nearest_line
 
311
  PARAMS ((bfd *, asection *, asymbol **, bfd_vma offset,
 
312
           const char **filename_ptr, const char **fnname_ptr,
 
313
           unsigned int *retline_ptr));
 
314
#define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
 
315
#define _bfd_ecoff_read_minisymbols _bfd_generic_read_minisymbols
 
316
#define _bfd_ecoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
 
317
 
 
318
#define _bfd_ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
 
319
extern long _bfd_ecoff_canonicalize_reloc
 
320
  PARAMS ((bfd *, asection *, arelent **, asymbol **symbols));
 
321
/* ecoff_bfd_reloc_type_lookup defined by backend. */
 
322
 
 
323
extern boolean _bfd_ecoff_set_arch_mach
 
324
  PARAMS ((bfd *, enum bfd_architecture, unsigned long));
 
325
extern boolean _bfd_ecoff_set_section_contents
 
326
  PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
 
327
 
 
328
extern int _bfd_ecoff_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
 
329
/* ecoff_bfd_get_relocated_section_contents defined by backend.  */
 
330
/* ecoff_bfd_relax_section defined by backend.  */
 
331
extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create
 
332
  PARAMS ((bfd *));
 
333
#define _bfd_ecoff_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 
334
extern boolean _bfd_ecoff_bfd_link_add_symbols
 
335
  PARAMS ((bfd *, struct bfd_link_info *));
 
336
#define _bfd_ecoff_bfd_link_just_syms _bfd_generic_link_just_syms
 
337
extern boolean _bfd_ecoff_bfd_final_link
 
338
  PARAMS ((bfd *, struct bfd_link_info *));
 
339
 
 
340
/* Hook functions for the generic COFF section reading code.  */
 
341
 
 
342
extern PTR _bfd_ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
 
343
#define _bfd_ecoff_set_alignment_hook \
 
344
  ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
 
345
extern boolean _bfd_ecoff_set_arch_mach_hook PARAMS ((bfd *abfd, PTR filehdr));
 
346
extern boolean _bfd_ecoff_styp_to_sec_flags
 
347
  PARAMS ((bfd *, PTR, const char *, asection *, flagword *));
 
348
extern boolean _bfd_ecoff_slurp_symbol_table PARAMS ((bfd *abfd));
 
349
 
 
350
/* ECOFF auxiliary information swapping routines.  These are the same
 
351
   for all ECOFF targets, so they are defined in ecofflink.c.  */
 
352
 
 
353
extern void _bfd_ecoff_swap_tir_in
 
354
  PARAMS ((int, const struct tir_ext *, TIR *));
 
355
extern void _bfd_ecoff_swap_tir_out
 
356
  PARAMS ((int, const TIR *, struct tir_ext *));
 
357
extern void _bfd_ecoff_swap_rndx_in
 
358
  PARAMS ((int, const struct rndx_ext *, RNDXR *));
 
359
extern void _bfd_ecoff_swap_rndx_out
 
360
  PARAMS ((int, const RNDXR *, struct rndx_ext *));