]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/libecoff.h
* ecoff.c: New file for generic ECOFF functions.
[thirdparty/binutils-gdb.git] / bfd / libecoff.h
CommitLineData
dae31cf5
ILT
1/* BFD ECOFF object file private structure.
2 Copyright (C) 1993 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
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. */
26
27#define ecoff_backend(abfd) (ecoff_data (abfd)->backend_data)
28
29struct ecoff_backend_data
30{
31 /* Supported architecture. */
32 enum bfd_architecture arch;
33 /* Big endian magic number. */
34 int big_magic;
35 /* Little endian magic number. */
36 int little_magic;
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. */
41 bfd_vma round;
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));
80};
81
82/* This is the target specific information kept for ECOFF files. */
83
84#define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
85
86typedef struct ecoff_tdata
87{
88 /* Constant backend information. */
89 const struct ecoff_backend_data *backend_data;
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 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 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 unsigned long gprmask;
114 unsigned long cprmask[4];
115
116 /* The size of the unswapped ECOFF symbolic information. */
117 bfd_size_type raw_size;
118
119 /* The unswapped ECOFF symbolic information. */
120 PTR raw_syments;
121
122 /* The swapped ECOFF symbolic header. */
123 HDRR symbolic_header;
124
125 /* Pointers to the unswapped symbolic information. */
126 unsigned char *line;
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;
132 char *ss;
133 char *ssext;
134 PTR external_fdr; /* struct fdr_ext */
135 PTR external_rfd; /* struct rfd_ext */
136 PTR external_ext; /* struct ext_ext */
137
138 /* The swapped FDR information. */
139 FDR *fdr;
140
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;
144
145 /* The canonical BFD symbols. */
146 struct ecoff_symbol_struct *canonical_symbols;
147
148} ecoff_data_type;
149
150/* Each canonical asymbol really looks like this. */
151
152typedef 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 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)))
172
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))
178
179/* Make an empty ECOFF symbol. */
180extern asymbol *ecoff_make_empty_symbol PARAMS ((bfd *abfd));
181
182/* Read in the ECOFF symbolic debugging information. */
183extern boolean ecoff_slurp_symbolic_info PARAMS ((bfd *));
184
185/* Generic ECOFF BFD backend vectors. */
186extern unsigned int ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd));
187extern unsigned int ecoff_get_symtab PARAMS ((bfd *abfd,
188 asymbol **alocation));
189extern void ecoff_get_symbol_info PARAMS ((bfd *abfd,
190 asymbol *symbol,
191 symbol_info *ret));
192extern void ecoff_print_symbol PARAMS ((bfd *abfd, PTR filep,
193 asymbol *symbol,
194 bfd_print_symbol_type how));
195extern unsigned int ecoff_canonicalize_reloc PARAMS ((bfd *abfd,
196 asection *section,
197 arelent **relptr,
198 asymbol **symbols));
199extern CONST struct reloc_howto_struct *ecoff_bfd_reloc_type_lookup
200 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
201extern boolean ecoff_find_nearest_line PARAMS ((bfd *abfd,
202 asection *section,
203 asymbol **symbols,
204 bfd_vma offset,
205 CONST char **filename_ptr,
206 CONST char **fnname_ptr,
207 unsigned int *retline_ptr));
208extern boolean ecoff_bfd_seclet_link PARAMS ((bfd *abfd, PTR data,
209 boolean relocateable));
210extern boolean ecoff_set_arch_mach PARAMS ((bfd *abfd,
211 enum bfd_architecture arch,
212 unsigned long machine));
213extern int ecoff_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
214extern boolean ecoff_set_section_contents PARAMS ((bfd *abfd,
215 asection *section,
216 PTR location,
217 file_ptr offset,
218 bfd_size_type count));
219extern boolean ecoff_write_object_contents PARAMS ((bfd *abfd));
220extern boolean ecoff_slurp_armap PARAMS ((bfd *abfd));
221extern boolean ecoff_write_armap PARAMS ((bfd *abfd, unsigned int elength,
222 struct orl *map,
223 unsigned int orl_count,
224 int stridx));
225#define ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
226extern 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)
244
245/* Hook functions for the generic COFF section reading code. */
246extern asection *ecoff_make_section_hook PARAMS ((bfd *abfd, char *name));
247extern boolean ecoff_new_section_hook PARAMS ((bfd *abfd,
248 asection *section));
249#define ecoff_set_alignment_hook \
250 ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
251extern boolean ecoff_set_arch_mach_hook PARAMS ((bfd *abfd, PTR filehdr));
252extern long ecoff_sec_to_styp_flags PARAMS ((CONST char *name,
253 flagword flags));
254extern flagword ecoff_styp_to_sec_flags PARAMS ((bfd *abfd, PTR hdr));
255extern boolean ecoff_slurp_symbol_table PARAMS ((bfd *abfd));