Back to index

cell-binutils  2.17cvs20070401
libbfd-in.h
Go to the documentation of this file.
00001 /* libbfd.h -- Declarations used by bfd library *implementation*.
00002    (This include file is not for users of the library.)
00003 
00004    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
00005    1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
00006    Free Software Foundation, Inc.
00007 
00008    Written by Cygnus Support.
00009 
00010 This file is part of BFD, the Binary File Descriptor library.
00011 
00012 This program is free software; you can redistribute it and/or modify
00013 it under the terms of the GNU General Public License as published by
00014 the Free Software Foundation; either version 2 of the License, or
00015 (at your option) any later version.
00016 
00017 This program is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 GNU General Public License for more details.
00021 
00022 You should have received a copy of the GNU General Public License
00023 along with this program; if not, write to the Free Software
00024 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00025 
00026 #include "hashtab.h"
00027 
00028 /* Align an address upward to a boundary, expressed as a number of bytes.
00029    E.g. align to an 8-byte boundary with argument of 8.  Take care never
00030    to wrap around if the address is within boundary-1 of the end of the
00031    address space.  */
00032 #define BFD_ALIGN(this, boundary)                                \
00033   ((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this))            \
00034    ? (((bfd_vma) (this) + ((boundary) - 1)) & ~ (bfd_vma) ((boundary)-1)) \
00035    : ~ (bfd_vma) 0)
00036 
00037 /* If you want to read and write large blocks, you might want to do it
00038    in quanta of this amount */
00039 #define DEFAULT_BUFFERSIZE 8192
00040 
00041 /* Set a tdata field.  Can't use the other macros for this, since they
00042    do casts, and casting to the left of assignment isn't portable.  */
00043 #define set_tdata(bfd, v) ((bfd)->tdata.any = (v))
00044 
00045 /* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points
00046    to an instance of this structure.  */
00047 
00048 struct bfd_in_memory
00049 {
00050   /* Size of buffer.  */
00051   bfd_size_type size;
00052   /* Buffer holding contents of BFD.  */
00053   bfd_byte *buffer;
00054 };
00055 
00056 struct section_hash_entry
00057 {
00058   struct bfd_hash_entry root;
00059   asection section;
00060 };
00061 
00062 /* tdata for an archive.  For an input archive, cache
00063    needs to be free()'d.  For an output archive, symdefs do.  */
00064 
00065 struct artdata {
00066   file_ptr first_file_filepos;
00067   /* Speed up searching the armap */
00068   htab_t cache;
00069   bfd *archive_head;        /* Only interesting in output routines */
00070   carsym *symdefs;          /* the symdef entries */
00071   symindex symdef_count;    /* how many there are */
00072   char *extended_names;            /* clever intel extension */
00073   bfd_size_type extended_names_size; /* Size of extended names */
00074   /* when more compilers are standard C, this can be a time_t */
00075   long  armap_timestamp;    /* Timestamp value written into armap.
00076                                This is used for BSD archives to check
00077                                that the timestamp is recent enough
00078                                for the BSD linker to not complain,
00079                                just before we finish writing an
00080                                archive.  */
00081   file_ptr armap_datepos;   /* Position within archive to seek to
00082                                rewrite the date field.  */
00083   void *tdata;                     /* Backend specific information.  */
00084 };
00085 
00086 #define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
00087 
00088 /* Goes in bfd's arelt_data slot */
00089 struct areltdata {
00090   char * arch_header;              /* it's actually a string */
00091   unsigned int parsed_size; /* octets of filesize not including ar_hdr */
00092   char *filename;           /* null-terminated */
00093 };
00094 
00095 #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
00096 
00097 extern void *bfd_malloc
00098   (bfd_size_type);
00099 extern void *bfd_realloc
00100   (void *, bfd_size_type);
00101 extern void *bfd_zmalloc
00102   (bfd_size_type);
00103 extern void *bfd_malloc2
00104   (bfd_size_type, bfd_size_type);
00105 extern void *bfd_realloc2
00106   (void *, bfd_size_type, bfd_size_type);
00107 extern void *bfd_zmalloc2
00108   (bfd_size_type, bfd_size_type);
00109 
00110 extern void _bfd_default_error_handler (const char *s, ...);
00111 extern bfd_error_handler_type _bfd_error_handler;
00112 
00113 /* These routines allocate and free things on the BFD's objalloc.  */
00114 
00115 extern void *bfd_alloc
00116   (bfd *, bfd_size_type);
00117 extern void *bfd_zalloc
00118   (bfd *, bfd_size_type);
00119 extern void *bfd_alloc2
00120   (bfd *, bfd_size_type, bfd_size_type);
00121 extern void *bfd_zalloc2
00122   (bfd *, bfd_size_type, bfd_size_type);
00123 extern void bfd_release
00124   (bfd *, void *);
00125 
00126 bfd * _bfd_create_empty_archive_element_shell
00127   (bfd *obfd);
00128 bfd * _bfd_look_for_bfd_in_cache
00129   (bfd *, file_ptr);
00130 bfd_boolean _bfd_add_bfd_to_archive_cache
00131   (bfd *, file_ptr, bfd *);
00132 bfd_boolean _bfd_generic_mkarchive
00133   (bfd *abfd);
00134 const bfd_target *bfd_generic_archive_p
00135   (bfd *abfd);
00136 bfd_boolean bfd_slurp_armap
00137   (bfd *abfd);
00138 bfd_boolean bfd_slurp_bsd_armap_f2
00139   (bfd *abfd);
00140 #define bfd_slurp_bsd_armap bfd_slurp_armap
00141 #define bfd_slurp_coff_armap bfd_slurp_armap
00142 bfd_boolean _bfd_slurp_extended_name_table
00143   (bfd *abfd);
00144 extern bfd_boolean _bfd_construct_extended_name_table
00145   (bfd *, bfd_boolean, char **, bfd_size_type *);
00146 bfd_boolean _bfd_write_archive_contents
00147   (bfd *abfd);
00148 bfd_boolean _bfd_compute_and_write_armap
00149   (bfd *, unsigned int elength);
00150 bfd *_bfd_get_elt_at_filepos
00151   (bfd *archive, file_ptr filepos);
00152 extern bfd *_bfd_generic_get_elt_at_index
00153   (bfd *, symindex);
00154 bfd * _bfd_new_bfd
00155   (void);
00156 void _bfd_delete_bfd
00157   (bfd *);
00158 bfd_boolean _bfd_free_cached_info
00159   (bfd *);
00160 
00161 bfd_boolean bfd_false
00162   (bfd *ignore);
00163 bfd_boolean bfd_true
00164   (bfd *ignore);
00165 void *bfd_nullvoidptr
00166   (bfd *ignore);
00167 int bfd_0
00168   (bfd *ignore);
00169 unsigned int bfd_0u
00170   (bfd *ignore);
00171 long bfd_0l
00172   (bfd *ignore);
00173 long _bfd_n1
00174   (bfd *ignore);
00175 void bfd_void
00176   (bfd *ignore);
00177 
00178 bfd *_bfd_new_bfd_contained_in
00179   (bfd *);
00180 const bfd_target *_bfd_dummy_target
00181   (bfd *abfd);
00182 
00183 void bfd_dont_truncate_arname
00184   (bfd *abfd, const char *filename, char *hdr);
00185 void bfd_bsd_truncate_arname
00186   (bfd *abfd, const char *filename, char *hdr);
00187 void bfd_gnu_truncate_arname
00188   (bfd *abfd, const char *filename, char *hdr);
00189 
00190 bfd_boolean bsd_write_armap
00191   (bfd *arch, unsigned int elength, struct orl *map, unsigned int orl_count,
00192    int stridx);
00193 
00194 bfd_boolean coff_write_armap
00195   (bfd *arch, unsigned int elength, struct orl *map, unsigned int orl_count,
00196    int stridx);
00197 
00198 extern void *_bfd_generic_read_ar_hdr
00199   (bfd *);
00200 extern void _bfd_ar_spacepad
00201   (char *, size_t, const char *, long);
00202 
00203 extern void *_bfd_generic_read_ar_hdr_mag
00204   (bfd *, const char *);
00205 
00206 bfd * bfd_generic_openr_next_archived_file
00207   (bfd *archive, bfd *last_file);
00208 
00209 int bfd_generic_stat_arch_elt
00210   (bfd *, struct stat *);
00211 
00212 #define _bfd_read_ar_hdr(abfd) \
00213   BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
00214 
00215 /* Generic routines to use for BFD_JUMP_TABLE_GENERIC.  Use
00216    BFD_JUMP_TABLE_GENERIC (_bfd_generic).  */
00217 
00218 #define _bfd_generic_close_and_cleanup bfd_true
00219 #define _bfd_generic_bfd_free_cached_info bfd_true
00220 extern bfd_boolean _bfd_generic_new_section_hook
00221   (bfd *, asection *);
00222 extern bfd_boolean _bfd_generic_get_section_contents
00223   (bfd *, asection *, void *, file_ptr, bfd_size_type);
00224 extern bfd_boolean _bfd_generic_get_section_contents_in_window
00225   (bfd *, asection *, bfd_window *, file_ptr, bfd_size_type);
00226 
00227 /* Generic routines to use for BFD_JUMP_TABLE_COPY.  Use
00228    BFD_JUMP_TABLE_COPY (_bfd_generic).  */
00229 
00230 #define _bfd_generic_bfd_copy_private_bfd_data \
00231   ((bfd_boolean (*) (bfd *, bfd *)) bfd_true)
00232 #define _bfd_generic_bfd_merge_private_bfd_data \
00233   ((bfd_boolean (*) (bfd *, bfd *)) bfd_true)
00234 #define _bfd_generic_bfd_set_private_flags \
00235   ((bfd_boolean (*) (bfd *, flagword)) bfd_true)
00236 #define _bfd_generic_bfd_copy_private_section_data \
00237   ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true)
00238 #define _bfd_generic_bfd_copy_private_symbol_data \
00239   ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true)
00240 #define _bfd_generic_bfd_copy_private_header_data \
00241   ((bfd_boolean (*) (bfd *, bfd *)) bfd_true)
00242 #define _bfd_generic_bfd_print_private_bfd_data \
00243   ((bfd_boolean (*) (bfd *, void *)) bfd_true)
00244 
00245 extern bfd_boolean _bfd_generic_init_private_section_data
00246   (bfd *, asection *, bfd *, asection *, struct bfd_link_info *);
00247 
00248 /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
00249    support.  Use BFD_JUMP_TABLE_CORE (_bfd_nocore).  */
00250 
00251 extern char *_bfd_nocore_core_file_failing_command
00252   (bfd *);
00253 extern int _bfd_nocore_core_file_failing_signal
00254   (bfd *);
00255 extern bfd_boolean _bfd_nocore_core_file_matches_executable_p
00256   (bfd *, bfd *);
00257 
00258 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
00259    file support.  Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive).  */
00260 
00261 #define _bfd_noarchive_slurp_armap bfd_false
00262 #define _bfd_noarchive_slurp_extended_name_table bfd_false
00263 #define _bfd_noarchive_construct_extended_name_table \
00264   ((bfd_boolean (*) (bfd *, char **, bfd_size_type *, const char **)) \
00265    bfd_false)
00266 #define _bfd_noarchive_truncate_arname \
00267   ((void (*) (bfd *, const char *, char *)) bfd_void)
00268 #define _bfd_noarchive_write_armap \
00269   ((bfd_boolean (*) (bfd *, unsigned int, struct orl *, unsigned int, int)) \
00270    bfd_false)
00271 #define _bfd_noarchive_read_ar_hdr bfd_nullvoidptr
00272 #define _bfd_noarchive_openr_next_archived_file \
00273   ((bfd *(*) (bfd *, bfd *)) bfd_nullvoidptr)
00274 #define _bfd_noarchive_get_elt_at_index \
00275   ((bfd *(*) (bfd *, symindex)) bfd_nullvoidptr)
00276 #define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
00277 #define _bfd_noarchive_update_armap_timestamp bfd_false
00278 
00279 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
00280    archives.  Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd).  */
00281 
00282 #define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
00283 #define _bfd_archive_bsd_slurp_extended_name_table \
00284   _bfd_slurp_extended_name_table
00285 extern bfd_boolean _bfd_archive_bsd_construct_extended_name_table
00286   (bfd *, char **, bfd_size_type *, const char **);
00287 #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
00288 #define _bfd_archive_bsd_write_armap bsd_write_armap
00289 #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
00290 #define _bfd_archive_bsd_openr_next_archived_file \
00291   bfd_generic_openr_next_archived_file
00292 #define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
00293 #define _bfd_archive_bsd_generic_stat_arch_elt \
00294   bfd_generic_stat_arch_elt
00295 extern bfd_boolean _bfd_archive_bsd_update_armap_timestamp
00296   (bfd *);
00297 
00298 /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
00299    archives.  Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff).  */
00300 
00301 #define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
00302 #define _bfd_archive_coff_slurp_extended_name_table \
00303   _bfd_slurp_extended_name_table
00304 extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
00305   (bfd *, char **, bfd_size_type *, const char **);
00306 #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
00307 #define _bfd_archive_coff_write_armap coff_write_armap
00308 #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
00309 #define _bfd_archive_coff_openr_next_archived_file \
00310   bfd_generic_openr_next_archived_file
00311 #define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
00312 #define _bfd_archive_coff_generic_stat_arch_elt \
00313   bfd_generic_stat_arch_elt
00314 #define _bfd_archive_coff_update_armap_timestamp bfd_true
00315 
00316 /* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
00317    support.  Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols).  */
00318 
00319 #define _bfd_nosymbols_get_symtab_upper_bound _bfd_n1
00320 #define _bfd_nosymbols_canonicalize_symtab \
00321   ((long (*) (bfd *, asymbol **)) _bfd_n1)
00322 #define _bfd_nosymbols_make_empty_symbol _bfd_generic_make_empty_symbol
00323 #define _bfd_nosymbols_print_symbol \
00324   ((void (*) (bfd *, void *, asymbol *, bfd_print_symbol_type)) bfd_void)
00325 #define _bfd_nosymbols_get_symbol_info \
00326   ((void (*) (bfd *, asymbol *, symbol_info *)) bfd_void)
00327 #define _bfd_nosymbols_bfd_is_local_label_name \
00328   ((bfd_boolean (*) (bfd *, const char *)) bfd_false)
00329 #define _bfd_nosymbols_bfd_is_target_special_symbol \
00330   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
00331 #define _bfd_nosymbols_get_lineno \
00332   ((alent *(*) (bfd *, asymbol *)) bfd_nullvoidptr)
00333 #define _bfd_nosymbols_find_nearest_line \
00334   ((bfd_boolean (*) (bfd *, asection *, asymbol **, bfd_vma, const char **, \
00335                    const char **, unsigned int *)) \
00336    bfd_false)
00337 #define _bfd_nosymbols_find_inliner_info \
00338   ((bfd_boolean (*) (bfd *, const char **, const char **, unsigned int *)) \
00339    bfd_false)
00340 #define _bfd_nosymbols_bfd_make_debug_symbol \
00341   ((asymbol *(*) (bfd *, void *, unsigned long)) bfd_nullvoidptr)
00342 #define _bfd_nosymbols_read_minisymbols \
00343   ((long (*) (bfd *, bfd_boolean, void **, unsigned int *)) _bfd_n1)
00344 #define _bfd_nosymbols_minisymbol_to_symbol \
00345   ((asymbol *(*) (bfd *, bfd_boolean, const void *, asymbol *)) \
00346    bfd_nullvoidptr)
00347 
00348 /* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
00349    support.  Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs).  */
00350 
00351 extern long _bfd_norelocs_get_reloc_upper_bound (bfd *, asection *);
00352 extern long _bfd_norelocs_canonicalize_reloc (bfd *, asection *,
00353                                          arelent **, asymbol **);
00354 #define _bfd_norelocs_bfd_reloc_type_lookup \
00355   ((reloc_howto_type *(*) (bfd *, bfd_reloc_code_real_type)) bfd_nullvoidptr)
00356 #define _bfd_norelocs_bfd_reloc_name_lookup \
00357   ((reloc_howto_type *(*) (bfd *, const char *)) bfd_nullvoidptr)
00358 
00359 /* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
00360    be written.  Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite).  */
00361 
00362 #define _bfd_nowrite_set_arch_mach \
00363   ((bfd_boolean (*) (bfd *, enum bfd_architecture, unsigned long)) \
00364    bfd_false)
00365 #define _bfd_nowrite_set_section_contents \
00366   ((bfd_boolean (*) (bfd *, asection *, const void *, file_ptr, bfd_size_type)) \
00367    bfd_false)
00368 
00369 /* Generic routines to use for BFD_JUMP_TABLE_WRITE.  Use
00370    BFD_JUMP_TABLE_WRITE (_bfd_generic).  */
00371 
00372 #define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
00373 extern bfd_boolean _bfd_generic_set_section_contents
00374   (bfd *, asection *, const void *, file_ptr, bfd_size_type);
00375 
00376 /* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
00377    support linking.  Use BFD_JUMP_TABLE_LINK (_bfd_nolink).  */
00378 
00379 #define _bfd_nolink_sizeof_headers \
00380   ((int (*) (bfd *, struct bfd_link_info *)) bfd_0)
00381 #define _bfd_nolink_bfd_get_relocated_section_contents \
00382   ((bfd_byte *(*) (bfd *, struct bfd_link_info *, struct bfd_link_order *, \
00383                  bfd_byte *, bfd_boolean, asymbol **)) \
00384    bfd_nullvoidptr)
00385 #define _bfd_nolink_bfd_relax_section \
00386   ((bfd_boolean (*) \
00387     (bfd *, asection *, struct bfd_link_info *, bfd_boolean *)) \
00388    bfd_false)
00389 #define _bfd_nolink_bfd_gc_sections \
00390   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
00391    bfd_false)
00392 #define _bfd_nolink_bfd_merge_sections \
00393   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
00394    bfd_false)
00395 #define _bfd_nolink_bfd_is_group_section \
00396   ((bfd_boolean (*) (bfd *, const struct bfd_section *)) \
00397    bfd_false)
00398 #define _bfd_nolink_bfd_discard_group \
00399   ((bfd_boolean (*) (bfd *, struct bfd_section *)) \
00400    bfd_false)
00401 #define _bfd_nolink_bfd_link_hash_table_create \
00402   ((struct bfd_link_hash_table *(*) (bfd *)) bfd_nullvoidptr)
00403 #define _bfd_nolink_bfd_link_hash_table_free \
00404   ((void (*) (struct bfd_link_hash_table *)) bfd_void)
00405 #define _bfd_nolink_bfd_link_add_symbols \
00406   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) bfd_false)
00407 #define _bfd_nolink_bfd_link_just_syms \
00408   ((void (*) (asection *, struct bfd_link_info *)) bfd_void)
00409 #define _bfd_nolink_bfd_final_link \
00410   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) bfd_false)
00411 #define _bfd_nolink_bfd_link_split_section \
00412   ((bfd_boolean (*) (bfd *, struct bfd_section *)) bfd_false)
00413 #define _bfd_nolink_section_already_linked \
00414   ((void (*) (bfd *, struct bfd_section *, struct bfd_link_info *)) bfd_void)
00415 
00416 /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
00417    have dynamic symbols or relocs.  Use BFD_JUMP_TABLE_DYNAMIC
00418    (_bfd_nodynamic).  */
00419 
00420 #define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_n1
00421 #define _bfd_nodynamic_canonicalize_dynamic_symtab \
00422   ((long (*) (bfd *, asymbol **)) _bfd_n1)
00423 #define _bfd_nodynamic_get_synthetic_symtab \
00424   ((long (*) (bfd *, long, asymbol **, long, asymbol **, asymbol **)) _bfd_n1)
00425 #define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_n1
00426 #define _bfd_nodynamic_canonicalize_dynamic_reloc \
00427   ((long (*) (bfd *, arelent **, asymbol **)) _bfd_n1)
00428 
00429 /* Generic routine to determine of the given symbol is a local
00430    label.  */
00431 extern bfd_boolean bfd_generic_is_local_label_name
00432   (bfd *, const char *);
00433 
00434 /* Generic minisymbol routines.  */
00435 extern long _bfd_generic_read_minisymbols
00436   (bfd *, bfd_boolean, void **, unsigned int *);
00437 extern asymbol *_bfd_generic_minisymbol_to_symbol
00438   (bfd *, bfd_boolean, const void *, asymbol *);
00439 
00440 /* Find the nearest line using .stab/.stabstr sections.  */
00441 extern bfd_boolean _bfd_stab_section_find_nearest_line
00442   (bfd *, asymbol **, asection *, bfd_vma, bfd_boolean *,
00443    const char **, const char **, unsigned int *, void **);
00444 
00445 /* Find the nearest line using DWARF 1 debugging information.  */
00446 extern bfd_boolean _bfd_dwarf1_find_nearest_line
00447   (bfd *, asection *, asymbol **, bfd_vma, const char **,
00448    const char **, unsigned int *);
00449 
00450 /* Find the nearest line using DWARF 2 debugging information.  */
00451 extern bfd_boolean _bfd_dwarf2_find_nearest_line
00452   (bfd *, asection *, asymbol **, bfd_vma, const char **, const char **,
00453    unsigned int *, unsigned int, void **);
00454 
00455 /* Find the line using DWARF 2 debugging information.  */
00456 extern bfd_boolean _bfd_dwarf2_find_line
00457   (bfd *, asymbol **, asymbol *, const char **,
00458    unsigned int *, unsigned int, void **);
00459 
00460 bfd_boolean _bfd_generic_find_line
00461   (bfd *, asymbol **, asymbol *, const char **, unsigned int *);
00462 
00463 /* Find inliner info after calling bfd_find_nearest_line. */
00464 extern bfd_boolean _bfd_dwarf2_find_inliner_info
00465   (bfd *, const char **, const char **, unsigned int *, void **);
00466   
00467 /* Create a new section entry.  */
00468 extern struct bfd_hash_entry *bfd_section_hash_newfunc
00469   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
00470 
00471 /* A routine to create entries for a bfd_link_hash_table.  */
00472 extern struct bfd_hash_entry *_bfd_link_hash_newfunc
00473   (struct bfd_hash_entry *entry, struct bfd_hash_table *table,
00474    const char *string);
00475 
00476 /* Initialize a bfd_link_hash_table.  */
00477 extern bfd_boolean _bfd_link_hash_table_init
00478   (struct bfd_link_hash_table *, bfd *,
00479    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
00480                             struct bfd_hash_table *,
00481                             const char *),
00482    unsigned int);
00483 
00484 /* Generic link hash table creation routine.  */
00485 extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
00486   (bfd *);
00487 
00488 /* Generic link hash table destruction routine.  */
00489 extern void _bfd_generic_link_hash_table_free
00490   (struct bfd_link_hash_table *);
00491 
00492 /* Generic add symbol routine.  */
00493 extern bfd_boolean _bfd_generic_link_add_symbols
00494   (bfd *, struct bfd_link_info *);
00495 
00496 /* Generic add symbol routine.  This version is used by targets for
00497    which the linker must collect constructors and destructors by name,
00498    as the collect2 program does.  */
00499 extern bfd_boolean _bfd_generic_link_add_symbols_collect
00500   (bfd *, struct bfd_link_info *);
00501 
00502 /* Generic archive add symbol routine.  */
00503 extern bfd_boolean _bfd_generic_link_add_archive_symbols
00504   (bfd *, struct bfd_link_info *,
00505    bfd_boolean (*) (bfd *, struct bfd_link_info *, bfd_boolean *));
00506 
00507 /* Forward declaration to avoid prototype errors.  */
00508 typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
00509 
00510 /* Generic routine to add a single symbol.  */
00511 extern bfd_boolean _bfd_generic_link_add_one_symbol
00512   (struct bfd_link_info *, bfd *, const char *name, flagword,
00513    asection *, bfd_vma, const char *, bfd_boolean copy,
00514    bfd_boolean constructor, struct bfd_link_hash_entry **);
00515 
00516 /* Generic routine to mark section as supplying symbols only.  */
00517 extern void _bfd_generic_link_just_syms
00518   (asection *, struct bfd_link_info *);
00519 
00520 /* Generic link routine.  */
00521 extern bfd_boolean _bfd_generic_final_link
00522   (bfd *, struct bfd_link_info *);
00523 
00524 extern bfd_boolean _bfd_generic_link_split_section
00525   (bfd *, struct bfd_section *);
00526 
00527 extern void _bfd_generic_section_already_linked
00528   (bfd *, struct bfd_section *, struct bfd_link_info *);
00529 
00530 /* Generic reloc_link_order processing routine.  */
00531 extern bfd_boolean _bfd_generic_reloc_link_order
00532   (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *);
00533 
00534 /* Default link order processing routine.  */
00535 extern bfd_boolean _bfd_default_link_order
00536   (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *);
00537 
00538 /* Count the number of reloc entries in a link order list.  */
00539 extern unsigned int _bfd_count_link_order_relocs
00540   (struct bfd_link_order *);
00541 
00542 /* Final link relocation routine.  */
00543 extern bfd_reloc_status_type _bfd_final_link_relocate
00544   (reloc_howto_type *, bfd *, asection *, bfd_byte *,
00545    bfd_vma, bfd_vma, bfd_vma);
00546 
00547 /* Relocate a particular location by a howto and a value.  */
00548 extern bfd_reloc_status_type _bfd_relocate_contents
00549   (reloc_howto_type *, bfd *, bfd_vma, bfd_byte *);
00550 
00551 /* Clear a given location using a given howto.  */
00552 extern void _bfd_clear_contents (reloc_howto_type *howto, bfd *input_bfd,
00553                              bfd_byte *location);
00554 
00555 /* Link stabs in sections in the first pass.  */
00556 
00557 extern bfd_boolean _bfd_link_section_stabs
00558   (bfd *, struct stab_info *, asection *, asection *, void **,
00559    bfd_size_type *);
00560 
00561 /* Eliminate stabs for discarded functions and symbols.  */
00562 extern bfd_boolean _bfd_discard_section_stabs
00563   (bfd *, asection *, void *, bfd_boolean (*) (bfd_vma, void *), void *);
00564 
00565 /* Write out the .stab section when linking stabs in sections.  */
00566 
00567 extern bfd_boolean _bfd_write_section_stabs
00568   (bfd *, struct stab_info *, asection *, void **, bfd_byte *);
00569 
00570 /* Write out the .stabstr string table when linking stabs in sections.  */
00571 
00572 extern bfd_boolean _bfd_write_stab_strings
00573   (bfd *, struct stab_info *);
00574 
00575 /* Find an offset within a .stab section when linking stabs in
00576    sections.  */
00577 
00578 extern bfd_vma _bfd_stab_section_offset
00579   (asection *, void *, bfd_vma);
00580 
00581 /* Register a SEC_MERGE section as a candidate for merging.  */
00582 
00583 extern bfd_boolean _bfd_add_merge_section
00584   (bfd *, void **, asection *, void **);
00585 
00586 /* Attempt to merge SEC_MERGE sections.  */
00587 
00588 extern bfd_boolean _bfd_merge_sections
00589   (bfd *, struct bfd_link_info *, void *, void (*) (bfd *, asection *));
00590 
00591 /* Write out a merged section.  */
00592 
00593 extern bfd_boolean _bfd_write_merged_section
00594   (bfd *, asection *, void *);
00595 
00596 /* Find an offset within a modified SEC_MERGE section.  */
00597 
00598 extern bfd_vma _bfd_merged_section_offset
00599   (bfd *, asection **, void *, bfd_vma);
00600 
00601 /* Create a string table.  */
00602 extern struct bfd_strtab_hash *_bfd_stringtab_init
00603   (void);
00604 
00605 /* Create an XCOFF .debug section style string table.  */
00606 extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init
00607   (void);
00608 
00609 /* Free a string table.  */
00610 extern void _bfd_stringtab_free
00611   (struct bfd_strtab_hash *);
00612 
00613 /* Get the size of a string table.  */
00614 extern bfd_size_type _bfd_stringtab_size
00615   (struct bfd_strtab_hash *);
00616 
00617 /* Add a string to a string table.  */
00618 extern bfd_size_type _bfd_stringtab_add
00619   (struct bfd_strtab_hash *, const char *, bfd_boolean hash, bfd_boolean copy);
00620 
00621 /* Write out a string table.  */
00622 extern bfd_boolean _bfd_stringtab_emit
00623   (bfd *, struct bfd_strtab_hash *);
00624 
00625 /* Check that endianness of input and output file match.  */
00626 extern bfd_boolean _bfd_generic_verify_endian_match
00627   (bfd *, bfd *);
00628 
00629 /* Macros to tell if bfds are read or write enabled.
00630 
00631    Note that bfds open for read may be scribbled into if the fd passed
00632    to bfd_fdopenr is actually open both for read and write
00633    simultaneously.  However an output bfd will never be open for
00634    read.  Therefore sometimes you want to check bfd_read_p or
00635    !bfd_read_p, and only sometimes bfd_write_p.
00636 */
00637 
00638 #define       bfd_read_p(abfd) \
00639   ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
00640 #define       bfd_write_p(abfd) \
00641   ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
00642 
00643 void bfd_assert
00644   (const char*,int);
00645 
00646 #define BFD_ASSERT(x) \
00647   do { if (!(x)) bfd_assert(__FILE__,__LINE__); } while (0)
00648 
00649 #define BFD_FAIL() \
00650   do { bfd_assert(__FILE__,__LINE__); } while (0)
00651 
00652 extern void _bfd_abort
00653   (const char *, int, const char *) ATTRIBUTE_NORETURN;
00654 
00655 /* if gcc >= 2.6, we can give a function name, too */
00656 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
00657 #define __PRETTY_FUNCTION__  ((char *) NULL)
00658 #endif
00659 
00660 #undef abort
00661 #define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
00662 
00663 /* Manipulate a system FILE but using BFD's "file_ptr", rather than
00664    the system "off_t" or "off64_t", as the offset.  */
00665 extern file_ptr real_ftell (FILE *file);
00666 extern int real_fseek (FILE *file, file_ptr offset, int whence);
00667 extern FILE *real_fopen (const char *filename, const char *modes);
00668 
00669 /* List of supported target vectors, and the default vector (if
00670    bfd_default_vector[0] is NULL, there is no default).  */
00671 extern const bfd_target * const *bfd_target_vector;
00672 extern const bfd_target *bfd_default_vector[];
00673 
00674 /* List of associated target vectors.  */
00675 extern const bfd_target * const *bfd_associated_vector;
00676 
00677 /* Functions shared by the ECOFF and MIPS ELF backends, which have no
00678    other common header files.  */
00679 
00680 #if defined(__STDC__) || defined(ALMOST_STDC)
00681 struct ecoff_find_line;
00682 #endif
00683 
00684 extern bfd_boolean _bfd_ecoff_locate_line
00685   (bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
00686    const struct ecoff_debug_swap * const, struct ecoff_find_line *,
00687    const char **, const char **, unsigned int *);
00688 extern bfd_boolean _bfd_ecoff_get_accumulated_pdr
00689   (void *, bfd_byte *);
00690 extern bfd_boolean _bfd_ecoff_get_accumulated_sym
00691   (void *, bfd_byte *);
00692 extern bfd_boolean _bfd_ecoff_get_accumulated_ss
00693   (void *, bfd_byte *);
00694 
00695 extern bfd_vma _bfd_get_gp_value
00696   (bfd *);
00697 extern void _bfd_set_gp_value
00698   (bfd *, bfd_vma);
00699 
00700 /* Function shared by the COFF and ELF SH backends, which have no
00701    other common header files.  */
00702 
00703 #ifndef _bfd_sh_align_load_span
00704 extern bfd_boolean _bfd_sh_align_load_span
00705   (bfd *, asection *, bfd_byte *,
00706    bfd_boolean (*) (bfd *, asection *, void *, bfd_byte *, bfd_vma),
00707    void *, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, bfd_boolean *);
00708 #endif
00709 
00710 /* This is the shape of the elements inside the already_linked hash
00711    table. It maps a name onto a list of already_linked elements with
00712    the same name.  */
00713 
00714 struct bfd_section_already_linked_hash_entry
00715 {
00716   struct bfd_hash_entry root;
00717   struct bfd_section_already_linked *entry;
00718 };
00719 
00720 struct bfd_section_already_linked
00721 {
00722   struct bfd_section_already_linked *next;
00723   asection *sec;
00724 };
00725 
00726 extern struct bfd_section_already_linked_hash_entry *
00727   bfd_section_already_linked_table_lookup (const char *);
00728 extern void bfd_section_already_linked_table_insert
00729   (struct bfd_section_already_linked_hash_entry *, asection *);
00730 extern void bfd_section_already_linked_table_traverse
00731   (bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *,
00732                   void *), void *);
00733 
00734 extern bfd_vma read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *);
00735 extern bfd_signed_vma read_signed_leb128 (bfd *, bfd_byte *, unsigned int *);
00736