]>
Commit | Line | Data |
---|---|---|
3c8a3c56 | 1 | /* BFD COFF object file private structure. |
d19df9b5 | 2 | Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. |
3c8a3c56 | 3 | Written by Cygnus Support. |
4a81b561 | 4 | |
d6e0e2f7 ILT |
5 | ** NOTE: libcoff.h is a GENERATED file. Don't change it; instead, |
6 | ** change libcoff-in.h or coffcode.h. | |
7 | ||
3c8a3c56 | 8 | This file is part of BFD, the Binary File Descriptor library. |
4a81b561 | 9 | |
3c8a3c56 | 10 | This program is free software; you can redistribute it and/or modify |
4a81b561 | 11 | it under the terms of the GNU General Public License as published by |
3c8a3c56 JG |
12 | the Free Software Foundation; either version 2 of the License, or |
13 | (at your option) any later version. | |
4a81b561 | 14 | |
3c8a3c56 | 15 | This program is distributed in the hope that it will be useful, |
4a81b561 DHW |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
3c8a3c56 | 21 | along with this program; if not, write to the Free Software |
e9614321 | 22 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
4a81b561 | 23 | |
69645d10 | 24 | #include "bfdlink.h" |
4a81b561 | 25 | |
4a81b561 DHW |
26 | /* Object file tdata; access macros */ |
27 | ||
2f8640fe | 28 | #define coff_data(bfd) ((bfd)->tdata.coff_obj_data) |
3b4f1a5d | 29 | #define exec_hdr(bfd) (coff_data(bfd)->hdr) |
e9614321 | 30 | #define obj_pe(bfd) (coff_data(bfd)->pe) |
3b4f1a5d SC |
31 | #define obj_symbols(bfd) (coff_data(bfd)->symbols) |
32 | #define obj_sym_filepos(bfd) (coff_data(bfd)->sym_filepos) | |
3c8a3c56 | 33 | |
3b4f1a5d SC |
34 | #define obj_relocbase(bfd) (coff_data(bfd)->relocbase) |
35 | #define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments) | |
85fe7cff | 36 | #define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count) |
3b4f1a5d | 37 | #define obj_convert(bfd) (coff_data(bfd)->conversion_table) |
07de8e96 | 38 | #define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size) |
0cda46cf | 39 | |
69645d10 | 40 | #define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms) |
e9614321 | 41 | #define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms) |
69645d10 | 42 | #define obj_coff_strings(bfd) (coff_data (bfd)->strings) |
e9614321 | 43 | #define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings) |
69645d10 | 44 | #define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes) |
4a81b561 | 45 | |
d6f41a7d KK |
46 | #define obj_coff_local_toc_table(bfd) (coff_data(bfd)->local_toc_sym_map) |
47 | ||
3b4f1a5d | 48 | /* `Tdata' information kept for COFF files. */ |
3c8a3c56 | 49 | |
3b4f1a5d SC |
50 | typedef struct coff_tdata |
51 | { | |
52 | struct coff_symbol_struct *symbols; /* symtab for input bfd */ | |
4a81b561 | 53 | unsigned int *conversion_table; |
07de8e96 | 54 | int conv_table_size; |
4a81b561 DHW |
55 | file_ptr sym_filepos; |
56 | ||
3b4f1a5d | 57 | struct coff_ptr_struct *raw_syments; |
4a81b561 | 58 | unsigned int raw_syment_count; |
3b4f1a5d | 59 | |
4a81b561 DHW |
60 | /* These are only valid once writing has begun */ |
61 | long int relocbase; | |
3b4f1a5d SC |
62 | |
63 | /* These members communicate important constants about the symbol table | |
64 | to GDB's symbol-reading code. These `constants' unfortunately vary | |
65 | from coff implementation to implementation... */ | |
66 | unsigned local_n_btmask; | |
67 | unsigned local_n_btshft; | |
68 | unsigned local_n_tmask; | |
69 | unsigned local_n_tshift; | |
70 | unsigned local_symesz; | |
71 | unsigned local_auxesz; | |
72 | unsigned local_linesz; | |
69645d10 | 73 | |
e9614321 SC |
74 | /* The unswapped external symbols. May be NULL. Read by |
75 | _bfd_coff_get_external_symbols. */ | |
69645d10 | 76 | PTR external_syms; |
e9614321 SC |
77 | /* If this is true, the external_syms may not be freed. */ |
78 | boolean keep_syms; | |
79 | ||
80 | /* The string table. May be NULL. Read by | |
81 | _bfd_coff_read_string_table. */ | |
69645d10 | 82 | char *strings; |
e9614321 SC |
83 | /* If this is true, the strings may not be freed. */ |
84 | boolean keep_strings; | |
85 | ||
86 | /* is this a PE format coff file */ | |
87 | int pe; | |
88 | /* Used by the COFF backend linker. */ | |
69645d10 | 89 | struct coff_link_hash_entry **sym_hashes; |
beee31b1 | 90 | |
d6f41a7d KK |
91 | /* used by the pe linker for PowerPC */ |
92 | int *local_toc_sym_map; | |
93 | ||
e9614321 | 94 | struct bfd_link_info *link_info; |
86aac8ea ILT |
95 | |
96 | /* Used by coff_find_nearest_line. */ | |
97 | PTR line_info; | |
9872a49c | 98 | } coff_data_type; |
4a81b561 | 99 | |
beee31b1 SC |
100 | /* Tdata for pe image files. */ |
101 | typedef struct pe_tdata | |
102 | { | |
103 | coff_data_type coff; | |
104 | struct internal_extra_pe_aouthdr pe_opthdr; | |
105 | int dll; | |
106 | int has_reloc_section; | |
28a0c103 | 107 | boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *)); |
d6f41a7d | 108 | flagword real_flags; |
beee31b1 SC |
109 | } pe_data_type; |
110 | ||
111 | #define pe_data(bfd) ((bfd)->tdata.pe_obj_data) | |
112 | ||
5f710a3a ILT |
113 | /* Tdata for XCOFF files. */ |
114 | ||
115 | struct xcoff_tdata | |
116 | { | |
117 | /* Basic COFF information. */ | |
118 | coff_data_type coff; | |
119 | ||
867d923d ILT |
120 | /* True if a large a.out header should be generated. */ |
121 | boolean full_aouthdr; | |
122 | ||
5f710a3a ILT |
123 | /* TOC value. */ |
124 | bfd_vma toc; | |
125 | ||
86aac8ea ILT |
126 | /* Index of section holding TOC. */ |
127 | int sntoc; | |
867d923d | 128 | |
86aac8ea ILT |
129 | /* Index of section holding entry point. */ |
130 | int snentry; | |
867d923d | 131 | |
5f710a3a ILT |
132 | /* .text alignment from optional header. */ |
133 | int text_align_power; | |
134 | ||
135 | /* .data alignment from optional header. */ | |
136 | int data_align_power; | |
137 | ||
138 | /* modtype from optional header. */ | |
139 | short modtype; | |
140 | ||
28a0c103 ILT |
141 | /* cputype from optional header. */ |
142 | short cputype; | |
143 | ||
5f710a3a ILT |
144 | /* maxdata from optional header. */ |
145 | bfd_size_type maxdata; | |
146 | ||
147 | /* maxstack from optional header. */ | |
148 | bfd_size_type maxstack; | |
28a0c103 ILT |
149 | |
150 | /* Used by the XCOFF backend linker. */ | |
151 | asection **csects; | |
152 | unsigned long *debug_indices; | |
153 | unsigned int import_file_id; | |
5f710a3a ILT |
154 | }; |
155 | ||
156 | #define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data) | |
beee31b1 | 157 | |
fc723380 | 158 | /* We take the address of the first element of a asymbol to ensure that the |
4a81b561 DHW |
159 | * macro is only ever applied to an asymbol. */ |
160 | #define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd))) | |
fc723380 | 161 | |
e9614321 SC |
162 | /* The used_by_bfd field of a section may be set to a pointer to this |
163 | structure. */ | |
164 | ||
165 | struct coff_section_tdata | |
166 | { | |
167 | /* The relocs, swapped into COFF internal form. This may be NULL. */ | |
168 | struct internal_reloc *relocs; | |
169 | /* If this is true, the relocs entry may not be freed. */ | |
170 | boolean keep_relocs; | |
171 | /* The section contents. This may be NULL. */ | |
172 | bfd_byte *contents; | |
173 | /* If this is true, the contents entry may not be freed. */ | |
174 | boolean keep_contents; | |
25b5a53d ILT |
175 | /* Information cached by coff_find_nearest_line. */ |
176 | bfd_vma offset; | |
177 | unsigned int i; | |
178 | const char *function; | |
179 | int line_base; | |
f5d65485 ILT |
180 | /* A pointer used for .stab linking optimizations. */ |
181 | PTR stab_info; | |
a208a70f ILT |
182 | /* Available for individual backends. */ |
183 | PTR tdata; | |
e9614321 SC |
184 | }; |
185 | ||
186 | /* An accessor macro for the coff_section_tdata structure. */ | |
187 | #define coff_section_data(abfd, sec) \ | |
188 | ((struct coff_section_tdata *) (sec)->used_by_bfd) | |
189 | ||
28a0c103 ILT |
190 | /* Tdata for sections in XCOFF files. This is used by the linker. */ |
191 | ||
192 | struct xcoff_section_tdata | |
193 | { | |
194 | /* Used for XCOFF csects created by the linker; points to the real | |
195 | XCOFF section which contains this csect. */ | |
196 | asection *enclosing; | |
b73322d9 ILT |
197 | /* The lineno_count field for the enclosing section, because we are |
198 | going to clobber it there. */ | |
199 | unsigned int lineno_count; | |
28a0c103 ILT |
200 | /* The first and one past the last symbol indices for symbols used |
201 | by this csect. */ | |
202 | unsigned long first_symndx; | |
203 | unsigned long last_symndx; | |
28a0c103 ILT |
204 | }; |
205 | ||
206 | /* An accessor macro the xcoff_section_tdata structure. */ | |
207 | #define xcoff_section_data(abfd, sec) \ | |
208 | ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata) | |
209 | ||
69645d10 ILT |
210 | /* COFF linker hash table entries. */ |
211 | ||
212 | struct coff_link_hash_entry | |
213 | { | |
214 | struct bfd_link_hash_entry root; | |
215 | ||
216 | /* Symbol index in output file. Set to -1 initially. Set to -2 if | |
217 | there is a reloc against this symbol. */ | |
218 | long indx; | |
219 | ||
220 | /* Symbol type. */ | |
221 | unsigned short type; | |
222 | ||
223 | /* Symbol class. */ | |
224 | unsigned char class; | |
225 | ||
226 | /* Number of auxiliary entries. */ | |
227 | char numaux; | |
228 | ||
229 | /* BFD to take auxiliary entries from. */ | |
230 | bfd *auxbfd; | |
231 | ||
232 | /* Pointer to array of auxiliary entries, if any. */ | |
233 | union internal_auxent *aux; | |
234 | }; | |
235 | ||
236 | /* COFF linker hash table. */ | |
237 | ||
238 | struct coff_link_hash_table | |
239 | { | |
240 | struct bfd_link_hash_table root; | |
f5d65485 ILT |
241 | /* A pointer to information used to link stabs in sections. */ |
242 | PTR stab_info; | |
69645d10 ILT |
243 | }; |
244 | ||
245 | /* Look up an entry in a COFF linker hash table. */ | |
246 | ||
247 | #define coff_link_hash_lookup(table, string, create, copy, follow) \ | |
248 | ((struct coff_link_hash_entry *) \ | |
249 | bfd_link_hash_lookup (&(table)->root, (string), (create), \ | |
250 | (copy), (follow))) | |
251 | ||
252 | /* Traverse a COFF linker hash table. */ | |
253 | ||
254 | #define coff_link_hash_traverse(table, func, info) \ | |
255 | (bfd_link_hash_traverse \ | |
256 | (&(table)->root, \ | |
257 | (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \ | |
258 | (info))) | |
259 | ||
260 | /* Get the COFF linker hash table from a link_info structure. */ | |
261 | ||
262 | #define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash)) | |
263 | ||
075caafd | 264 | /* Functions in coffgen.c. */ |
e8fbe6d9 | 265 | extern const bfd_target *coff_object_p PARAMS ((bfd *)); |
075caafd | 266 | extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int)); |
326e32d7 ILT |
267 | extern long coff_get_symtab_upper_bound PARAMS ((bfd *)); |
268 | extern long coff_get_symtab PARAMS ((bfd *, asymbol **)); | |
85fe7cff | 269 | extern int coff_count_linenumbers PARAMS ((bfd *)); |
075caafd | 270 | extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *)); |
e9614321 | 271 | extern boolean coff_renumber_symbols PARAMS ((bfd *, int *)); |
075caafd | 272 | extern void coff_mangle_symbols PARAMS ((bfd *)); |
e8fbe6d9 | 273 | extern boolean coff_write_symbols PARAMS ((bfd *)); |
326e32d7 | 274 | extern boolean coff_write_linenumbers PARAMS ((bfd *)); |
075caafd ILT |
275 | extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *)); |
276 | extern asymbol *coff_section_symbol PARAMS ((bfd *, char *)); | |
e9614321 SC |
277 | extern boolean _bfd_coff_get_external_symbols PARAMS ((bfd *)); |
278 | extern const char *_bfd_coff_read_string_table PARAMS ((bfd *)); | |
279 | extern boolean _bfd_coff_free_symbols PARAMS ((bfd *)); | |
075caafd | 280 | extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *)); |
326e32d7 | 281 | extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); |
075caafd ILT |
282 | extern asymbol *coff_make_empty_symbol PARAMS ((bfd *)); |
283 | extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *, | |
284 | bfd_print_symbol_type how)); | |
330595d0 ILT |
285 | extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *, |
286 | symbol_info *ret)); | |
287 | extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR, | |
288 | unsigned long)); | |
075caafd ILT |
289 | extern boolean coff_find_nearest_line PARAMS ((bfd *, |
290 | asection *, | |
291 | asymbol **, | |
292 | bfd_vma offset, | |
293 | CONST char **filename_ptr, | |
294 | CONST char **functionname_ptr, | |
295 | unsigned int *line_ptr)); | |
296 | extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc)); | |
326e32d7 ILT |
297 | extern boolean bfd_coff_reloc16_relax_section |
298 | PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *)); | |
075caafd | 299 | extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents |
330595d0 ILT |
300 | PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, |
301 | bfd_byte *, boolean relocateable, asymbol **)); | |
075caafd | 302 | extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *, |
330595d0 ILT |
303 | struct bfd_link_info *, |
304 | asection *)); | |
326e32d7 | 305 | extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip, |
330595d0 | 306 | asection *input_section, |
326e32d7 | 307 | bfd_vma val)); |
3c8a3c56 | 308 | |
13d1a4dd KK |
309 | /* Functions and types in cofflink.c. */ |
310 | ||
311 | #define STRING_SIZE_SIZE (4) | |
bdd2e7f1 | 312 | |
13d1a4dd KK |
313 | /* We use a hash table to merge identical enum, struct, and union |
314 | definitions in the linker. */ | |
315 | ||
316 | /* Information we keep for a single element (an enum value, a | |
317 | structure or union field) in the debug merge hash table. */ | |
318 | ||
319 | struct coff_debug_merge_element | |
320 | { | |
321 | /* Next element. */ | |
322 | struct coff_debug_merge_element *next; | |
323 | ||
324 | /* Name. */ | |
325 | const char *name; | |
326 | ||
327 | /* Type. */ | |
328 | unsigned int type; | |
329 | ||
330 | /* Symbol index for complex type. */ | |
331 | long tagndx; | |
332 | }; | |
333 | ||
334 | /* A linked list of debug merge entries for a given name. */ | |
335 | ||
336 | struct coff_debug_merge_type | |
337 | { | |
338 | /* Next type with the same name. */ | |
339 | struct coff_debug_merge_type *next; | |
340 | ||
341 | /* Class of type. */ | |
342 | int class; | |
343 | ||
344 | /* Symbol index where this type is defined. */ | |
345 | long indx; | |
346 | ||
347 | /* List of elements. */ | |
348 | struct coff_debug_merge_element *elements; | |
349 | }; | |
350 | ||
351 | /* Information we store in the debug merge hash table. */ | |
352 | ||
353 | struct coff_debug_merge_hash_entry | |
354 | { | |
355 | struct bfd_hash_entry root; | |
356 | ||
357 | /* A list of types with this name. */ | |
358 | struct coff_debug_merge_type *types; | |
359 | }; | |
360 | ||
361 | /* The debug merge hash table. */ | |
362 | ||
363 | struct coff_debug_merge_hash_table | |
364 | { | |
365 | struct bfd_hash_table root; | |
366 | }; | |
367 | ||
368 | /* Initialize a COFF debug merge hash table. */ | |
369 | ||
370 | #define coff_debug_merge_hash_table_init(table) \ | |
bdd2e7f1 | 371 | (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc)) |
13d1a4dd KK |
372 | |
373 | /* Free a COFF debug merge hash table. */ | |
374 | ||
375 | #define coff_debug_merge_hash_table_free(table) \ | |
376 | (bfd_hash_table_free (&(table)->root)) | |
377 | ||
378 | /* Look up an entry in a COFF debug merge hash table. */ | |
379 | ||
380 | #define coff_debug_merge_hash_lookup(table, string, create, copy) \ | |
381 | ((struct coff_debug_merge_hash_entry *) \ | |
382 | bfd_hash_lookup (&(table)->root, (string), (create), (copy))) | |
383 | ||
384 | /* Information we keep for each section in the output file when doing | |
385 | a relocateable link. */ | |
386 | ||
387 | struct coff_link_section_info | |
388 | { | |
389 | /* The relocs to be output. */ | |
390 | struct internal_reloc *relocs; | |
391 | /* For each reloc against a global symbol whose index was not known | |
392 | when the reloc was handled, the global hash table entry. */ | |
393 | struct coff_link_hash_entry **rel_hashes; | |
394 | }; | |
395 | ||
396 | /* Information that we pass around while doing the final link step. */ | |
397 | ||
398 | struct coff_final_link_info | |
399 | { | |
400 | /* General link information. */ | |
401 | struct bfd_link_info *info; | |
402 | /* Output BFD. */ | |
403 | bfd *output_bfd; | |
404 | /* Used to indicate failure in traversal routine. */ | |
405 | boolean failed; | |
406 | /* Hash table for long symbol names. */ | |
407 | struct bfd_strtab_hash *strtab; | |
408 | /* When doing a relocateable link, an array of information kept for | |
409 | each output section, indexed by the target_index field. */ | |
410 | struct coff_link_section_info *section_info; | |
411 | /* Symbol index of last C_FILE symbol (-1 if none). */ | |
412 | long last_file_index; | |
413 | /* Contents of last C_FILE symbol. */ | |
414 | struct internal_syment last_file; | |
d6e0e2f7 ILT |
415 | /* Symbol index of first aux entry of last .bf symbol with an empty |
416 | endndx field (-1 if none). */ | |
417 | long last_bf_index; | |
418 | /* Contents of last_bf_index aux entry. */ | |
419 | union internal_auxent last_bf; | |
13d1a4dd KK |
420 | /* Hash table used to merge debug information. */ |
421 | struct coff_debug_merge_hash_table debug_merge; | |
422 | /* Buffer large enough to hold swapped symbols of any input file. */ | |
423 | struct internal_syment *internal_syms; | |
424 | /* Buffer large enough to hold sections of symbols of any input file. */ | |
425 | asection **sec_ptrs; | |
426 | /* Buffer large enough to hold output indices of symbols of any | |
427 | input file. */ | |
428 | long *sym_indices; | |
429 | /* Buffer large enough to hold output symbols for any input file. */ | |
430 | bfd_byte *outsyms; | |
431 | /* Buffer large enough to hold external line numbers for any input | |
432 | section. */ | |
433 | bfd_byte *linenos; | |
434 | /* Buffer large enough to hold any input section. */ | |
435 | bfd_byte *contents; | |
436 | /* Buffer large enough to hold external relocs of any input section. */ | |
437 | bfd_byte *external_relocs; | |
438 | /* Buffer large enough to hold swapped relocs of any input section. */ | |
439 | struct internal_reloc *internal_relocs; | |
440 | }; | |
69645d10 | 441 | |
28a0c103 ILT |
442 | extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc |
443 | PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); | |
444 | extern boolean _bfd_coff_link_hash_table_init | |
445 | PARAMS ((struct coff_link_hash_table *, bfd *, | |
446 | struct bfd_hash_entry *(*) (struct bfd_hash_entry *, | |
447 | struct bfd_hash_table *, | |
448 | const char *))); | |
69645d10 ILT |
449 | extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create |
450 | PARAMS ((bfd *)); | |
a208a70f ILT |
451 | extern const char *_bfd_coff_internal_syment_name |
452 | PARAMS ((bfd *, const struct internal_syment *, char *)); | |
69645d10 ILT |
453 | extern boolean _bfd_coff_link_add_symbols |
454 | PARAMS ((bfd *, struct bfd_link_info *)); | |
455 | extern boolean _bfd_coff_final_link | |
456 | PARAMS ((bfd *, struct bfd_link_info *)); | |
e9614321 SC |
457 | extern struct internal_reloc *_bfd_coff_read_internal_relocs |
458 | PARAMS ((bfd *, asection *, boolean, bfd_byte *, boolean, | |
459 | struct internal_reloc *)); | |
460 | extern boolean _bfd_coff_generic_relocate_section | |
461 | PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, | |
462 | struct internal_reloc *, struct internal_syment *, asection **)); | |
28a0c103 | 463 | |
bdd2e7f1 | 464 | extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc |
13d1a4dd | 465 | PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); |
bdd2e7f1 | 466 | extern boolean _bfd_coff_write_global_sym |
13d1a4dd | 467 | PARAMS ((struct coff_link_hash_entry *, PTR)); |
bdd2e7f1 | 468 | extern boolean _bfd_coff_link_input_bfd |
13d1a4dd | 469 | PARAMS ((struct coff_final_link_info *, bfd *)); |
bdd2e7f1 | 470 | extern boolean _bfd_coff_reloc_link_order |
13d1a4dd KK |
471 | PARAMS ((bfd *, struct coff_final_link_info *, asection *, |
472 | struct bfd_link_order *)); | |
473 | ||
474 | ||
4fe6d901 KR |
475 | #define coff_get_section_contents_in_window \ |
476 | _bfd_generic_get_section_contents_in_window | |
477 | ||
28a0c103 ILT |
478 | /* Functions in xcofflink.c. */ |
479 | ||
f5d65485 ILT |
480 | extern long _bfd_xcoff_get_dynamic_symtab_upper_bound PARAMS ((bfd *)); |
481 | extern long _bfd_xcoff_canonicalize_dynamic_symtab | |
482 | PARAMS ((bfd *, asymbol **)); | |
483 | extern long _bfd_xcoff_get_dynamic_reloc_upper_bound PARAMS ((bfd *)); | |
484 | extern long _bfd_xcoff_canonicalize_dynamic_reloc | |
485 | PARAMS ((bfd *, arelent **, asymbol **)); | |
28a0c103 ILT |
486 | extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create |
487 | PARAMS ((bfd *)); | |
488 | extern boolean _bfd_xcoff_bfd_link_add_symbols | |
489 | PARAMS ((bfd *, struct bfd_link_info *)); | |
490 | extern boolean _bfd_xcoff_bfd_final_link | |
491 | PARAMS ((bfd *, struct bfd_link_info *)); | |
492 | extern boolean _bfd_ppc_xcoff_relocate_section | |
493 | PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, | |
494 | struct internal_reloc *, struct internal_syment *, asection **)); | |
69645d10 | 495 | |
616ebcfd | 496 | /* And more taken from the source .. */ |
3c8a3c56 | 497 | |
326e32d7 | 498 | typedef struct coff_ptr_struct |
0cda46cf | 499 | { |
616ebcfd SC |
500 | |
501 | /* Remembers the offset from the first symbol in the file for | |
502 | this symbol. Generated by coff_renumber_symbols. */ | |
0cda46cf | 503 | unsigned int offset; |
616ebcfd | 504 | |
c8d672fe ILT |
505 | /* Should the value of this symbol be renumbered. Used for |
506 | XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */ | |
507 | unsigned int fix_value : 1; | |
508 | ||
616ebcfd SC |
509 | /* Should the tag field of this symbol be renumbered. |
510 | Created by coff_pointerize_aux. */ | |
c8d672fe | 511 | unsigned int fix_tag : 1; |
616ebcfd SC |
512 | |
513 | /* Should the endidx field of this symbol be renumbered. | |
514 | Created by coff_pointerize_aux. */ | |
c8d672fe ILT |
515 | unsigned int fix_end : 1; |
516 | ||
517 | /* Should the x_csect.x_scnlen field be renumbered. | |
0fc9ada9 | 518 | Created by coff_pointerize_aux. */ |
c8d672fe | 519 | unsigned int fix_scnlen : 1; |
49488f2b ILT |
520 | |
521 | /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the | |
522 | index into the line number entries. Set by | |
523 | coff_slurp_symbol_table. */ | |
524 | unsigned int fix_line : 1; | |
616ebcfd SC |
525 | |
526 | /* The container for the symbol structure as read and translated | |
527 | from the file. */ | |
528 | ||
0cda46cf SC |
529 | union { |
530 | union internal_auxent auxent; | |
531 | struct internal_syment syment; | |
532 | } u; | |
533 | } combined_entry_type; | |
616ebcfd SC |
534 | |
535 | ||
536 | /* Each canonical asymbol really looks like this: */ | |
537 | ||
0cda46cf SC |
538 | typedef struct coff_symbol_struct |
539 | { | |
07de8e96 KR |
540 | /* The actual symbol which the rest of BFD works with */ |
541 | asymbol symbol; | |
616ebcfd | 542 | |
07de8e96 KR |
543 | /* A pointer to the hidden information for this symbol */ |
544 | combined_entry_type *native; | |
c618de01 | 545 | |
07de8e96 KR |
546 | /* A pointer to the linenumber information for this symbol */ |
547 | struct lineno_cache_entry *lineno; | |
548 | ||
549 | /* Have the line numbers been relocated yet ? */ | |
550 | boolean done_lineno; | |
616ebcfd | 551 | } coff_symbol_type; |
326e32d7 | 552 | typedef struct |
075caafd | 553 | { |
07de8e96 | 554 | void (*_bfd_coff_swap_aux_in) PARAMS (( |
330595d0 | 555 | bfd *abfd, |
07de8e96 KR |
556 | PTR ext, |
557 | int type, | |
330595d0 ILT |
558 | int class, |
559 | int indaux, | |
560 | int numaux, | |
07de8e96 KR |
561 | PTR in)); |
562 | ||
563 | void (*_bfd_coff_swap_sym_in) PARAMS (( | |
564 | bfd *abfd , | |
565 | PTR ext, | |
566 | PTR in)); | |
567 | ||
568 | void (*_bfd_coff_swap_lineno_in) PARAMS (( | |
569 | bfd *abfd, | |
570 | PTR ext, | |
571 | PTR in)); | |
572 | ||
573 | unsigned int (*_bfd_coff_swap_aux_out) PARAMS (( | |
574 | bfd *abfd, | |
575 | PTR in, | |
576 | int type, | |
577 | int class, | |
330595d0 ILT |
578 | int indaux, |
579 | int numaux, | |
07de8e96 KR |
580 | PTR ext)); |
581 | ||
582 | unsigned int (*_bfd_coff_swap_sym_out) PARAMS (( | |
583 | bfd *abfd, | |
584 | PTR in, | |
585 | PTR ext)); | |
586 | ||
587 | unsigned int (*_bfd_coff_swap_lineno_out) PARAMS (( | |
588 | bfd *abfd, | |
589 | PTR in, | |
590 | PTR ext)); | |
591 | ||
592 | unsigned int (*_bfd_coff_swap_reloc_out) PARAMS (( | |
593 | bfd *abfd, | |
594 | PTR src, | |
595 | PTR dst)); | |
596 | ||
597 | unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS (( | |
598 | bfd *abfd, | |
599 | PTR in, | |
600 | PTR out)); | |
601 | ||
602 | unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS (( | |
603 | bfd *abfd, | |
604 | PTR in, | |
605 | PTR out)); | |
606 | ||
607 | unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS (( | |
608 | bfd *abfd, | |
609 | PTR in, | |
610 | PTR out)); | |
611 | ||
075caafd ILT |
612 | unsigned int _bfd_filhsz; |
613 | unsigned int _bfd_aoutsz; | |
614 | unsigned int _bfd_scnhsz; | |
615 | unsigned int _bfd_symesz; | |
616 | unsigned int _bfd_auxesz; | |
69645d10 | 617 | unsigned int _bfd_relsz; |
075caafd ILT |
618 | unsigned int _bfd_linesz; |
619 | boolean _bfd_coff_long_filenames; | |
e8f3bb64 | 620 | boolean _bfd_coff_long_section_names; |
075caafd ILT |
621 | void (*_bfd_coff_swap_filehdr_in) PARAMS (( |
622 | bfd *abfd, | |
623 | PTR ext, | |
624 | PTR in)); | |
625 | void (*_bfd_coff_swap_aouthdr_in) PARAMS (( | |
626 | bfd *abfd, | |
627 | PTR ext, | |
628 | PTR in)); | |
629 | void (*_bfd_coff_swap_scnhdr_in) PARAMS (( | |
630 | bfd *abfd, | |
631 | PTR ext, | |
632 | PTR in)); | |
69645d10 ILT |
633 | void (*_bfd_coff_swap_reloc_in) PARAMS (( |
634 | bfd *abfd, | |
635 | PTR ext, | |
636 | PTR in)); | |
075caafd ILT |
637 | boolean (*_bfd_coff_bad_format_hook) PARAMS (( |
638 | bfd *abfd, | |
639 | PTR internal_filehdr)); | |
640 | boolean (*_bfd_coff_set_arch_mach_hook) PARAMS (( | |
641 | bfd *abfd, | |
642 | PTR internal_filehdr)); | |
643 | PTR (*_bfd_coff_mkobject_hook) PARAMS (( | |
644 | bfd *abfd, | |
85fe7cff PB |
645 | PTR internal_filehdr, |
646 | PTR internal_aouthdr)); | |
075caafd ILT |
647 | flagword (*_bfd_styp_to_sec_flags_hook) PARAMS (( |
648 | bfd *abfd, | |
e8fbe6d9 ILT |
649 | PTR internal_scnhdr, |
650 | const char *name)); | |
075caafd ILT |
651 | void (*_bfd_set_alignment_hook) PARAMS (( |
652 | bfd *abfd, | |
653 | asection *sec, | |
654 | PTR internal_scnhdr)); | |
655 | boolean (*_bfd_coff_slurp_symbol_table) PARAMS (( | |
656 | bfd *abfd)); | |
657 | boolean (*_bfd_coff_symname_in_debug) PARAMS (( | |
658 | bfd *abfd, | |
659 | struct internal_syment *sym)); | |
c80cc833 ILT |
660 | boolean (*_bfd_coff_pointerize_aux_hook) PARAMS (( |
661 | bfd *abfd, | |
662 | combined_entry_type *table_base, | |
663 | combined_entry_type *symbol, | |
664 | unsigned int indaux, | |
665 | combined_entry_type *aux)); | |
0fc9ada9 ILT |
666 | boolean (*_bfd_coff_print_aux) PARAMS (( |
667 | bfd *abfd, | |
668 | FILE *file, | |
669 | combined_entry_type *table_base, | |
670 | combined_entry_type *symbol, | |
671 | combined_entry_type *aux, | |
672 | unsigned int indaux)); | |
075caafd ILT |
673 | void (*_bfd_coff_reloc16_extra_cases) PARAMS (( |
674 | bfd *abfd, | |
330595d0 ILT |
675 | struct bfd_link_info *link_info, |
676 | struct bfd_link_order *link_order, | |
075caafd ILT |
677 | arelent *reloc, |
678 | bfd_byte *data, | |
679 | unsigned int *src_ptr, | |
680 | unsigned int *dst_ptr)); | |
330595d0 | 681 | int (*_bfd_coff_reloc16_estimate) PARAMS (( |
326e32d7 | 682 | bfd *abfd, |
330595d0 | 683 | asection *input_section, |
330595d0 ILT |
684 | arelent *r, |
685 | unsigned int shrink, | |
686 | struct bfd_link_info *link_info)); | |
69645d10 ILT |
687 | boolean (*_bfd_coff_sym_is_global) PARAMS (( |
688 | bfd *abfd, | |
689 | struct internal_syment *)); | |
690 | void (*_bfd_coff_compute_section_file_positions) PARAMS (( | |
691 | bfd *abfd)); | |
a208a70f ILT |
692 | boolean (*_bfd_coff_start_final_link) PARAMS (( |
693 | bfd *output_bfd, | |
694 | struct bfd_link_info *info)); | |
69645d10 ILT |
695 | boolean (*_bfd_coff_relocate_section) PARAMS (( |
696 | bfd *output_bfd, | |
697 | struct bfd_link_info *info, | |
698 | bfd *input_bfd, | |
699 | asection *input_section, | |
700 | bfd_byte *contents, | |
701 | struct internal_reloc *relocs, | |
702 | struct internal_syment *syms, | |
703 | asection **sections)); | |
e9614321 SC |
704 | reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS (( |
705 | bfd *abfd, | |
706 | asection *sec, | |
707 | struct internal_reloc *rel, | |
708 | struct coff_link_hash_entry *h, | |
709 | struct internal_syment *sym, | |
710 | bfd_vma *addendp)); | |
711 | boolean (*_bfd_coff_adjust_symndx) PARAMS (( | |
712 | bfd *obfd, | |
713 | struct bfd_link_info *info, | |
714 | bfd *ibfd, | |
715 | asection *sec, | |
716 | struct internal_reloc *reloc, | |
717 | boolean *adjustedp)); | |
d19df9b5 ILT |
718 | boolean (*_bfd_coff_link_add_one_symbol) PARAMS (( |
719 | struct bfd_link_info *info, | |
720 | bfd *abfd, | |
721 | const char *name, | |
722 | flagword flags, | |
723 | asection *section, | |
724 | bfd_vma value, | |
725 | const char *string, | |
726 | boolean copy, | |
727 | boolean collect, | |
728 | struct bfd_link_hash_entry **hashp)); | |
330595d0 | 729 | |
07de8e96 KR |
730 | } bfd_coff_backend_data; |
731 | ||
07de8e96 KR |
732 | #define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data) |
733 | ||
330595d0 ILT |
734 | #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \ |
735 | ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i)) | |
07de8e96 KR |
736 | |
737 | #define bfd_coff_swap_sym_in(a,e,i) \ | |
738 | ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i)) | |
739 | ||
740 | #define bfd_coff_swap_lineno_in(a,e,i) \ | |
741 | ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i)) | |
742 | ||
743 | #define bfd_coff_swap_reloc_out(abfd, i, o) \ | |
744 | ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o)) | |
745 | ||
746 | #define bfd_coff_swap_lineno_out(abfd, i, o) \ | |
747 | ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o)) | |
748 | ||
330595d0 ILT |
749 | #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \ |
750 | ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o)) | |
07de8e96 KR |
751 | |
752 | #define bfd_coff_swap_sym_out(abfd, i,o) \ | |
753 | ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o)) | |
754 | ||
755 | #define bfd_coff_swap_scnhdr_out(abfd, i,o) \ | |
756 | ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o)) | |
757 | ||
758 | #define bfd_coff_swap_filehdr_out(abfd, i,o) \ | |
759 | ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o)) | |
760 | ||
761 | #define bfd_coff_swap_aouthdr_out(abfd, i,o) \ | |
762 | ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o)) | |
763 | ||
075caafd ILT |
764 | #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz) |
765 | #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz) | |
766 | #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz) | |
767 | #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz) | |
768 | #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz) | |
69645d10 | 769 | #define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz) |
075caafd ILT |
770 | #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz) |
771 | #define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames) | |
e8f3bb64 ILT |
772 | #define bfd_coff_long_section_names(abfd) \ |
773 | (coff_backend_info (abfd)->_bfd_coff_long_section_names) | |
075caafd ILT |
774 | #define bfd_coff_swap_filehdr_in(abfd, i,o) \ |
775 | ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) | |
776 | ||
777 | #define bfd_coff_swap_aouthdr_in(abfd, i,o) \ | |
778 | ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o)) | |
779 | ||
780 | #define bfd_coff_swap_scnhdr_in(abfd, i,o) \ | |
781 | ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o)) | |
782 | ||
69645d10 ILT |
783 | #define bfd_coff_swap_reloc_in(abfd, i, o) \ |
784 | ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o)) | |
785 | ||
075caafd ILT |
786 | #define bfd_coff_bad_format_hook(abfd, filehdr) \ |
787 | ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr)) | |
788 | ||
789 | #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\ | |
790 | ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr)) | |
85fe7cff PB |
791 | #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\ |
792 | ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr)) | |
075caafd | 793 | |
e8fbe6d9 ILT |
794 | #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\ |
795 | ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name)) | |
075caafd | 796 | |
075caafd ILT |
797 | #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\ |
798 | ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr)) | |
799 | ||
800 | #define bfd_coff_slurp_symbol_table(abfd)\ | |
801 | ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd)) | |
802 | ||
803 | #define bfd_coff_symname_in_debug(abfd, sym)\ | |
804 | ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym)) | |
805 | ||
0fc9ada9 ILT |
806 | #define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\ |
807 | ((coff_backend_info (abfd)->_bfd_coff_print_aux)\ | |
808 | (abfd, file, base, symbol, aux, indaux)) | |
809 | ||
330595d0 | 810 | #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\ |
075caafd | 811 | ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\ |
330595d0 ILT |
812 | (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)) |
813 | ||
326e32d7 | 814 | #define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\ |
330595d0 | 815 | ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\ |
326e32d7 ILT |
816 | (abfd, section, reloc, shrink, link_info)) |
817 | ||
69645d10 ILT |
818 | #define bfd_coff_sym_is_global(abfd, sym)\ |
819 | ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\ | |
820 | (abfd, sym)) | |
821 | ||
822 | #define bfd_coff_compute_section_file_positions(abfd)\ | |
823 | ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\ | |
824 | (abfd)) | |
825 | ||
a208a70f ILT |
826 | #define bfd_coff_start_final_link(obfd, info)\ |
827 | ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\ | |
828 | (obfd, info)) | |
69645d10 ILT |
829 | #define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\ |
830 | ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\ | |
831 | (obfd, info, ibfd, o, con, rel, isyms, secs)) | |
e9614321 SC |
832 | #define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\ |
833 | ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\ | |
834 | (abfd, sec, rel, h, sym, addendp)) | |
835 | #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\ | |
836 | ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\ | |
837 | (obfd, info, ibfd, sec, rel, adjustedp)) | |
d6e0e2f7 | 838 | #define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\ |
d19df9b5 ILT |
839 | ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\ |
840 | (info, abfd, name, flags, section, value, string, cp, coll, hashp)) | |
69645d10 | 841 |