1 /* libbfd.h -- Declarations used by bfd library *implementation*.
2 (This include file is not for users of the library.)
4 Copyright (C) 1990-2018 Free Software Foundation, Inc.
6 Written by Cygnus Support.
8 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
28 #ifndef ATTRIBUTE_HIDDEN
30 #define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
32 #define ATTRIBUTE_HIDDEN
42 /* If you want to read and write large blocks, you might want to do it
43 in quanta of this amount */
44 #define DEFAULT_BUFFERSIZE 8192
46 /* Set a tdata field. Can't use the other macros for this, since they
47 do casts, and casting to the left of assignment isn't portable. */
48 #define set_tdata(bfd, v) ((bfd)->tdata.any = (v))
50 /* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points
51 to an instance of this structure. */
57 /* Buffer holding contents of BFD. */
61 struct section_hash_entry
63 struct bfd_hash_entry root;
67 /* Unique section id. */
68 extern unsigned int _bfd_section_id ATTRIBUTE_HIDDEN;
70 /* tdata for an archive. For an input archive, cache
71 needs to be free()'d. For an output archive, symdefs do. */
75 file_ptr first_file_filepos;
76 /* Speed up searching the armap */
78 bfd *archive_head; /* Only interesting in output routines. */
79 carsym *symdefs; /* The symdef entries. */
80 symindex symdef_count; /* How many there are. */
81 char *extended_names; /* Clever intel extension. */
82 bfd_size_type extended_names_size; /* Size of extended names. */
83 /* When more compilers are standard C, this can be a time_t. */
84 long armap_timestamp; /* Timestamp value written into armap.
85 This is used for BSD archives to check
86 that the timestamp is recent enough
87 for the BSD linker to not complain,
88 just before we finish writing an
90 file_ptr armap_datepos; /* Position within archive to seek to
91 rewrite the date field. */
92 void *tdata; /* Backend specific information. */
95 #define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
97 /* Goes in bfd's arelt_data slot */
100 char * arch_header; /* It's actually a string. */
101 bfd_size_type parsed_size; /* Octets of filesize not including ar_hdr. */
102 bfd_size_type extra_size; /* BSD4.4: extra bytes after the header. */
103 char *filename; /* Null-terminated. */
104 file_ptr origin; /* For element of a thin archive. */
105 void *parent_cache; /* Where and how to find this member. */
109 #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
111 extern void *bfd_malloc
112 (bfd_size_type) ATTRIBUTE_HIDDEN;
113 extern void *bfd_realloc
114 (void *, bfd_size_type) ATTRIBUTE_HIDDEN;
115 extern void *bfd_realloc_or_free
116 (void *, bfd_size_type) ATTRIBUTE_HIDDEN;
117 extern void *bfd_zmalloc
118 (bfd_size_type) ATTRIBUTE_HIDDEN;
119 extern void *bfd_malloc2
120 (bfd_size_type, bfd_size_type) ATTRIBUTE_HIDDEN;
121 extern void *bfd_realloc2
122 (void *, bfd_size_type, bfd_size_type) ATTRIBUTE_HIDDEN;
123 extern void *bfd_zmalloc2
124 (bfd_size_type, bfd_size_type) ATTRIBUTE_HIDDEN;
126 extern void _bfd_error_handler (const char *s, ...)
127 ATTRIBUTE_PRINTF_1 ATTRIBUTE_HIDDEN;
129 /* These routines allocate and free things on the BFD's objalloc. */
131 extern void *bfd_alloc2
132 (bfd *, bfd_size_type, bfd_size_type) ATTRIBUTE_HIDDEN;
133 extern void *bfd_zalloc2
134 (bfd *, bfd_size_type, bfd_size_type) ATTRIBUTE_HIDDEN;
135 extern void bfd_release
136 (bfd *, void *) ATTRIBUTE_HIDDEN;
138 extern bfd * _bfd_create_empty_archive_element_shell
139 (bfd *) ATTRIBUTE_HIDDEN;
140 extern bfd * _bfd_look_for_bfd_in_cache
141 (bfd *, file_ptr) ATTRIBUTE_HIDDEN;
142 extern bfd_boolean _bfd_add_bfd_to_archive_cache
143 (bfd *, file_ptr, bfd *) ATTRIBUTE_HIDDEN;
144 extern bfd_boolean _bfd_generic_mkarchive
145 (bfd *) ATTRIBUTE_HIDDEN;
146 extern char *_bfd_append_relative_path
147 (bfd *, char *) ATTRIBUTE_HIDDEN;
148 extern const bfd_target *bfd_generic_archive_p
149 (bfd *) ATTRIBUTE_HIDDEN;
150 extern bfd_boolean bfd_slurp_armap
151 (bfd *) ATTRIBUTE_HIDDEN;
152 #define bfd_slurp_bsd_armap bfd_slurp_armap
153 #define bfd_slurp_coff_armap bfd_slurp_armap
154 extern bfd_boolean _bfd_archive_64_bit_slurp_armap
155 (bfd *) ATTRIBUTE_HIDDEN;
156 extern bfd_boolean _bfd_archive_64_bit_write_armap
157 (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN;
158 #define _bfd_archive_64_bit_slurp_extended_name_table \
159 _bfd_slurp_extended_name_table
160 #define _bfd_archive_64_bit_construct_extended_name_table \
161 _bfd_archive_coff_construct_extended_name_table
162 #define _bfd_archive_64_bit_truncate_arname \
163 bfd_dont_truncate_arname
164 #define _bfd_archive_64_bit_read_ar_hdr \
165 _bfd_generic_read_ar_hdr
166 #define _bfd_archive_64_bit_write_ar_hdr \
167 _bfd_generic_write_ar_hdr
168 #define _bfd_archive_64_bit_openr_next_archived_file \
169 bfd_generic_openr_next_archived_file
170 #define _bfd_archive_64_bit_get_elt_at_index \
171 _bfd_generic_get_elt_at_index
172 #define _bfd_archive_64_bit_generic_stat_arch_elt \
173 bfd_generic_stat_arch_elt
174 #define _bfd_archive_64_bit_update_armap_timestamp _bfd_bool_bfd_true
176 extern bfd_boolean _bfd_slurp_extended_name_table
177 (bfd *) ATTRIBUTE_HIDDEN;
178 extern bfd_boolean _bfd_construct_extended_name_table
179 (bfd *, bfd_boolean, char **, bfd_size_type *) ATTRIBUTE_HIDDEN;
180 extern bfd_boolean _bfd_write_archive_contents
181 (bfd *) ATTRIBUTE_HIDDEN;
182 extern bfd_boolean _bfd_compute_and_write_armap
183 (bfd *, unsigned int) ATTRIBUTE_HIDDEN;
184 extern bfd *_bfd_get_elt_at_filepos
185 (bfd *, file_ptr) ATTRIBUTE_HIDDEN;
186 extern bfd *_bfd_generic_get_elt_at_index
187 (bfd *, symindex) ATTRIBUTE_HIDDEN;
188 extern bfd * _bfd_new_bfd
189 (void) ATTRIBUTE_HIDDEN;
190 extern bfd_boolean _bfd_free_cached_info
191 (bfd *) ATTRIBUTE_HIDDEN;
193 extern bfd_boolean _bfd_bool_bfd_false
194 (bfd *) ATTRIBUTE_HIDDEN;
195 extern bfd_boolean _bfd_bool_bfd_asymbol_false
196 (bfd *, asymbol *) ATTRIBUTE_HIDDEN;
197 extern bfd_boolean _bfd_bool_bfd_false_error
198 (bfd *) ATTRIBUTE_HIDDEN;
199 extern bfd_boolean _bfd_bool_bfd_link_false_error
200 (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
201 extern bfd_boolean _bfd_bool_bfd_true
202 (bfd *) ATTRIBUTE_HIDDEN;
203 extern bfd_boolean _bfd_bool_bfd_link_true
204 (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
205 extern bfd_boolean _bfd_bool_bfd_bfd_true
206 (bfd *, bfd *) ATTRIBUTE_HIDDEN;
207 extern bfd_boolean _bfd_bool_bfd_uint_true
208 (bfd *, unsigned int) ATTRIBUTE_HIDDEN;
209 extern bfd_boolean _bfd_bool_bfd_asection_bfd_asection_true
210 (bfd *, asection *, bfd *, asection *) ATTRIBUTE_HIDDEN;
211 extern bfd_boolean _bfd_bool_bfd_asymbol_bfd_asymbol_true
212 (bfd *, asymbol *, bfd *, asymbol *) ATTRIBUTE_HIDDEN;
213 extern bfd_boolean _bfd_bool_bfd_ptr_true
214 (bfd *, void *) ATTRIBUTE_HIDDEN;
215 extern void *_bfd_ptr_bfd_null_error
216 (bfd *) ATTRIBUTE_HIDDEN;
217 extern int _bfd_int_bfd_0
218 (bfd *) ATTRIBUTE_HIDDEN;
219 extern unsigned int _bfd_uint_bfd_0
220 (bfd *) ATTRIBUTE_HIDDEN;
221 extern long _bfd_long_bfd_0
222 (bfd *) ATTRIBUTE_HIDDEN;
223 extern long _bfd_long_bfd_n1_error
224 (bfd *) ATTRIBUTE_HIDDEN;
225 extern void _bfd_void_bfd
226 (bfd *) ATTRIBUTE_HIDDEN;
227 extern void _bfd_void_bfd_link
228 (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
229 extern void _bfd_void_bfd_asection
230 (bfd *, asection *) ATTRIBUTE_HIDDEN;
232 extern bfd *_bfd_new_bfd_contained_in
233 (bfd *) ATTRIBUTE_HIDDEN;
234 extern const bfd_target *_bfd_dummy_target
235 (bfd *) ATTRIBUTE_HIDDEN;
237 extern void bfd_dont_truncate_arname
238 (bfd *, const char *, char *) ATTRIBUTE_HIDDEN;
239 extern void bfd_bsd_truncate_arname
240 (bfd *, const char *, char *) ATTRIBUTE_HIDDEN;
241 extern void bfd_gnu_truncate_arname
242 (bfd *, const char *, char *) ATTRIBUTE_HIDDEN;
244 extern bfd_boolean _bfd_bsd_write_armap
245 (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN;
247 extern bfd_boolean _bfd_coff_write_armap
248 (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN;
250 extern void *_bfd_generic_read_ar_hdr
251 (bfd *) ATTRIBUTE_HIDDEN;
252 extern void _bfd_ar_spacepad
253 (char *, size_t, const char *, long) ATTRIBUTE_HIDDEN;
254 extern bfd_boolean _bfd_ar_sizepad
255 (char *, size_t, bfd_size_type) ATTRIBUTE_HIDDEN;
257 extern void *_bfd_generic_read_ar_hdr_mag
258 (bfd *, const char *) ATTRIBUTE_HIDDEN;
260 extern bfd_boolean _bfd_generic_write_ar_hdr
261 (bfd *, bfd *) ATTRIBUTE_HIDDEN;
263 extern bfd_boolean _bfd_bsd44_write_ar_hdr
264 (bfd *, bfd *) ATTRIBUTE_HIDDEN;
266 extern bfd * bfd_generic_openr_next_archived_file
267 (bfd *, bfd *) ATTRIBUTE_HIDDEN;
269 extern int bfd_generic_stat_arch_elt
270 (bfd *, struct stat *) ATTRIBUTE_HIDDEN;
272 #define _bfd_read_ar_hdr(abfd) \
273 BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
274 #define _bfd_write_ar_hdr(archive, abfd) \
275 BFD_SEND (abfd, _bfd_write_ar_hdr_fn, (archive, abfd))
277 /* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
278 BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
280 #define _bfd_generic_close_and_cleanup _bfd_archive_close_and_cleanup
281 extern bfd_boolean _bfd_archive_close_and_cleanup
282 (bfd *) ATTRIBUTE_HIDDEN;
283 #define _bfd_generic_bfd_free_cached_info _bfd_bool_bfd_true
284 extern bfd_boolean _bfd_generic_new_section_hook
285 (bfd *, asection *) ATTRIBUTE_HIDDEN;
286 extern bfd_boolean _bfd_generic_get_section_contents
287 (bfd *, asection *, void *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN;
288 extern bfd_boolean _bfd_generic_get_section_contents_in_window
289 (bfd *, asection *, bfd_window *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN;
291 /* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
292 BFD_JUMP_TABLE_COPY (_bfd_generic). */
294 #define _bfd_generic_bfd_copy_private_bfd_data _bfd_bool_bfd_bfd_true
295 #define _bfd_generic_bfd_merge_private_bfd_data \
296 _bfd_bool_bfd_link_true
297 #define _bfd_generic_bfd_set_private_flags _bfd_bool_bfd_uint_true
298 #define _bfd_generic_bfd_copy_private_section_data \
299 _bfd_bool_bfd_asection_bfd_asection_true
300 #define _bfd_generic_bfd_copy_private_symbol_data \
301 _bfd_bool_bfd_asymbol_bfd_asymbol_true
302 #define _bfd_generic_bfd_copy_private_header_data _bfd_bool_bfd_bfd_true
303 #define _bfd_generic_bfd_print_private_bfd_data _bfd_bool_bfd_ptr_true
305 extern bfd_boolean _bfd_generic_init_private_section_data
306 (bfd *, asection *, bfd *, asection *, struct bfd_link_info *)
309 /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
310 support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */
312 extern char *_bfd_nocore_core_file_failing_command
313 (bfd *) ATTRIBUTE_HIDDEN;
314 extern int _bfd_nocore_core_file_failing_signal
315 (bfd *) ATTRIBUTE_HIDDEN;
316 extern bfd_boolean _bfd_nocore_core_file_matches_executable_p
317 (bfd *, bfd *) ATTRIBUTE_HIDDEN;
318 extern int _bfd_nocore_core_file_pid
319 (bfd *) ATTRIBUTE_HIDDEN;
321 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
322 file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
324 #define _bfd_noarchive_slurp_armap _bfd_bool_bfd_false_error
325 #define _bfd_noarchive_slurp_extended_name_table _bfd_bool_bfd_false_error
326 extern bfd_boolean _bfd_noarchive_construct_extended_name_table
327 (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN;
328 extern void _bfd_noarchive_truncate_arname
329 (bfd *, const char *, char *) ATTRIBUTE_HIDDEN;
330 extern bfd_boolean _bfd_noarchive_write_armap
331 (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN;
332 #define _bfd_noarchive_read_ar_hdr _bfd_ptr_bfd_null_error
333 extern bfd_boolean _bfd_noarchive_write_ar_hdr
334 (bfd *, bfd *) ATTRIBUTE_HIDDEN;
336 _bfd_noarchive_openr_next_archived_file
337 (bfd *, bfd *) ATTRIBUTE_HIDDEN;
338 extern bfd * _bfd_noarchive_get_elt_at_index
339 (bfd *, symindex) ATTRIBUTE_HIDDEN;
340 #define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
341 #define _bfd_noarchive_update_armap_timestamp _bfd_bool_bfd_false_error
343 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
344 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */
346 #define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
347 #define _bfd_archive_bsd_slurp_extended_name_table \
348 _bfd_slurp_extended_name_table
349 extern bfd_boolean _bfd_archive_bsd_construct_extended_name_table
350 (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN;
351 #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
352 #define _bfd_archive_bsd_write_armap _bfd_bsd_write_armap
353 #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
354 #define _bfd_archive_bsd_write_ar_hdr _bfd_generic_write_ar_hdr
355 #define _bfd_archive_bsd_openr_next_archived_file \
356 bfd_generic_openr_next_archived_file
357 #define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
358 #define _bfd_archive_bsd_generic_stat_arch_elt \
359 bfd_generic_stat_arch_elt
360 extern bfd_boolean _bfd_archive_bsd_update_armap_timestamp
361 (bfd *) ATTRIBUTE_HIDDEN;
363 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
364 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */
366 #define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
367 #define _bfd_archive_coff_slurp_extended_name_table \
368 _bfd_slurp_extended_name_table
369 extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
370 (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN;
371 #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
372 #define _bfd_archive_coff_write_armap _bfd_coff_write_armap
373 #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
374 #define _bfd_archive_coff_write_ar_hdr _bfd_generic_write_ar_hdr
375 #define _bfd_archive_coff_openr_next_archived_file \
376 bfd_generic_openr_next_archived_file
377 #define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
378 #define _bfd_archive_coff_generic_stat_arch_elt \
379 bfd_generic_stat_arch_elt
380 #define _bfd_archive_coff_update_armap_timestamp _bfd_bool_bfd_true
382 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD4.4 style
383 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44). */
385 #define _bfd_archive_bsd44_slurp_armap bfd_slurp_bsd_armap
386 #define _bfd_archive_bsd44_slurp_extended_name_table \
387 _bfd_slurp_extended_name_table
388 extern bfd_boolean _bfd_archive_bsd44_construct_extended_name_table
389 (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN;
390 #define _bfd_archive_bsd44_truncate_arname bfd_bsd_truncate_arname
391 #define _bfd_archive_bsd44_write_armap _bfd_bsd_write_armap
392 #define _bfd_archive_bsd44_read_ar_hdr _bfd_generic_read_ar_hdr
393 #define _bfd_archive_bsd44_write_ar_hdr _bfd_bsd44_write_ar_hdr
394 #define _bfd_archive_bsd44_openr_next_archived_file \
395 bfd_generic_openr_next_archived_file
396 #define _bfd_archive_bsd44_get_elt_at_index _bfd_generic_get_elt_at_index
397 #define _bfd_archive_bsd44_generic_stat_arch_elt \
398 bfd_generic_stat_arch_elt
399 #define _bfd_archive_bsd44_update_armap_timestamp \
400 _bfd_archive_bsd_update_armap_timestamp
402 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get VMS style
403 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib). Some of them
406 extern bfd_boolean _bfd_vms_lib_write_archive_contents
407 (bfd *) ATTRIBUTE_HIDDEN;
408 #define _bfd_vms_lib_slurp_armap _bfd_noarchive_slurp_armap
409 #define _bfd_vms_lib_slurp_extended_name_table \
410 _bfd_noarchive_slurp_extended_name_table
411 #define _bfd_vms_lib_construct_extended_name_table \
412 _bfd_noarchive_construct_extended_name_table
413 #define _bfd_vms_lib_truncate_arname _bfd_noarchive_truncate_arname
414 #define _bfd_vms_lib_write_armap _bfd_noarchive_write_armap
415 #define _bfd_vms_lib_read_ar_hdr _bfd_noarchive_read_ar_hdr
416 #define _bfd_vms_lib_write_ar_hdr _bfd_noarchive_write_ar_hdr
417 extern bfd *_bfd_vms_lib_openr_next_archived_file
418 (bfd *, bfd *) ATTRIBUTE_HIDDEN;
419 extern bfd *_bfd_vms_lib_get_elt_at_index
420 (bfd *, symindex) ATTRIBUTE_HIDDEN;
421 extern int _bfd_vms_lib_generic_stat_arch_elt
422 (bfd *, struct stat *) ATTRIBUTE_HIDDEN;
423 #define _bfd_vms_lib_update_armap_timestamp _bfd_bool_bfd_true
425 /* Extra routines for VMS style archives. */
427 extern symindex _bfd_vms_lib_find_symbol
428 (bfd *, const char *) ATTRIBUTE_HIDDEN;
429 extern bfd *_bfd_vms_lib_get_imagelib_file
430 (bfd *) ATTRIBUTE_HIDDEN;
431 extern const bfd_target *_bfd_vms_lib_alpha_archive_p
432 (bfd *) ATTRIBUTE_HIDDEN;
433 extern const bfd_target *_bfd_vms_lib_ia64_archive_p
434 (bfd *) ATTRIBUTE_HIDDEN;
435 extern bfd_boolean _bfd_vms_lib_alpha_mkarchive
436 (bfd *) ATTRIBUTE_HIDDEN;
437 extern bfd_boolean _bfd_vms_lib_ia64_mkarchive
438 (bfd *) ATTRIBUTE_HIDDEN;
440 /* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
441 support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
443 #define _bfd_nosymbols_get_symtab_upper_bound _bfd_long_bfd_n1_error
444 extern long _bfd_nosymbols_canonicalize_symtab
445 (bfd *, asymbol **) ATTRIBUTE_HIDDEN;
446 #define _bfd_nosymbols_make_empty_symbol _bfd_generic_make_empty_symbol
447 extern void _bfd_nosymbols_print_symbol
448 (bfd *, void *, asymbol *, bfd_print_symbol_type) ATTRIBUTE_HIDDEN;
449 extern void _bfd_nosymbols_get_symbol_info
450 (bfd *, asymbol *, symbol_info *) ATTRIBUTE_HIDDEN;
451 extern const char * _bfd_nosymbols_get_symbol_version_string
452 (bfd *, asymbol *, bfd_boolean *) ATTRIBUTE_HIDDEN;
453 extern bfd_boolean _bfd_nosymbols_bfd_is_local_label_name
454 (bfd *, const char *) ATTRIBUTE_HIDDEN;
455 #define _bfd_nosymbols_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
456 extern alent *_bfd_nosymbols_get_lineno
457 (bfd *, asymbol *) ATTRIBUTE_HIDDEN;
458 extern bfd_boolean _bfd_nosymbols_find_nearest_line
459 (bfd *, asymbol **, asection *, bfd_vma,
460 const char **, const char **, unsigned int *, unsigned int *)
462 extern bfd_boolean _bfd_nosymbols_find_line
463 (bfd *, asymbol **, asymbol *, const char **, unsigned int *)
465 extern bfd_boolean _bfd_nosymbols_find_inliner_info
466 (bfd *, const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN;
467 extern asymbol *_bfd_nosymbols_bfd_make_debug_symbol
468 (bfd *, void *, unsigned long) ATTRIBUTE_HIDDEN;
469 extern long _bfd_nosymbols_read_minisymbols
470 (bfd *, bfd_boolean, void **, unsigned int *) ATTRIBUTE_HIDDEN;
471 extern asymbol *_bfd_nosymbols_minisymbol_to_symbol
472 (bfd *, bfd_boolean, const void *, asymbol *) ATTRIBUTE_HIDDEN;
474 /* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
475 support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */
477 extern long _bfd_norelocs_get_reloc_upper_bound
478 (bfd *, asection *) ATTRIBUTE_HIDDEN;
479 extern long _bfd_norelocs_canonicalize_reloc
480 (bfd *, asection *, arelent **, asymbol **) ATTRIBUTE_HIDDEN;
481 extern void _bfd_norelocs_set_reloc
482 (bfd *, asection *, arelent **, unsigned int) ATTRIBUTE_HIDDEN;
483 extern reloc_howto_type *_bfd_norelocs_bfd_reloc_type_lookup
484 (bfd *, bfd_reloc_code_real_type) ATTRIBUTE_HIDDEN;
485 extern reloc_howto_type *_bfd_norelocs_bfd_reloc_name_lookup
486 (bfd *, const char *) ATTRIBUTE_HIDDEN;
488 /* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
489 be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */
491 extern bfd_boolean _bfd_nowrite_set_arch_mach
492 (bfd *, enum bfd_architecture, unsigned long) ATTRIBUTE_HIDDEN;
493 extern bfd_boolean _bfd_nowrite_set_section_contents
494 (bfd *, asection *, const void *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN;
496 /* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use
497 BFD_JUMP_TABLE_WRITE (_bfd_generic). */
499 #define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
500 extern bfd_boolean _bfd_generic_set_section_contents
501 (bfd *, asection *, const void *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN;
503 /* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
504 support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */
506 extern int _bfd_nolink_sizeof_headers
507 (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
508 extern bfd_byte *_bfd_nolink_bfd_get_relocated_section_contents
509 (bfd *, struct bfd_link_info *, struct bfd_link_order *,
510 bfd_byte *, bfd_boolean, asymbol **) ATTRIBUTE_HIDDEN;
511 extern bfd_boolean _bfd_nolink_bfd_relax_section
512 (bfd *, asection *, struct bfd_link_info *, bfd_boolean *) ATTRIBUTE_HIDDEN;
513 #define _bfd_nolink_bfd_gc_sections _bfd_bool_bfd_link_false_error
514 extern bfd_boolean _bfd_nolink_bfd_lookup_section_flags
515 (struct bfd_link_info *, struct flag_info *, asection *) ATTRIBUTE_HIDDEN;
516 #define _bfd_nolink_bfd_merge_sections _bfd_bool_bfd_link_false_error
517 extern bfd_boolean _bfd_nolink_bfd_is_group_section
518 (bfd *, const asection *) ATTRIBUTE_HIDDEN;
519 extern bfd_boolean _bfd_nolink_bfd_discard_group
520 (bfd *, asection *) ATTRIBUTE_HIDDEN;
521 extern struct bfd_link_hash_table *_bfd_nolink_bfd_link_hash_table_create
522 (bfd *) ATTRIBUTE_HIDDEN;
523 #define _bfd_nolink_bfd_link_add_symbols _bfd_bool_bfd_link_false_error
524 extern void _bfd_nolink_bfd_link_just_syms
525 (asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
526 extern void _bfd_nolink_bfd_copy_link_hash_symbol_type
527 (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *)
529 #define _bfd_nolink_bfd_final_link _bfd_bool_bfd_link_false_error
530 extern bfd_boolean _bfd_nolink_bfd_link_split_section
531 (bfd *, struct bfd_section *) ATTRIBUTE_HIDDEN;
532 extern bfd_boolean _bfd_nolink_section_already_linked
533 (bfd *, asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
534 extern bfd_boolean _bfd_nolink_bfd_define_common_symbol
535 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *)
537 #define _bfd_nolink_bfd_link_hide_symbol \
538 _bfd_generic_link_hide_symbol
539 extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
540 (struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN;
541 #define _bfd_nolink_bfd_link_check_relocs \
542 _bfd_generic_link_check_relocs
544 /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
545 have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
548 #define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_long_bfd_n1_error
549 #define _bfd_nodynamic_canonicalize_dynamic_symtab \
550 _bfd_nosymbols_canonicalize_symtab
551 extern long _bfd_nodynamic_get_synthetic_symtab
552 (bfd *, long, asymbol **, long, asymbol **, asymbol **) ATTRIBUTE_HIDDEN;
553 #define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_long_bfd_n1_error
554 extern long _bfd_nodynamic_canonicalize_dynamic_reloc
555 (bfd *, arelent **, asymbol **) ATTRIBUTE_HIDDEN;
557 /* Generic routine to determine of the given symbol is a local
559 extern bfd_boolean bfd_generic_is_local_label_name
560 (bfd *, const char *) ATTRIBUTE_HIDDEN;
562 /* Generic minisymbol routines. */
563 extern long _bfd_generic_read_minisymbols
564 (bfd *, bfd_boolean, void **, unsigned int *) ATTRIBUTE_HIDDEN;
565 extern asymbol *_bfd_generic_minisymbol_to_symbol
566 (bfd *, bfd_boolean, const void *, asymbol *) ATTRIBUTE_HIDDEN;
568 /* Find the nearest line using .stab/.stabstr sections. */
569 extern bfd_boolean _bfd_stab_section_find_nearest_line
570 (bfd *, asymbol **, asection *, bfd_vma, bfd_boolean *,
571 const char **, const char **, unsigned int *, void **) ATTRIBUTE_HIDDEN;
573 /* Find the nearest line using DWARF 1 debugging information. */
574 extern bfd_boolean _bfd_dwarf1_find_nearest_line
575 (bfd *, asymbol **, asection *, bfd_vma,
576 const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN;
578 struct dwarf_debug_section
580 const char * uncompressed_name;
581 const char * compressed_name;
584 /* Map of uncompressed DWARF debug section name to compressed one. It
585 is terminated by NULL uncompressed_name. */
587 extern const struct dwarf_debug_section dwarf_debug_sections[] ATTRIBUTE_HIDDEN;
589 /* Find the nearest line using DWARF 2 debugging information. */
590 extern bfd_boolean _bfd_dwarf2_find_nearest_line
591 (bfd *, asymbol **, asymbol *, asection *, bfd_vma,
592 const char **, const char **, unsigned int *, unsigned int *,
593 const struct dwarf_debug_section *, unsigned int, void **) ATTRIBUTE_HIDDEN;
595 /* Find the bias between DWARF addresses and real addresses. */
596 extern bfd_signed_vma _bfd_dwarf2_find_symbol_bias
597 (asymbol **, void **) ATTRIBUTE_HIDDEN;
599 /* Find inliner info after calling bfd_find_nearest_line. */
600 extern bfd_boolean _bfd_dwarf2_find_inliner_info
601 (bfd *, const char **, const char **, unsigned int *, void **)
604 /* Read DWARF 2 debugging information. */
605 extern bfd_boolean _bfd_dwarf2_slurp_debug_info
606 (bfd *, bfd *, const struct dwarf_debug_section *, asymbol **, void **,
607 bfd_boolean) ATTRIBUTE_HIDDEN;
609 /* Clean up the data used to handle DWARF 2 debugging information. */
610 extern void _bfd_dwarf2_cleanup_debug_info
611 (bfd *, void **) ATTRIBUTE_HIDDEN;
613 /* Create a new section entry. */
614 extern struct bfd_hash_entry *bfd_section_hash_newfunc
615 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *)
618 /* A routine to create entries for a bfd_link_hash_table. */
619 extern struct bfd_hash_entry *_bfd_link_hash_newfunc
620 (struct bfd_hash_entry *entry, struct bfd_hash_table *table,
621 const char *string) ATTRIBUTE_HIDDEN;
623 /* Initialize a bfd_link_hash_table. */
624 extern bfd_boolean _bfd_link_hash_table_init
625 (struct bfd_link_hash_table *, bfd *,
626 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
627 struct bfd_hash_table *,
629 unsigned int) ATTRIBUTE_HIDDEN;
631 /* Generic link hash table creation routine. */
632 extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
633 (bfd *) ATTRIBUTE_HIDDEN;
635 /* Generic link hash table destruction routine. */
636 extern void _bfd_generic_link_hash_table_free
637 (bfd *) ATTRIBUTE_HIDDEN;
639 /* Generic add symbol routine. */
640 extern bfd_boolean _bfd_generic_link_add_symbols
641 (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
643 /* Generic archive add symbol routine. */
644 extern bfd_boolean _bfd_generic_link_add_archive_symbols
645 (bfd *, struct bfd_link_info *,
646 bfd_boolean (*) (bfd *, struct bfd_link_info *,
647 struct bfd_link_hash_entry *, const char *,
648 bfd_boolean *)) ATTRIBUTE_HIDDEN;
650 /* Forward declaration to avoid prototype errors. */
651 typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
653 /* Generic routine to add a single symbol. */
654 extern bfd_boolean _bfd_generic_link_add_one_symbol
655 (struct bfd_link_info *, bfd *, const char *name, flagword,
656 asection *, bfd_vma, const char *, bfd_boolean copy,
657 bfd_boolean constructor, struct bfd_link_hash_entry **) ATTRIBUTE_HIDDEN;
659 /* Generic routine to mark section as supplying symbols only. */
660 extern void _bfd_generic_link_just_syms
661 (asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
663 /* Generic routine that does nothing. */
664 extern void _bfd_generic_copy_link_hash_symbol_type
665 (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *)
668 /* Generic link routine. */
669 extern bfd_boolean _bfd_generic_final_link
670 (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
672 extern bfd_boolean _bfd_generic_link_split_section
673 (bfd *, struct bfd_section *) ATTRIBUTE_HIDDEN;
675 extern bfd_boolean _bfd_generic_section_already_linked
676 (bfd *, asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
678 /* Generic reloc_link_order processing routine. */
679 extern bfd_boolean _bfd_generic_reloc_link_order
680 (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *)
683 /* Default link order processing routine. */
684 extern bfd_boolean _bfd_default_link_order
685 (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *)
688 /* Count the number of reloc entries in a link order list. */
689 extern unsigned int _bfd_count_link_order_relocs
690 (struct bfd_link_order *) ATTRIBUTE_HIDDEN;
692 /* Final link relocation routine. */
693 extern bfd_reloc_status_type _bfd_final_link_relocate
694 (reloc_howto_type *, bfd *, asection *, bfd_byte *,
695 bfd_vma, bfd_vma, bfd_vma) ATTRIBUTE_HIDDEN;
697 /* Relocate a particular location by a howto and a value. */
698 extern bfd_reloc_status_type _bfd_relocate_contents
699 (reloc_howto_type *, bfd *, bfd_vma, bfd_byte *) ATTRIBUTE_HIDDEN;
701 /* Clear a given location using a given howto. */
702 extern void _bfd_clear_contents
703 (reloc_howto_type *, bfd *, asection *, bfd_byte *) ATTRIBUTE_HIDDEN;
705 /* Link stabs in sections in the first pass. */
707 extern bfd_boolean _bfd_link_section_stabs
708 (bfd *, struct stab_info *, asection *, asection *, void **,
709 bfd_size_type *) ATTRIBUTE_HIDDEN;
711 /* Eliminate stabs for discarded functions and symbols. */
712 extern bfd_boolean _bfd_discard_section_stabs
713 (bfd *, asection *, void *, bfd_boolean (*) (bfd_vma, void *), void *)
716 /* Write out the .stab section when linking stabs in sections. */
718 extern bfd_boolean _bfd_write_section_stabs
719 (bfd *, struct stab_info *, asection *, void **, bfd_byte *)
722 /* Write out the .stabstr string table when linking stabs in sections. */
724 extern bfd_boolean _bfd_write_stab_strings
725 (bfd *, struct stab_info *) ATTRIBUTE_HIDDEN;
727 /* Find an offset within a .stab section when linking stabs in
730 extern bfd_vma _bfd_stab_section_offset
731 (asection *, void *, bfd_vma) ATTRIBUTE_HIDDEN;
733 /* Register a SEC_MERGE section as a candidate for merging. */
735 extern bfd_boolean _bfd_add_merge_section
736 (bfd *, void **, asection *, void **) ATTRIBUTE_HIDDEN;
738 /* Attempt to merge SEC_MERGE sections. */
740 extern bfd_boolean _bfd_merge_sections
741 (bfd *, struct bfd_link_info *, void *, void (*) (bfd *, asection *))
744 /* Write out a merged section. */
746 extern bfd_boolean _bfd_write_merged_section
747 (bfd *, asection *, void *) ATTRIBUTE_HIDDEN;
749 /* Find an offset within a modified SEC_MERGE section. */
751 extern bfd_vma _bfd_merged_section_offset
752 (bfd *, asection **, void *, bfd_vma) ATTRIBUTE_HIDDEN;
754 /* Tidy up when done. */
756 extern void _bfd_merge_sections_free (void *) ATTRIBUTE_HIDDEN;
758 /* Create a string table. */
759 extern struct bfd_strtab_hash *_bfd_stringtab_init
760 (void) ATTRIBUTE_HIDDEN;
762 /* Create an XCOFF .debug section style string table. */
763 extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init
764 (void) ATTRIBUTE_HIDDEN;
766 /* Free a string table. */
767 extern void _bfd_stringtab_free
768 (struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN;
770 /* Get the size of a string table. */
771 extern bfd_size_type _bfd_stringtab_size
772 (struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN;
774 /* Add a string to a string table. */
775 extern bfd_size_type _bfd_stringtab_add
776 (struct bfd_strtab_hash *, const char *, bfd_boolean hash, bfd_boolean copy)
779 /* Write out a string table. */
780 extern bfd_boolean _bfd_stringtab_emit
781 (bfd *, struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN;
783 /* Macros to tell if bfds are read or write enabled.
785 Note that bfds open for read may be scribbled into if the fd passed
786 to bfd_fdopenr is actually open both for read and write
787 simultaneously. However an output bfd will never be open for
788 read. Therefore sometimes you want to check bfd_read_p or
789 !bfd_read_p, and only sometimes bfd_write_p.
792 #define bfd_read_p(abfd) \
793 ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
794 #define bfd_write_p(abfd) \
795 ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
797 extern void bfd_assert
798 (const char*,int) ATTRIBUTE_HIDDEN;
800 #define BFD_ASSERT(x) \
801 do { if (!(x)) bfd_assert(__FILE__,__LINE__); } while (0)
804 do { bfd_assert(__FILE__,__LINE__); } while (0)
806 extern void _bfd_abort
807 (const char *, int, const char *) ATTRIBUTE_NORETURN ATTRIBUTE_HIDDEN;
809 /* if gcc >= 2.6, we can give a function name, too */
810 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
811 #define __PRETTY_FUNCTION__ ((char *) NULL)
815 #define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
817 /* Manipulate a system FILE but using BFD's "file_ptr", rather than
818 the system "off_t" or "off64_t", as the offset. */
819 extern file_ptr _bfd_real_ftell
820 (FILE *) ATTRIBUTE_HIDDEN;
821 extern int _bfd_real_fseek
822 (FILE *, file_ptr, int) ATTRIBUTE_HIDDEN;
823 extern FILE *_bfd_real_fopen
824 (const char *, const char *) ATTRIBUTE_HIDDEN;
826 /* List of supported target vectors, and the default vector (if
827 bfd_default_vector[0] is NULL, there is no default). */
828 extern const bfd_target * const *bfd_target_vector ATTRIBUTE_HIDDEN;
829 extern const bfd_target *bfd_default_vector[] ATTRIBUTE_HIDDEN;
831 /* List of associated target vectors. */
832 extern const bfd_target * const *bfd_associated_vector ATTRIBUTE_HIDDEN;
834 /* Functions shared by the ECOFF and MIPS ELF backends, which have no
835 other common header files. */
837 #if defined(__STDC__) || defined(ALMOST_STDC)
838 struct ecoff_find_line;
841 extern bfd_boolean _bfd_ecoff_locate_line
842 (bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
843 const struct ecoff_debug_swap * const, struct ecoff_find_line *,
844 const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN;
845 extern bfd_boolean _bfd_ecoff_get_accumulated_pdr
846 (void *, bfd_byte *) ATTRIBUTE_HIDDEN;
847 extern bfd_boolean _bfd_ecoff_get_accumulated_sym
848 (void *, bfd_byte *) ATTRIBUTE_HIDDEN;
849 extern bfd_boolean _bfd_ecoff_get_accumulated_ss
850 (void *, bfd_byte *) ATTRIBUTE_HIDDEN;
852 extern bfd_vma _bfd_get_gp_value
853 (bfd *) ATTRIBUTE_HIDDEN;
854 extern void _bfd_set_gp_value
855 (bfd *, bfd_vma) ATTRIBUTE_HIDDEN;
857 /* Function shared by the COFF and ELF SH backends, which have no
858 other common header files. */
860 #ifndef _bfd_sh_align_load_span
861 extern bfd_boolean _bfd_sh_align_load_span
862 (bfd *, asection *, bfd_byte *,
863 bfd_boolean (*) (bfd *, asection *, void *, bfd_byte *, bfd_vma),
864 void *, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, bfd_boolean *) ATTRIBUTE_HIDDEN;
867 /* This is the shape of the elements inside the already_linked hash
868 table. It maps a name onto a list of already_linked elements with
871 struct bfd_section_already_linked_hash_entry
873 struct bfd_hash_entry root;
874 struct bfd_section_already_linked *entry;
877 struct bfd_section_already_linked
879 struct bfd_section_already_linked *next;
883 extern struct bfd_section_already_linked_hash_entry *
884 bfd_section_already_linked_table_lookup (const char *) ATTRIBUTE_HIDDEN;
885 extern bfd_boolean bfd_section_already_linked_table_insert
886 (struct bfd_section_already_linked_hash_entry *, asection *)
888 extern void bfd_section_already_linked_table_traverse
889 (bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *,
890 void *), void *) ATTRIBUTE_HIDDEN;
892 extern bfd_vma _bfd_read_unsigned_leb128
893 (bfd *, bfd_byte *, unsigned int *) ATTRIBUTE_HIDDEN;
894 extern bfd_signed_vma _bfd_read_signed_leb128
895 (bfd *, bfd_byte *, unsigned int *) ATTRIBUTE_HIDDEN;
896 extern bfd_vma _bfd_safe_read_leb128
897 (bfd *, bfd_byte *, unsigned int *, bfd_boolean, const bfd_byte * const)