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