* coffgen.c (coff_print_symbol): Cast pointer different to long
[deliverable/binutils-gdb.git] / bfd / libcoff.h
CommitLineData
3c8a3c56 1/* BFD COFF object file private structure.
326e32d7 2 Copyright (C) 1990, 1991, 1992, 1993, 1994 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 77/* Functions in coffgen.c. */
e8fbe6d9 78extern const bfd_target *coff_object_p PARAMS ((bfd *));
075caafd 79extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
326e32d7
ILT
80extern long coff_get_symtab_upper_bound PARAMS ((bfd *));
81extern long coff_get_symtab PARAMS ((bfd *, asymbol **));
85fe7cff 82extern int coff_count_linenumbers PARAMS ((bfd *));
075caafd 83extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
326e32d7 84extern boolean coff_renumber_symbols PARAMS ((bfd *));
075caafd 85extern void coff_mangle_symbols PARAMS ((bfd *));
e8fbe6d9 86extern boolean coff_write_symbols PARAMS ((bfd *));
326e32d7 87extern boolean coff_write_linenumbers PARAMS ((bfd *));
075caafd
ILT
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 *));
326e32d7 91extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
075caafd
ILT
92extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
93extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
94 bfd_print_symbol_type how));
330595d0
ILT
95extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *,
96 symbol_info *ret));
97extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR,
98 unsigned long));
075caafd
ILT
99extern boolean coff_find_nearest_line PARAMS ((bfd *,
100 asection *,
101 asymbol **,
102 bfd_vma offset,
103 CONST char **filename_ptr,
104 CONST char **functionname_ptr,
105 unsigned int *line_ptr));
106extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
326e32d7
ILT
107extern boolean bfd_coff_reloc16_relax_section
108 PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
075caafd 109extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
330595d0
ILT
110 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
111 bfd_byte *, boolean relocateable, asymbol **));
075caafd 112extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
330595d0
ILT
113 struct bfd_link_info *,
114 asection *));
326e32d7 115extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip,
330595d0 116 asection *input_section,
326e32d7 117 bfd_vma val));
3c8a3c56 118
616ebcfd 119/* And more taken from the source .. */
3c8a3c56 120
326e32d7 121typedef struct coff_ptr_struct
0cda46cf 122{
616ebcfd
SC
123
124 /* Remembers the offset from the first symbol in the file for
125 this symbol. Generated by coff_renumber_symbols. */
0cda46cf 126unsigned int offset;
616ebcfd 127
c8d672fe
ILT
128 /* Should the value of this symbol be renumbered. Used for
129 XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */
130unsigned int fix_value : 1;
131
616ebcfd
SC
132 /* Should the tag field of this symbol be renumbered.
133 Created by coff_pointerize_aux. */
c8d672fe 134unsigned int fix_tag : 1;
616ebcfd
SC
135
136 /* Should the endidx field of this symbol be renumbered.
137 Created by coff_pointerize_aux. */
c8d672fe
ILT
138unsigned int fix_end : 1;
139
140 /* Should the x_csect.x_scnlen field be renumbered.
141 Created by coff_slurp_symbol_table. */
142unsigned int fix_scnlen : 1;
616ebcfd
SC
143
144 /* The container for the symbol structure as read and translated
145 from the file. */
146
0cda46cf
SC
147union {
148 union internal_auxent auxent;
149 struct internal_syment syment;
150 } u;
151} combined_entry_type;
616ebcfd
SC
152
153
154 /* Each canonical asymbol really looks like this: */
155
0cda46cf
SC
156typedef struct coff_symbol_struct
157{
07de8e96
KR
158 /* The actual symbol which the rest of BFD works with */
159asymbol symbol;
616ebcfd 160
07de8e96
KR
161 /* A pointer to the hidden information for this symbol */
162combined_entry_type *native;
c618de01 163
07de8e96
KR
164 /* A pointer to the linenumber information for this symbol */
165struct lineno_cache_entry *lineno;
166
167 /* Have the line numbers been relocated yet ? */
168boolean done_lineno;
616ebcfd 169} coff_symbol_type;
326e32d7 170typedef struct
075caafd 171{
07de8e96 172 void (*_bfd_coff_swap_aux_in) PARAMS ((
330595d0 173 bfd *abfd,
07de8e96
KR
174 PTR ext,
175 int type,
330595d0
ILT
176 int class,
177 int indaux,
178 int numaux,
07de8e96
KR
179 PTR in));
180
181 void (*_bfd_coff_swap_sym_in) PARAMS ((
182 bfd *abfd ,
183 PTR ext,
184 PTR in));
185
186 void (*_bfd_coff_swap_lineno_in) PARAMS ((
187 bfd *abfd,
188 PTR ext,
189 PTR in));
190
191 unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
192 bfd *abfd,
193 PTR in,
194 int type,
195 int class,
330595d0
ILT
196 int indaux,
197 int numaux,
07de8e96
KR
198 PTR ext));
199
200 unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
201 bfd *abfd,
202 PTR in,
203 PTR ext));
204
205 unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
206 bfd *abfd,
207 PTR in,
208 PTR ext));
209
210 unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
211 bfd *abfd,
212 PTR src,
213 PTR dst));
214
215 unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
216 bfd *abfd,
217 PTR in,
218 PTR out));
219
220 unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
221 bfd *abfd,
222 PTR in,
223 PTR out));
224
225 unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
226 bfd *abfd,
227 PTR in,
228 PTR out));
229
075caafd
ILT
230 unsigned int _bfd_filhsz;
231 unsigned int _bfd_aoutsz;
232 unsigned int _bfd_scnhsz;
233 unsigned int _bfd_symesz;
234 unsigned int _bfd_auxesz;
235 unsigned int _bfd_linesz;
236 boolean _bfd_coff_long_filenames;
237 void (*_bfd_coff_swap_filehdr_in) PARAMS ((
238 bfd *abfd,
239 PTR ext,
240 PTR in));
241 void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
242 bfd *abfd,
243 PTR ext,
244 PTR in));
245 void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
246 bfd *abfd,
247 PTR ext,
248 PTR in));
249 boolean (*_bfd_coff_bad_format_hook) PARAMS ((
250 bfd *abfd,
251 PTR internal_filehdr));
252 boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
253 bfd *abfd,
254 PTR internal_filehdr));
255 PTR (*_bfd_coff_mkobject_hook) PARAMS ((
256 bfd *abfd,
85fe7cff
PB
257 PTR internal_filehdr,
258 PTR internal_aouthdr));
075caafd
ILT
259 flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
260 bfd *abfd,
e8fbe6d9
ILT
261 PTR internal_scnhdr,
262 const char *name));
075caafd
ILT
263 asection *(*_bfd_make_section_hook) PARAMS ((
264 bfd *abfd,
265 char *name));
266 void (*_bfd_set_alignment_hook) PARAMS ((
267 bfd *abfd,
268 asection *sec,
269 PTR internal_scnhdr));
270 boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
271 bfd *abfd));
272 boolean (*_bfd_coff_symname_in_debug) PARAMS ((
273 bfd *abfd,
274 struct internal_syment *sym));
275 void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
276 bfd *abfd,
330595d0
ILT
277 struct bfd_link_info *link_info,
278 struct bfd_link_order *link_order,
075caafd
ILT
279 arelent *reloc,
280 bfd_byte *data,
281 unsigned int *src_ptr,
282 unsigned int *dst_ptr));
330595d0 283 int (*_bfd_coff_reloc16_estimate) PARAMS ((
326e32d7 284 bfd *abfd,
330595d0 285 asection *input_section,
330595d0
ILT
286 arelent *r,
287 unsigned int shrink,
288 struct bfd_link_info *link_info));
289
07de8e96
KR
290} bfd_coff_backend_data;
291
07de8e96
KR
292#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
293
330595d0
ILT
294#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
295 ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
07de8e96
KR
296
297#define bfd_coff_swap_sym_in(a,e,i) \
298 ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
299
300#define bfd_coff_swap_lineno_in(a,e,i) \
301 ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
302
303#define bfd_coff_swap_reloc_out(abfd, i, o) \
304 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
305
306#define bfd_coff_swap_lineno_out(abfd, i, o) \
307 ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
308
330595d0
ILT
309#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
310 ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
07de8e96
KR
311
312#define bfd_coff_swap_sym_out(abfd, i,o) \
313 ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
314
315#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
316 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
317
318#define bfd_coff_swap_filehdr_out(abfd, i,o) \
319 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
320
321#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
322 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
323
075caafd
ILT
324#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
325#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
326#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
327#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
328#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
329#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
330#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
331#define bfd_coff_swap_filehdr_in(abfd, i,o) \
332 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
333
334#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
335 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
336
337#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
338 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
339
340#define bfd_coff_bad_format_hook(abfd, filehdr) \
341 ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
342
343#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
344 ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
85fe7cff
PB
345#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
346 ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
075caafd 347
e8fbe6d9
ILT
348#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\
349 ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name))
075caafd
ILT
350
351#define bfd_coff_make_section_hook(abfd, name)\
352 ((coff_backend_info (abfd)->_bfd_make_section_hook) (abfd, name))
353
354#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
355 ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
356
357#define bfd_coff_slurp_symbol_table(abfd)\
358 ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
359
360#define bfd_coff_symname_in_debug(abfd, sym)\
361 ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
362
330595d0 363#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
075caafd 364 ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
330595d0
ILT
365 (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
366
326e32d7 367#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
330595d0 368 ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
326e32d7
ILT
369 (abfd, section, reloc, shrink, link_info))
370
This page took 0.140332 seconds and 4 git commands to generate.