Fix typo in previous commit
[deliverable/binutils-gdb.git] / bfd / libbfd-in.h
1 /* libbfd.h -- Declarations used by bfd library *implementation*.
2 (This include file is not for users of the library.)
3
4 Copyright (C) 1990-2016 Free Software Foundation, Inc.
5
6 Written by Cygnus Support.
7
8 This file is part of BFD, the Binary File Descriptor library.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
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
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23 MA 02110-1301, USA. */
24
25 #include "hashtab.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* Align an address upward to a boundary, expressed as a number of bytes.
32 E.g. align to an 8-byte boundary with argument of 8. Take care never
33 to wrap around if the address is within boundary-1 of the end of the
34 address space. */
35 #define BFD_ALIGN(this, boundary) \
36 ((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this)) \
37 ? (((bfd_vma) (this) + ((boundary) - 1)) & ~ (bfd_vma) ((boundary)-1)) \
38 : ~ (bfd_vma) 0)
39
40 /* If you want to read and write large blocks, you might want to do it
41 in quanta of this amount */
42 #define DEFAULT_BUFFERSIZE 8192
43
44 /* Set a tdata field. Can't use the other macros for this, since they
45 do casts, and casting to the left of assignment isn't portable. */
46 #define set_tdata(bfd, v) ((bfd)->tdata.any = (v))
47
48 /* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points
49 to an instance of this structure. */
50
51 struct bfd_in_memory
52 {
53 /* Size of buffer. */
54 bfd_size_type size;
55 /* Buffer holding contents of BFD. */
56 bfd_byte *buffer;
57 };
58
59 struct section_hash_entry
60 {
61 struct bfd_hash_entry root;
62 asection section;
63 };
64
65 /* tdata for an archive. For an input archive, cache
66 needs to be free()'d. For an output archive, symdefs do. */
67
68 struct artdata
69 {
70 file_ptr first_file_filepos;
71 /* Speed up searching the armap */
72 htab_t cache;
73 bfd *archive_head; /* Only interesting in output routines. */
74 carsym *symdefs; /* The symdef entries. */
75 symindex symdef_count; /* How many there are. */
76 char *extended_names; /* Clever intel extension. */
77 bfd_size_type extended_names_size; /* Size of extended names. */
78 /* When more compilers are standard C, this can be a time_t. */
79 long armap_timestamp; /* Timestamp value written into armap.
80 This is used for BSD archives to check
81 that the timestamp is recent enough
82 for the BSD linker to not complain,
83 just before we finish writing an
84 archive. */
85 file_ptr armap_datepos; /* Position within archive to seek to
86 rewrite the date field. */
87 void *tdata; /* Backend specific information. */
88 };
89
90 #define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
91
92 /* Goes in bfd's arelt_data slot */
93 struct areltdata
94 {
95 char * arch_header; /* It's actually a string. */
96 bfd_size_type parsed_size; /* Octets of filesize not including ar_hdr. */
97 bfd_size_type extra_size; /* BSD4.4: extra bytes after the header. */
98 char *filename; /* Null-terminated. */
99 file_ptr origin; /* For element of a thin archive. */
100 void *parent_cache; /* Where and how to find this member. */
101 file_ptr key;
102 };
103
104 #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
105
106 extern void *bfd_malloc
107 (bfd_size_type);
108 extern void *bfd_realloc
109 (void *, bfd_size_type);
110 extern void *bfd_realloc_or_free
111 (void *, bfd_size_type);
112 extern void *bfd_zmalloc
113 (bfd_size_type);
114 extern void *bfd_malloc2
115 (bfd_size_type, bfd_size_type);
116 extern void *bfd_realloc2
117 (void *, bfd_size_type, bfd_size_type);
118 extern void *bfd_zmalloc2
119 (bfd_size_type, bfd_size_type);
120
121 extern void _bfd_default_error_handler (const char *s, ...);
122 extern bfd_error_handler_type _bfd_error_handler;
123 extern bfd_assert_handler_type _bfd_assert_handler;
124
125 /* These routines allocate and free things on the BFD's objalloc. */
126
127 extern void *bfd_alloc2
128 (bfd *, bfd_size_type, bfd_size_type);
129 extern void *bfd_zalloc2
130 (bfd *, bfd_size_type, bfd_size_type);
131 extern void bfd_release
132 (bfd *, void *);
133
134 bfd * _bfd_create_empty_archive_element_shell
135 (bfd *obfd);
136 bfd * _bfd_look_for_bfd_in_cache
137 (bfd *, file_ptr);
138 bfd_boolean _bfd_add_bfd_to_archive_cache
139 (bfd *, file_ptr, bfd *);
140 bfd_boolean _bfd_generic_mkarchive
141 (bfd *abfd);
142 char *_bfd_append_relative_path
143 (bfd *arch, char *elt_name);
144 const bfd_target *bfd_generic_archive_p
145 (bfd *abfd);
146 bfd_boolean bfd_slurp_armap
147 (bfd *abfd);
148 bfd_boolean bfd_slurp_bsd_armap_f2
149 (bfd *abfd);
150 #define bfd_slurp_bsd_armap bfd_slurp_armap
151 #define bfd_slurp_coff_armap bfd_slurp_armap
152 bfd_boolean _bfd_archive_64_bit_slurp_armap
153 (bfd *);
154 bfd_boolean _bfd_archive_64_bit_write_armap
155 (bfd *, unsigned int, struct orl *, unsigned int, int);
156 #define _bfd_archive_64_bit_slurp_extended_name_table \
157 _bfd_slurp_extended_name_table
158 #define _bfd_archive_64_bit_construct_extended_name_table \
159 _bfd_archive_coff_construct_extended_name_table
160 #define _bfd_archive_64_bit_truncate_arname \
161 bfd_dont_truncate_arname
162 #define _bfd_archive_64_bit_read_ar_hdr \
163 _bfd_generic_read_ar_hdr
164 #define _bfd_archive_64_bit_write_ar_hdr \
165 _bfd_generic_write_ar_hdr
166 #define _bfd_archive_64_bit_openr_next_archived_file \
167 bfd_generic_openr_next_archived_file
168 #define _bfd_archive_64_bit_get_elt_at_index \
169 _bfd_generic_get_elt_at_index
170 #define _bfd_archive_64_bit_generic_stat_arch_elt \
171 bfd_generic_stat_arch_elt
172 #define _bfd_archive_64_bit_update_armap_timestamp \
173 bfd_true
174
175 bfd_boolean _bfd_slurp_extended_name_table
176 (bfd *abfd);
177 extern bfd_boolean _bfd_construct_extended_name_table
178 (bfd *, bfd_boolean, char **, bfd_size_type *);
179 bfd_boolean _bfd_write_archive_contents
180 (bfd *abfd);
181 bfd_boolean _bfd_compute_and_write_armap
182 (bfd *, unsigned int elength);
183 bfd *_bfd_get_elt_at_filepos
184 (bfd *archive, file_ptr filepos);
185 extern bfd *_bfd_generic_get_elt_at_index
186 (bfd *, symindex);
187 bfd * _bfd_new_bfd
188 (void);
189 bfd_boolean _bfd_free_cached_info
190 (bfd *);
191
192 bfd_boolean bfd_false
193 (bfd *ignore);
194 bfd_boolean bfd_true
195 (bfd *ignore);
196 void *bfd_nullvoidptr
197 (bfd *ignore);
198 int bfd_0
199 (bfd *ignore);
200 unsigned int bfd_0u
201 (bfd *ignore);
202 long bfd_0l
203 (bfd *ignore);
204 long _bfd_n1
205 (bfd *ignore);
206 void bfd_void
207 (bfd *ignore);
208
209 bfd *_bfd_new_bfd_contained_in
210 (bfd *);
211 const bfd_target *_bfd_dummy_target
212 (bfd *abfd);
213
214 void bfd_dont_truncate_arname
215 (bfd *abfd, const char *filename, char *hdr);
216 void bfd_bsd_truncate_arname
217 (bfd *abfd, const char *filename, char *hdr);
218 void bfd_gnu_truncate_arname
219 (bfd *abfd, const char *filename, char *hdr);
220
221 bfd_boolean bsd_write_armap
222 (bfd *arch, unsigned int elength, struct orl *map, unsigned int orl_count,
223 int stridx);
224
225 bfd_boolean coff_write_armap
226 (bfd *arch, unsigned int elength, struct orl *map, unsigned int orl_count,
227 int stridx);
228
229 extern void *_bfd_generic_read_ar_hdr
230 (bfd *);
231 extern void _bfd_ar_spacepad
232 (char *, size_t, const char *, long);
233 extern bfd_boolean _bfd_ar_sizepad
234 (char *, size_t, bfd_size_type);
235
236 extern void *_bfd_generic_read_ar_hdr_mag
237 (bfd *, const char *);
238
239 extern bfd_boolean _bfd_generic_write_ar_hdr
240 (bfd *, bfd *);
241
242 extern bfd_boolean _bfd_bsd44_write_ar_hdr
243 (bfd *, bfd *);
244
245 bfd * bfd_generic_openr_next_archived_file
246 (bfd *archive, bfd *last_file);
247
248 int bfd_generic_stat_arch_elt
249 (bfd *, struct stat *);
250
251 #define _bfd_read_ar_hdr(abfd) \
252 BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
253 #define _bfd_write_ar_hdr(archive, abfd) \
254 BFD_SEND (abfd, _bfd_write_ar_hdr_fn, (archive, abfd))
255 \f
256 /* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
257 BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
258
259 #define _bfd_generic_close_and_cleanup _bfd_archive_close_and_cleanup
260 extern bfd_boolean _bfd_archive_close_and_cleanup
261 (bfd *);
262 #define _bfd_generic_bfd_free_cached_info bfd_true
263 extern bfd_boolean _bfd_generic_new_section_hook
264 (bfd *, asection *);
265 extern bfd_boolean _bfd_generic_get_section_contents
266 (bfd *, asection *, void *, file_ptr, bfd_size_type);
267 extern bfd_boolean _bfd_generic_get_section_contents_in_window
268 (bfd *, asection *, bfd_window *, file_ptr, bfd_size_type);
269
270 /* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
271 BFD_JUMP_TABLE_COPY (_bfd_generic). */
272
273 #define _bfd_generic_bfd_copy_private_bfd_data \
274 ((bfd_boolean (*) (bfd *, bfd *)) bfd_true)
275 #define _bfd_generic_bfd_merge_private_bfd_data \
276 ((bfd_boolean (*) (bfd *, bfd *)) bfd_true)
277 #define _bfd_generic_bfd_set_private_flags \
278 ((bfd_boolean (*) (bfd *, flagword)) bfd_true)
279 #define _bfd_generic_bfd_copy_private_section_data \
280 ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true)
281 #define _bfd_generic_bfd_copy_private_symbol_data \
282 ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true)
283 #define _bfd_generic_bfd_copy_private_header_data \
284 ((bfd_boolean (*) (bfd *, bfd *)) bfd_true)
285 #define _bfd_generic_bfd_print_private_bfd_data \
286 ((bfd_boolean (*) (bfd *, void *)) bfd_true)
287
288 extern bfd_boolean _bfd_generic_init_private_section_data
289 (bfd *, asection *, bfd *, asection *, struct bfd_link_info *);
290
291 /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
292 support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */
293
294 extern char *_bfd_nocore_core_file_failing_command
295 (bfd *);
296 extern int _bfd_nocore_core_file_failing_signal
297 (bfd *);
298 extern bfd_boolean _bfd_nocore_core_file_matches_executable_p
299 (bfd *, bfd *);
300 extern int _bfd_nocore_core_file_pid
301 (bfd *);
302
303 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
304 file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
305
306 #define _bfd_noarchive_slurp_armap bfd_false
307 #define _bfd_noarchive_slurp_extended_name_table bfd_false
308 #define _bfd_noarchive_construct_extended_name_table \
309 ((bfd_boolean (*) (bfd *, char **, bfd_size_type *, const char **)) \
310 bfd_false)
311 #define _bfd_noarchive_truncate_arname \
312 ((void (*) (bfd *, const char *, char *)) bfd_void)
313 #define _bfd_noarchive_write_armap \
314 ((bfd_boolean (*) (bfd *, unsigned int, struct orl *, unsigned int, int)) \
315 bfd_false)
316 #define _bfd_noarchive_read_ar_hdr bfd_nullvoidptr
317 #define _bfd_noarchive_write_ar_hdr \
318 ((bfd_boolean (*) (bfd *, bfd *)) bfd_false)
319 #define _bfd_noarchive_openr_next_archived_file \
320 ((bfd *(*) (bfd *, bfd *)) bfd_nullvoidptr)
321 #define _bfd_noarchive_get_elt_at_index \
322 ((bfd *(*) (bfd *, symindex)) bfd_nullvoidptr)
323 #define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
324 #define _bfd_noarchive_update_armap_timestamp bfd_false
325
326 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
327 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */
328
329 #define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
330 #define _bfd_archive_bsd_slurp_extended_name_table \
331 _bfd_slurp_extended_name_table
332 extern bfd_boolean _bfd_archive_bsd_construct_extended_name_table
333 (bfd *, char **, bfd_size_type *, const char **);
334 #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
335 #define _bfd_archive_bsd_write_armap bsd_write_armap
336 #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
337 #define _bfd_archive_bsd_write_ar_hdr _bfd_generic_write_ar_hdr
338 #define _bfd_archive_bsd_openr_next_archived_file \
339 bfd_generic_openr_next_archived_file
340 #define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
341 #define _bfd_archive_bsd_generic_stat_arch_elt \
342 bfd_generic_stat_arch_elt
343 extern bfd_boolean _bfd_archive_bsd_update_armap_timestamp
344 (bfd *);
345
346 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
347 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */
348
349 #define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
350 #define _bfd_archive_coff_slurp_extended_name_table \
351 _bfd_slurp_extended_name_table
352 extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
353 (bfd *, char **, bfd_size_type *, const char **);
354 #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
355 #define _bfd_archive_coff_write_armap coff_write_armap
356 #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
357 #define _bfd_archive_coff_write_ar_hdr _bfd_generic_write_ar_hdr
358 #define _bfd_archive_coff_openr_next_archived_file \
359 bfd_generic_openr_next_archived_file
360 #define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
361 #define _bfd_archive_coff_generic_stat_arch_elt \
362 bfd_generic_stat_arch_elt
363 #define _bfd_archive_coff_update_armap_timestamp bfd_true
364
365 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD4.4 style
366 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44). */
367
368 #define _bfd_archive_bsd44_slurp_armap bfd_slurp_bsd_armap
369 #define _bfd_archive_bsd44_slurp_extended_name_table \
370 _bfd_slurp_extended_name_table
371 extern bfd_boolean _bfd_archive_bsd44_construct_extended_name_table
372 (bfd *, char **, bfd_size_type *, const char **);
373 #define _bfd_archive_bsd44_truncate_arname bfd_bsd_truncate_arname
374 #define _bfd_archive_bsd44_write_armap bsd_write_armap
375 #define _bfd_archive_bsd44_read_ar_hdr _bfd_generic_read_ar_hdr
376 #define _bfd_archive_bsd44_write_ar_hdr _bfd_bsd44_write_ar_hdr
377 #define _bfd_archive_bsd44_openr_next_archived_file \
378 bfd_generic_openr_next_archived_file
379 #define _bfd_archive_bsd44_get_elt_at_index _bfd_generic_get_elt_at_index
380 #define _bfd_archive_bsd44_generic_stat_arch_elt \
381 bfd_generic_stat_arch_elt
382 #define _bfd_archive_bsd44_update_armap_timestamp \
383 _bfd_archive_bsd_update_armap_timestamp
384
385 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get VMS style
386 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib). Some of them
387 are irrelevant and never called, so defined as NULL. */
388
389 extern bfd_boolean _bfd_vms_lib_write_archive_contents (bfd *arch);
390 #define _bfd_vms_lib_slurp_armap NULL
391 #define _bfd_vms_lib_slurp_extended_name_table NULL
392 #define _bfd_vms_lib_construct_extended_name_table NULL
393 #define _bfd_vms_lib_truncate_arname NULL
394 #define _bfd_vms_lib_write_armap NULL
395 #define _bfd_vms_lib_read_ar_hdr NULL
396 #define _bfd_vms_lib_write_ar_hdr NULL
397 extern bfd *_bfd_vms_lib_openr_next_archived_file (bfd *, bfd *);
398 extern bfd *_bfd_vms_lib_get_elt_at_index (bfd *, symindex);
399 extern int _bfd_vms_lib_generic_stat_arch_elt (bfd *, struct stat *);
400 #define _bfd_vms_lib_update_armap_timestamp bfd_true
401
402 /* Extra routines for VMS style archives. */
403
404 extern symindex _bfd_vms_lib_find_symbol (bfd *, const char *);
405 extern bfd *_bfd_vms_lib_get_imagelib_file (bfd *);
406 extern const bfd_target *_bfd_vms_lib_alpha_archive_p (bfd *abfd);
407 extern const bfd_target *_bfd_vms_lib_ia64_archive_p (bfd *abfd);
408 extern bfd_boolean _bfd_vms_lib_alpha_mkarchive (bfd *abfd);
409 extern bfd_boolean _bfd_vms_lib_ia64_mkarchive (bfd *abfd);
410
411 /* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
412 support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
413
414 #define _bfd_nosymbols_get_symtab_upper_bound _bfd_n1
415 #define _bfd_nosymbols_canonicalize_symtab \
416 ((long (*) (bfd *, asymbol **)) _bfd_n1)
417 #define _bfd_nosymbols_make_empty_symbol _bfd_generic_make_empty_symbol
418 #define _bfd_nosymbols_print_symbol \
419 ((void (*) (bfd *, void *, asymbol *, bfd_print_symbol_type)) bfd_void)
420 #define _bfd_nosymbols_get_symbol_info \
421 ((void (*) (bfd *, asymbol *, symbol_info *)) bfd_void)
422 #define _bfd_nosymbols_get_symbol_version_string \
423 ((const char *(*) (bfd *, asymbol *, bfd_boolean *)) bfd_nullvoidptr)
424 #define _bfd_nosymbols_bfd_is_local_label_name \
425 ((bfd_boolean (*) (bfd *, const char *)) bfd_false)
426 #define _bfd_nosymbols_bfd_is_target_special_symbol \
427 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
428 #define _bfd_nosymbols_get_lineno \
429 ((alent *(*) (bfd *, asymbol *)) bfd_nullvoidptr)
430 #define _bfd_nosymbols_find_nearest_line \
431 ((bfd_boolean (*) (bfd *, asymbol **, asection *, bfd_vma, \
432 const char **, const char **, unsigned int *, \
433 unsigned int *)) \
434 bfd_false)
435 #define _bfd_nosymbols_find_line \
436 ((bfd_boolean (*) (bfd *, asymbol **, asymbol *, \
437 const char **, unsigned int *)) \
438 bfd_false)
439 #define _bfd_nosymbols_find_inliner_info \
440 ((bfd_boolean (*) (bfd *, const char **, const char **, unsigned int *)) \
441 bfd_false)
442 #define _bfd_nosymbols_bfd_make_debug_symbol \
443 ((asymbol *(*) (bfd *, void *, unsigned long)) bfd_nullvoidptr)
444 #define _bfd_nosymbols_read_minisymbols \
445 ((long (*) (bfd *, bfd_boolean, void **, unsigned int *)) _bfd_n1)
446 #define _bfd_nosymbols_minisymbol_to_symbol \
447 ((asymbol *(*) (bfd *, bfd_boolean, const void *, asymbol *)) \
448 bfd_nullvoidptr)
449
450 /* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
451 support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */
452
453 extern long _bfd_norelocs_get_reloc_upper_bound (bfd *, asection *);
454 extern long _bfd_norelocs_canonicalize_reloc (bfd *, asection *,
455 arelent **, asymbol **);
456 #define _bfd_norelocs_bfd_reloc_type_lookup \
457 ((reloc_howto_type *(*) (bfd *, bfd_reloc_code_real_type)) bfd_nullvoidptr)
458 #define _bfd_norelocs_bfd_reloc_name_lookup \
459 ((reloc_howto_type *(*) (bfd *, const char *)) bfd_nullvoidptr)
460
461 /* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
462 be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */
463
464 #define _bfd_nowrite_set_arch_mach \
465 ((bfd_boolean (*) (bfd *, enum bfd_architecture, unsigned long)) \
466 bfd_false)
467 #define _bfd_nowrite_set_section_contents \
468 ((bfd_boolean (*) (bfd *, asection *, const void *, file_ptr, bfd_size_type)) \
469 bfd_false)
470
471 /* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use
472 BFD_JUMP_TABLE_WRITE (_bfd_generic). */
473
474 #define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
475 extern bfd_boolean _bfd_generic_set_section_contents
476 (bfd *, asection *, const void *, file_ptr, bfd_size_type);
477
478 /* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
479 support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */
480
481 #define _bfd_nolink_sizeof_headers \
482 ((int (*) (bfd *, struct bfd_link_info *)) bfd_0)
483 #define _bfd_nolink_bfd_get_relocated_section_contents \
484 ((bfd_byte *(*) (bfd *, struct bfd_link_info *, struct bfd_link_order *, \
485 bfd_byte *, bfd_boolean, asymbol **)) \
486 bfd_nullvoidptr)
487 #define _bfd_nolink_bfd_relax_section \
488 ((bfd_boolean (*) \
489 (bfd *, asection *, struct bfd_link_info *, bfd_boolean *)) \
490 bfd_false)
491 #define _bfd_nolink_bfd_gc_sections \
492 ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
493 bfd_false)
494 #define _bfd_nolink_bfd_lookup_section_flags \
495 ((bfd_boolean (*) (struct bfd_link_info *, struct flag_info *, asection *)) \
496 bfd_0)
497 #define _bfd_nolink_bfd_merge_sections \
498 ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
499 bfd_false)
500 #define _bfd_nolink_bfd_is_group_section \
501 ((bfd_boolean (*) (bfd *, const struct bfd_section *)) \
502 bfd_false)
503 #define _bfd_nolink_bfd_discard_group \
504 ((bfd_boolean (*) (bfd *, struct bfd_section *)) \
505 bfd_false)
506 #define _bfd_nolink_bfd_link_hash_table_create \
507 ((struct bfd_link_hash_table *(*) (bfd *)) bfd_nullvoidptr)
508 #define _bfd_nolink_bfd_link_add_symbols \
509 ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) bfd_false)
510 #define _bfd_nolink_bfd_link_just_syms \
511 ((void (*) (asection *, struct bfd_link_info *)) bfd_void)
512 #define _bfd_nolink_bfd_copy_link_hash_symbol_type \
513 ((void (*) (bfd *, struct bfd_link_hash_entry *, \
514 struct bfd_link_hash_entry *)) bfd_void)
515 #define _bfd_nolink_bfd_final_link \
516 ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) bfd_false)
517 #define _bfd_nolink_bfd_link_split_section \
518 ((bfd_boolean (*) (bfd *, struct bfd_section *)) bfd_false)
519 #define _bfd_nolink_section_already_linked \
520 ((bfd_boolean (*) (bfd *, asection *, \
521 struct bfd_link_info *)) bfd_false)
522 #define _bfd_nolink_bfd_define_common_symbol \
523 ((bfd_boolean (*) (bfd *, struct bfd_link_info *, \
524 struct bfd_link_hash_entry *)) bfd_false)
525 #define _bfd_nolink_bfd_link_check_relocs \
526 _bfd_generic_link_check_relocs
527
528 /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
529 have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
530 (_bfd_nodynamic). */
531
532 #define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_n1
533 #define _bfd_nodynamic_canonicalize_dynamic_symtab \
534 ((long (*) (bfd *, asymbol **)) _bfd_n1)
535 #define _bfd_nodynamic_get_synthetic_symtab \
536 ((long (*) (bfd *, long, asymbol **, long, asymbol **, asymbol **)) _bfd_n1)
537 #define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_n1
538 #define _bfd_nodynamic_canonicalize_dynamic_reloc \
539 ((long (*) (bfd *, arelent **, asymbol **)) _bfd_n1)
540 \f
541 /* Generic routine to determine of the given symbol is a local
542 label. */
543 extern bfd_boolean bfd_generic_is_local_label_name
544 (bfd *, const char *);
545
546 /* Generic minisymbol routines. */
547 extern long _bfd_generic_read_minisymbols
548 (bfd *, bfd_boolean, void **, unsigned int *);
549 extern asymbol *_bfd_generic_minisymbol_to_symbol
550 (bfd *, bfd_boolean, const void *, asymbol *);
551
552 /* Find the nearest line using .stab/.stabstr sections. */
553 extern bfd_boolean _bfd_stab_section_find_nearest_line
554 (bfd *, asymbol **, asection *, bfd_vma, bfd_boolean *,
555 const char **, const char **, unsigned int *, void **);
556
557 /* Find the nearest line using DWARF 1 debugging information. */
558 extern bfd_boolean _bfd_dwarf1_find_nearest_line
559 (bfd *, asymbol **, asection *, bfd_vma,
560 const char **, const char **, unsigned int *);
561
562 struct dwarf_debug_section
563 {
564 const char *uncompressed_name;
565 const char *compressed_name;
566 };
567
568 /* Map of uncompressed DWARF debug section name to compressed one. It
569 is terminated by NULL uncompressed_name. */
570
571 extern const struct dwarf_debug_section dwarf_debug_sections[];
572
573 /* Find the nearest line using DWARF 2 debugging information. */
574 extern bfd_boolean _bfd_dwarf2_find_nearest_line
575 (bfd *, asymbol **, asymbol *, asection *, bfd_vma,
576 const char **, const char **, unsigned int *, unsigned int *,
577 const struct dwarf_debug_section *, unsigned int, void **);
578
579 /* Find the bias between DWARF addresses and real addresses. */
580 extern bfd_signed_vma _bfd_dwarf2_find_symbol_bias
581 (asymbol **, void **);
582
583 /* Find inliner info after calling bfd_find_nearest_line. */
584 extern bfd_boolean _bfd_dwarf2_find_inliner_info
585 (bfd *, const char **, const char **, unsigned int *, void **);
586
587 /* Read DWARF 2 debugging information. */
588 extern bfd_boolean _bfd_dwarf2_slurp_debug_info
589 (bfd *, bfd *, const struct dwarf_debug_section *, asymbol **, void **,
590 bfd_boolean);
591
592 /* Clean up the data used to handle DWARF 2 debugging information. */
593 extern void _bfd_dwarf2_cleanup_debug_info
594 (bfd *, void **);
595
596 /* Create a new section entry. */
597 extern struct bfd_hash_entry *bfd_section_hash_newfunc
598 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
599
600 /* A routine to create entries for a bfd_link_hash_table. */
601 extern struct bfd_hash_entry *_bfd_link_hash_newfunc
602 (struct bfd_hash_entry *entry, struct bfd_hash_table *table,
603 const char *string);
604
605 /* Initialize a bfd_link_hash_table. */
606 extern bfd_boolean _bfd_link_hash_table_init
607 (struct bfd_link_hash_table *, bfd *,
608 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
609 struct bfd_hash_table *,
610 const char *),
611 unsigned int);
612
613 /* Generic link hash table creation routine. */
614 extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
615 (bfd *);
616
617 /* Generic link hash table destruction routine. */
618 extern void _bfd_generic_link_hash_table_free
619 (bfd *);
620
621 /* Generic add symbol routine. */
622 extern bfd_boolean _bfd_generic_link_add_symbols
623 (bfd *, struct bfd_link_info *);
624
625 /* Generic add symbol routine. This version is used by targets for
626 which the linker must collect constructors and destructors by name,
627 as the collect2 program does. */
628 extern bfd_boolean _bfd_generic_link_add_symbols_collect
629 (bfd *, struct bfd_link_info *);
630
631 /* Generic archive add symbol routine. */
632 extern bfd_boolean _bfd_generic_link_add_archive_symbols
633 (bfd *, struct bfd_link_info *,
634 bfd_boolean (*) (bfd *, struct bfd_link_info *,
635 struct bfd_link_hash_entry *, const char *,
636 bfd_boolean *));
637
638 /* Forward declaration to avoid prototype errors. */
639 typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
640
641 /* Generic routine to add a single symbol. */
642 extern bfd_boolean _bfd_generic_link_add_one_symbol
643 (struct bfd_link_info *, bfd *, const char *name, flagword,
644 asection *, bfd_vma, const char *, bfd_boolean copy,
645 bfd_boolean constructor, struct bfd_link_hash_entry **);
646
647 /* Generic routine to mark section as supplying symbols only. */
648 extern void _bfd_generic_link_just_syms
649 (asection *, struct bfd_link_info *);
650
651 /* Generic routine that does nothing. */
652 extern void _bfd_generic_copy_link_hash_symbol_type
653 (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *);
654
655 /* Generic link routine. */
656 extern bfd_boolean _bfd_generic_final_link
657 (bfd *, struct bfd_link_info *);
658
659 extern bfd_boolean _bfd_generic_link_split_section
660 (bfd *, struct bfd_section *);
661
662 extern bfd_boolean _bfd_generic_section_already_linked
663 (bfd *, asection *, struct bfd_link_info *);
664
665 /* Generic reloc_link_order processing routine. */
666 extern bfd_boolean _bfd_generic_reloc_link_order
667 (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *);
668
669 /* Default link order processing routine. */
670 extern bfd_boolean _bfd_default_link_order
671 (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *);
672
673 /* Count the number of reloc entries in a link order list. */
674 extern unsigned int _bfd_count_link_order_relocs
675 (struct bfd_link_order *);
676
677 /* Final link relocation routine. */
678 extern bfd_reloc_status_type _bfd_final_link_relocate
679 (reloc_howto_type *, bfd *, asection *, bfd_byte *,
680 bfd_vma, bfd_vma, bfd_vma);
681
682 /* Relocate a particular location by a howto and a value. */
683 extern bfd_reloc_status_type _bfd_relocate_contents
684 (reloc_howto_type *, bfd *, bfd_vma, bfd_byte *);
685
686 /* Clear a given location using a given howto. */
687 extern void _bfd_clear_contents (reloc_howto_type *howto, bfd *input_bfd,
688 asection *input_section, bfd_byte *location);
689
690 /* Link stabs in sections in the first pass. */
691
692 extern bfd_boolean _bfd_link_section_stabs
693 (bfd *, struct stab_info *, asection *, asection *, void **,
694 bfd_size_type *);
695
696 /* Eliminate stabs for discarded functions and symbols. */
697 extern bfd_boolean _bfd_discard_section_stabs
698 (bfd *, asection *, void *, bfd_boolean (*) (bfd_vma, void *), void *);
699
700 /* Write out the .stab section when linking stabs in sections. */
701
702 extern bfd_boolean _bfd_write_section_stabs
703 (bfd *, struct stab_info *, asection *, void **, bfd_byte *);
704
705 /* Write out the .stabstr string table when linking stabs in sections. */
706
707 extern bfd_boolean _bfd_write_stab_strings
708 (bfd *, struct stab_info *);
709
710 /* Find an offset within a .stab section when linking stabs in
711 sections. */
712
713 extern bfd_vma _bfd_stab_section_offset
714 (asection *, void *, bfd_vma);
715
716 /* Register a SEC_MERGE section as a candidate for merging. */
717
718 extern bfd_boolean _bfd_add_merge_section
719 (bfd *, void **, asection *, void **);
720
721 /* Attempt to merge SEC_MERGE sections. */
722
723 extern bfd_boolean _bfd_merge_sections
724 (bfd *, struct bfd_link_info *, void *, void (*) (bfd *, asection *));
725
726 /* Write out a merged section. */
727
728 extern bfd_boolean _bfd_write_merged_section
729 (bfd *, asection *, void *);
730
731 /* Find an offset within a modified SEC_MERGE section. */
732
733 extern bfd_vma _bfd_merged_section_offset
734 (bfd *, asection **, void *, bfd_vma);
735
736 /* Tidy up when done. */
737
738 extern void _bfd_merge_sections_free (void *);
739
740 /* Create a string table. */
741 extern struct bfd_strtab_hash *_bfd_stringtab_init
742 (void);
743
744 /* Create an XCOFF .debug section style string table. */
745 extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init
746 (void);
747
748 /* Free a string table. */
749 extern void _bfd_stringtab_free
750 (struct bfd_strtab_hash *);
751
752 /* Get the size of a string table. */
753 extern bfd_size_type _bfd_stringtab_size
754 (struct bfd_strtab_hash *);
755
756 /* Add a string to a string table. */
757 extern bfd_size_type _bfd_stringtab_add
758 (struct bfd_strtab_hash *, const char *, bfd_boolean hash, bfd_boolean copy);
759
760 /* Write out a string table. */
761 extern bfd_boolean _bfd_stringtab_emit
762 (bfd *, struct bfd_strtab_hash *);
763
764 /* Check that endianness of input and output file match. */
765 extern bfd_boolean _bfd_generic_verify_endian_match
766 (bfd *, bfd *);
767 \f
768 /* Macros to tell if bfds are read or write enabled.
769
770 Note that bfds open for read may be scribbled into if the fd passed
771 to bfd_fdopenr is actually open both for read and write
772 simultaneously. However an output bfd will never be open for
773 read. Therefore sometimes you want to check bfd_read_p or
774 !bfd_read_p, and only sometimes bfd_write_p.
775 */
776
777 #define bfd_read_p(abfd) \
778 ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
779 #define bfd_write_p(abfd) \
780 ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
781
782 void bfd_assert
783 (const char*,int);
784
785 #define BFD_ASSERT(x) \
786 do { if (!(x)) bfd_assert(__FILE__,__LINE__); } while (0)
787
788 #define BFD_FAIL() \
789 do { bfd_assert(__FILE__,__LINE__); } while (0)
790
791 extern void _bfd_abort
792 (const char *, int, const char *) ATTRIBUTE_NORETURN;
793
794 /* if gcc >= 2.6, we can give a function name, too */
795 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
796 #define __PRETTY_FUNCTION__ ((char *) NULL)
797 #endif
798
799 #undef abort
800 #define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
801
802 /* Manipulate a system FILE but using BFD's "file_ptr", rather than
803 the system "off_t" or "off64_t", as the offset. */
804 extern file_ptr real_ftell (FILE *file);
805 extern int real_fseek (FILE *file, file_ptr offset, int whence);
806 extern FILE *real_fopen (const char *filename, const char *modes);
807
808 /* List of supported target vectors, and the default vector (if
809 bfd_default_vector[0] is NULL, there is no default). */
810 extern const bfd_target * const *bfd_target_vector;
811 extern const bfd_target *bfd_default_vector[];
812
813 /* List of associated target vectors. */
814 extern const bfd_target * const *bfd_associated_vector;
815
816 /* Functions shared by the ECOFF and MIPS ELF backends, which have no
817 other common header files. */
818
819 #if defined(__STDC__) || defined(ALMOST_STDC)
820 struct ecoff_find_line;
821 #endif
822
823 extern bfd_boolean _bfd_ecoff_locate_line
824 (bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
825 const struct ecoff_debug_swap * const, struct ecoff_find_line *,
826 const char **, const char **, unsigned int *);
827 extern bfd_boolean _bfd_ecoff_get_accumulated_pdr
828 (void *, bfd_byte *);
829 extern bfd_boolean _bfd_ecoff_get_accumulated_sym
830 (void *, bfd_byte *);
831 extern bfd_boolean _bfd_ecoff_get_accumulated_ss
832 (void *, bfd_byte *);
833
834 extern bfd_vma _bfd_get_gp_value
835 (bfd *);
836 extern void _bfd_set_gp_value
837 (bfd *, bfd_vma);
838
839 /* Function shared by the COFF and ELF SH backends, which have no
840 other common header files. */
841
842 #ifndef _bfd_sh_align_load_span
843 extern bfd_boolean _bfd_sh_align_load_span
844 (bfd *, asection *, bfd_byte *,
845 bfd_boolean (*) (bfd *, asection *, void *, bfd_byte *, bfd_vma),
846 void *, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, bfd_boolean *);
847 #endif
848
849 /* This is the shape of the elements inside the already_linked hash
850 table. It maps a name onto a list of already_linked elements with
851 the same name. */
852
853 struct bfd_section_already_linked_hash_entry
854 {
855 struct bfd_hash_entry root;
856 struct bfd_section_already_linked *entry;
857 };
858
859 struct bfd_section_already_linked
860 {
861 struct bfd_section_already_linked *next;
862 asection *sec;
863 };
864
865 extern struct bfd_section_already_linked_hash_entry *
866 bfd_section_already_linked_table_lookup (const char *);
867 extern bfd_boolean bfd_section_already_linked_table_insert
868 (struct bfd_section_already_linked_hash_entry *, asection *);
869 extern void bfd_section_already_linked_table_traverse
870 (bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *,
871 void *), void *);
872
873 extern bfd_vma read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *);
874 extern bfd_signed_vma read_signed_leb128 (bfd *, bfd_byte *, unsigned int *);
875 extern bfd_vma safe_read_leb128 (bfd *, bfd_byte *, unsigned int *,
876 bfd_boolean, const bfd_byte * const);
This page took 0.11175 seconds and 4 git commands to generate.