* opncls.c (bfd_alloc): Rename from bfd_alloc_by_size_t. Remove
[binutils-gdb.git] / bfd / libbfd.h
1 /* libbfd.h -- Declarations used by bfd library *implementation*.
2 (This include file is not for users of the library.)
3 Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
4 Written by Cygnus Support.
5
6 ** NOTE: libbfd.h is a GENERATED file. Don't change it; instead,
7 ** change libbfd-in.h or the other BFD source files processed to
8 ** generate this file.
9
10 This file is part of BFD, the Binary File Descriptor library.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25
26 /* Align an address upward to a boundary, expressed as a number of bytes.
27 E.g. align to an 8-byte boundary with argument of 8. */
28 #define BFD_ALIGN(this, boundary) \
29 ((( (this) + ((boundary) -1)) & (~((boundary)-1))))
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 = (PTR) (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 /* tdata for an archive. For an input archive, cache
51 needs to be free()'d. For an output archive, symdefs do. */
52
53 struct artdata {
54 file_ptr first_file_filepos;
55 /* Speed up searching the armap */
56 struct ar_cache *cache;
57 bfd *archive_head; /* Only interesting in output routines */
58 carsym *symdefs; /* the symdef entries */
59 symindex symdef_count; /* how many there are */
60 char *extended_names; /* clever intel extension */
61 /* when more compilers are standard C, this can be a time_t */
62 long armap_timestamp; /* Timestamp value written into armap.
63 This is used for BSD archives to check
64 that the timestamp is recent enough
65 for the BSD linker to not complain,
66 just before we finish writing an
67 archive. */
68 file_ptr armap_datepos; /* Position within archive to seek to
69 rewrite the date field. */
70 PTR tdata; /* Backend specific information. */
71 };
72
73 #define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
74
75 /* Goes in bfd's arelt_data slot */
76 struct areltdata {
77 char * arch_header; /* it's actually a string */
78 unsigned int parsed_size; /* octets of filesize not including ar_hdr */
79 char *filename; /* null-terminated */
80 };
81
82 #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
83
84 extern PTR bfd_malloc PARAMS ((size_t));
85 extern PTR bfd_realloc PARAMS ((PTR, size_t));
86 extern PTR bfd_zmalloc PARAMS ((size_t));
87
88 extern bfd_error_handler_type _bfd_error_handler;
89
90 /* These routines allocate and free things on the BFD's obstack. */
91
92 PTR bfd_alloc PARAMS ((bfd *abfd, size_t size));
93 PTR bfd_zalloc PARAMS ((bfd *abfd, size_t size));
94 void bfd_alloc_grow PARAMS ((bfd *abfd, PTR thing, size_t size));
95 PTR bfd_alloc_finish PARAMS ((bfd *abfd));
96
97 #define bfd_release(x,y) (void) obstack_free(&(x->memory),y)
98
99 bfd * _bfd_create_empty_archive_element_shell PARAMS ((bfd *obfd));
100 bfd * _bfd_look_for_bfd_in_cache PARAMS ((bfd *arch_bfd, file_ptr index));
101 boolean _bfd_add_bfd_to_archive_cache PARAMS ((bfd *, file_ptr, bfd *));
102 boolean _bfd_generic_mkarchive PARAMS ((bfd *abfd));
103 const bfd_target *bfd_generic_archive_p PARAMS ((bfd *abfd));
104 boolean bfd_slurp_armap PARAMS ((bfd *abfd));
105 boolean bfd_slurp_bsd_armap_f2 PARAMS ((bfd *abfd));
106 #define bfd_slurp_bsd_armap bfd_slurp_armap
107 #define bfd_slurp_coff_armap bfd_slurp_armap
108 boolean _bfd_slurp_extended_name_table PARAMS ((bfd *abfd));
109 extern boolean _bfd_construct_extended_name_table
110 PARAMS ((bfd *, boolean, char **, bfd_size_type *));
111 boolean _bfd_write_archive_contents PARAMS ((bfd *abfd));
112 boolean _bfd_compute_and_write_armap PARAMS ((bfd *, unsigned int elength));
113 bfd *_bfd_get_elt_at_filepos PARAMS ((bfd *archive, file_ptr filepos));
114 extern bfd *_bfd_generic_get_elt_at_index PARAMS ((bfd *, symindex));
115 bfd * _bfd_new_bfd PARAMS ((void));
116
117 boolean bfd_false PARAMS ((bfd *ignore));
118 boolean bfd_true PARAMS ((bfd *ignore));
119 PTR bfd_nullvoidptr PARAMS ((bfd *ignore));
120 int bfd_0 PARAMS ((bfd *ignore));
121 unsigned int bfd_0u PARAMS ((bfd *ignore));
122 long bfd_0l PARAMS ((bfd *ignore));
123 long _bfd_n1 PARAMS ((bfd *ignore));
124 void bfd_void PARAMS ((bfd *ignore));
125
126 bfd *_bfd_new_bfd_contained_in PARAMS ((bfd *));
127 const bfd_target *_bfd_dummy_target PARAMS ((bfd *abfd));
128
129 void bfd_dont_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
130 char *hdr));
131 void bfd_bsd_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
132 char *hdr));
133 void bfd_gnu_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
134 char *hdr));
135
136 boolean bsd_write_armap PARAMS ((bfd *arch, unsigned int elength,
137 struct orl *map, unsigned int orl_count, int stridx));
138
139 boolean coff_write_armap PARAMS ((bfd *arch, unsigned int elength,
140 struct orl *map, unsigned int orl_count, int stridx));
141
142 extern PTR _bfd_generic_read_ar_hdr PARAMS ((bfd *));
143
144 extern PTR _bfd_generic_read_ar_hdr_mag PARAMS ((bfd *, const char *));
145
146 bfd * bfd_generic_openr_next_archived_file PARAMS ((bfd *archive,
147 bfd *last_file));
148
149 int bfd_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
150
151 #define _bfd_read_ar_hdr(abfd) \
152 BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
153 \f
154 /* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
155 BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
156
157 #define _bfd_generic_close_and_cleanup bfd_true
158 #define _bfd_generic_bfd_free_cached_info bfd_true
159 #define _bfd_generic_new_section_hook \
160 ((boolean (*) PARAMS ((bfd *, asection *))) bfd_true)
161 extern boolean _bfd_generic_get_section_contents
162 PARAMS ((bfd *, asection *, PTR location, file_ptr offset,
163 bfd_size_type count));
164 extern boolean _bfd_generic_get_section_contents_in_window
165 PARAMS ((bfd *, asection *, bfd_window *, file_ptr, bfd_size_type));
166
167 /* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
168 BFD_JUMP_TABLE_COPY (_bfd_generic). */
169
170 #define _bfd_generic_bfd_copy_private_bfd_data \
171 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
172 #define _bfd_generic_bfd_merge_private_bfd_data \
173 ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
174 #define _bfd_generic_bfd_set_private_flags \
175 ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
176 #define _bfd_generic_bfd_copy_private_section_data \
177 ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true)
178 #define _bfd_generic_bfd_copy_private_symbol_data \
179 ((boolean (*) PARAMS ((bfd *, asymbol *, bfd *, asymbol *))) bfd_true)
180 #define _bfd_generic_bfd_print_private_bfd_data \
181 ((boolean (*) PARAMS ((bfd *, PTR))) bfd_true)
182
183 /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
184 support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */
185
186 extern char *_bfd_nocore_core_file_failing_command PARAMS ((bfd *));
187 extern int _bfd_nocore_core_file_failing_signal PARAMS ((bfd *));
188 extern boolean _bfd_nocore_core_file_matches_executable_p
189 PARAMS ((bfd *, bfd *));
190
191 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
192 file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
193
194 #define _bfd_noarchive_slurp_armap bfd_false
195 #define _bfd_noarchive_slurp_extended_name_table bfd_false
196 #define _bfd_noarchive_construct_extended_name_table \
197 ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
198 bfd_false)
199 #define _bfd_noarchive_truncate_arname \
200 ((void (*) PARAMS ((bfd *, const char *, char *))) bfd_void)
201 #define _bfd_noarchive_write_armap \
202 ((boolean (*) \
203 PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
204 bfd_false)
205 #define _bfd_noarchive_read_ar_hdr bfd_nullvoidptr
206 #define _bfd_noarchive_openr_next_archived_file \
207 ((bfd *(*) PARAMS ((bfd *, bfd *))) bfd_nullvoidptr)
208 #define _bfd_noarchive_get_elt_at_index \
209 ((bfd *(*) PARAMS ((bfd *, symindex))) bfd_nullvoidptr)
210 #define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
211 #define _bfd_noarchive_update_armap_timestamp bfd_false
212
213 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
214 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */
215
216 #define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
217 #define _bfd_archive_bsd_slurp_extended_name_table \
218 _bfd_slurp_extended_name_table
219 extern boolean _bfd_archive_bsd_construct_extended_name_table
220 PARAMS ((bfd *, char **, bfd_size_type *, const char **));
221 #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
222 #define _bfd_archive_bsd_write_armap bsd_write_armap
223 #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
224 #define _bfd_archive_bsd_openr_next_archived_file \
225 bfd_generic_openr_next_archived_file
226 #define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
227 #define _bfd_archive_bsd_generic_stat_arch_elt \
228 bfd_generic_stat_arch_elt
229 extern boolean _bfd_archive_bsd_update_armap_timestamp PARAMS ((bfd *));
230
231 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
232 archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */
233
234 #define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
235 #define _bfd_archive_coff_slurp_extended_name_table \
236 _bfd_slurp_extended_name_table
237 extern boolean _bfd_archive_coff_construct_extended_name_table
238 PARAMS ((bfd *, char **, bfd_size_type *, const char **));
239 #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
240 #define _bfd_archive_coff_write_armap coff_write_armap
241 #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
242 #define _bfd_archive_coff_openr_next_archived_file \
243 bfd_generic_openr_next_archived_file
244 #define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
245 #define _bfd_archive_coff_generic_stat_arch_elt \
246 bfd_generic_stat_arch_elt
247 #define _bfd_archive_coff_update_armap_timestamp bfd_true
248
249 /* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
250 support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
251
252 #define _bfd_nosymbols_get_symtab_upper_bound _bfd_n1
253 #define _bfd_nosymbols_get_symtab \
254 ((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
255 #define _bfd_nosymbols_make_empty_symbol \
256 ((asymbol *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
257 #define _bfd_nosymbols_print_symbol \
258 ((void (*) PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type))) bfd_void)
259 #define _bfd_nosymbols_get_symbol_info \
260 ((void (*) PARAMS ((bfd *, asymbol *, symbol_info *))) bfd_void)
261 #define _bfd_nosymbols_bfd_is_local_label_name \
262 ((boolean (*) PARAMS ((bfd *, const char *))) bfd_false)
263 #define _bfd_nosymbols_get_lineno \
264 ((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
265 #define _bfd_nosymbols_find_nearest_line \
266 ((boolean (*) \
267 PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, \
268 const char **, unsigned int *))) \
269 bfd_false)
270 #define _bfd_nosymbols_bfd_make_debug_symbol \
271 ((asymbol *(*) PARAMS ((bfd *, PTR, unsigned long))) bfd_nullvoidptr)
272 #define _bfd_nosymbols_read_minisymbols \
273 ((long (*) PARAMS ((bfd *, boolean, PTR *, unsigned int *))) _bfd_n1)
274 #define _bfd_nosymbols_minisymbol_to_symbol \
275 ((asymbol *(*) PARAMS ((bfd *, boolean, const PTR, asymbol *))) \
276 bfd_nullvoidptr)
277
278 /* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
279 support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */
280
281 #define _bfd_norelocs_get_reloc_upper_bound \
282 ((long (*) PARAMS ((bfd *, asection *))) _bfd_n1)
283 #define _bfd_norelocs_canonicalize_reloc \
284 ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) _bfd_n1)
285 #define _bfd_norelocs_bfd_reloc_type_lookup \
286 ((reloc_howto_type *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) \
287 bfd_nullvoidptr)
288
289 /* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
290 be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */
291
292 #define _bfd_nowrite_set_arch_mach \
293 ((boolean (*) PARAMS ((bfd *, enum bfd_architecture, unsigned long))) \
294 bfd_false)
295 #define _bfd_nowrite_set_section_contents \
296 ((boolean (*) PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type))) \
297 bfd_false)
298
299 /* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use
300 BFD_JUMP_TABLE_WRITE (_bfd_generic). */
301
302 #define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
303 extern boolean _bfd_generic_set_section_contents
304 PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
305
306 /* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
307 support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */
308
309 #define _bfd_nolink_sizeof_headers ((int (*) PARAMS ((bfd *, boolean))) bfd_0)
310 #define _bfd_nolink_bfd_get_relocated_section_contents \
311 ((bfd_byte *(*) \
312 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, \
313 bfd_byte *, boolean, asymbol **))) \
314 bfd_nullvoidptr)
315 #define _bfd_nolink_bfd_relax_section \
316 ((boolean (*) \
317 PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *))) \
318 bfd_false)
319 #define _bfd_nolink_bfd_link_hash_table_create \
320 ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
321 #define _bfd_nolink_bfd_link_add_symbols \
322 ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
323 #define _bfd_nolink_bfd_final_link \
324 ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
325 #define _bfd_nolink_bfd_link_split_section \
326 ((boolean (*) PARAMS ((bfd *, struct sec *))) bfd_false)
327
328 /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
329 have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
330 (_bfd_nodynamic). */
331
332 #define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_n1
333 #define _bfd_nodynamic_canonicalize_dynamic_symtab \
334 ((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
335 #define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_n1
336 #define _bfd_nodynamic_canonicalize_dynamic_reloc \
337 ((long (*) PARAMS ((bfd *, arelent **, asymbol **))) _bfd_n1)
338 \f
339 /* Generic routine to determine of the given symbol is a local
340 label. */
341 extern boolean bfd_generic_is_local_label_name PARAMS ((bfd *, const char *));
342
343 /* Generic minisymbol routines. */
344 extern long _bfd_generic_read_minisymbols
345 PARAMS ((bfd *, boolean, PTR *, unsigned int *));
346 extern asymbol *_bfd_generic_minisymbol_to_symbol
347 PARAMS ((bfd *, boolean, const PTR, asymbol *));
348
349 /* Find the nearest line using .stab/.stabstr sections. */
350 extern boolean _bfd_stab_section_find_nearest_line
351 PARAMS ((bfd *, asymbol **, asection *, bfd_vma, boolean *, const char **,
352 const char **, unsigned int *, PTR *));
353
354 /* A routine to create entries for a bfd_link_hash_table. */
355 extern struct bfd_hash_entry *_bfd_link_hash_newfunc
356 PARAMS ((struct bfd_hash_entry *entry,
357 struct bfd_hash_table *table,
358 const char *string));
359
360 /* Initialize a bfd_link_hash_table. */
361 extern boolean _bfd_link_hash_table_init
362 PARAMS ((struct bfd_link_hash_table *, bfd *,
363 struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
364 struct bfd_hash_table *,
365 const char *)));
366
367 /* Generic link hash table creation routine. */
368 extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
369 PARAMS ((bfd *));
370
371 /* Generic add symbol routine. */
372 extern boolean _bfd_generic_link_add_symbols
373 PARAMS ((bfd *, struct bfd_link_info *));
374
375 /* Generic add symbol routine. This version is used by targets for
376 which the linker must collect constructors and destructors by name,
377 as the collect2 program does. */
378 extern boolean _bfd_generic_link_add_symbols_collect
379 PARAMS ((bfd *, struct bfd_link_info *));
380
381 /* Generic archive add symbol routine. */
382 extern boolean _bfd_generic_link_add_archive_symbols
383 PARAMS ((bfd *, struct bfd_link_info *,
384 boolean (*checkfn) (bfd *, struct bfd_link_info *, boolean *)));
385
386
387
388 /* Forward declaration to avoid prototype errors. */
389 typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
390
391 /* Generic routine to add a single symbol. */
392 extern boolean _bfd_generic_link_add_one_symbol
393 PARAMS ((struct bfd_link_info *, bfd *, const char *name, flagword,
394 asection *, bfd_vma, const char *, boolean copy,
395 boolean constructor, struct bfd_link_hash_entry **));
396
397 /* Generic link routine. */
398 extern boolean _bfd_generic_final_link
399 PARAMS ((bfd *, struct bfd_link_info *));
400
401 extern boolean _bfd_generic_link_split_section
402 PARAMS ((bfd *, struct sec *));
403
404 /* Generic reloc_link_order processing routine. */
405 extern boolean _bfd_generic_reloc_link_order
406 PARAMS ((bfd *, struct bfd_link_info *, asection *,
407 struct bfd_link_order *));
408
409 /* Default link order processing routine. */
410 extern boolean _bfd_default_link_order
411 PARAMS ((bfd *, struct bfd_link_info *, asection *,
412 struct bfd_link_order *));
413
414 /* Count the number of reloc entries in a link order list. */
415 extern unsigned int _bfd_count_link_order_relocs
416 PARAMS ((struct bfd_link_order *));
417
418 /* Final link relocation routine. */
419 extern bfd_reloc_status_type _bfd_final_link_relocate
420 PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
421 bfd_vma address, bfd_vma value, bfd_vma addend));
422
423 /* Relocate a particular location by a howto and a value. */
424 extern bfd_reloc_status_type _bfd_relocate_contents
425 PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *));
426
427 /* Link stabs in sections in the first pass. */
428
429 extern boolean _bfd_link_section_stabs
430 PARAMS ((bfd *, PTR *, asection *, asection *, PTR *));
431
432 /* Write out the .stab section when linking stabs in sections. */
433
434 extern boolean _bfd_write_section_stabs
435 PARAMS ((bfd *, asection *, PTR *, bfd_byte *));
436
437 /* Write out the .stabstr string table when linking stabs in sections. */
438
439 extern boolean _bfd_write_stab_strings PARAMS ((bfd *, PTR *));
440
441 /* Create a string table. */
442 extern struct bfd_strtab_hash *_bfd_stringtab_init PARAMS ((void));
443
444 /* Create an XCOFF .debug section style string table. */
445 extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init PARAMS ((void));
446
447 /* Free a string table. */
448 extern void _bfd_stringtab_free PARAMS ((struct bfd_strtab_hash *));
449
450 /* Get the size of a string table. */
451 extern bfd_size_type _bfd_stringtab_size PARAMS ((struct bfd_strtab_hash *));
452
453 /* Add a string to a string table. */
454 extern bfd_size_type _bfd_stringtab_add
455 PARAMS ((struct bfd_strtab_hash *, const char *, boolean hash,
456 boolean copy));
457
458 /* Write out a string table. */
459 extern boolean _bfd_stringtab_emit PARAMS ((bfd *, struct bfd_strtab_hash *));
460 \f
461 /* Macros to tell if bfds are read or write enabled.
462
463 Note that bfds open for read may be scribbled into if the fd passed
464 to bfd_fdopenr is actually open both for read and write
465 simultaneously. However an output bfd will never be open for
466 read. Therefore sometimes you want to check bfd_read_p or
467 !bfd_read_p, and only sometimes bfd_write_p.
468 */
469
470 #define bfd_read_p(abfd) ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
471 #define bfd_write_p(abfd) ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
472
473 void bfd_assert PARAMS ((const char*,int));
474
475 #define BFD_ASSERT(x) \
476 { if (!(x)) bfd_assert(__FILE__,__LINE__); }
477
478 #define BFD_FAIL() \
479 { bfd_assert(__FILE__,__LINE__); }
480
481 FILE * bfd_cache_lookup_worker PARAMS ((bfd *));
482
483 extern bfd *bfd_last_cache;
484
485 /* List of supported target vectors, and the default vector (if
486 bfd_default_vector[0] is NULL, there is no default). */
487 extern const bfd_target * const bfd_target_vector[];
488 extern const bfd_target *bfd_default_vector[];
489
490 /* Functions shared by the ECOFF and MIPS ELF backends, which have no
491 other common header files. */
492
493 #if defined(__STDC__) || defined(ALMOST_STDC)
494 struct ecoff_find_line;
495 #endif
496
497 extern boolean _bfd_ecoff_locate_line
498 PARAMS ((bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
499 const struct ecoff_debug_swap * const, struct ecoff_find_line *,
500 const char **, const char **, unsigned int *));
501 extern boolean _bfd_ecoff_get_accumulated_pdr PARAMS ((PTR, bfd_byte *));
502 extern boolean _bfd_ecoff_get_accumulated_sym PARAMS ((PTR, bfd_byte *));
503 extern boolean _bfd_ecoff_get_accumulated_ss PARAMS ((PTR, bfd_byte *));
504
505 extern bfd_vma _bfd_get_gp_value PARAMS ((bfd *));
506 extern void _bfd_set_gp_value PARAMS ((bfd *, bfd_vma));
507
508 /* Function shared by the COFF and ELF SH backends, which have no
509 other common header files. */
510
511 extern boolean _bfd_sh_align_load_span
512 PARAMS ((bfd *, asection *, bfd_byte *,
513 boolean (*) (bfd *, asection *, PTR, bfd_byte *, bfd_vma),
514 PTR, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, boolean *));
515
516 /* And more follows */
517
518 void
519 bfd_write_bigendian_4byte_int PARAMS ((bfd *abfd, int i));
520
521 unsigned int
522 bfd_log2 PARAMS ((bfd_vma x));
523
524 #define BFD_CACHE_MAX_OPEN 10
525 extern bfd *bfd_last_cache;
526
527 #define bfd_cache_lookup(x) \
528 ((x)==bfd_last_cache? \
529 (FILE*)(bfd_last_cache->iostream): \
530 bfd_cache_lookup_worker(x))
531 boolean
532 bfd_cache_init PARAMS ((bfd *abfd));
533
534 boolean
535 bfd_cache_close PARAMS ((bfd *abfd));
536
537 FILE*
538 bfd_open_file PARAMS ((bfd *abfd));
539
540 FILE *
541 bfd_cache_lookup_worker PARAMS ((bfd *abfd));
542
543 #ifdef _BFD_MAKE_TABLE_bfd_reloc_code_real
544
545 static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
546
547 "BFD_RELOC_64",
548 "BFD_RELOC_32",
549 "BFD_RELOC_26",
550 "BFD_RELOC_24",
551 "BFD_RELOC_16",
552 "BFD_RELOC_14",
553 "BFD_RELOC_8",
554 "BFD_RELOC_64_PCREL",
555 "BFD_RELOC_32_PCREL",
556 "BFD_RELOC_24_PCREL",
557 "BFD_RELOC_16_PCREL",
558 "BFD_RELOC_12_PCREL",
559 "BFD_RELOC_8_PCREL",
560 "BFD_RELOC_32_GOT_PCREL",
561 "BFD_RELOC_16_GOT_PCREL",
562 "BFD_RELOC_8_GOT_PCREL",
563 "BFD_RELOC_32_GOTOFF",
564 "BFD_RELOC_16_GOTOFF",
565 "BFD_RELOC_LO16_GOTOFF",
566 "BFD_RELOC_HI16_GOTOFF",
567 "BFD_RELOC_HI16_S_GOTOFF",
568 "BFD_RELOC_8_GOTOFF",
569 "BFD_RELOC_32_PLT_PCREL",
570 "BFD_RELOC_24_PLT_PCREL",
571 "BFD_RELOC_16_PLT_PCREL",
572 "BFD_RELOC_8_PLT_PCREL",
573 "BFD_RELOC_32_PLTOFF",
574 "BFD_RELOC_16_PLTOFF",
575 "BFD_RELOC_LO16_PLTOFF",
576 "BFD_RELOC_HI16_PLTOFF",
577 "BFD_RELOC_HI16_S_PLTOFF",
578 "BFD_RELOC_8_PLTOFF",
579 "BFD_RELOC_68K_GLOB_DAT",
580 "BFD_RELOC_68K_JMP_SLOT",
581 "BFD_RELOC_68K_RELATIVE",
582 "BFD_RELOC_32_BASEREL",
583 "BFD_RELOC_16_BASEREL",
584 "BFD_RELOC_LO16_BASEREL",
585 "BFD_RELOC_HI16_BASEREL",
586 "BFD_RELOC_HI16_S_BASEREL",
587 "BFD_RELOC_8_BASEREL",
588 "BFD_RELOC_RVA",
589 "BFD_RELOC_8_FFnn",
590 "BFD_RELOC_32_PCREL_S2",
591 "BFD_RELOC_16_PCREL_S2",
592 "BFD_RELOC_23_PCREL_S2",
593 "BFD_RELOC_HI22",
594 "BFD_RELOC_LO10",
595 "BFD_RELOC_GPREL16",
596 "BFD_RELOC_GPREL32",
597 "BFD_RELOC_I960_CALLJ",
598 "BFD_RELOC_NONE",
599 "BFD_RELOC_SPARC_WDISP22",
600 "BFD_RELOC_SPARC22",
601 "BFD_RELOC_SPARC13",
602 "BFD_RELOC_SPARC_GOT10",
603 "BFD_RELOC_SPARC_GOT13",
604 "BFD_RELOC_SPARC_GOT22",
605 "BFD_RELOC_SPARC_PC10",
606 "BFD_RELOC_SPARC_PC22",
607 "BFD_RELOC_SPARC_WPLT30",
608 "BFD_RELOC_SPARC_COPY",
609 "BFD_RELOC_SPARC_GLOB_DAT",
610 "BFD_RELOC_SPARC_JMP_SLOT",
611 "BFD_RELOC_SPARC_RELATIVE",
612 "BFD_RELOC_SPARC_UA32",
613 "BFD_RELOC_SPARC_BASE13",
614 "BFD_RELOC_SPARC_BASE22",
615 "BFD_RELOC_SPARC_10",
616 "BFD_RELOC_SPARC_11",
617 "BFD_RELOC_SPARC_OLO10",
618 "BFD_RELOC_SPARC_HH22",
619 "BFD_RELOC_SPARC_HM10",
620 "BFD_RELOC_SPARC_LM22",
621 "BFD_RELOC_SPARC_PC_HH22",
622 "BFD_RELOC_SPARC_PC_HM10",
623 "BFD_RELOC_SPARC_PC_LM22",
624 "BFD_RELOC_SPARC_WDISP16",
625 "BFD_RELOC_SPARC_WDISP19",
626 "BFD_RELOC_SPARC_GLOB_JMP",
627 "BFD_RELOC_SPARC_7",
628 "BFD_RELOC_SPARC_6",
629 "BFD_RELOC_SPARC_5",
630 "BFD_RELOC_ALPHA_GPDISP_HI16",
631 "BFD_RELOC_ALPHA_GPDISP_LO16",
632 "BFD_RELOC_ALPHA_GPDISP",
633 "BFD_RELOC_ALPHA_LITERAL",
634 "BFD_RELOC_ALPHA_ELF_LITERAL",
635 "BFD_RELOC_ALPHA_LITUSE",
636 "BFD_RELOC_ALPHA_HINT",
637 "BFD_RELOC_ALPHA_LINKAGE",
638 "BFD_RELOC_ALPHA_CODEADDR",
639 "BFD_RELOC_MIPS_JMP",
640 "BFD_RELOC_MIPS16_JMP",
641 "BFD_RELOC_MIPS16_GPREL",
642 "BFD_RELOC_HI16",
643 "BFD_RELOC_HI16_S",
644 "BFD_RELOC_LO16",
645 "BFD_RELOC_PCREL_HI16_S",
646 "BFD_RELOC_PCREL_LO16",
647 "BFD_RELOC_MIPS_LITERAL",
648 "BFD_RELOC_MIPS_GOT16",
649 "BFD_RELOC_MIPS_CALL16",
650 "BFD_RELOC_MIPS_GOT_HI16",
651 "BFD_RELOC_MIPS_GOT_LO16",
652 "BFD_RELOC_MIPS_CALL_HI16",
653 "BFD_RELOC_MIPS_CALL_LO16",
654 "BFD_RELOC_386_GOT32",
655 "BFD_RELOC_386_PLT32",
656 "BFD_RELOC_386_COPY",
657 "BFD_RELOC_386_GLOB_DAT",
658 "BFD_RELOC_386_JUMP_SLOT",
659 "BFD_RELOC_386_RELATIVE",
660 "BFD_RELOC_386_GOTOFF",
661 "BFD_RELOC_386_GOTPC",
662 "BFD_RELOC_NS32K_IMM_8",
663 "BFD_RELOC_NS32K_IMM_16",
664 "BFD_RELOC_NS32K_IMM_32",
665 "BFD_RELOC_NS32K_IMM_8_PCREL",
666 "BFD_RELOC_NS32K_IMM_16_PCREL",
667 "BFD_RELOC_NS32K_IMM_32_PCREL",
668 "BFD_RELOC_NS32K_DISP_8",
669 "BFD_RELOC_NS32K_DISP_16",
670 "BFD_RELOC_NS32K_DISP_32",
671 "BFD_RELOC_NS32K_DISP_8_PCREL",
672 "BFD_RELOC_NS32K_DISP_16_PCREL",
673 "BFD_RELOC_NS32K_DISP_32_PCREL",
674 "BFD_RELOC_PPC_B26",
675 "BFD_RELOC_PPC_BA26",
676 "BFD_RELOC_PPC_TOC16",
677 "BFD_RELOC_PPC_B16",
678 "BFD_RELOC_PPC_B16_BRTAKEN",
679 "BFD_RELOC_PPC_B16_BRNTAKEN",
680 "BFD_RELOC_PPC_BA16",
681 "BFD_RELOC_PPC_BA16_BRTAKEN",
682 "BFD_RELOC_PPC_BA16_BRNTAKEN",
683 "BFD_RELOC_PPC_COPY",
684 "BFD_RELOC_PPC_GLOB_DAT",
685 "BFD_RELOC_PPC_JMP_SLOT",
686 "BFD_RELOC_PPC_RELATIVE",
687 "BFD_RELOC_PPC_LOCAL24PC",
688 "BFD_RELOC_PPC_EMB_NADDR32",
689 "BFD_RELOC_PPC_EMB_NADDR16",
690 "BFD_RELOC_PPC_EMB_NADDR16_LO",
691 "BFD_RELOC_PPC_EMB_NADDR16_HI",
692 "BFD_RELOC_PPC_EMB_NADDR16_HA",
693 "BFD_RELOC_PPC_EMB_SDAI16",
694 "BFD_RELOC_PPC_EMB_SDA2I16",
695 "BFD_RELOC_PPC_EMB_SDA2REL",
696 "BFD_RELOC_PPC_EMB_SDA21",
697 "BFD_RELOC_PPC_EMB_MRKREF",
698 "BFD_RELOC_PPC_EMB_RELSEC16",
699 "BFD_RELOC_PPC_EMB_RELST_LO",
700 "BFD_RELOC_PPC_EMB_RELST_HI",
701 "BFD_RELOC_PPC_EMB_RELST_HA",
702 "BFD_RELOC_PPC_EMB_BIT_FLD",
703 "BFD_RELOC_PPC_EMB_RELSDA",
704 "BFD_RELOC_CTOR",
705 "BFD_RELOC_ARM_PCREL_BRANCH",
706 "BFD_RELOC_ARM_IMMEDIATE",
707 "BFD_RELOC_ARM_OFFSET_IMM",
708 "BFD_RELOC_ARM_SHIFT_IMM",
709 "BFD_RELOC_ARM_SWI",
710 "BFD_RELOC_ARM_MULTI",
711 "BFD_RELOC_ARM_CP_OFF_IMM",
712 "BFD_RELOC_ARM_ADR_IMM",
713 "BFD_RELOC_ARM_LDR_IMM",
714 "BFD_RELOC_ARM_LITERAL",
715 "BFD_RELOC_ARM_IN_POOL",
716 "BFD_RELOC_ARM_OFFSET_IMM8",
717 "BFD_RELOC_ARM_HWLITERAL",
718 "BFD_RELOC_ARM_THUMB_ADD",
719 "BFD_RELOC_ARM_THUMB_IMM",
720 "BFD_RELOC_ARM_THUMB_SHIFT",
721 "BFD_RELOC_ARM_THUMB_OFFSET",
722 "BFD_RELOC_SH_PCDISP8BY2",
723 "BFD_RELOC_SH_PCDISP12BY2",
724 "BFD_RELOC_SH_IMM4",
725 "BFD_RELOC_SH_IMM4BY2",
726 "BFD_RELOC_SH_IMM4BY4",
727 "BFD_RELOC_SH_IMM8",
728 "BFD_RELOC_SH_IMM8BY2",
729 "BFD_RELOC_SH_IMM8BY4",
730 "BFD_RELOC_SH_PCRELIMM8BY2",
731 "BFD_RELOC_SH_PCRELIMM8BY4",
732 "BFD_RELOC_SH_SWITCH16",
733 "BFD_RELOC_SH_SWITCH32",
734 "BFD_RELOC_SH_USES",
735 "BFD_RELOC_SH_COUNT",
736 "BFD_RELOC_SH_ALIGN",
737 "BFD_RELOC_SH_CODE",
738 "BFD_RELOC_SH_DATA",
739 "BFD_RELOC_SH_LABEL",
740 /* start-sanitize-arc */
741 "BFD_RELOC_ARC_B22_PCREL",
742 "BFD_RELOC_ARC_B26",
743 /* end-sanitize-arc */
744
745 "BFD_RELOC_D10V_10_PCREL_R",
746 "BFD_RELOC_D10V_10_PCREL_L",
747 "BFD_RELOC_D10V_18",
748 "BFD_RELOC_D10V_18_PCREL",
749
750 /* start-sanitize-d30v */
751 "BFD_RELOC_D30V_6",
752 "BFD_RELOC_D30V_15",
753 "BFD_RELOC_D30V_15_PCREL",
754 "BFD_RELOC_D30V_21",
755 "BFD_RELOC_D30V_21_PCREL",
756 "BFD_RELOC_D30V_32",
757 "BFD_RELOC_D30V_32_PCREL",
758 /* end-sanitize-d30v */
759
760 /* start-sanitize-m32r */
761 "BFD_RELOC_M32R_24",
762 "BFD_RELOC_M32R_10_PCREL",
763 "BFD_RELOC_M32R_18_PCREL",
764 "BFD_RELOC_M32R_26_PCREL",
765 "BFD_RELOC_M32R_HI16_ULO",
766 "BFD_RELOC_M32R_HI16_SLO",
767 "BFD_RELOC_M32R_LO16",
768 "BFD_RELOC_M32R_SDA16",
769 /* end-sanitize-m32r */
770
771 /* start-sanitize-v850 */
772 "BFD_RELOC_V850_9_PCREL",
773 "BFD_RELOC_V850_22_PCREL",
774 "BFD_RELOC_V850_SDA_OFFSET",
775 "BFD_RELOC_V850_ZDA_OFFSET",
776 "BFD_RELOC_V850_TDA_OFFSET",
777 /* end-sanitize-v850 */
778
779 "BFD_RELOC_MN10300_32_PCREL",
780 "BFD_RELOC_MN10300_16_PCREL",
781 "@@overflow: BFD_RELOC_UNUSED@@",
782 };
783 #endif
784
785 reloc_howto_type *
786 bfd_default_reloc_type_lookup
787 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
788
789 boolean
790 bfd_generic_relax_section
791 PARAMS ((bfd *abfd,
792 asection *section,
793 struct bfd_link_info *,
794 boolean *));
795
796 bfd_byte *
797
798 bfd_generic_get_relocated_section_contents PARAMS ((bfd *abfd,
799 struct bfd_link_info *link_info,
800 struct bfd_link_order *link_order,
801 bfd_byte *data,
802 boolean relocateable,
803 asymbol **symbols));
804
805 extern const bfd_arch_info_type bfd_default_arch_struct;
806 boolean
807 bfd_default_set_arch_mach PARAMS ((bfd *abfd,
808 enum bfd_architecture arch,
809 unsigned long mach));
810
811 const bfd_arch_info_type *
812 bfd_default_compatible
813 PARAMS ((const bfd_arch_info_type *a,
814 const bfd_arch_info_type *b));
815
816 boolean
817 bfd_default_scan PARAMS ((const struct bfd_arch_info *info, const char *string));
818
819 struct elf_internal_shdr *
820 bfd_elf_find_section PARAMS ((bfd *abfd, char *name));
821