PR22458, failure to choose a matching ELF target
[deliverable/binutils-gdb.git] / bfd / libbfd-in.h
CommitLineData
252b5132
RH
1/* libbfd.h -- Declarations used by bfd library *implementation*.
2 (This include file is not for users of the library.)
7c192733 3
219d1afa 4 Copyright (C) 1990-2018 Free Software Foundation, Inc.
7c192733 5
252b5132
RH
6 Written by Cygnus Support.
7
cd123cb7
NC
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. */
252b5132 24
109f7096
BE
25#include "hashtab.h"
26
55172d69
PA
27#ifdef __cplusplus
28extern "C" {
29#endif
30
252b5132
RH
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. */
c58b9523 37#define set_tdata(bfd, v) ((bfd)->tdata.any = (v))
252b5132
RH
38
39/* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points
40 to an instance of this structure. */
41
42struct 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
66eb6687
AM
50struct section_hash_entry
51{
52 struct bfd_hash_entry root;
53 asection section;
54};
55
7cf7fcc8
AM
56/* Unique section id. */
57extern unsigned int _bfd_section_id;
58
252b5132
RH
59/* tdata for an archive. For an input archive, cache
60 needs to be free()'d. For an output archive, symdefs do. */
61
f1bb16f8
NC
62struct artdata
63{
252b5132
RH
64 file_ptr first_file_filepos;
65 /* Speed up searching the armap */
109f7096 66 htab_t cache;
f1bb16f8
NC
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. */
252b5132
RH
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. */
c58b9523 81 void *tdata; /* Backend specific information. */
252b5132
RH
82};
83
84#define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
85
86/* Goes in bfd's arelt_data slot */
f1bb16f8
NC
87struct 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. */
eeb1f9ae
AM
94 void *parent_cache; /* Where and how to find this member. */
95 file_ptr key;
252b5132
RH
96};
97
98#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
99
c58b9523
AM
100extern void *bfd_malloc
101 (bfd_size_type);
102extern void *bfd_realloc
103 (void *, bfd_size_type);
515ef31d
NC
104extern void *bfd_realloc_or_free
105 (void *, bfd_size_type);
c58b9523
AM
106extern void *bfd_zmalloc
107 (bfd_size_type);
d0fb9a8d
JJ
108extern void *bfd_malloc2
109 (bfd_size_type, bfd_size_type);
110extern void *bfd_realloc2
111 (void *, bfd_size_type, bfd_size_type);
112extern void *bfd_zmalloc2
113 (bfd_size_type, bfd_size_type);
252b5132 114
f2b740ac 115extern void _bfd_error_handler (const char *s, ...) ATTRIBUTE_PRINTF_1;
252b5132
RH
116
117/* These routines allocate and free things on the BFD's objalloc. */
118
d0fb9a8d
JJ
119extern void *bfd_alloc2
120 (bfd *, bfd_size_type, bfd_size_type);
121extern void *bfd_zalloc2
122 (bfd *, bfd_size_type, bfd_size_type);
b34976b6 123extern void bfd_release
c58b9523 124 (bfd *, void *);
b34976b6
AM
125
126bfd * _bfd_create_empty_archive_element_shell
68d20676 127 (bfd *);
b34976b6 128bfd * _bfd_look_for_bfd_in_cache
c58b9523 129 (bfd *, file_ptr);
b34976b6 130bfd_boolean _bfd_add_bfd_to_archive_cache
c58b9523 131 (bfd *, file_ptr, bfd *);
b34976b6 132bfd_boolean _bfd_generic_mkarchive
68d20676 133 (bfd *);
4b544b64 134char *_bfd_append_relative_path
68d20676 135 (bfd *, char *);
b34976b6 136const bfd_target *bfd_generic_archive_p
68d20676 137 (bfd *);
b34976b6 138bfd_boolean bfd_slurp_armap
68d20676 139 (bfd *);
252b5132
RH
140#define bfd_slurp_bsd_armap bfd_slurp_armap
141#define bfd_slurp_coff_armap bfd_slurp_armap
e6cc316a
L
142bfd_boolean _bfd_archive_64_bit_slurp_armap
143 (bfd *);
144bfd_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
d00dd7dc 162#define _bfd_archive_64_bit_update_armap_timestamp _bfd_bool_bfd_true
e6cc316a 163
b34976b6 164bfd_boolean _bfd_slurp_extended_name_table
68d20676 165 (bfd *);
b34976b6 166extern bfd_boolean _bfd_construct_extended_name_table
c58b9523 167 (bfd *, bfd_boolean, char **, bfd_size_type *);
b34976b6 168bfd_boolean _bfd_write_archive_contents
68d20676 169 (bfd *);
b34976b6 170bfd_boolean _bfd_compute_and_write_armap
68d20676 171 (bfd *, unsigned int);
b34976b6 172bfd *_bfd_get_elt_at_filepos
68d20676 173 (bfd *, file_ptr);
b34976b6 174extern bfd *_bfd_generic_get_elt_at_index
c58b9523 175 (bfd *, symindex);
b34976b6 176bfd * _bfd_new_bfd
c58b9523 177 (void);
b25e3d87
L
178bfd_boolean _bfd_free_cached_info
179 (bfd *);
b34976b6 180
d00dd7dc 181extern bfd_boolean _bfd_bool_bfd_false
68d20676 182 (bfd *);
d00dd7dc
AM
183extern bfd_boolean _bfd_bool_bfd_asymbol_false
184 (bfd *, asymbol *);
185extern bfd_boolean _bfd_bool_bfd_false_error
68d20676 186 (bfd *);
d00dd7dc
AM
187extern bfd_boolean _bfd_bool_bfd_link_false_error
188 (bfd *, struct bfd_link_info *);
189extern bfd_boolean _bfd_bool_bfd_true
68d20676 190 (bfd *);
d00dd7dc
AM
191extern bfd_boolean _bfd_bool_bfd_link_true
192 (bfd *, struct bfd_link_info *);
193extern bfd_boolean _bfd_bool_bfd_bfd_true
194 (bfd *, bfd *);
195extern bfd_boolean _bfd_bool_bfd_uint_true
196 (bfd *, unsigned int);
197extern bfd_boolean _bfd_bool_bfd_asection_bfd_asection_true
198 (bfd *, asection *, bfd *, asection *);
199extern bfd_boolean _bfd_bool_bfd_asymbol_bfd_asymbol_true
200 (bfd *, asymbol *, bfd *, asymbol *);
201extern bfd_boolean _bfd_bool_bfd_ptr_true
202 (bfd *, void *);
203extern void *_bfd_ptr_bfd_null_error
204 (bfd *);
205extern int _bfd_int_bfd_0
68d20676 206 (bfd *);
d00dd7dc 207extern unsigned int _bfd_uint_bfd_0
68d20676 208 (bfd *);
d00dd7dc 209extern long _bfd_long_bfd_0
68d20676 210 (bfd *);
d00dd7dc 211extern long _bfd_long_bfd_n1_error
68d20676 212 (bfd *);
d00dd7dc 213extern void _bfd_void_bfd
68d20676 214 (bfd *);
d00dd7dc
AM
215extern void _bfd_void_bfd_link
216 (bfd *, struct bfd_link_info *);
217extern void _bfd_void_bfd_asection
218 (bfd *, asection *);
b34976b6
AM
219
220bfd *_bfd_new_bfd_contained_in
c58b9523 221 (bfd *);
b34976b6 222const bfd_target *_bfd_dummy_target
68d20676 223 (bfd *);
b34976b6
AM
224
225void bfd_dont_truncate_arname
68d20676 226 (bfd *, const char *, char *);
b34976b6 227void bfd_bsd_truncate_arname
68d20676 228 (bfd *, const char *, char *);
b34976b6 229void bfd_gnu_truncate_arname
68d20676 230 (bfd *, const char *, char *);
b34976b6 231
7ec22e0f 232bfd_boolean _bfd_bsd_write_armap
68d20676 233 (bfd *, unsigned int, struct orl *, unsigned int, int);
b34976b6 234
7ec22e0f 235bfd_boolean _bfd_coff_write_armap
68d20676 236 (bfd *, unsigned int, struct orl *, unsigned int, int);
b34976b6 237
c58b9523
AM
238extern void *_bfd_generic_read_ar_hdr
239 (bfd *);
390c0e42
JJ
240extern void _bfd_ar_spacepad
241 (char *, size_t, const char *, long);
f1bb16f8
NC
242extern bfd_boolean _bfd_ar_sizepad
243 (char *, size_t, bfd_size_type);
b34976b6 244
c58b9523
AM
245extern void *_bfd_generic_read_ar_hdr_mag
246 (bfd *, const char *);
b34976b6 247
8f95b6e4
TG
248extern bfd_boolean _bfd_generic_write_ar_hdr
249 (bfd *, bfd *);
250
251extern bfd_boolean _bfd_bsd44_write_ar_hdr
252 (bfd *, bfd *);
253
b34976b6 254bfd * bfd_generic_openr_next_archived_file
68d20676 255 (bfd *, bfd *);
b34976b6
AM
256
257int bfd_generic_stat_arch_elt
c58b9523 258 (bfd *, struct stat *);
252b5132
RH
259
260#define _bfd_read_ar_hdr(abfd) \
07d6d2b8
AM
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))
252b5132
RH
264\f
265/* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
266 BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
267
eeb1f9ae
AM
268#define _bfd_generic_close_and_cleanup _bfd_archive_close_and_cleanup
269extern bfd_boolean _bfd_archive_close_and_cleanup
270 (bfd *);
d00dd7dc 271#define _bfd_generic_bfd_free_cached_info _bfd_bool_bfd_true
f592407e
AM
272extern bfd_boolean _bfd_generic_new_section_hook
273 (bfd *, asection *);
b34976b6 274extern bfd_boolean _bfd_generic_get_section_contents
c58b9523 275 (bfd *, asection *, void *, file_ptr, bfd_size_type);
b34976b6 276extern bfd_boolean _bfd_generic_get_section_contents_in_window
c58b9523 277 (bfd *, asection *, bfd_window *, file_ptr, bfd_size_type);
252b5132
RH
278
279/* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
280 BFD_JUMP_TABLE_COPY (_bfd_generic). */
281
d00dd7dc 282#define _bfd_generic_bfd_copy_private_bfd_data _bfd_bool_bfd_bfd_true
252b5132 283#define _bfd_generic_bfd_merge_private_bfd_data \
d00dd7dc
AM
284 _bfd_bool_bfd_link_true
285#define _bfd_generic_bfd_set_private_flags _bfd_bool_bfd_uint_true
252b5132 286#define _bfd_generic_bfd_copy_private_section_data \
d00dd7dc 287 _bfd_bool_bfd_asection_bfd_asection_true
252b5132 288#define _bfd_generic_bfd_copy_private_symbol_data \
d00dd7dc
AM
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
252b5132 292
ccd2ec6a
L
293extern bfd_boolean _bfd_generic_init_private_section_data
294 (bfd *, asection *, bfd *, asection *, struct bfd_link_info *);
295
252b5132
RH
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
b34976b6 299extern char *_bfd_nocore_core_file_failing_command
c58b9523 300 (bfd *);
b34976b6 301extern int _bfd_nocore_core_file_failing_signal
c58b9523 302 (bfd *);
b34976b6 303extern bfd_boolean _bfd_nocore_core_file_matches_executable_p
c58b9523 304 (bfd *, bfd *);
261b8d08
PA
305extern int _bfd_nocore_core_file_pid
306 (bfd *);
252b5132
RH
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
d00dd7dc
AM
311#define _bfd_noarchive_slurp_armap _bfd_bool_bfd_false_error
312#define _bfd_noarchive_slurp_extended_name_table _bfd_bool_bfd_false_error
313extern bfd_boolean _bfd_noarchive_construct_extended_name_table
314 (bfd *, char **, bfd_size_type *, const char **);
315extern void _bfd_noarchive_truncate_arname
316 (bfd *, const char *, char *);
317extern 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
320extern bfd_boolean _bfd_noarchive_write_ar_hdr
321 (bfd *, bfd *);
322extern bfd *
323_bfd_noarchive_openr_next_archived_file
324 (bfd *, bfd *);
325extern bfd * _bfd_noarchive_get_elt_at_index
326 (bfd *, symindex);
252b5132 327#define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
d00dd7dc 328#define _bfd_noarchive_update_armap_timestamp _bfd_bool_bfd_false_error
252b5132
RH
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
b34976b6 336extern bfd_boolean _bfd_archive_bsd_construct_extended_name_table
c58b9523 337 (bfd *, char **, bfd_size_type *, const char **);
252b5132 338#define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
7ec22e0f 339#define _bfd_archive_bsd_write_armap _bfd_bsd_write_armap
252b5132 340#define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
8f95b6e4 341#define _bfd_archive_bsd_write_ar_hdr _bfd_generic_write_ar_hdr
252b5132
RH
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
b34976b6 347extern bfd_boolean _bfd_archive_bsd_update_armap_timestamp
c58b9523 348 (bfd *);
252b5132
RH
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
b34976b6 356extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
c58b9523 357 (bfd *, char **, bfd_size_type *, const char **);
252b5132 358#define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
7ec22e0f 359#define _bfd_archive_coff_write_armap _bfd_coff_write_armap
252b5132 360#define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
8f95b6e4 361#define _bfd_archive_coff_write_ar_hdr _bfd_generic_write_ar_hdr
252b5132
RH
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
d00dd7dc 367#define _bfd_archive_coff_update_armap_timestamp _bfd_bool_bfd_true
252b5132 368
8f95b6e4
TG
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
375extern 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
7ec22e0f 378#define _bfd_archive_bsd44_write_armap _bfd_bsd_write_armap
8f95b6e4
TG
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
4b544b64
TG
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
f0d19df9 391 are irrelevant. */
4b544b64 392
68d20676 393extern bfd_boolean _bfd_vms_lib_write_archive_contents (bfd *);
f0d19df9
AM
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
4b544b64
TG
403extern bfd *_bfd_vms_lib_openr_next_archived_file (bfd *, bfd *);
404extern bfd *_bfd_vms_lib_get_elt_at_index (bfd *, symindex);
405extern int _bfd_vms_lib_generic_stat_arch_elt (bfd *, struct stat *);
d00dd7dc 406#define _bfd_vms_lib_update_armap_timestamp _bfd_bool_bfd_true
4b544b64
TG
407
408/* Extra routines for VMS style archives. */
409
410extern symindex _bfd_vms_lib_find_symbol (bfd *, const char *);
411extern bfd *_bfd_vms_lib_get_imagelib_file (bfd *);
68d20676
NC
412extern const bfd_target *_bfd_vms_lib_alpha_archive_p (bfd *);
413extern const bfd_target *_bfd_vms_lib_ia64_archive_p (bfd *);
414extern bfd_boolean _bfd_vms_lib_alpha_mkarchive (bfd *);
415extern bfd_boolean _bfd_vms_lib_ia64_mkarchive (bfd *);
4b544b64 416
252b5132
RH
417/* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
418 support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
419
d00dd7dc
AM
420#define _bfd_nosymbols_get_symtab_upper_bound _bfd_long_bfd_n1_error
421extern long _bfd_nosymbols_canonicalize_symtab
422 (bfd *, asymbol **);
3f3c5c34 423#define _bfd_nosymbols_make_empty_symbol _bfd_generic_make_empty_symbol
d00dd7dc
AM
424extern void _bfd_nosymbols_print_symbol
425 (bfd *, void *, asymbol *, bfd_print_symbol_type);
426extern void _bfd_nosymbols_get_symbol_info
427 (bfd *, asymbol *, symbol_info *);
428extern const char * _bfd_nosymbols_get_symbol_version_string
429 (bfd *, asymbol *, bfd_boolean *);
430extern 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
433extern alent *_bfd_nosymbols_get_lineno
434 (bfd *, asymbol *);
435extern bfd_boolean _bfd_nosymbols_find_nearest_line
436 (bfd *, asymbol **, asection *, bfd_vma,
437 const char **, const char **, unsigned int *, unsigned int *);
438extern bfd_boolean _bfd_nosymbols_find_line
439 (bfd *, asymbol **, asymbol *, const char **, unsigned int *);
440extern bfd_boolean _bfd_nosymbols_find_inliner_info
441 (bfd *, const char **, const char **, unsigned int *);
442extern asymbol *_bfd_nosymbols_bfd_make_debug_symbol
443 (bfd *, void *, unsigned long);
444extern long _bfd_nosymbols_read_minisymbols
445 (bfd *, bfd_boolean, void **, unsigned int *);
446extern asymbol *_bfd_nosymbols_minisymbol_to_symbol
447 (bfd *, bfd_boolean, const void *, asymbol *);
252b5132
RH
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
72f6ea61
AM
452extern long _bfd_norelocs_get_reloc_upper_bound (bfd *, asection *);
453extern long _bfd_norelocs_canonicalize_reloc (bfd *, asection *,
454 arelent **, asymbol **);
23186865 455extern void _bfd_norelocs_set_reloc (bfd *, asection *,
07d6d2b8 456 arelent **, unsigned int);
d00dd7dc
AM
457extern reloc_howto_type *_bfd_norelocs_bfd_reloc_type_lookup
458 (bfd *, bfd_reloc_code_real_type);
459extern reloc_howto_type *_bfd_norelocs_bfd_reloc_name_lookup
460 (bfd *, const char *);
252b5132
RH
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
d00dd7dc
AM
465extern bfd_boolean _bfd_nowrite_set_arch_mach
466 (bfd *, enum bfd_architecture, unsigned long);
467extern bfd_boolean _bfd_nowrite_set_section_contents
468 (bfd *, asection *, const void *, file_ptr, bfd_size_type);
252b5132
RH
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
b34976b6 474extern bfd_boolean _bfd_generic_set_section_contents
0f867abe 475 (bfd *, asection *, const void *, file_ptr, bfd_size_type);
252b5132
RH
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
d00dd7dc
AM
480extern int _bfd_nolink_sizeof_headers
481 (bfd *, struct bfd_link_info *);
482extern 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 **);
485extern 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
488extern 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
491extern bfd_boolean _bfd_nolink_bfd_is_group_section
492 (bfd *, const asection *);
493extern bfd_boolean _bfd_nolink_bfd_discard_group
494 (bfd *, asection *);
495extern 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
498extern void _bfd_nolink_bfd_link_just_syms
499 (asection *, struct bfd_link_info *);
500extern 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
503extern bfd_boolean _bfd_nolink_bfd_link_split_section
504 (bfd *, struct bfd_section *);
505extern bfd_boolean _bfd_nolink_section_already_linked
506 (bfd *, asection *, struct bfd_link_info *);
507extern bfd_boolean _bfd_nolink_bfd_define_common_symbol
508 (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
509extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop
510 (struct bfd_link_info *, const char *, asection *);
4f3b23b3
NC
511#define _bfd_nolink_bfd_link_check_relocs \
512 _bfd_generic_link_check_relocs
252b5132
RH
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
d00dd7dc 518#define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_long_bfd_n1_error
252b5132 519#define _bfd_nodynamic_canonicalize_dynamic_symtab \
d00dd7dc
AM
520 _bfd_nosymbols_canonicalize_symtab
521extern 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
524extern long _bfd_nodynamic_canonicalize_dynamic_reloc
525 (bfd *, arelent **, asymbol **);
252b5132
RH
526\f
527/* Generic routine to determine of the given symbol is a local
528 label. */
b34976b6 529extern bfd_boolean bfd_generic_is_local_label_name
c58b9523 530 (bfd *, const char *);
252b5132
RH
531
532/* Generic minisymbol routines. */
533extern long _bfd_generic_read_minisymbols
c58b9523 534 (bfd *, bfd_boolean, void **, unsigned int *);
252b5132 535extern asymbol *_bfd_generic_minisymbol_to_symbol
c58b9523 536 (bfd *, bfd_boolean, const void *, asymbol *);
252b5132
RH
537
538/* Find the nearest line using .stab/.stabstr sections. */
b34976b6 539extern bfd_boolean _bfd_stab_section_find_nearest_line
c58b9523
AM
540 (bfd *, asymbol **, asection *, bfd_vma, bfd_boolean *,
541 const char **, const char **, unsigned int *, void **);
252b5132 542
2db3311b 543/* Find the nearest line using DWARF 1 debugging information. */
b34976b6 544extern bfd_boolean _bfd_dwarf1_find_nearest_line
fb167eb2
AM
545 (bfd *, asymbol **, asection *, bfd_vma,
546 const char **, const char **, unsigned int *);
252b5132 547
fc28f9aa
TG
548struct dwarf_debug_section
549{
68d20676
NC
550 const char * uncompressed_name;
551 const char * compressed_name;
fc28f9aa
TG
552};
553
554/* Map of uncompressed DWARF debug section name to compressed one. It
555 is terminated by NULL uncompressed_name. */
556
557extern const struct dwarf_debug_section dwarf_debug_sections[];
558
252b5132 559/* Find the nearest line using DWARF 2 debugging information. */
b34976b6 560extern bfd_boolean _bfd_dwarf2_find_nearest_line
fb167eb2
AM
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 **);
9b8d1a36 564
425bd9e1
NC
565/* Find the bias between DWARF addresses and real addresses. */
566extern bfd_signed_vma _bfd_dwarf2_find_symbol_bias
567 (asymbol **, void **);
1b786873 568
4ab527b0
FF
569/* Find inliner info after calling bfd_find_nearest_line. */
570extern bfd_boolean _bfd_dwarf2_find_inliner_info
571 (bfd *, const char **, const char **, unsigned int *, void **);
d9071b0c 572
2ca7691a
TG
573/* Read DWARF 2 debugging information. */
574extern bfd_boolean _bfd_dwarf2_slurp_debug_info
93ee1e36
AM
575 (bfd *, bfd *, const struct dwarf_debug_section *, asymbol **, void **,
576 bfd_boolean);
2ca7691a 577
d9071b0c
TG
578/* Clean up the data used to handle DWARF 2 debugging information. */
579extern void _bfd_dwarf2_cleanup_debug_info
580 (bfd *, void **);
581
73e87d70
AM
582/* Create a new section entry. */
583extern struct bfd_hash_entry *bfd_section_hash_newfunc
c58b9523 584 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
73e87d70 585
252b5132
RH
586/* A routine to create entries for a bfd_link_hash_table. */
587extern struct bfd_hash_entry *_bfd_link_hash_newfunc
c58b9523
AM
588 (struct bfd_hash_entry *entry, struct bfd_hash_table *table,
589 const char *string);
252b5132
RH
590
591/* Initialize a bfd_link_hash_table. */
b34976b6 592extern bfd_boolean _bfd_link_hash_table_init
c58b9523
AM
593 (struct bfd_link_hash_table *, bfd *,
594 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
595 struct bfd_hash_table *,
66eb6687
AM
596 const char *),
597 unsigned int);
252b5132
RH
598
599/* Generic link hash table creation routine. */
600extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
c58b9523 601 (bfd *);
252b5132 602
e2d34d7d
DJ
603/* Generic link hash table destruction routine. */
604extern void _bfd_generic_link_hash_table_free
d495ab0d 605 (bfd *);
e2d34d7d 606
252b5132 607/* Generic add symbol routine. */
b34976b6 608extern bfd_boolean _bfd_generic_link_add_symbols
c58b9523 609 (bfd *, struct bfd_link_info *);
252b5132 610
252b5132 611/* Generic archive add symbol routine. */
b34976b6 612extern bfd_boolean _bfd_generic_link_add_archive_symbols
c58b9523 613 (bfd *, struct bfd_link_info *,
13e570f8
AM
614 bfd_boolean (*) (bfd *, struct bfd_link_info *,
615 struct bfd_link_hash_entry *, const char *,
616 bfd_boolean *));
252b5132 617
252b5132
RH
618/* Forward declaration to avoid prototype errors. */
619typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
620
621/* Generic routine to add a single symbol. */
b34976b6 622extern bfd_boolean _bfd_generic_link_add_one_symbol
c58b9523
AM
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 **);
252b5132 626
2d653fc7
AM
627/* Generic routine to mark section as supplying symbols only. */
628extern void _bfd_generic_link_just_syms
c58b9523 629 (asection *, struct bfd_link_info *);
2d653fc7 630
1338dd10
PB
631/* Generic routine that does nothing. */
632extern void _bfd_generic_copy_link_hash_symbol_type
633 (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *);
634
252b5132 635/* Generic link routine. */
b34976b6 636extern bfd_boolean _bfd_generic_final_link
c58b9523 637 (bfd *, struct bfd_link_info *);
252b5132 638
b34976b6 639extern bfd_boolean _bfd_generic_link_split_section
198beae2 640 (bfd *, struct bfd_section *);
252b5132 641
43e1669b 642extern bfd_boolean _bfd_generic_section_already_linked
c77ec726 643 (bfd *, asection *, struct bfd_link_info *);
082b7297 644
252b5132 645/* Generic reloc_link_order processing routine. */
b34976b6 646extern bfd_boolean _bfd_generic_reloc_link_order
c58b9523 647 (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *);
252b5132
RH
648
649/* Default link order processing routine. */
b34976b6 650extern bfd_boolean _bfd_default_link_order
c58b9523 651 (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *);
252b5132
RH
652
653/* Count the number of reloc entries in a link order list. */
654extern unsigned int _bfd_count_link_order_relocs
c58b9523 655 (struct bfd_link_order *);
252b5132
RH
656
657/* Final link relocation routine. */
658extern bfd_reloc_status_type _bfd_final_link_relocate
c58b9523
AM
659 (reloc_howto_type *, bfd *, asection *, bfd_byte *,
660 bfd_vma, bfd_vma, bfd_vma);
252b5132
RH
661
662/* Relocate a particular location by a howto and a value. */
663extern bfd_reloc_status_type _bfd_relocate_contents
c58b9523 664 (reloc_howto_type *, bfd *, bfd_vma, bfd_byte *);
252b5132 665
b1e24c02
DJ
666/* Clear a given location using a given howto. */
667extern void _bfd_clear_contents (reloc_howto_type *howto, bfd *input_bfd,
e4067dbb 668 asection *input_section, bfd_byte *location);
b1e24c02 669
252b5132
RH
670/* Link stabs in sections in the first pass. */
671
b34976b6 672extern bfd_boolean _bfd_link_section_stabs
3722b82f
AM
673 (bfd *, struct stab_info *, asection *, asection *, void **,
674 bfd_size_type *);
252b5132 675
73d074b4 676/* Eliminate stabs for discarded functions and symbols. */
b34976b6 677extern bfd_boolean _bfd_discard_section_stabs
c58b9523 678 (bfd *, asection *, void *, bfd_boolean (*) (bfd_vma, void *), void *);
73d074b4 679
252b5132
RH
680/* Write out the .stab section when linking stabs in sections. */
681
b34976b6 682extern bfd_boolean _bfd_write_section_stabs
3722b82f 683 (bfd *, struct stab_info *, asection *, void **, bfd_byte *);
252b5132
RH
684
685/* Write out the .stabstr string table when linking stabs in sections. */
686
b34976b6 687extern bfd_boolean _bfd_write_stab_strings
3722b82f 688 (bfd *, struct stab_info *);
252b5132
RH
689
690/* Find an offset within a .stab section when linking stabs in
691 sections. */
692
693extern bfd_vma _bfd_stab_section_offset
eea6121a 694 (asection *, void *, bfd_vma);
252b5132 695
57ceae94 696/* Register a SEC_MERGE section as a candidate for merging. */
f5fa8ca2 697
57ceae94 698extern bfd_boolean _bfd_add_merge_section
c58b9523 699 (bfd *, void **, asection *, void **);
f5fa8ca2 700
8550eb6e
JJ
701/* Attempt to merge SEC_MERGE sections. */
702
b34976b6 703extern bfd_boolean _bfd_merge_sections
57ceae94 704 (bfd *, struct bfd_link_info *, void *, void (*) (bfd *, asection *));
8550eb6e 705
f5fa8ca2
JJ
706/* Write out a merged section. */
707
b34976b6 708extern bfd_boolean _bfd_write_merged_section
c58b9523 709 (bfd *, asection *, void *);
f5fa8ca2
JJ
710
711/* Find an offset within a modified SEC_MERGE section. */
712
713extern bfd_vma _bfd_merged_section_offset
753731ee 714 (bfd *, asection **, void *, bfd_vma);
f5fa8ca2 715
9f7c3e5e
AM
716/* Tidy up when done. */
717
718extern void _bfd_merge_sections_free (void *);
719
252b5132 720/* Create a string table. */
b34976b6 721extern struct bfd_strtab_hash *_bfd_stringtab_init
c58b9523 722 (void);
252b5132
RH
723
724/* Create an XCOFF .debug section style string table. */
b34976b6 725extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init
c58b9523 726 (void);
252b5132
RH
727
728/* Free a string table. */
b34976b6 729extern void _bfd_stringtab_free
c58b9523 730 (struct bfd_strtab_hash *);
252b5132
RH
731
732/* Get the size of a string table. */
b34976b6 733extern bfd_size_type _bfd_stringtab_size
c58b9523 734 (struct bfd_strtab_hash *);
252b5132
RH
735
736/* Add a string to a string table. */
737extern bfd_size_type _bfd_stringtab_add
c58b9523 738 (struct bfd_strtab_hash *, const char *, bfd_boolean hash, bfd_boolean copy);
252b5132
RH
739
740/* Write out a string table. */
b34976b6 741extern bfd_boolean _bfd_stringtab_emit
c58b9523 742 (bfd *, struct bfd_strtab_hash *);
252b5132
RH
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
c58b9523
AM
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)
252b5132 757
b34976b6 758void bfd_assert
c58b9523 759 (const char*,int);
252b5132
RH
760
761#define BFD_ASSERT(x) \
f12123c0 762 do { if (!(x)) bfd_assert(__FILE__,__LINE__); } while (0)
252b5132
RH
763
764#define BFD_FAIL() \
f12123c0 765 do { bfd_assert(__FILE__,__LINE__); } while (0)
252b5132 766
b34976b6 767extern void _bfd_abort
c58b9523 768 (const char *, int, const char *) ATTRIBUTE_NORETURN;
c0bed66d 769
a1934524
AM
770/* if gcc >= 2.6, we can give a function name, too */
771#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
c0bed66d
ILT
772#define __PRETTY_FUNCTION__ ((char *) NULL)
773#endif
774
775#undef abort
776#define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
777
7c192733
AC
778/* Manipulate a system FILE but using BFD's "file_ptr", rather than
779 the system "off_t" or "off64_t", as the offset. */
c7c3d11b
PA
780extern file_ptr _bfd_real_ftell (FILE *file);
781extern int _bfd_real_fseek (FILE *file, file_ptr offset, int whence);
782extern FILE *_bfd_real_fopen (const char *filename, const char *modes);
7c192733 783
252b5132
RH
784/* List of supported target vectors, and the default vector (if
785 bfd_default_vector[0] is NULL, there is no default). */
7340082d 786extern const bfd_target * const *bfd_target_vector;
252b5132
RH
787extern const bfd_target *bfd_default_vector[];
788
08f74004
AM
789/* List of associated target vectors. */
790extern const bfd_target * const *bfd_associated_vector;
791
252b5132
RH
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)
796struct ecoff_find_line;
797#endif
798
b34976b6 799extern bfd_boolean _bfd_ecoff_locate_line
c58b9523
AM
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 *);
b34976b6 803extern bfd_boolean _bfd_ecoff_get_accumulated_pdr
c58b9523 804 (void *, bfd_byte *);
b34976b6 805extern bfd_boolean _bfd_ecoff_get_accumulated_sym
c58b9523 806 (void *, bfd_byte *);
b34976b6 807extern bfd_boolean _bfd_ecoff_get_accumulated_ss
c58b9523 808 (void *, bfd_byte *);
b34976b6
AM
809
810extern bfd_vma _bfd_get_gp_value
c58b9523 811 (bfd *);
b34976b6 812extern void _bfd_set_gp_value
c58b9523 813 (bfd *, bfd_vma);
252b5132
RH
814
815/* Function shared by the COFF and ELF SH backends, which have no
816 other common header files. */
817
c58b9523 818#ifndef _bfd_sh_align_load_span
b34976b6 819extern bfd_boolean _bfd_sh_align_load_span
c58b9523
AM
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
082b7297
L
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
829struct bfd_section_already_linked_hash_entry
830{
831 struct bfd_hash_entry root;
832 struct bfd_section_already_linked *entry;
833};
834
835struct bfd_section_already_linked
836{
837 struct bfd_section_already_linked *next;
c77ec726 838 asection *sec;
082b7297
L
839};
840
841extern struct bfd_section_already_linked_hash_entry *
842 bfd_section_already_linked_table_lookup (const char *);
a6626e8c 843extern bfd_boolean bfd_section_already_linked_table_insert
c77ec726 844 (struct bfd_section_already_linked_hash_entry *, asection *);
3d7f7666
L
845extern void bfd_section_already_linked_table_traverse
846 (bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *,
847 void *), void *);
848
4265548c
PA
849extern bfd_vma _bfd_read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *);
850extern bfd_signed_vma _bfd_read_signed_leb128 (bfd *, bfd_byte *, unsigned int *);
851extern bfd_vma _bfd_safe_read_leb128 (bfd *, bfd_byte *, unsigned int *,
852 bfd_boolean, const bfd_byte * const);
This page took 1.061252 seconds and 4 git commands to generate.