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