1 /* BFD ECOFF object file private structure.
2 Copyright (C) 1993 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* This is the backend information kept for ECOFF files. This
22 structure is constant for a particular backend. ECOFF already
23 keeps a bfd_coff_backend_data structure in the bfd_target
24 backend_data field, so a pointer to this backend structure is kept
25 in the tdata field. */
27 #define ecoff_backend(abfd) (ecoff_data (abfd)->backend_data)
29 struct ecoff_backend_data
31 /* Supported architecture. */
32 enum bfd_architecture arch
;
33 /* Big endian magic number. */
35 /* Little endian magic number. */
37 /* Alignment of debugging information. E.g., 4. */
38 bfd_size_type debug_align
;
39 /* The page boundary used to align sections in a demand-paged
40 executable file. E.g., 0x1000. */
42 /* Bitsize of constructor entries. */
43 unsigned int constructor_bitsize
;
44 /* Sizes of external symbolic information. */
45 bfd_size_type external_hdr_size
;
46 bfd_size_type external_dnr_size
;
47 bfd_size_type external_pdr_size
;
48 bfd_size_type external_sym_size
;
49 bfd_size_type external_opt_size
;
50 bfd_size_type external_fdr_size
;
51 bfd_size_type external_rfd_size
;
52 bfd_size_type external_ext_size
;
53 /* Functions to swap in external symbolic data. */
54 void (*swap_hdr_in
) PARAMS ((bfd
*, PTR
, HDRR
*));
55 void (*swap_dnr_in
) PARAMS ((bfd
*, PTR
, DNR
*));
56 void (*swap_pdr_in
) PARAMS ((bfd
*, PTR
, PDR
*));
57 void (*swap_sym_in
) PARAMS ((bfd
*, PTR
, SYMR
*));
58 void (*swap_opt_in
) PARAMS ((bfd
*, PTR
, OPTR
*));
59 void (*swap_fdr_in
) PARAMS ((bfd
*, PTR
, FDR
*));
60 void (*swap_rfd_in
) PARAMS ((bfd
*, PTR
, RFDT
*));
61 void (*swap_ext_in
) PARAMS ((bfd
*, PTR
, EXTR
*));
62 /* Functions to swap out external symbolic data. */
63 void (*swap_hdr_out
) PARAMS ((bfd
*, const HDRR
*, PTR
));
64 void (*swap_dnr_out
) PARAMS ((bfd
*, const DNR
*, PTR
));
65 void (*swap_pdr_out
) PARAMS ((bfd
*, const PDR
*, PTR
));
66 void (*swap_sym_out
) PARAMS ((bfd
*, const SYMR
*, PTR
));
67 void (*swap_opt_out
) PARAMS ((bfd
*, const OPTR
*, PTR
));
68 void (*swap_fdr_out
) PARAMS ((bfd
*, const FDR
*, PTR
));
69 void (*swap_rfd_out
) PARAMS ((bfd
*, const RFDT
*, PTR
));
70 void (*swap_ext_out
) PARAMS ((bfd
*, const EXTR
*, PTR
));
71 /* It so happens that the auxiliary type information has the same
72 type and format for all known ECOFF targets. I don't see any
73 reason that that should change, so at least for now the auxiliary
74 swapping information is not in this table. */
75 /* External reloc size. */
76 bfd_size_type external_reloc_size
;
77 /* Reloc swapping functions. */
78 void (*swap_reloc_in
) PARAMS ((bfd
*, PTR
, struct internal_reloc
*));
79 void (*swap_reloc_out
) PARAMS ((bfd
*, const struct internal_reloc
*, PTR
));
82 /* This is the target specific information kept for ECOFF files. */
84 #define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
86 typedef struct ecoff_tdata
88 /* Constant backend information. */
89 const struct ecoff_backend_data
*backend_data
;
91 /* The reloc file position, set by
92 ecoff_compute_section_file_positions. */
93 file_ptr reloc_filepos
;
95 /* The symbol table file position, set by ecoff_mkobject_hook. */
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
;
103 /* The cached gp value. This is used when relocating. */
106 /* The maximum size of objects to optimize using gp. This is
107 typically set by the -G option to the compiler, assembler or
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 unsigned long gprmask
;
114 unsigned long cprmask
[4];
116 /* The size of the unswapped ECOFF symbolic information. */
117 bfd_size_type raw_size
;
119 /* The unswapped ECOFF symbolic information. */
122 /* The swapped ECOFF symbolic header. */
123 HDRR symbolic_header
;
125 /* Pointers to the unswapped symbolic information. */
127 PTR external_dnr
; /* struct dnr_ext */
128 PTR external_pdr
; /* struct pdr_ext */
129 PTR external_sym
; /* struct sym_ext */
130 PTR external_opt
; /* struct opt_ext */
131 union aux_ext
*external_aux
;
134 PTR external_fdr
; /* struct fdr_ext */
135 PTR external_rfd
; /* struct rfd_ext */
136 PTR external_ext
; /* struct ext_ext */
138 /* The swapped FDR information. */
141 /* The FDR index. This is set for an input BFD to a link so that
142 the external symbols can set their FDR index correctly. */
143 unsigned int ifdbase
;
145 /* The canonical BFD symbols. */
146 struct ecoff_symbol_struct
*canonical_symbols
;
150 /* Each canonical asymbol really looks like this. */
152 typedef struct ecoff_symbol_struct
154 /* The actual symbol which the rest of BFD works with */
157 /* The fdr for this symbol. */
160 /* true if this is a local symbol rather than an external one. */
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. */
169 /* We take the address of the first element of a asymbol to ensure that the
170 macro is only ever applied to an asymbol. */
171 #define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
173 /* This is a hack borrowed from coffcode.h; we need to save the index
174 of an external symbol when we write it out so that can set the
175 symbol index correctly when we write out the relocs. */
176 #define ecoff_get_sym_index(symbol) ((unsigned long) (symbol)->udata)
177 #define ecoff_set_sym_index(symbol, idx) ((symbol)->udata = (PTR) (idx))
179 /* Make an empty ECOFF symbol. */
180 extern asymbol
*ecoff_make_empty_symbol
PARAMS ((bfd
*abfd
));
182 /* Read in the ECOFF symbolic debugging information. */
183 extern boolean ecoff_slurp_symbolic_info
PARAMS ((bfd
*));
185 /* Generic ECOFF BFD backend vectors. */
186 extern unsigned int ecoff_get_symtab_upper_bound
PARAMS ((bfd
*abfd
));
187 extern unsigned int ecoff_get_symtab
PARAMS ((bfd
*abfd
,
188 asymbol
**alocation
));
189 extern void ecoff_get_symbol_info
PARAMS ((bfd
*abfd
,
192 extern void ecoff_print_symbol
PARAMS ((bfd
*abfd
, PTR filep
,
194 bfd_print_symbol_type how
));
195 extern unsigned int ecoff_canonicalize_reloc
PARAMS ((bfd
*abfd
,
199 extern CONST
struct reloc_howto_struct
*ecoff_bfd_reloc_type_lookup
200 PARAMS ((bfd
*abfd
, bfd_reloc_code_real_type code
));
201 extern boolean ecoff_find_nearest_line
PARAMS ((bfd
*abfd
,
205 CONST
char **filename_ptr
,
206 CONST
char **fnname_ptr
,
207 unsigned int *retline_ptr
));
208 extern boolean ecoff_bfd_seclet_link
PARAMS ((bfd
*abfd
, PTR data
,
209 boolean relocateable
));
210 extern boolean ecoff_set_arch_mach
PARAMS ((bfd
*abfd
,
211 enum bfd_architecture arch
,
212 unsigned long machine
));
213 extern int ecoff_sizeof_headers
PARAMS ((bfd
*abfd
, boolean reloc
));
214 extern boolean ecoff_set_section_contents
PARAMS ((bfd
*abfd
,
218 bfd_size_type count
));
219 extern boolean ecoff_write_object_contents
PARAMS ((bfd
*abfd
));
220 extern boolean ecoff_slurp_armap
PARAMS ((bfd
*abfd
));
221 extern boolean ecoff_write_armap
PARAMS ((bfd
*abfd
, unsigned int elength
,
223 unsigned int orl_count
,
225 #define ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
226 extern bfd_target
*ecoff_archive_p
PARAMS ((bfd
*abfd
));
227 #define ecoff_get_lineno \
228 ((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
229 #define ecoff_truncate_arname bfd_dont_truncate_arname
230 #define ecoff_openr_next_archived_file bfd_generic_openr_next_archived_file
231 #define ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
232 #define ecoff_get_section_contents bfd_generic_get_section_contents
233 #define ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
234 #define ecoff_close_and_cleanup bfd_generic_close_and_cleanup
235 #define ecoff_bfd_debug_info_start bfd_void
236 #define ecoff_bfd_debug_info_end bfd_void
237 #define ecoff_bfd_debug_info_accumulate \
238 ((void (*) PARAMS ((bfd *, struct sec *))) bfd_void)
239 #define ecoff_bfd_get_relocated_section_contents \
240 bfd_generic_get_relocated_section_contents
241 #define ecoff_bfd_relax_section bfd_generic_relax_section
242 #define ecoff_bfd_make_debug_symbol \
243 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
245 /* Hook functions for the generic COFF section reading code. */
246 extern asection
*ecoff_make_section_hook
PARAMS ((bfd
*abfd
, char *name
));
247 extern boolean ecoff_new_section_hook
PARAMS ((bfd
*abfd
,
249 #define ecoff_set_alignment_hook \
250 ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
251 extern boolean ecoff_set_arch_mach_hook
PARAMS ((bfd
*abfd
, PTR filehdr
));
252 extern long ecoff_sec_to_styp_flags
PARAMS ((CONST
char *name
,
254 extern flagword ecoff_styp_to_sec_flags
PARAMS ((bfd
*abfd
, PTR hdr
));
255 extern boolean ecoff_slurp_symbol_table
PARAMS ((bfd
*abfd
));