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