Revisions from Jeff Law to HPPA-directives section.
[deliverable/binutils-gdb.git] / bfd / libcoff.h
CommitLineData
3c8a3c56 1/* BFD COFF object file private structure.
85fe7cff 2 Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3c8a3c56 3 Written by Cygnus Support.
4a81b561 4
3c8a3c56 5This file is part of BFD, the Binary File Descriptor library.
4a81b561 6
3c8a3c56 7This program is free software; you can redistribute it and/or modify
4a81b561 8it under the terms of the GNU General Public License as published by
3c8a3c56
JG
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
4a81b561 11
3c8a3c56 12This program is distributed in the hope that it will be useful,
4a81b561
DHW
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
3c8a3c56
JG
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
4a81b561 20
4a81b561 21
4a81b561
DHW
22/* Object file tdata; access macros */
23
2f8640fe 24#define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
3b4f1a5d
SC
25#define exec_hdr(bfd) (coff_data(bfd)->hdr)
26#define obj_symbols(bfd) (coff_data(bfd)->symbols)
27#define obj_sym_filepos(bfd) (coff_data(bfd)->sym_filepos)
3c8a3c56 28
3b4f1a5d
SC
29#define obj_relocbase(bfd) (coff_data(bfd)->relocbase)
30#define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments)
85fe7cff 31#define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count)
3b4f1a5d 32#define obj_convert(bfd) (coff_data(bfd)->conversion_table)
07de8e96 33#define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size)
0cda46cf
SC
34#if CFILE_STUFF
35#define obj_symbol_slew(bfd) (coff_data(bfd)->symbol_index_slew)
36#else
37#define obj_symbol_slew(bfd) 0
38#endif
39
4a81b561 40
3b4f1a5d 41/* `Tdata' information kept for COFF files. */
3c8a3c56 42
3b4f1a5d
SC
43typedef struct coff_tdata
44{
45 struct coff_symbol_struct *symbols; /* symtab for input bfd */
4a81b561 46 unsigned int *conversion_table;
07de8e96 47 int conv_table_size;
4a81b561
DHW
48 file_ptr sym_filepos;
49
50 long symbol_index_slew; /* used during read to mark whether a
51 C_FILE symbol as been added. */
52
3b4f1a5d 53 struct coff_ptr_struct *raw_syments;
4a81b561
DHW
54 struct lineno *raw_linenos;
55 unsigned int raw_syment_count;
9872a49c 56 unsigned short flags;
3b4f1a5d 57
4a81b561
DHW
58 /* These are only valid once writing has begun */
59 long int relocbase;
3b4f1a5d
SC
60
61 /* These members communicate important constants about the symbol table
62 to GDB's symbol-reading code. These `constants' unfortunately vary
63 from coff implementation to implementation... */
64 unsigned local_n_btmask;
65 unsigned local_n_btshft;
66 unsigned local_n_tmask;
67 unsigned local_n_tshift;
68 unsigned local_symesz;
69 unsigned local_auxesz;
70 unsigned local_linesz;
9872a49c 71} coff_data_type;
4a81b561 72
fc723380 73/* We take the address of the first element of a asymbol to ensure that the
4a81b561
DHW
74 * macro is only ever applied to an asymbol. */
75#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
fc723380 76
075caafd
ILT
77/* Functions in coffgen.c. */
78extern bfd_target *coff_object_p PARAMS ((bfd *));
79extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
80extern unsigned int coff_get_symtab_upper_bound PARAMS ((bfd *));
81extern unsigned int coff_get_symtab PARAMS ((bfd *, asymbol **));
85fe7cff 82extern int coff_count_linenumbers PARAMS ((bfd *));
075caafd
ILT
83extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
84extern void coff_renumber_symbols PARAMS ((bfd *));
85extern void coff_mangle_symbols PARAMS ((bfd *));
86extern void coff_write_symbols PARAMS ((bfd *));
87extern void coff_write_linenumbers PARAMS ((bfd *));
88extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
89extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
90extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *));
91extern unsigned int coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
92extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
93extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
94 bfd_print_symbol_type how));
95extern asymbol *coff_make_debug_symbol PARAMS ((bfd *, PTR, unsigned long));
96extern boolean coff_find_nearest_line PARAMS ((bfd *,
97 asection *,
98 asymbol **,
99 bfd_vma offset,
100 CONST char **filename_ptr,
101 CONST char **functionname_ptr,
102 unsigned int *line_ptr));
103extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
104extern boolean bfd_coff_reloc16_relax_section PARAMS ((bfd *,
105 asection *,
106 asymbol **));
107extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
0c2fae09 108 PARAMS ((bfd *, struct bfd_seclet *, bfd_byte *, boolean relocateable));
075caafd 109extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
918356b9 110 struct bfd_seclet *));
3c8a3c56 111
616ebcfd 112/* And more taken from the source .. */
3c8a3c56 113
2f8640fe 114typedef struct coff_ptr_struct
0cda46cf 115{
616ebcfd
SC
116
117 /* Remembers the offset from the first symbol in the file for
118 this symbol. Generated by coff_renumber_symbols. */
0cda46cf 119unsigned int offset;
616ebcfd
SC
120
121 /* Should the tag field of this symbol be renumbered.
122 Created by coff_pointerize_aux. */
0cda46cf 123char fix_tag;
616ebcfd
SC
124
125 /* Should the endidx field of this symbol be renumbered.
126 Created by coff_pointerize_aux. */
0cda46cf 127char fix_end;
616ebcfd
SC
128
129 /* The container for the symbol structure as read and translated
130 from the file. */
131
0cda46cf
SC
132union {
133 union internal_auxent auxent;
134 struct internal_syment syment;
135 } u;
136} combined_entry_type;
616ebcfd
SC
137
138
139 /* Each canonical asymbol really looks like this: */
140
0cda46cf
SC
141typedef struct coff_symbol_struct
142{
07de8e96
KR
143 /* The actual symbol which the rest of BFD works with */
144asymbol symbol;
616ebcfd 145
07de8e96
KR
146 /* A pointer to the hidden information for this symbol */
147combined_entry_type *native;
c618de01 148
07de8e96
KR
149 /* A pointer to the linenumber information for this symbol */
150struct lineno_cache_entry *lineno;
151
152 /* Have the line numbers been relocated yet ? */
153boolean done_lineno;
616ebcfd 154} coff_symbol_type;
075caafd
ILT
155typedef struct
156{
07de8e96
KR
157 void (*_bfd_coff_swap_aux_in) PARAMS ((
158 bfd *abfd ,
159 PTR ext,
160 int type,
161 int class ,
162 PTR in));
163
164 void (*_bfd_coff_swap_sym_in) PARAMS ((
165 bfd *abfd ,
166 PTR ext,
167 PTR in));
168
169 void (*_bfd_coff_swap_lineno_in) PARAMS ((
170 bfd *abfd,
171 PTR ext,
172 PTR in));
173
174 unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
175 bfd *abfd,
176 PTR in,
177 int type,
178 int class,
179 PTR ext));
180
181 unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
182 bfd *abfd,
183 PTR in,
184 PTR ext));
185
186 unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
187 bfd *abfd,
188 PTR in,
189 PTR ext));
190
191 unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
192 bfd *abfd,
193 PTR src,
194 PTR dst));
195
196 unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
197 bfd *abfd,
198 PTR in,
199 PTR out));
200
201 unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
202 bfd *abfd,
203 PTR in,
204 PTR out));
205
206 unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
207 bfd *abfd,
208 PTR in,
209 PTR out));
210
075caafd
ILT
211 unsigned int _bfd_filhsz;
212 unsigned int _bfd_aoutsz;
213 unsigned int _bfd_scnhsz;
214 unsigned int _bfd_symesz;
215 unsigned int _bfd_auxesz;
216 unsigned int _bfd_linesz;
217 boolean _bfd_coff_long_filenames;
218 void (*_bfd_coff_swap_filehdr_in) PARAMS ((
219 bfd *abfd,
220 PTR ext,
221 PTR in));
222 void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
223 bfd *abfd,
224 PTR ext,
225 PTR in));
226 void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
227 bfd *abfd,
228 PTR ext,
229 PTR in));
230 boolean (*_bfd_coff_bad_format_hook) PARAMS ((
231 bfd *abfd,
232 PTR internal_filehdr));
233 boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
234 bfd *abfd,
235 PTR internal_filehdr));
236 PTR (*_bfd_coff_mkobject_hook) PARAMS ((
237 bfd *abfd,
85fe7cff
PB
238 PTR internal_filehdr,
239 PTR internal_aouthdr));
075caafd
ILT
240 flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
241 bfd *abfd,
242 PTR internal_scnhdr));
243 asection *(*_bfd_make_section_hook) PARAMS ((
244 bfd *abfd,
245 char *name));
246 void (*_bfd_set_alignment_hook) PARAMS ((
247 bfd *abfd,
248 asection *sec,
249 PTR internal_scnhdr));
250 boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
251 bfd *abfd));
252 boolean (*_bfd_coff_symname_in_debug) PARAMS ((
253 bfd *abfd,
254 struct internal_syment *sym));
255 void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
256 bfd *abfd,
918356b9 257 struct bfd_seclet *seclet,
075caafd
ILT
258 arelent *reloc,
259 bfd_byte *data,
260 unsigned int *src_ptr,
261 unsigned int *dst_ptr));
07de8e96
KR
262} bfd_coff_backend_data;
263
07de8e96
KR
264#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
265
266#define bfd_coff_swap_aux_in(a,e,t,c,i) \
267 ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,i))
268
269#define bfd_coff_swap_sym_in(a,e,i) \
270 ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
271
272#define bfd_coff_swap_lineno_in(a,e,i) \
273 ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
274
275#define bfd_coff_swap_reloc_out(abfd, i, o) \
276 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
277
278#define bfd_coff_swap_lineno_out(abfd, i, o) \
279 ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
280
281#define bfd_coff_swap_aux_out(abfd, i, t,c,o) \
282 ((coff_backend_info (abfd)->_bfd_coff_swap_aux_out) (abfd, i,t,c, o))
283
284#define bfd_coff_swap_sym_out(abfd, i,o) \
285 ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
286
287#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
288 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
289
290#define bfd_coff_swap_filehdr_out(abfd, i,o) \
291 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
292
293#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
294 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
295
075caafd
ILT
296#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
297#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
298#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
299#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
300#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
301#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
302#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
303#define bfd_coff_swap_filehdr_in(abfd, i,o) \
304 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
305
306#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
307 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
308
309#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
310 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
311
312#define bfd_coff_bad_format_hook(abfd, filehdr) \
313 ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
314
315#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
316 ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
85fe7cff
PB
317#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
318 ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
075caafd
ILT
319
320#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr)\
321 ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr))
322
323#define bfd_coff_make_section_hook(abfd, name)\
324 ((coff_backend_info (abfd)->_bfd_make_section_hook) (abfd, name))
325
326#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
327 ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
328
329#define bfd_coff_slurp_symbol_table(abfd)\
330 ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
331
332#define bfd_coff_symname_in_debug(abfd, sym)\
333 ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
334
335#define bfd_coff_reloc16_extra_cases(abfd, seclet, reloc, data, src_ptr, dst_ptr)\
336 ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
337 (abfd, seclet, reloc, data, src_ptr, dst_ptr))
338
This page took 0.122893 seconds and 4 git commands to generate.