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