1 /* BFD COFF object file private structure.
2 Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3 Written by 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. */
22 /* Object file tdata; access macros */
24 #define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
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)
29 #define obj_relocbase(bfd) (coff_data(bfd)->relocbase)
30 #define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments)
31 #define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count)
32 #define obj_convert(bfd) (coff_data(bfd)->conversion_table)
33 #define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size)
35 #define obj_symbol_slew(bfd) (coff_data(bfd)->symbol_index_slew)
37 #define obj_symbol_slew(bfd) 0
41 /* `Tdata' information kept for COFF files. */
43 typedef struct coff_tdata
45 struct coff_symbol_struct *symbols; /* symtab for input bfd */
46 unsigned int *conversion_table;
50 long symbol_index_slew; /* used during read to mark whether a
51 C_FILE symbol as been added. */
53 struct coff_ptr_struct *raw_syments;
54 struct lineno *raw_linenos;
55 unsigned int raw_syment_count;
58 /* These are only valid once writing has begun */
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;
73 /* We take the address of the first element of a asymbol to ensure that the
74 * macro is only ever applied to an asymbol. */
75 #define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
77 /* Functions in coffgen.c. */
78 extern bfd_target *coff_object_p PARAMS ((bfd *));
79 extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
80 extern unsigned int coff_get_symtab_upper_bound PARAMS ((bfd *));
81 extern unsigned int coff_get_symtab PARAMS ((bfd *, asymbol **));
82 extern int coff_count_linenumbers PARAMS ((bfd *));
83 extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
84 extern void coff_renumber_symbols PARAMS ((bfd *));
85 extern void coff_mangle_symbols PARAMS ((bfd *));
86 extern void coff_write_symbols PARAMS ((bfd *));
87 extern void coff_write_linenumbers PARAMS ((bfd *));
88 extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
89 extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
90 extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *));
91 extern unsigned int coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
92 extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
93 extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
94 bfd_print_symbol_type how));
95 extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *,
97 extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR,
99 extern boolean coff_find_nearest_line PARAMS ((bfd *,
103 CONST char **filename_ptr,
104 CONST char **functionname_ptr,
105 unsigned int *line_ptr));
106 extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
107 extern boolean bfd_coff_reloc16_relax_section PARAMS ((bfd *,
109 struct bfd_link_info *,
111 extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
112 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
113 bfd_byte *, boolean relocateable, asymbol **));
114 extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
115 struct bfd_link_info *,
117 extern void bfd_perform_slip PARAMS ((asymbol **s, unsigned int slip,
118 asection *input_section,
121 /* And more taken from the source .. */
123 typedef struct coff_ptr_struct
126 /* Remembers the offset from the first symbol in the file for
127 this symbol. Generated by coff_renumber_symbols. */
130 /* Should the tag field of this symbol be renumbered.
131 Created by coff_pointerize_aux. */
134 /* Should the endidx field of this symbol be renumbered.
135 Created by coff_pointerize_aux. */
138 /* The container for the symbol structure as read and translated
142 union internal_auxent auxent;
143 struct internal_syment syment;
145 } combined_entry_type;
148 /* Each canonical asymbol really looks like this: */
150 typedef struct coff_symbol_struct
152 /* The actual symbol which the rest of BFD works with */
155 /* A pointer to the hidden information for this symbol */
156 combined_entry_type *native;
158 /* A pointer to the linenumber information for this symbol */
159 struct lineno_cache_entry *lineno;
161 /* Have the line numbers been relocated yet ? */
166 void (*_bfd_coff_swap_aux_in) PARAMS ((
175 void (*_bfd_coff_swap_sym_in) PARAMS ((
180 void (*_bfd_coff_swap_lineno_in) PARAMS ((
185 unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
194 unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
199 unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
204 unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
209 unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
214 unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
219 unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
224 unsigned int _bfd_filhsz;
225 unsigned int _bfd_aoutsz;
226 unsigned int _bfd_scnhsz;
227 unsigned int _bfd_symesz;
228 unsigned int _bfd_auxesz;
229 unsigned int _bfd_linesz;
230 boolean _bfd_coff_long_filenames;
231 void (*_bfd_coff_swap_filehdr_in) PARAMS ((
235 void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
239 void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
243 boolean (*_bfd_coff_bad_format_hook) PARAMS ((
245 PTR internal_filehdr));
246 boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
248 PTR internal_filehdr));
249 PTR (*_bfd_coff_mkobject_hook) PARAMS ((
251 PTR internal_filehdr,
252 PTR internal_aouthdr));
253 flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
255 PTR internal_scnhdr));
256 asection *(*_bfd_make_section_hook) PARAMS ((
259 void (*_bfd_set_alignment_hook) PARAMS ((
262 PTR internal_scnhdr));
263 boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
265 boolean (*_bfd_coff_symname_in_debug) PARAMS ((
267 struct internal_syment *sym));
268 void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
270 struct bfd_link_info *link_info,
271 struct bfd_link_order *link_order,
274 unsigned int *src_ptr,
275 unsigned int *dst_ptr));
276 int (*_bfd_coff_reloc16_estimate) PARAMS ((
277 asection *input_section,
281 struct bfd_link_info *link_info));
283 } bfd_coff_backend_data;
285 #define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
287 #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
288 ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
290 #define bfd_coff_swap_sym_in(a,e,i) \
291 ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
293 #define bfd_coff_swap_lineno_in(a,e,i) \
294 ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
296 #define bfd_coff_swap_reloc_out(abfd, i, o) \
297 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
299 #define bfd_coff_swap_lineno_out(abfd, i, o) \
300 ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
302 #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
303 ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
305 #define bfd_coff_swap_sym_out(abfd, i,o) \
306 ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
308 #define bfd_coff_swap_scnhdr_out(abfd, i,o) \
309 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
311 #define bfd_coff_swap_filehdr_out(abfd, i,o) \
312 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
314 #define bfd_coff_swap_aouthdr_out(abfd, i,o) \
315 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
317 #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
318 #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
319 #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
320 #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
321 #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
322 #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
323 #define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
324 #define bfd_coff_swap_filehdr_in(abfd, i,o) \
325 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
327 #define bfd_coff_swap_aouthdr_in(abfd, i,o) \
328 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
330 #define bfd_coff_swap_scnhdr_in(abfd, i,o) \
331 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
333 #define bfd_coff_bad_format_hook(abfd, filehdr) \
334 ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
336 #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
337 ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
338 #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
339 ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
341 #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr)\
342 ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr))
344 #define bfd_coff_make_section_hook(abfd, name)\
345 ((coff_backend_info (abfd)->_bfd_make_section_hook) (abfd, name))
347 #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
348 ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
350 #define bfd_coff_slurp_symbol_table(abfd)\
351 ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
353 #define bfd_coff_symname_in_debug(abfd, sym)\
354 ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
356 #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
357 ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
358 (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
360 #define bfd_coff_reloc16_estimate(abfd, section, symbols, reloc, shrink, link_info)\
361 ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
362 (section, symbols, reloc, shrink, link_info))