1 /* libbfd.h -- Declarations used by bfd library *implementation*.
2 (This include file is not for users of the library.)
4 Copyright (C) 1990-2021 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
;
115 bfd_strdup (const char *str
)
117 size_t len
= strlen (str
) + 1;
118 char *buf
= bfd_malloc (len
);
120 memcpy (buf
, str
, len
);
123 /* These routines allocate and free things on the BFD's objalloc. */
125 extern void bfd_release
126 (bfd
*, void *) ATTRIBUTE_HIDDEN
;
128 extern bfd
* _bfd_create_empty_archive_element_shell
129 (bfd
*) ATTRIBUTE_HIDDEN
;
130 extern bfd
* _bfd_look_for_bfd_in_cache
131 (bfd
*, file_ptr
) ATTRIBUTE_HIDDEN
;
132 extern bool _bfd_add_bfd_to_archive_cache
133 (bfd
*, file_ptr
, bfd
*) ATTRIBUTE_HIDDEN
;
134 extern bool _bfd_generic_mkarchive
135 (bfd
*) ATTRIBUTE_HIDDEN
;
136 extern char *_bfd_append_relative_path
137 (bfd
*, char *) ATTRIBUTE_HIDDEN
;
138 extern bfd_cleanup bfd_generic_archive_p
139 (bfd
*) ATTRIBUTE_HIDDEN
;
140 extern bool bfd_slurp_armap
141 (bfd
*) ATTRIBUTE_HIDDEN
;
142 #define bfd_slurp_bsd_armap bfd_slurp_armap
143 #define bfd_slurp_coff_armap bfd_slurp_armap
144 extern bool _bfd_archive_64_bit_slurp_armap
145 (bfd
*) ATTRIBUTE_HIDDEN
;
146 extern bool _bfd_archive_64_bit_write_armap
147 (bfd
*, unsigned int, struct orl
*, unsigned int, int) ATTRIBUTE_HIDDEN
;
148 #define _bfd_archive_64_bit_slurp_extended_name_table \
149 _bfd_slurp_extended_name_table
150 #define _bfd_archive_64_bit_construct_extended_name_table \
151 _bfd_archive_coff_construct_extended_name_table
152 #define _bfd_archive_64_bit_truncate_arname \
153 bfd_dont_truncate_arname
154 #define _bfd_archive_64_bit_read_ar_hdr \
155 _bfd_generic_read_ar_hdr
156 #define _bfd_archive_64_bit_write_ar_hdr \
157 _bfd_generic_write_ar_hdr
158 #define _bfd_archive_64_bit_openr_next_archived_file \
159 bfd_generic_openr_next_archived_file
160 #define _bfd_archive_64_bit_get_elt_at_index \
161 _bfd_generic_get_elt_at_index
162 #define _bfd_archive_64_bit_generic_stat_arch_elt \
163 bfd_generic_stat_arch_elt
164 #define _bfd_archive_64_bit_update_armap_timestamp _bfd_bool_bfd_true
166 extern bool _bfd_slurp_extended_name_table
167 (bfd
*) ATTRIBUTE_HIDDEN
;
168 extern bool _bfd_construct_extended_name_table
169 (bfd
*, bool, char **, bfd_size_type
*) ATTRIBUTE_HIDDEN
;
170 extern bool _bfd_write_archive_contents
171 (bfd
*) ATTRIBUTE_HIDDEN
;
172 extern bool _bfd_compute_and_write_armap
173 (bfd
*, unsigned int) ATTRIBUTE_HIDDEN
;
174 extern bfd
*_bfd_get_elt_at_filepos
175 (bfd
*, file_ptr
) ATTRIBUTE_HIDDEN
;
176 extern bfd
*_bfd_generic_get_elt_at_index
177 (bfd
*, symindex
) ATTRIBUTE_HIDDEN
;
178 extern bfd
* _bfd_new_bfd
179 (void) ATTRIBUTE_HIDDEN
;
180 extern bool _bfd_free_cached_info
181 (bfd
*) ATTRIBUTE_HIDDEN
;
183 extern bool _bfd_bool_bfd_false
184 (bfd
*) ATTRIBUTE_HIDDEN
;
185 extern bool _bfd_bool_bfd_asymbol_false
186 (bfd
*, asymbol
*) ATTRIBUTE_HIDDEN
;
187 extern bool _bfd_bool_bfd_false_error
188 (bfd
*) ATTRIBUTE_HIDDEN
;
189 extern bool _bfd_bool_bfd_link_false_error
190 (bfd
*, struct bfd_link_info
*) ATTRIBUTE_HIDDEN
;
191 extern bool _bfd_bool_bfd_true
192 (bfd
*) ATTRIBUTE_HIDDEN
;
193 extern bool _bfd_bool_bfd_link_true
194 (bfd
*, struct bfd_link_info
*) ATTRIBUTE_HIDDEN
;
195 extern bool _bfd_bool_bfd_bfd_true
196 (bfd
*, bfd
*) ATTRIBUTE_HIDDEN
;
197 extern bool _bfd_bool_bfd_uint_true
198 (bfd
*, unsigned int) ATTRIBUTE_HIDDEN
;
199 extern bool _bfd_bool_bfd_asection_bfd_asection_true
200 (bfd
*, asection
*, bfd
*, asection
*) ATTRIBUTE_HIDDEN
;
201 extern bool _bfd_bool_bfd_asymbol_bfd_asymbol_true
202 (bfd
*, asymbol
*, bfd
*, asymbol
*) ATTRIBUTE_HIDDEN
;
203 extern bool _bfd_bool_bfd_ptr_true
204 (bfd
*, void *) ATTRIBUTE_HIDDEN
;
205 extern void *_bfd_ptr_bfd_null_error
206 (bfd
*) ATTRIBUTE_HIDDEN
;
207 extern int _bfd_int_bfd_0
208 (bfd
*) ATTRIBUTE_HIDDEN
;
209 extern unsigned int _bfd_uint_bfd_0
210 (bfd
*) ATTRIBUTE_HIDDEN
;
211 extern long _bfd_long_bfd_0
212 (bfd
*) ATTRIBUTE_HIDDEN
;
213 extern long _bfd_long_bfd_n1_error
214 (bfd
*) ATTRIBUTE_HIDDEN
;
215 extern void _bfd_void_bfd
216 (bfd
*) ATTRIBUTE_HIDDEN
;
217 extern void _bfd_void_bfd_link
218 (bfd
*, struct bfd_link_info
*) ATTRIBUTE_HIDDEN
;
219 extern void _bfd_void_bfd_asection
220 (bfd
*, asection
*) ATTRIBUTE_HIDDEN
;
222 extern bfd
*_bfd_new_bfd_contained_in
223 (bfd
*) ATTRIBUTE_HIDDEN
;
224 extern bfd_cleanup _bfd_dummy_target
225 (bfd
*) ATTRIBUTE_HIDDEN
;
226 #define _bfd_no_cleanup _bfd_void_bfd
228 extern void bfd_dont_truncate_arname
229 (bfd
*, const char *, char *) ATTRIBUTE_HIDDEN
;
230 extern void bfd_bsd_truncate_arname
231 (bfd
*, const char *, char *) ATTRIBUTE_HIDDEN
;
232 extern void bfd_gnu_truncate_arname
233 (bfd
*, const char *, char *) ATTRIBUTE_HIDDEN
;
235 extern bool _bfd_bsd_write_armap
236 (bfd
*, unsigned int, struct orl
*, unsigned int, int) ATTRIBUTE_HIDDEN
;
238 extern bool _bfd_coff_write_armap
239 (bfd
*, unsigned int, struct orl
*, unsigned int, int) ATTRIBUTE_HIDDEN
;
241 extern void *_bfd_generic_read_ar_hdr
242 (bfd
*) ATTRIBUTE_HIDDEN
;
243 extern void _bfd_ar_spacepad
244 (char *, size_t, const char *, long) ATTRIBUTE_HIDDEN
;
245 extern bool _bfd_ar_sizepad
246 (char *, size_t, bfd_size_type
) ATTRIBUTE_HIDDEN
;
248 extern void *_bfd_generic_read_ar_hdr_mag
249 (bfd
*, const char *) ATTRIBUTE_HIDDEN
;
251 extern bool _bfd_generic_write_ar_hdr
252 (bfd
*, bfd
*) ATTRIBUTE_HIDDEN
;
254 extern bool _bfd_bsd44_write_ar_hdr
255 (bfd
*, bfd
*) ATTRIBUTE_HIDDEN
;
257 extern bfd
* bfd_generic_openr_next_archived_file
258 (bfd
*, bfd
*) ATTRIBUTE_HIDDEN
;
260 extern int bfd_generic_stat_arch_elt
261 (bfd
*, struct stat
*) ATTRIBUTE_HIDDEN
;
263 #define _bfd_read_ar_hdr(abfd) \
264 BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
265 #define _bfd_write_ar_hdr(archive, abfd) \
266 BFD_SEND (abfd, _bfd_write_ar_hdr_fn, (archive, abfd))
268 /* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
269 BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
271 #define _bfd_generic_close_and_cleanup _bfd_archive_close_and_cleanup
272 extern bool _bfd_archive_close_and_cleanup
273 (bfd
*) ATTRIBUTE_HIDDEN
;
274 extern void _bfd_unlink_from_archive_parent (bfd
*) ATTRIBUTE_HIDDEN
;
275 #define _bfd_generic_bfd_free_cached_info _bfd_bool_bfd_true
276 extern bool _bfd_generic_new_section_hook
277 (bfd
*, asection
*) ATTRIBUTE_HIDDEN
;
278 extern bool _bfd_generic_get_section_contents
279 (bfd
*, asection
*, void *, file_ptr
, bfd_size_type
) ATTRIBUTE_HIDDEN
;
280 extern bool _bfd_generic_get_section_contents_in_window
281 (bfd
*, asection
*, bfd_window
*, file_ptr
, bfd_size_type
) ATTRIBUTE_HIDDEN
;
283 /* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
284 BFD_JUMP_TABLE_COPY (_bfd_generic). */
286 #define _bfd_generic_bfd_copy_private_bfd_data _bfd_bool_bfd_bfd_true
287 #define _bfd_generic_bfd_merge_private_bfd_data \
288 _bfd_bool_bfd_link_true
289 #define _bfd_generic_bfd_set_private_flags _bfd_bool_bfd_uint_true
290 #define _bfd_generic_bfd_copy_private_section_data \
291 _bfd_bool_bfd_asection_bfd_asection_true
292 #define _bfd_generic_bfd_copy_private_symbol_data \
293 _bfd_bool_bfd_asymbol_bfd_asymbol_true
294 #define _bfd_generic_bfd_copy_private_header_data _bfd_bool_bfd_bfd_true
295 #define _bfd_generic_bfd_print_private_bfd_data _bfd_bool_bfd_ptr_true
297 extern bool _bfd_generic_init_private_section_data
298 (bfd
*, asection
*, bfd
*, asection
*, struct bfd_link_info
*)
301 /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
302 support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */
304 extern char *_bfd_nocore_core_file_failing_command
305 (bfd
*) ATTRIBUTE_HIDDEN
;
306 extern int _bfd_nocore_core_file_failing_signal
307 (bfd
*) ATTRIBUTE_HIDDEN
;
308 extern bool _bfd_nocore_core_file_matches_executable_p
309 (bfd
*, bfd
*) ATTRIBUTE_HIDDEN
;
310 extern int _bfd_nocore_core_file_pid
311 (bfd
*) ATTRIBUTE_HIDDEN
;
313 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
314 file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
316 #define _bfd_noarchive_slurp_armap _bfd_bool_bfd_false_error
317 #define _bfd_noarchive_slurp_extended_name_table _bfd_bool_bfd_false_error
318 extern bool _bfd_noarchive_construct_extended_name_table
319 (bfd
*, char **, bfd_size_type
*, const char **) ATTRIBUTE_HIDDEN
;
320 extern void _bfd_noarchive_truncate_arname
321 (bfd
*, const char *, char *) ATTRIBUTE_HIDDEN
;
322 extern bool _bfd_noarchive_write_armap
323 (bfd
*, unsigned int, struct orl
*, unsigned int, int) ATTRIBUTE_HIDDEN
;
324 #define _bfd_noarchive_read_ar_hdr _bfd_ptr_bfd_null_error
325 extern bool _bfd_noarchive_write_ar_hdr
326 (bfd
*, bfd
*) ATTRIBUTE_HIDDEN
;
328 _bfd_noarchive_openr_next_archived_file
329 (bfd
*, bfd
*) ATTRIBUTE_HIDDEN
;
330 extern bfd
* _bfd_noarchive_get_elt_at_index
331 (bfd
*, symindex
) ATTRIBUTE_HIDDEN
;
332 #define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
333 #define _bfd_noarchive_update_armap_timestamp _bfd_bool_bfd_false_error
335 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
336 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */
338 #define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
339 #define _bfd_archive_bsd_slurp_extended_name_table \
340 _bfd_slurp_extended_name_table
341 extern bool _bfd_archive_bsd_construct_extended_name_table
342 (bfd
*, char **, bfd_size_type
*, const char **) ATTRIBUTE_HIDDEN
;
343 #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
344 #define _bfd_archive_bsd_write_armap _bfd_bsd_write_armap
345 #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
346 #define _bfd_archive_bsd_write_ar_hdr _bfd_generic_write_ar_hdr
347 #define _bfd_archive_bsd_openr_next_archived_file \
348 bfd_generic_openr_next_archived_file
349 #define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
350 #define _bfd_archive_bsd_generic_stat_arch_elt \
351 bfd_generic_stat_arch_elt
352 extern bool _bfd_archive_bsd_update_armap_timestamp
353 (bfd
*) ATTRIBUTE_HIDDEN
;
355 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
356 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */
358 #define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
359 #define _bfd_archive_coff_slurp_extended_name_table \
360 _bfd_slurp_extended_name_table
361 extern bool _bfd_archive_coff_construct_extended_name_table
362 (bfd
*, char **, bfd_size_type
*, const char **) ATTRIBUTE_HIDDEN
;
363 #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
364 #define _bfd_archive_coff_write_armap _bfd_coff_write_armap
365 #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
366 #define _bfd_archive_coff_write_ar_hdr _bfd_generic_write_ar_hdr
367 #define _bfd_archive_coff_openr_next_archived_file \
368 bfd_generic_openr_next_archived_file
369 #define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
370 #define _bfd_archive_coff_generic_stat_arch_elt \
371 bfd_generic_stat_arch_elt
372 #define _bfd_archive_coff_update_armap_timestamp _bfd_bool_bfd_true
374 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD4.4 style
375 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44). */
377 #define _bfd_archive_bsd44_slurp_armap bfd_slurp_bsd_armap
378 #define _bfd_archive_bsd44_slurp_extended_name_table \
379 _bfd_slurp_extended_name_table
380 extern bool _bfd_archive_bsd44_construct_extended_name_table
381 (bfd
*, char **, bfd_size_type
*, const char **) ATTRIBUTE_HIDDEN
;
382 #define _bfd_archive_bsd44_truncate_arname bfd_bsd_truncate_arname
383 #define _bfd_archive_bsd44_write_armap _bfd_bsd_write_armap
384 #define _bfd_archive_bsd44_read_ar_hdr _bfd_generic_read_ar_hdr
385 #define _bfd_archive_bsd44_write_ar_hdr _bfd_bsd44_write_ar_hdr
386 #define _bfd_archive_bsd44_openr_next_archived_file \
387 bfd_generic_openr_next_archived_file
388 #define _bfd_archive_bsd44_get_elt_at_index _bfd_generic_get_elt_at_index
389 #define _bfd_archive_bsd44_generic_stat_arch_elt \
390 bfd_generic_stat_arch_elt
391 #define _bfd_archive_bsd44_update_armap_timestamp \
392 _bfd_archive_bsd_update_armap_timestamp
394 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get VMS style
395 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib). Some of them
398 extern bool _bfd_vms_lib_write_archive_contents
399 (bfd
*) ATTRIBUTE_HIDDEN
;
400 #define _bfd_vms_lib_slurp_armap _bfd_noarchive_slurp_armap
401 #define _bfd_vms_lib_slurp_extended_name_table \
402 _bfd_noarchive_slurp_extended_name_table
403 #define _bfd_vms_lib_construct_extended_name_table \
404 _bfd_noarchive_construct_extended_name_table
405 #define _bfd_vms_lib_truncate_arname _bfd_noarchive_truncate_arname
406 #define _bfd_vms_lib_write_armap _bfd_noarchive_write_armap
407 #define _bfd_vms_lib_read_ar_hdr _bfd_noarchive_read_ar_hdr
408 #define _bfd_vms_lib_write_ar_hdr _bfd_noarchive_write_ar_hdr
409 extern bfd
*_bfd_vms_lib_openr_next_archived_file
410 (bfd
*, bfd
*) ATTRIBUTE_HIDDEN
;
411 extern bfd
*_bfd_vms_lib_get_elt_at_index
412 (bfd
*, symindex
) ATTRIBUTE_HIDDEN
;
413 extern int _bfd_vms_lib_generic_stat_arch_elt
414 (bfd
*, struct stat
*) ATTRIBUTE_HIDDEN
;
415 #define _bfd_vms_lib_update_armap_timestamp _bfd_bool_bfd_true
417 /* Extra routines for VMS style archives. */
419 extern symindex _bfd_vms_lib_find_symbol
420 (bfd
*, const char *) ATTRIBUTE_HIDDEN
;
421 extern bfd
*_bfd_vms_lib_get_imagelib_file
422 (bfd
*) ATTRIBUTE_HIDDEN
;
423 extern bfd_cleanup _bfd_vms_lib_alpha_archive_p
424 (bfd
*) ATTRIBUTE_HIDDEN
;
425 extern bfd_cleanup _bfd_vms_lib_ia64_archive_p
426 (bfd
*) ATTRIBUTE_HIDDEN
;
427 extern bool _bfd_vms_lib_alpha_mkarchive
428 (bfd
*) ATTRIBUTE_HIDDEN
;
429 extern bool _bfd_vms_lib_ia64_mkarchive
430 (bfd
*) ATTRIBUTE_HIDDEN
;
432 /* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
433 support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
435 #define _bfd_nosymbols_get_symtab_upper_bound _bfd_long_bfd_n1_error
436 extern long _bfd_nosymbols_canonicalize_symtab
437 (bfd
*, asymbol
**) ATTRIBUTE_HIDDEN
;
438 #define _bfd_nosymbols_make_empty_symbol _bfd_generic_make_empty_symbol
439 extern void _bfd_nosymbols_print_symbol
440 (bfd
*, void *, asymbol
*, bfd_print_symbol_type
) ATTRIBUTE_HIDDEN
;
441 extern void _bfd_nosymbols_get_symbol_info
442 (bfd
*, asymbol
*, symbol_info
*) ATTRIBUTE_HIDDEN
;
443 extern const char * _bfd_nosymbols_get_symbol_version_string
444 (bfd
*, asymbol
*, bool, bool *) ATTRIBUTE_HIDDEN
;
445 extern bool _bfd_nosymbols_bfd_is_local_label_name
446 (bfd
*, const char *) ATTRIBUTE_HIDDEN
;
447 #define _bfd_nosymbols_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
448 extern alent
*_bfd_nosymbols_get_lineno
449 (bfd
*, asymbol
*) ATTRIBUTE_HIDDEN
;
450 extern bool _bfd_nosymbols_find_nearest_line
451 (bfd
*, asymbol
**, asection
*, bfd_vma
,
452 const char **, const char **, unsigned int *, unsigned int *)
454 extern bool _bfd_nosymbols_find_line
455 (bfd
*, asymbol
**, asymbol
*, const char **, unsigned int *)
457 extern bool _bfd_nosymbols_find_inliner_info
458 (bfd
*, const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN
;
459 extern asymbol
*_bfd_nosymbols_bfd_make_debug_symbol
460 (bfd
*, void *, unsigned long) ATTRIBUTE_HIDDEN
;
461 extern long _bfd_nosymbols_read_minisymbols
462 (bfd
*, bool, void **, unsigned int *) ATTRIBUTE_HIDDEN
;
463 extern asymbol
*_bfd_nosymbols_minisymbol_to_symbol
464 (bfd
*, bool, const void *, asymbol
*) ATTRIBUTE_HIDDEN
;
466 /* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
467 support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */
469 extern long _bfd_norelocs_get_reloc_upper_bound
470 (bfd
*, asection
*) ATTRIBUTE_HIDDEN
;
471 extern long _bfd_norelocs_canonicalize_reloc
472 (bfd
*, asection
*, arelent
**, asymbol
**) ATTRIBUTE_HIDDEN
;
473 extern void _bfd_norelocs_set_reloc
474 (bfd
*, asection
*, arelent
**, unsigned int) ATTRIBUTE_HIDDEN
;
475 extern reloc_howto_type
*_bfd_norelocs_bfd_reloc_type_lookup
476 (bfd
*, bfd_reloc_code_real_type
) ATTRIBUTE_HIDDEN
;
477 extern reloc_howto_type
*_bfd_norelocs_bfd_reloc_name_lookup
478 (bfd
*, const char *) ATTRIBUTE_HIDDEN
;
480 /* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
481 be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */
483 extern bool _bfd_nowrite_set_arch_mach
484 (bfd
*, enum bfd_architecture
, unsigned long) ATTRIBUTE_HIDDEN
;
485 extern bool _bfd_nowrite_set_section_contents
486 (bfd
*, asection
*, const void *, file_ptr
, bfd_size_type
) ATTRIBUTE_HIDDEN
;
488 /* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use
489 BFD_JUMP_TABLE_WRITE (_bfd_generic). */
491 #define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
492 extern bool _bfd_generic_set_section_contents
493 (bfd
*, asection
*, const void *, file_ptr
, bfd_size_type
) ATTRIBUTE_HIDDEN
;
495 /* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
496 support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */
498 extern int _bfd_nolink_sizeof_headers
499 (bfd
*, struct bfd_link_info
*) ATTRIBUTE_HIDDEN
;
500 extern bfd_byte
*_bfd_nolink_bfd_get_relocated_section_contents
501 (bfd
*, struct bfd_link_info
*, struct bfd_link_order
*,
502 bfd_byte
*, bool, asymbol
**) ATTRIBUTE_HIDDEN
;
503 extern bool _bfd_nolink_bfd_relax_section
504 (bfd
*, asection
*, struct bfd_link_info
*, bool *) ATTRIBUTE_HIDDEN
;
505 #define _bfd_nolink_bfd_gc_sections _bfd_bool_bfd_link_false_error
506 extern bool _bfd_nolink_bfd_lookup_section_flags
507 (struct bfd_link_info
*, struct flag_info
*, asection
*) ATTRIBUTE_HIDDEN
;
508 #define _bfd_nolink_bfd_merge_sections _bfd_bool_bfd_link_false_error
509 extern bool _bfd_nolink_bfd_is_group_section
510 (bfd
*, const asection
*) ATTRIBUTE_HIDDEN
;
511 extern const char *_bfd_nolink_bfd_group_name
512 (bfd
*, const asection
*) ATTRIBUTE_HIDDEN
;
513 extern bool _bfd_nolink_bfd_discard_group
514 (bfd
*, asection
*) ATTRIBUTE_HIDDEN
;
515 extern struct bfd_link_hash_table
*_bfd_nolink_bfd_link_hash_table_create
516 (bfd
*) ATTRIBUTE_HIDDEN
;
517 #define _bfd_nolink_bfd_link_add_symbols _bfd_bool_bfd_link_false_error
518 extern void _bfd_nolink_bfd_link_just_syms
519 (asection
*, struct bfd_link_info
*) ATTRIBUTE_HIDDEN
;
520 extern void _bfd_nolink_bfd_copy_link_hash_symbol_type
521 (bfd
*, struct bfd_link_hash_entry
*, struct bfd_link_hash_entry
*)
523 #define _bfd_nolink_bfd_final_link _bfd_bool_bfd_link_false_error
524 extern bool _bfd_nolink_bfd_link_split_section
525 (bfd
*, struct bfd_section
*) ATTRIBUTE_HIDDEN
;
526 extern bool _bfd_nolink_section_already_linked
527 (bfd
*, asection
*, struct bfd_link_info
*) ATTRIBUTE_HIDDEN
;
528 extern bool _bfd_nolink_bfd_define_common_symbol
529 (bfd
*, struct bfd_link_info
*, struct bfd_link_hash_entry
*)
531 #define _bfd_nolink_bfd_link_hide_symbol \
532 _bfd_generic_link_hide_symbol
533 extern struct bfd_link_hash_entry
*_bfd_nolink_bfd_define_start_stop
534 (struct bfd_link_info
*, const char *, asection
*) ATTRIBUTE_HIDDEN
;
535 #define _bfd_nolink_bfd_link_check_relocs \
536 _bfd_generic_link_check_relocs
538 /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
539 have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
542 #define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_long_bfd_n1_error
543 #define _bfd_nodynamic_canonicalize_dynamic_symtab \
544 _bfd_nosymbols_canonicalize_symtab
545 extern long _bfd_nodynamic_get_synthetic_symtab
546 (bfd
*, long, asymbol
**, long, asymbol
**, asymbol
**) ATTRIBUTE_HIDDEN
;
547 #define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_long_bfd_n1_error
548 extern long _bfd_nodynamic_canonicalize_dynamic_reloc
549 (bfd
*, arelent
**, asymbol
**) ATTRIBUTE_HIDDEN
;
551 /* Generic routine to determine of the given symbol is a local
553 extern bool bfd_generic_is_local_label_name
554 (bfd
*, const char *) ATTRIBUTE_HIDDEN
;
556 /* Generic minisymbol routines. */
557 extern long _bfd_generic_read_minisymbols
558 (bfd
*, bool, void **, unsigned int *) ATTRIBUTE_HIDDEN
;
559 extern asymbol
*_bfd_generic_minisymbol_to_symbol
560 (bfd
*, bool, const void *, asymbol
*) ATTRIBUTE_HIDDEN
;
562 /* Find the nearest line using .stab/.stabstr sections. */
563 extern bool _bfd_stab_section_find_nearest_line
564 (bfd
*, asymbol
**, asection
*, bfd_vma
, bool *,
565 const char **, const char **, unsigned int *, void **) ATTRIBUTE_HIDDEN
;
567 /* Find the nearest line using DWARF 1 debugging information. */
568 extern bool _bfd_dwarf1_find_nearest_line
569 (bfd
*, asymbol
**, asection
*, bfd_vma
,
570 const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN
;
572 struct dwarf_debug_section
574 const char * uncompressed_name
;
575 const char * compressed_name
;
578 /* Map of uncompressed DWARF debug section name to compressed one. It
579 is terminated by NULL uncompressed_name. */
581 extern const struct dwarf_debug_section dwarf_debug_sections
[] ATTRIBUTE_HIDDEN
;
583 /* Find the nearest line using DWARF 2 debugging information. */
584 extern int _bfd_dwarf2_find_nearest_line
585 (bfd
*, asymbol
**, asymbol
*, asection
*, bfd_vma
,
586 const char **, const char **, unsigned int *, unsigned int *,
587 const struct dwarf_debug_section
*, void **) ATTRIBUTE_HIDDEN
;
589 /* Find the bias between DWARF addresses and real addresses. */
590 extern bfd_signed_vma _bfd_dwarf2_find_symbol_bias
591 (asymbol
**, void **) ATTRIBUTE_HIDDEN
;
593 /* Find inliner info after calling bfd_find_nearest_line. */
594 extern bool _bfd_dwarf2_find_inliner_info
595 (bfd
*, const char **, const char **, unsigned int *, void **)
598 /* Read DWARF 2 debugging information. */
599 extern bool _bfd_dwarf2_slurp_debug_info
600 (bfd
*, bfd
*, const struct dwarf_debug_section
*, asymbol
**, void **,
601 bool) ATTRIBUTE_HIDDEN
;
603 /* Clean up the data used to handle DWARF 2 debugging information. */
604 extern void _bfd_dwarf2_cleanup_debug_info
605 (bfd
*, void **) ATTRIBUTE_HIDDEN
;
607 /* Create a new section entry. */
608 extern struct bfd_hash_entry
*bfd_section_hash_newfunc
609 (struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *)
612 /* A routine to create entries for a bfd_link_hash_table. */
613 extern struct bfd_hash_entry
*_bfd_link_hash_newfunc
614 (struct bfd_hash_entry
*entry
, struct bfd_hash_table
*table
,
615 const char *string
) ATTRIBUTE_HIDDEN
;
617 /* Initialize a bfd_link_hash_table. */
618 extern bool _bfd_link_hash_table_init
619 (struct bfd_link_hash_table
*, bfd
*,
620 struct bfd_hash_entry
*(*) (struct bfd_hash_entry
*,
621 struct bfd_hash_table
*,
623 unsigned int) ATTRIBUTE_HIDDEN
;
625 /* Generic link hash table creation routine. */
626 extern struct bfd_link_hash_table
*_bfd_generic_link_hash_table_create
627 (bfd
*) ATTRIBUTE_HIDDEN
;
629 /* Generic link hash table destruction routine. */
630 extern void _bfd_generic_link_hash_table_free
631 (bfd
*) ATTRIBUTE_HIDDEN
;
633 /* Generic add symbol routine. */
634 extern bool _bfd_generic_link_add_symbols
635 (bfd
*, struct bfd_link_info
*) ATTRIBUTE_HIDDEN
;
637 /* Generic archive add symbol routine. */
638 extern bool _bfd_generic_link_add_archive_symbols
639 (bfd
*, struct bfd_link_info
*,
640 bool (*) (bfd
*, struct bfd_link_info
*,
641 struct bfd_link_hash_entry
*, const char *,
642 bool *)) ATTRIBUTE_HIDDEN
;
644 /* Forward declaration to avoid prototype errors. */
645 typedef struct bfd_link_hash_entry _bfd_link_hash_entry
;
647 /* Generic routine to add a single symbol. */
648 extern bool _bfd_generic_link_add_one_symbol
649 (struct bfd_link_info
*, bfd
*, const char *name
, flagword
,
650 asection
*, bfd_vma
, const char *, bool copy
,
651 bool constructor
, struct bfd_link_hash_entry
**) ATTRIBUTE_HIDDEN
;
653 /* Generic routine to mark section as supplying symbols only. */
654 extern void _bfd_generic_link_just_syms
655 (asection
*, struct bfd_link_info
*) ATTRIBUTE_HIDDEN
;
657 /* Generic routine that does nothing. */
658 extern void _bfd_generic_copy_link_hash_symbol_type
659 (bfd
*, struct bfd_link_hash_entry
*, struct bfd_link_hash_entry
*)
662 /* Generic link routine. */
663 extern bool _bfd_generic_final_link
664 (bfd
*, struct bfd_link_info
*) ATTRIBUTE_HIDDEN
;
666 extern bool _bfd_generic_link_split_section
667 (bfd
*, struct bfd_section
*) ATTRIBUTE_HIDDEN
;
669 extern bool _bfd_generic_section_already_linked
670 (bfd
*, asection
*, struct bfd_link_info
*) ATTRIBUTE_HIDDEN
;
672 /* Generic reloc_link_order processing routine. */
673 extern bool _bfd_generic_reloc_link_order
674 (bfd
*, struct bfd_link_info
*, asection
*, struct bfd_link_order
*)
677 /* Default link order processing routine. */
678 extern bool _bfd_default_link_order
679 (bfd
*, struct bfd_link_info
*, asection
*, struct bfd_link_order
*)
682 /* Count the number of reloc entries in a link order list. */
683 extern unsigned int _bfd_count_link_order_relocs
684 (struct bfd_link_order
*) ATTRIBUTE_HIDDEN
;
686 /* Final link relocation routine. */
687 extern bfd_reloc_status_type _bfd_final_link_relocate
688 (reloc_howto_type
*, bfd
*, asection
*, bfd_byte
*,
689 bfd_vma
, bfd_vma
, bfd_vma
) ATTRIBUTE_HIDDEN
;
691 /* Relocate a particular location by a howto and a value. */
692 extern bfd_reloc_status_type _bfd_relocate_contents
693 (reloc_howto_type
*, bfd
*, bfd_vma
, bfd_byte
*) ATTRIBUTE_HIDDEN
;
695 /* Clear a given location using a given howto. */
696 extern bfd_reloc_status_type _bfd_clear_contents
697 (reloc_howto_type
*, bfd
*, asection
*, bfd_byte
*, bfd_vma
) ATTRIBUTE_HIDDEN
;
699 /* Link stabs in sections in the first pass. */
701 extern bool _bfd_link_section_stabs
702 (bfd
*, struct stab_info
*, asection
*, asection
*, void **,
703 bfd_size_type
*) ATTRIBUTE_HIDDEN
;
705 /* Eliminate stabs for discarded functions and symbols. */
706 extern bool _bfd_discard_section_stabs
707 (bfd
*, asection
*, void *, bool (*) (bfd_vma
, void *), void *)
710 /* Write out the .stab section when linking stabs in sections. */
712 extern bool _bfd_write_section_stabs
713 (bfd
*, struct stab_info
*, asection
*, void **, bfd_byte
*)
716 /* Write out the .stabstr string table when linking stabs in sections. */
718 extern bool _bfd_write_stab_strings
719 (bfd
*, struct stab_info
*) ATTRIBUTE_HIDDEN
;
721 /* Find an offset within a .stab section when linking stabs in
724 extern bfd_vma _bfd_stab_section_offset
725 (asection
*, void *, bfd_vma
) ATTRIBUTE_HIDDEN
;
727 /* Register a SEC_MERGE section as a candidate for merging. */
729 extern bool _bfd_add_merge_section
730 (bfd
*, void **, asection
*, void **) ATTRIBUTE_HIDDEN
;
732 /* Attempt to merge SEC_MERGE sections. */
734 extern bool _bfd_merge_sections
735 (bfd
*, struct bfd_link_info
*, void *, void (*) (bfd
*, asection
*))
738 /* Write out a merged section. */
740 extern bool _bfd_write_merged_section
741 (bfd
*, asection
*, void *) ATTRIBUTE_HIDDEN
;
743 /* Find an offset within a modified SEC_MERGE section. */
745 extern bfd_vma _bfd_merged_section_offset
746 (bfd
*, asection
**, void *, bfd_vma
) ATTRIBUTE_HIDDEN
;
748 /* Tidy up when done. */
750 extern void _bfd_merge_sections_free (void *) ATTRIBUTE_HIDDEN
;
752 /* Create a string table. */
753 extern struct bfd_strtab_hash
*_bfd_stringtab_init
754 (void) ATTRIBUTE_HIDDEN
;
756 /* Create an XCOFF .debug section style string table. */
757 extern struct bfd_strtab_hash
*_bfd_xcoff_stringtab_init
758 (bool isxcoff64
) ATTRIBUTE_HIDDEN
;
760 /* Free a string table. */
761 extern void _bfd_stringtab_free
762 (struct bfd_strtab_hash
*) ATTRIBUTE_HIDDEN
;
764 /* Get the size of a string table. */
765 extern bfd_size_type _bfd_stringtab_size
766 (struct bfd_strtab_hash
*) ATTRIBUTE_HIDDEN
;
768 /* Add a string to a string table. */
769 extern bfd_size_type _bfd_stringtab_add
770 (struct bfd_strtab_hash
*, const char *, bool hash
, bool copy
)
773 /* Write out a string table. */
774 extern bool _bfd_stringtab_emit
775 (bfd
*, struct bfd_strtab_hash
*) ATTRIBUTE_HIDDEN
;
777 /* Macros to tell if bfds are read or write enabled.
779 Note that bfds open for read may be scribbled into if the fd passed
780 to bfd_fdopenr is actually open both for read and write
781 simultaneously. However an output bfd will never be open for
782 read. Therefore sometimes you want to check bfd_read_p or
783 !bfd_read_p, and only sometimes bfd_write_p.
786 #define bfd_read_p(abfd) \
787 ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
788 #define bfd_write_p(abfd) \
789 ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
791 extern void bfd_assert
792 (const char*,int) ATTRIBUTE_HIDDEN
;
794 #define BFD_ASSERT(x) \
795 do { if (!(x)) bfd_assert(__FILE__,__LINE__); } while (0)
798 do { bfd_assert(__FILE__,__LINE__); } while (0)
800 extern void _bfd_abort
801 (const char *, int, const char *) ATTRIBUTE_NORETURN ATTRIBUTE_HIDDEN
;
803 /* if gcc >= 2.6, we can give a function name, too */
804 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
805 #define __PRETTY_FUNCTION__ ((char *) NULL)
809 #define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
811 /* Manipulate a system FILE but using BFD's "file_ptr", rather than
812 the system "off_t" or "off64_t", as the offset. */
813 extern file_ptr _bfd_real_ftell
814 (FILE *) ATTRIBUTE_HIDDEN
;
815 extern int _bfd_real_fseek
816 (FILE *, file_ptr
, int) ATTRIBUTE_HIDDEN
;
817 extern FILE *_bfd_real_fopen
818 (const char *, const char *) ATTRIBUTE_HIDDEN
;
820 /* List of supported target vectors, and the default vector (if
821 bfd_default_vector[0] is NULL, there is no default). */
822 extern const bfd_target
*const *const bfd_target_vector ATTRIBUTE_HIDDEN
;
823 extern const bfd_target
*bfd_default_vector
[] ATTRIBUTE_HIDDEN
;
825 /* List of associated target vectors. */
826 extern const bfd_target
*const *const bfd_associated_vector ATTRIBUTE_HIDDEN
;
828 /* Functions shared by the ECOFF and MIPS ELF backends, which have no
829 other common header files. */
831 #if defined(__STDC__) || defined(ALMOST_STDC)
832 struct ecoff_find_line
;
835 extern bool _bfd_ecoff_locate_line
836 (bfd
*, asection
*, bfd_vma
, struct ecoff_debug_info
* const,
837 const struct ecoff_debug_swap
* const, struct ecoff_find_line
*,
838 const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN
;
839 extern bool _bfd_ecoff_get_accumulated_pdr
840 (void *, bfd_byte
*) ATTRIBUTE_HIDDEN
;
841 extern bool _bfd_ecoff_get_accumulated_sym
842 (void *, bfd_byte
*) ATTRIBUTE_HIDDEN
;
843 extern bool _bfd_ecoff_get_accumulated_ss
844 (void *, bfd_byte
*) ATTRIBUTE_HIDDEN
;
846 extern bfd_vma _bfd_get_gp_value
847 (bfd
*) ATTRIBUTE_HIDDEN
;
848 extern void _bfd_set_gp_value
849 (bfd
*, bfd_vma
) ATTRIBUTE_HIDDEN
;
851 /* Function shared by the COFF and ELF SH backends, which have no
852 other common header files. */
854 #ifndef _bfd_sh_align_load_span
855 extern bool _bfd_sh_align_load_span
856 (bfd
*, asection
*, bfd_byte
*,
857 bool (*) (bfd
*, asection
*, void *, bfd_byte
*, bfd_vma
),
858 void *, bfd_vma
**, bfd_vma
*, bfd_vma
, bfd_vma
, bool *) ATTRIBUTE_HIDDEN
;
861 /* This is the shape of the elements inside the already_linked hash
862 table. It maps a name onto a list of already_linked elements with
865 struct bfd_section_already_linked_hash_entry
867 struct bfd_hash_entry root
;
868 struct bfd_section_already_linked
*entry
;
871 struct bfd_section_already_linked
873 struct bfd_section_already_linked
*next
;
877 extern struct bfd_section_already_linked_hash_entry
*
878 bfd_section_already_linked_table_lookup (const char *) ATTRIBUTE_HIDDEN
;
879 extern bool bfd_section_already_linked_table_insert
880 (struct bfd_section_already_linked_hash_entry
*, asection
*)
882 extern void bfd_section_already_linked_table_traverse
883 (bool (*) (struct bfd_section_already_linked_hash_entry
*,
884 void *), void *) ATTRIBUTE_HIDDEN
;
886 extern bfd_vma _bfd_read_unsigned_leb128
887 (bfd
*, bfd_byte
*, unsigned int *) ATTRIBUTE_HIDDEN
;
888 extern bfd_signed_vma _bfd_read_signed_leb128
889 (bfd
*, bfd_byte
*, unsigned int *) ATTRIBUTE_HIDDEN
;
890 extern bfd_vma _bfd_safe_read_leb128
891 (bfd
*, bfd_byte
**, bool, const bfd_byte
* const) ATTRIBUTE_HIDDEN
;
892 extern bfd_byte
* _bfd_write_unsigned_leb128
893 (bfd_byte
*, bfd_byte
*, bfd_vma
) ATTRIBUTE_HIDDEN
;
895 extern struct bfd_link_info
*_bfd_get_link_info (bfd
*);
897 #if GCC_VERSION >= 7000
898 #define _bfd_mul_overflow(a, b, res) __builtin_mul_overflow (a, b, res)
900 /* Assumes unsigned values. Careful! Args evaluated multiple times. */
901 #define _bfd_mul_overflow(a, b, res) \
902 ((*res) = (a), (*res) *= (b), (b) != 0 && (*res) / (b) != (a))
906 #define _bfd_constant_p(v) __builtin_constant_p (v)
908 #define _bfd_constant_p(v) 0
911 static inline bfd_byte
*
912 _bfd_alloc_and_read (bfd
*abfd
, bfd_size_type asize
, bfd_size_type rsize
)
915 if (!_bfd_constant_p (rsize
))
917 ufile_ptr filesize
= bfd_get_file_size (abfd
);
918 if (filesize
!= 0 && rsize
> filesize
)
920 bfd_set_error (bfd_error_file_truncated
);
924 mem
= bfd_alloc (abfd
, asize
);
927 if (bfd_bread (mem
, rsize
, abfd
) == rsize
)
929 bfd_release (abfd
, mem
);
934 static inline bfd_byte
*
935 _bfd_malloc_and_read (bfd
*abfd
, bfd_size_type asize
, bfd_size_type rsize
)
938 if (!_bfd_constant_p (rsize
))
940 ufile_ptr filesize
= bfd_get_file_size (abfd
);
941 if (filesize
!= 0 && rsize
> filesize
)
943 bfd_set_error (bfd_error_file_truncated
);
947 mem
= bfd_malloc (asize
);
950 if (bfd_bread (mem
, rsize
, abfd
) == rsize
)