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