Back to index

cell-binutils  2.17cvs20070401
bfd-in.h
Go to the documentation of this file.
00001 /* Main header file for the bfd library -- portable access to object files.
00002 
00003    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
00004    1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
00005    Free Software Foundation, Inc.
00006 
00007    Contributed by Cygnus Support.
00008 
00009    This file is part of BFD, the Binary File Descriptor library.
00010 
00011    This program is free software; you can redistribute it and/or modify
00012    it under the terms of the GNU General Public License as published by
00013    the Free Software Foundation; either version 2 of the License, or
00014    (at your option) any later version.
00015 
00016    This program is distributed in the hope that it will be useful,
00017    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019    GNU General Public License for more details.
00020 
00021    You should have received a copy of the GNU General Public License
00022    along with this program; if not, write to the Free Software
00023    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00024 
00025 #ifndef __BFD_H_SEEN__
00026 #define __BFD_H_SEEN__
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 #include "ansidecl.h"
00033 #include "symcat.h"
00034 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00035 #ifndef SABER
00036 /* This hack is to avoid a problem with some strict ANSI C preprocessors.
00037    The problem is, "32_" is not a valid preprocessing token, and we don't
00038    want extra underscores (e.g., "nlm_32_").  The XCONCAT2 macro will
00039    cause the inner CONCAT2 macros to be evaluated first, producing
00040    still-valid pp-tokens.  Then the final concatenation can be done.  */
00041 #undef CONCAT4
00042 #define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d))
00043 #endif
00044 #endif
00045 
00046 /* This is a utility macro to handle the situation where the code
00047    wants to place a constant string into the code, followed by a
00048    comma and then the length of the string.  Doing this by hand
00049    is error prone, so using this macro is safer.  The macro will
00050    also safely handle the case where a NULL is passed as the arg.  */
00051 #define STRING_COMMA_LEN(STR) (STR), ((STR) ? sizeof (STR) - 1 : 0)
00052 /* Unfortunately it is not possible to use the STRING_COMMA_LEN macro
00053    to create the arguments to another macro, since the preprocessor
00054    will mis-count the number of arguments to the outer macro (by not
00055    evaluating STRING_COMMA_LEN and so missing the comma).  This is a
00056    problem for example when trying to use STRING_COMMA_LEN to build
00057    the arguments to the strncmp() macro.  Hence this alternative
00058    definition of strncmp is provided here.
00059    
00060    Note - these macros do NOT work if STR2 is not a constant string.  */
00061 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
00062   /* strcpy() can have a similar problem, but since we know we are
00063      copying a constant string, we can use memcpy which will be faster
00064      since there is no need to check for a NUL byte inside STR.  We
00065      can also save time if we do not need to copy the terminating NUL.  */
00066 #define LITMEMCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2) - 1)
00067 #define LITSTRCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2))
00068 
00069 
00070 /* The word size used by BFD on the host.  This may be 64 with a 32
00071    bit target if the host is 64 bit, or if other 64 bit targets have
00072    been selected with --enable-targets, or if --enable-64-bit-bfd.  */
00073 #define BFD_ARCH_SIZE @wordsize@
00074 
00075 /* The word size of the default bfd target.  */
00076 #define BFD_DEFAULT_TARGET_SIZE @bfd_default_target_size@
00077 
00078 #define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
00079 #define BFD_HOST_LONG_LONG @BFD_HOST_LONG_LONG@
00080 #if @BFD_HOST_64_BIT_DEFINED@
00081 #define BFD_HOST_64_BIT @BFD_HOST_64_BIT@
00082 #define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@
00083 typedef BFD_HOST_64_BIT bfd_int64_t;
00084 typedef BFD_HOST_U_64_BIT bfd_uint64_t;
00085 #endif
00086 
00087 #if BFD_ARCH_SIZE >= 64
00088 #define BFD64
00089 #endif
00090 
00091 #ifndef INLINE
00092 #if __GNUC__ >= 2
00093 #define INLINE __inline__
00094 #else
00095 #define INLINE
00096 #endif
00097 #endif
00098 
00099 /* Forward declaration.  */
00100 typedef struct bfd bfd;
00101 
00102 /* Boolean type used in bfd.  Too many systems define their own
00103    versions of "boolean" for us to safely typedef a "boolean" of
00104    our own.  Using an enum for "bfd_boolean" has its own set of
00105    problems, with strange looking casts required to avoid warnings
00106    on some older compilers.  Thus we just use an int.
00107 
00108    General rule: Functions which are bfd_boolean return TRUE on
00109    success and FALSE on failure (unless they're a predicate).  */
00110 
00111 typedef int bfd_boolean;
00112 #undef FALSE
00113 #undef TRUE
00114 #define FALSE 0
00115 #define TRUE 1
00116 
00117 #ifdef BFD64
00118 
00119 #ifndef BFD_HOST_64_BIT
00120  #error No 64 bit integer type available
00121 #endif /* ! defined (BFD_HOST_64_BIT) */
00122 
00123 typedef BFD_HOST_U_64_BIT bfd_vma;
00124 typedef BFD_HOST_64_BIT bfd_signed_vma;
00125 typedef BFD_HOST_U_64_BIT bfd_size_type;
00126 typedef BFD_HOST_U_64_BIT symvalue;
00127 
00128 #ifndef fprintf_vma
00129 #if BFD_HOST_64BIT_LONG
00130 #define sprintf_vma(s,x) sprintf (s, "%016lx", x)
00131 #define fprintf_vma(f,x) fprintf (f, "%016lx", x)
00132 #else
00133 #define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
00134 #define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
00135 #define fprintf_vma(s,x) \
00136   fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
00137 #define sprintf_vma(s,x) \
00138   sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
00139 #endif
00140 #endif
00141 
00142 #else /* not BFD64  */
00143 
00144 /* Represent a target address.  Also used as a generic unsigned type
00145    which is guaranteed to be big enough to hold any arithmetic types
00146    we need to deal with.  */
00147 typedef unsigned long bfd_vma;
00148 
00149 /* A generic signed type which is guaranteed to be big enough to hold any
00150    arithmetic types we need to deal with.  Can be assumed to be compatible
00151    with bfd_vma in the same way that signed and unsigned ints are compatible
00152    (as parameters, in assignment, etc).  */
00153 typedef long bfd_signed_vma;
00154 
00155 typedef unsigned long symvalue;
00156 typedef unsigned long bfd_size_type;
00157 
00158 /* Print a bfd_vma x on stream s.  */
00159 #define fprintf_vma(s,x) fprintf (s, "%08lx", x)
00160 #define sprintf_vma(s,x) sprintf (s, "%08lx", x)
00161 
00162 #endif /* not BFD64  */
00163 
00164 #define HALF_BFD_SIZE_TYPE \
00165   (((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2))
00166 
00167 #ifndef BFD_HOST_64_BIT
00168 /* Fall back on a 32 bit type.  The idea is to make these types always
00169    available for function return types, but in the case that
00170    BFD_HOST_64_BIT is undefined such a function should abort or
00171    otherwise signal an error.  */
00172 typedef bfd_signed_vma bfd_int64_t;
00173 typedef bfd_vma bfd_uint64_t;
00174 #endif
00175 
00176 /* An offset into a file.  BFD always uses the largest possible offset
00177    based on the build time availability of fseek, fseeko, or fseeko64.  */
00178 typedef @bfd_file_ptr@ file_ptr;
00179 typedef unsigned @bfd_file_ptr@ ufile_ptr;
00180 
00181 extern void bfd_sprintf_vma (bfd *, char *, bfd_vma);
00182 extern void bfd_fprintf_vma (bfd *, void *, bfd_vma);
00183 
00184 #define printf_vma(x) fprintf_vma(stdout,x)
00185 #define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x)
00186 
00187 typedef unsigned int flagword;     /* 32 bits of flags */
00188 typedef unsigned char bfd_byte;
00189 
00190 /* File formats.  */
00191 
00192 typedef enum bfd_format
00193 {
00194   bfd_unknown = 0,   /* File format is unknown.  */
00195   bfd_object,        /* Linker/assembler/compiler output.  */
00196   bfd_archive,              /* Object archive file.  */
00197   bfd_core,          /* Core dump.  */
00198   bfd_type_end              /* Marks the end; don't use it!  */
00199 }
00200 bfd_format;
00201 
00202 /* Values that may appear in the flags field of a BFD.  These also
00203    appear in the object_flags field of the bfd_target structure, where
00204    they indicate the set of flags used by that backend (not all flags
00205    are meaningful for all object file formats) (FIXME: at the moment,
00206    the object_flags values have mostly just been copied from backend
00207    to another, and are not necessarily correct).  */
00208 
00209 /* No flags.  */
00210 #define BFD_NO_FLAGS        0x00
00211 
00212 /* BFD contains relocation entries.  */
00213 #define HAS_RELOC    0x01
00214 
00215 /* BFD is directly executable.  */
00216 #define EXEC_P       0x02
00217 
00218 /* BFD has line number information (basically used for F_LNNO in a
00219    COFF header).  */
00220 #define HAS_LINENO   0x04
00221 
00222 /* BFD has debugging information.  */
00223 #define HAS_DEBUG    0x08
00224 
00225 /* BFD has symbols.  */
00226 #define HAS_SYMS     0x10
00227 
00228 /* BFD has local symbols (basically used for F_LSYMS in a COFF
00229    header).  */
00230 #define HAS_LOCALS   0x20
00231 
00232 /* BFD is a dynamic object.  */
00233 #define DYNAMIC      0x40
00234 
00235 /* Text section is write protected (if D_PAGED is not set, this is
00236    like an a.out NMAGIC file) (the linker sets this by default, but
00237    clears it for -r or -N).  */
00238 #define WP_TEXT      0x80
00239 
00240 /* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
00241    linker sets this by default, but clears it for -r or -n or -N).  */
00242 #define D_PAGED      0x100
00243 
00244 /* BFD is relaxable (this means that bfd_relax_section may be able to
00245    do something) (sometimes bfd_relax_section can do something even if
00246    this is not set).  */
00247 #define BFD_IS_RELAXABLE 0x200
00248 
00249 /* This may be set before writing out a BFD to request using a
00250    traditional format.  For example, this is used to request that when
00251    writing out an a.out object the symbols not be hashed to eliminate
00252    duplicates.  */
00253 #define BFD_TRADITIONAL_FORMAT 0x400
00254 
00255 /* This flag indicates that the BFD contents are actually cached in
00256    memory.  If this is set, iostream points to a bfd_in_memory struct.  */
00257 #define BFD_IN_MEMORY 0x800
00258 
00259 /* The sections in this BFD specify a memory page.  */
00260 #define HAS_LOAD_PAGE 0x1000
00261 
00262 /* This BFD has been created by the linker and doesn't correspond
00263    to any input file.  */
00264 #define BFD_LINKER_CREATED 0x2000
00265 
00266 /* Symbols and relocation.  */
00267 
00268 /* A count of carsyms (canonical archive symbols).  */
00269 typedef unsigned long symindex;
00270 
00271 /* How to perform a relocation.  */
00272 typedef const struct reloc_howto_struct reloc_howto_type;
00273 
00274 #define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
00275 
00276 /* General purpose part of a symbol X;
00277    target specific parts are in libcoff.h, libaout.h, etc.  */
00278 
00279 #define bfd_get_section(x) ((x)->section)
00280 #define bfd_get_output_section(x) ((x)->section->output_section)
00281 #define bfd_set_section(x,y) ((x)->section) = (y)
00282 #define bfd_asymbol_base(x) ((x)->section->vma)
00283 #define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
00284 #define bfd_asymbol_name(x) ((x)->name)
00285 /*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
00286 #define bfd_asymbol_bfd(x) ((x)->the_bfd)
00287 #define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
00288 
00289 /* A canonical archive symbol.  */
00290 /* This is a type pun with struct ranlib on purpose!  */
00291 typedef struct carsym
00292 {
00293   char *name;
00294   file_ptr file_offset;     /* Look here to find the file.  */
00295 }
00296 carsym;                     /* To make these you call a carsymogen.  */
00297 
00298 /* Used in generating armaps (archive tables of contents).
00299    Perhaps just a forward definition would do?  */
00300 struct orl                  /* Output ranlib.  */
00301 {
00302   char **name;              /* Symbol name.  */
00303   union
00304   {
00305     file_ptr pos;
00306     bfd *abfd;
00307   } u;               /* bfd* or file position.  */
00308   int namidx;        /* Index into string table.  */
00309 };
00310 
00311 /* Linenumber stuff.  */
00312 typedef struct lineno_cache_entry
00313 {
00314   unsigned int line_number; /* Linenumber from start of function.  */
00315   union
00316   {
00317     struct bfd_symbol *sym; /* Function name.  */
00318     bfd_vma offset;                /* Offset into section.  */
00319   } u;
00320 }
00321 alent;
00322 
00323 /* Object and core file sections.  */
00324 
00325 #define       align_power(addr, align)    \
00326   (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
00327 
00328 typedef struct bfd_section *sec_ptr;
00329 
00330 #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
00331 #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
00332 #define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
00333 #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
00334 #define bfd_section_name(bfd, ptr) ((ptr)->name)
00335 #define bfd_section_size(bfd, ptr) ((ptr)->size)
00336 #define bfd_get_section_size(ptr) ((ptr)->size)
00337 #define bfd_section_vma(bfd, ptr) ((ptr)->vma)
00338 #define bfd_section_lma(bfd, ptr) ((ptr)->lma)
00339 #define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
00340 #define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
00341 #define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
00342 
00343 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
00344 
00345 #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
00346 #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
00347 #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
00348 /* Find the address one past the end of SEC.  */
00349 #define bfd_get_section_limit(bfd, sec) \
00350   (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \
00351    / bfd_octets_per_byte (bfd))
00352 
00353 /* Return TRUE if section has been discarded.  */
00354 #define elf_discarded_section(sec)                      \
00355   (!bfd_is_abs_section (sec)                                   \
00356    && bfd_is_abs_section ((sec)->output_section)        \
00357    && (sec)->sec_info_type != ELF_INFO_TYPE_MERGE              \
00358    && (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
00359 
00360 /* Forward define.  */
00361 struct stat;
00362 
00363 typedef enum bfd_print_symbol
00364 {
00365   bfd_print_symbol_name,
00366   bfd_print_symbol_more,
00367   bfd_print_symbol_all
00368 } bfd_print_symbol_type;
00369 
00370 /* Information about a symbol that nm needs.  */
00371 
00372 typedef struct _symbol_info
00373 {
00374   symvalue value;
00375   char type;
00376   const char *name;            /* Symbol name.  */
00377   unsigned char stab_type;     /* Stab type.  */
00378   char stab_other;             /* Stab other.  */
00379   short stab_desc;             /* Stab desc.  */
00380   const char *stab_name;       /* String for stab type.  */
00381 } symbol_info;
00382 
00383 /* Get the name of a stabs type code.  */
00384 
00385 extern const char *bfd_get_stab_name (int);
00386 
00387 /* Hash table routines.  There is no way to free up a hash table.  */
00388 
00389 /* An element in the hash table.  Most uses will actually use a larger
00390    structure, and an instance of this will be the first field.  */
00391 
00392 struct bfd_hash_entry
00393 {
00394   /* Next entry for this hash code.  */
00395   struct bfd_hash_entry *next;
00396   /* String being hashed.  */
00397   const char *string;
00398   /* Hash code.  This is the full hash code, not the index into the
00399      table.  */
00400   unsigned long hash;
00401 };
00402 
00403 /* A hash table.  */
00404 
00405 struct bfd_hash_table
00406 {
00407   /* The hash array.  */
00408   struct bfd_hash_entry **table;
00409   /* A function used to create new elements in the hash table.  The
00410      first entry is itself a pointer to an element.  When this
00411      function is first invoked, this pointer will be NULL.  However,
00412      having the pointer permits a hierarchy of method functions to be
00413      built each of which calls the function in the superclass.  Thus
00414      each function should be written to allocate a new block of memory
00415      only if the argument is NULL.  */
00416   struct bfd_hash_entry *(*newfunc)
00417     (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
00418    /* An objalloc for this hash table.  This is a struct objalloc *,
00419      but we use void * to avoid requiring the inclusion of objalloc.h.  */
00420   void *memory;
00421   /* The number of slots in the hash table.  */
00422   unsigned int size;
00423   /* The number of entries in the hash table.  */
00424   unsigned int count;
00425   /* The size of elements.  */
00426   unsigned int entsize;
00427   /* If non-zero, don't grow the hash table.  */
00428   unsigned int frozen:1;
00429 };
00430 
00431 /* Initialize a hash table.  */
00432 extern bfd_boolean bfd_hash_table_init
00433   (struct bfd_hash_table *,
00434    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
00435                             struct bfd_hash_table *,
00436                             const char *),
00437    unsigned int);
00438 
00439 /* Initialize a hash table specifying a size.  */
00440 extern bfd_boolean bfd_hash_table_init_n
00441   (struct bfd_hash_table *,
00442    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
00443                             struct bfd_hash_table *,
00444                             const char *),
00445    unsigned int, unsigned int);
00446 
00447 /* Free up a hash table.  */
00448 extern void bfd_hash_table_free
00449   (struct bfd_hash_table *);
00450 
00451 /* Look up a string in a hash table.  If CREATE is TRUE, a new entry
00452    will be created for this string if one does not already exist.  The
00453    COPY argument must be TRUE if this routine should copy the string
00454    into newly allocated memory when adding an entry.  */
00455 extern struct bfd_hash_entry *bfd_hash_lookup
00456   (struct bfd_hash_table *, const char *, bfd_boolean create,
00457    bfd_boolean copy);
00458 
00459 /* Replace an entry in a hash table.  */
00460 extern void bfd_hash_replace
00461   (struct bfd_hash_table *, struct bfd_hash_entry *old,
00462    struct bfd_hash_entry *nw);
00463 
00464 /* Base method for creating a hash table entry.  */
00465 extern struct bfd_hash_entry *bfd_hash_newfunc
00466   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
00467 
00468 /* Grab some space for a hash table entry.  */
00469 extern void *bfd_hash_allocate
00470   (struct bfd_hash_table *, unsigned int);
00471 
00472 /* Traverse a hash table in a random order, calling a function on each
00473    element.  If the function returns FALSE, the traversal stops.  The
00474    INFO argument is passed to the function.  */
00475 extern void bfd_hash_traverse
00476   (struct bfd_hash_table *,
00477    bfd_boolean (*) (struct bfd_hash_entry *, void *),
00478    void *info);
00479 
00480 /* Allows the default size of a hash table to be configured. New hash
00481    tables allocated using bfd_hash_table_init will be created with
00482    this size.  */
00483 extern void bfd_hash_set_default_size (bfd_size_type);
00484 
00485 /* This structure is used to keep track of stabs in sections
00486    information while linking.  */
00487 
00488 struct stab_info
00489 {
00490   /* A hash table used to hold stabs strings.  */
00491   struct bfd_strtab_hash *strings;
00492   /* The header file hash table.  */
00493   struct bfd_hash_table includes;
00494   /* The first .stabstr section.  */
00495   struct bfd_section *stabstr;
00496 };
00497 
00498 #define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
00499 
00500 /* User program access to BFD facilities.  */
00501 
00502 /* Direct I/O routines, for programs which know more about the object
00503    file than BFD does.  Use higher level routines if possible.  */
00504 
00505 extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
00506 extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
00507 extern int bfd_seek (bfd *, file_ptr, int);
00508 extern file_ptr bfd_tell (bfd *);
00509 extern int bfd_flush (bfd *);
00510 extern int bfd_stat (bfd *, struct stat *);
00511 
00512 /* Deprecated old routines.  */
00513 #if __GNUC__
00514 #define bfd_read(BUF, ELTSIZE, NITEMS, ABFD)                          \
00515   (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__),    \
00516    bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
00517 #define bfd_write(BUF, ELTSIZE, NITEMS, ABFD)                         \
00518   (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__),   \
00519    bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
00520 #else
00521 #define bfd_read(BUF, ELTSIZE, NITEMS, ABFD)                          \
00522   (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
00523    bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
00524 #define bfd_write(BUF, ELTSIZE, NITEMS, ABFD)                         \
00525   (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
00526    bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
00527 #endif
00528 extern void warn_deprecated (const char *, const char *, int, const char *);
00529 
00530 /* Cast from const char * to char * so that caller can assign to
00531    a char * without a warning.  */
00532 #define bfd_get_filename(abfd) ((char *) (abfd)->filename)
00533 #define bfd_get_cacheable(abfd) ((abfd)->cacheable)
00534 #define bfd_get_format(abfd) ((abfd)->format)
00535 #define bfd_get_target(abfd) ((abfd)->xvec->name)
00536 #define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
00537 #define bfd_family_coff(abfd) \
00538   (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
00539    bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
00540 #define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
00541 #define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
00542 #define bfd_header_big_endian(abfd) \
00543   ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
00544 #define bfd_header_little_endian(abfd) \
00545   ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
00546 #define bfd_get_file_flags(abfd) ((abfd)->flags)
00547 #define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
00548 #define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
00549 #define bfd_my_archive(abfd) ((abfd)->my_archive)
00550 #define bfd_has_map(abfd) ((abfd)->has_armap)
00551 
00552 #define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
00553 #define bfd_usrdata(abfd) ((abfd)->usrdata)
00554 
00555 #define bfd_get_start_address(abfd) ((abfd)->start_address)
00556 #define bfd_get_symcount(abfd) ((abfd)->symcount)
00557 #define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
00558 #define bfd_count_sections(abfd) ((abfd)->section_count)
00559 
00560 #define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
00561 
00562 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
00563 
00564 #define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
00565 
00566 extern bfd_boolean bfd_cache_close
00567   (bfd *abfd);
00568 /* NB: This declaration should match the autogenerated one in libbfd.h.  */
00569 
00570 extern bfd_boolean bfd_cache_close_all (void);
00571 
00572 extern bfd_boolean bfd_record_phdr
00573   (bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
00574    bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **);
00575 
00576 /* Byte swapping routines.  */
00577 
00578 bfd_uint64_t bfd_getb64 (const void *);
00579 bfd_uint64_t bfd_getl64 (const void *);
00580 bfd_int64_t bfd_getb_signed_64 (const void *);
00581 bfd_int64_t bfd_getl_signed_64 (const void *);
00582 bfd_vma bfd_getb32 (const void *);
00583 bfd_vma bfd_getl32 (const void *);
00584 bfd_signed_vma bfd_getb_signed_32 (const void *);
00585 bfd_signed_vma bfd_getl_signed_32 (const void *);
00586 bfd_vma bfd_getb16 (const void *);
00587 bfd_vma bfd_getl16 (const void *);
00588 bfd_signed_vma bfd_getb_signed_16 (const void *);
00589 bfd_signed_vma bfd_getl_signed_16 (const void *);
00590 void bfd_putb64 (bfd_uint64_t, void *);
00591 void bfd_putl64 (bfd_uint64_t, void *);
00592 void bfd_putb32 (bfd_vma, void *);
00593 void bfd_putl32 (bfd_vma, void *);
00594 void bfd_putb16 (bfd_vma, void *);
00595 void bfd_putl16 (bfd_vma, void *);
00596 
00597 /* Byte swapping routines which take size and endiannes as arguments.  */
00598 
00599 bfd_uint64_t bfd_get_bits (const void *, int, bfd_boolean);
00600 void bfd_put_bits (bfd_uint64_t, void *, int, bfd_boolean);
00601 
00602 extern bfd_boolean bfd_section_already_linked_table_init (void);
00603 extern void bfd_section_already_linked_table_free (void);
00604 
00605 /* Externally visible ECOFF routines.  */
00606 
00607 #if defined(__STDC__) || defined(ALMOST_STDC)
00608 struct ecoff_debug_info;
00609 struct ecoff_debug_swap;
00610 struct ecoff_extr;
00611 struct bfd_symbol;
00612 struct bfd_link_info;
00613 struct bfd_link_hash_entry;
00614 struct bfd_elf_version_tree;
00615 #endif
00616 extern bfd_vma bfd_ecoff_get_gp_value
00617   (bfd * abfd);
00618 extern bfd_boolean bfd_ecoff_set_gp_value
00619   (bfd *abfd, bfd_vma gp_value);
00620 extern bfd_boolean bfd_ecoff_set_regmasks
00621   (bfd *abfd, unsigned long gprmask, unsigned long fprmask,
00622    unsigned long *cprmask);
00623 extern void *bfd_ecoff_debug_init
00624   (bfd *output_bfd, struct ecoff_debug_info *output_debug,
00625    const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
00626 extern void bfd_ecoff_debug_free
00627   (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
00628    const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
00629 extern bfd_boolean bfd_ecoff_debug_accumulate
00630   (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
00631    const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
00632    struct ecoff_debug_info *input_debug,
00633    const struct ecoff_debug_swap *input_swap, struct bfd_link_info *);
00634 extern bfd_boolean bfd_ecoff_debug_accumulate_other
00635   (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
00636    const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
00637    struct bfd_link_info *);
00638 extern bfd_boolean bfd_ecoff_debug_externals
00639   (bfd *abfd, struct ecoff_debug_info *debug,
00640    const struct ecoff_debug_swap *swap, bfd_boolean relocatable,
00641    bfd_boolean (*get_extr) (struct bfd_symbol *, struct ecoff_extr *),
00642    void (*set_index) (struct bfd_symbol *, bfd_size_type));
00643 extern bfd_boolean bfd_ecoff_debug_one_external
00644   (bfd *abfd, struct ecoff_debug_info *debug,
00645    const struct ecoff_debug_swap *swap, const char *name,
00646    struct ecoff_extr *esym);
00647 extern bfd_size_type bfd_ecoff_debug_size
00648   (bfd *abfd, struct ecoff_debug_info *debug,
00649    const struct ecoff_debug_swap *swap);
00650 extern bfd_boolean bfd_ecoff_write_debug
00651   (bfd *abfd, struct ecoff_debug_info *debug,
00652    const struct ecoff_debug_swap *swap, file_ptr where);
00653 extern bfd_boolean bfd_ecoff_write_accumulated_debug
00654   (void *handle, bfd *abfd, struct ecoff_debug_info *debug,
00655    const struct ecoff_debug_swap *swap,
00656    struct bfd_link_info *info, file_ptr where);
00657 
00658 /* Externally visible ELF routines.  */
00659 
00660 struct bfd_link_needed_list
00661 {
00662   struct bfd_link_needed_list *next;
00663   bfd *by;
00664   const char *name;
00665 };
00666 
00667 enum dynamic_lib_link_class {
00668   DYN_NORMAL = 0,
00669   DYN_AS_NEEDED = 1,
00670   DYN_DT_NEEDED = 2,
00671   DYN_NO_ADD_NEEDED = 4,
00672   DYN_NO_NEEDED = 8
00673 };
00674 
00675 enum notice_asneeded_action {
00676   notice_as_needed,
00677   notice_not_needed,
00678   notice_needed
00679 };
00680 
00681 extern bfd_boolean bfd_elf_record_link_assignment
00682   (bfd *, struct bfd_link_info *, const char *, bfd_boolean,
00683    bfd_boolean);
00684 extern struct bfd_link_needed_list *bfd_elf_get_needed_list
00685   (bfd *, struct bfd_link_info *);
00686 extern bfd_boolean bfd_elf_get_bfd_needed_list
00687   (bfd *, struct bfd_link_needed_list **);
00688 extern bfd_boolean bfd_elf_size_dynamic_sections
00689   (bfd *, const char *, const char *, const char *, const char * const *,
00690    struct bfd_link_info *, struct bfd_section **,
00691    struct bfd_elf_version_tree *);
00692 extern bfd_boolean bfd_elf_size_dynsym_hash_dynstr
00693   (bfd *, struct bfd_link_info *);
00694 extern void bfd_elf_set_dt_needed_name
00695   (bfd *, const char *);
00696 extern const char *bfd_elf_get_dt_soname
00697   (bfd *);
00698 extern void bfd_elf_set_dyn_lib_class
00699   (bfd *, enum dynamic_lib_link_class);
00700 extern int bfd_elf_get_dyn_lib_class
00701   (bfd *);
00702 extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
00703   (bfd *, struct bfd_link_info *);
00704 extern bfd_boolean bfd_elf_discard_info
00705   (bfd *, struct bfd_link_info *);
00706 extern unsigned int _bfd_elf_default_action_discarded
00707   (struct bfd_section *);
00708 
00709 /* Return an upper bound on the number of bytes required to store a
00710    copy of ABFD's program header table entries.  Return -1 if an error
00711    occurs; bfd_get_error will return an appropriate code.  */
00712 extern long bfd_get_elf_phdr_upper_bound
00713   (bfd *abfd);
00714 
00715 /* Copy ABFD's program header table entries to *PHDRS.  The entries
00716    will be stored as an array of Elf_Internal_Phdr structures, as
00717    defined in include/elf/internal.h.  To find out how large the
00718    buffer needs to be, call bfd_get_elf_phdr_upper_bound.
00719 
00720    Return the number of program header table entries read, or -1 if an
00721    error occurs; bfd_get_error will return an appropriate code.  */
00722 extern int bfd_get_elf_phdrs
00723   (bfd *abfd, void *phdrs);
00724 
00725 /* Create a new BFD as if by bfd_openr.  Rather than opening a file,
00726    reconstruct an ELF file by reading the segments out of remote memory
00727    based on the ELF file header at EHDR_VMA and the ELF program headers it
00728    points to.  If not null, *LOADBASEP is filled in with the difference
00729    between the VMAs from which the segments were read, and the VMAs the
00730    file headers (and hence BFD's idea of each section's VMA) put them at.
00731 
00732    The function TARGET_READ_MEMORY is called to copy LEN bytes from the
00733    remote memory at target address VMA into the local buffer at MYADDR; it
00734    should return zero on success or an `errno' code on failure.  TEMPL must
00735    be a BFD for an ELF target with the word size and byte order found in
00736    the remote memory.  */
00737 extern bfd *bfd_elf_bfd_from_remote_memory
00738   (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
00739    int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len));
00740 
00741 /* Return the arch_size field of an elf bfd, or -1 if not elf.  */
00742 extern int bfd_get_arch_size
00743   (bfd *);
00744 
00745 /* Return TRUE if address "naturally" sign extends, or -1 if not elf.  */
00746 extern int bfd_get_sign_extend_vma
00747   (bfd *);
00748 
00749 extern struct bfd_section *_bfd_elf_tls_setup
00750   (bfd *, struct bfd_link_info *);
00751 
00752 extern void _bfd_fix_excluded_sec_syms
00753   (bfd *, struct bfd_link_info *);
00754 
00755 extern unsigned bfd_m68k_mach_to_features (int);
00756 
00757 extern int bfd_m68k_features_to_mach (unsigned);
00758 
00759 extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
00760   (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
00761    char **);
00762 
00763 extern bfd_boolean bfd_bfin_elf32_create_embedded_relocs
00764   (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
00765    char **);
00766 
00767 /* SunOS shared library support routines for the linker.  */
00768 
00769 extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
00770   (bfd *, struct bfd_link_info *);
00771 extern bfd_boolean bfd_sunos_record_link_assignment
00772   (bfd *, struct bfd_link_info *, const char *);
00773 extern bfd_boolean bfd_sunos_size_dynamic_sections
00774   (bfd *, struct bfd_link_info *, struct bfd_section **,
00775    struct bfd_section **, struct bfd_section **);
00776 
00777 /* Linux shared library support routines for the linker.  */
00778 
00779 extern bfd_boolean bfd_i386linux_size_dynamic_sections
00780   (bfd *, struct bfd_link_info *);
00781 extern bfd_boolean bfd_m68klinux_size_dynamic_sections
00782   (bfd *, struct bfd_link_info *);
00783 extern bfd_boolean bfd_sparclinux_size_dynamic_sections
00784   (bfd *, struct bfd_link_info *);
00785 
00786 /* mmap hacks */
00787 
00788 struct _bfd_window_internal;
00789 typedef struct _bfd_window_internal bfd_window_internal;
00790 
00791 typedef struct _bfd_window
00792 {
00793   /* What the user asked for.  */
00794   void *data;
00795   bfd_size_type size;
00796   /* The actual window used by BFD.  Small user-requested read-only
00797      regions sharing a page may share a single window into the object
00798      file.  Read-write versions shouldn't until I've fixed things to
00799      keep track of which portions have been claimed by the
00800      application; don't want to give the same region back when the
00801      application wants two writable copies!  */
00802   struct _bfd_window_internal *i;
00803 }
00804 bfd_window;
00805 
00806 extern void bfd_init_window
00807   (bfd_window *);
00808 extern void bfd_free_window
00809   (bfd_window *);
00810 extern bfd_boolean bfd_get_file_window
00811   (bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean);
00812 
00813 /* XCOFF support routines for the linker.  */
00814 
00815 extern bfd_boolean bfd_xcoff_link_record_set
00816   (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_size_type);
00817 extern bfd_boolean bfd_xcoff_import_symbol
00818   (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_vma,
00819    const char *, const char *, const char *, unsigned int);
00820 extern bfd_boolean bfd_xcoff_export_symbol
00821   (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
00822 extern bfd_boolean bfd_xcoff_link_count_reloc
00823   (bfd *, struct bfd_link_info *, const char *);
00824 extern bfd_boolean bfd_xcoff_record_link_assignment
00825   (bfd *, struct bfd_link_info *, const char *);
00826 extern bfd_boolean bfd_xcoff_size_dynamic_sections
00827   (bfd *, struct bfd_link_info *, const char *, const char *,
00828    unsigned long, unsigned long, unsigned long, bfd_boolean,
00829    int, bfd_boolean, bfd_boolean, struct bfd_section **, bfd_boolean);
00830 extern bfd_boolean bfd_xcoff_link_generate_rtinit
00831   (bfd *, const char *, const char *, bfd_boolean);
00832 
00833 /* XCOFF support routines for ar.  */
00834 extern bfd_boolean bfd_xcoff_ar_archive_set_magic
00835   (bfd *, char *);
00836 
00837 /* Externally visible COFF routines.  */
00838 
00839 #if defined(__STDC__) || defined(ALMOST_STDC)
00840 struct internal_syment;
00841 union internal_auxent;
00842 #endif
00843 
00844 extern bfd_boolean bfd_coff_get_syment
00845   (bfd *, struct bfd_symbol *, struct internal_syment *);
00846 
00847 extern bfd_boolean bfd_coff_get_auxent
00848   (bfd *, struct bfd_symbol *, int, union internal_auxent *);
00849 
00850 extern bfd_boolean bfd_coff_set_symbol_class
00851   (bfd *, struct bfd_symbol *, unsigned int);
00852 
00853 extern bfd_boolean bfd_m68k_coff_create_embedded_relocs
00854   (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **);
00855 
00856 /* ARM VFP11 erratum workaround support.  */
00857 typedef enum
00858 {
00859   BFD_ARM_VFP11_FIX_DEFAULT,
00860   BFD_ARM_VFP11_FIX_NONE,
00861   BFD_ARM_VFP11_FIX_SCALAR,
00862   BFD_ARM_VFP11_FIX_VECTOR
00863 } bfd_arm_vfp11_fix;
00864 
00865 extern void bfd_elf32_arm_init_maps
00866   (bfd *);
00867 
00868 extern void bfd_elf32_arm_set_vfp11_fix
00869   (bfd *, struct bfd_link_info *);
00870 
00871 extern bfd_boolean bfd_elf32_arm_vfp11_erratum_scan
00872   (bfd *, struct bfd_link_info *);
00873 
00874 extern void bfd_elf32_arm_vfp11_fix_veneer_locations
00875   (bfd *, struct bfd_link_info *);
00876 
00877 /* ARM Interworking support.  Called from linker.  */
00878 extern bfd_boolean bfd_arm_allocate_interworking_sections
00879   (struct bfd_link_info *);
00880 
00881 extern bfd_boolean bfd_arm_process_before_allocation
00882   (bfd *, struct bfd_link_info *, int);
00883 
00884 extern bfd_boolean bfd_arm_get_bfd_for_interworking
00885   (bfd *, struct bfd_link_info *);
00886 
00887 /* PE ARM Interworking support.  Called from linker.  */
00888 extern bfd_boolean bfd_arm_pe_allocate_interworking_sections
00889   (struct bfd_link_info *);
00890 
00891 extern bfd_boolean bfd_arm_pe_process_before_allocation
00892   (bfd *, struct bfd_link_info *, int);
00893 
00894 extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking
00895   (bfd *, struct bfd_link_info *);
00896 
00897 /* ELF ARM Interworking support.  Called from linker.  */
00898 extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections
00899   (struct bfd_link_info *);
00900 
00901 extern bfd_boolean bfd_elf32_arm_process_before_allocation
00902   (bfd *, struct bfd_link_info *);
00903 
00904 void bfd_elf32_arm_set_target_relocs
00905   (bfd *, struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix,
00906    int, int);
00907 
00908 extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
00909   (bfd *, struct bfd_link_info *);
00910 
00911 extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd
00912   (bfd *, struct bfd_link_info *);
00913 
00914 /* ELF ARM mapping symbol support */
00915 #define BFD_ARM_SPECIAL_SYM_TYPE_MAP      (1 << 0)
00916 #define BFD_ARM_SPECIAL_SYM_TYPE_TAG      (1 << 1)
00917 #define BFD_ARM_SPECIAL_SYM_TYPE_OTHER  (1 << 2)
00918 #define BFD_ARM_SPECIAL_SYM_TYPE_ANY      (~0)
00919 extern bfd_boolean bfd_is_arm_special_symbol_name
00920   (const char * name, int type);
00921 
00922 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
00923 
00924 /* ARM Note section processing.  */
00925 extern bfd_boolean bfd_arm_merge_machines
00926   (bfd *, bfd *);
00927 
00928 extern bfd_boolean bfd_arm_update_notes
00929   (bfd *, const char *);
00930 
00931 extern unsigned int bfd_arm_get_mach_from_notes
00932   (bfd *, const char *);
00933 
00934 /* TI COFF load page support.  */
00935 extern void bfd_ticoff_set_section_load_page
00936   (struct bfd_section *, int);
00937 
00938 extern int bfd_ticoff_get_section_load_page
00939   (struct bfd_section *);
00940 
00941 /* H8/300 functions.  */
00942 extern bfd_vma bfd_h8300_pad_address
00943   (bfd *, bfd_vma);
00944 
00945 /* IA64 Itanium code generation.  Called from linker.  */
00946 extern void bfd_elf32_ia64_after_parse
00947   (int);
00948 
00949 extern void bfd_elf64_ia64_after_parse
00950   (int);
00951 
00952 /* This structure is used for a comdat section, as in PE.  A comdat
00953    section is associated with a particular symbol.  When the linker
00954    sees a comdat section, it keeps only one of the sections with a
00955    given name and associated with a given symbol.  */
00956 
00957 struct coff_comdat_info
00958 {
00959   /* The name of the symbol associated with a comdat section.  */
00960   const char *name;
00961 
00962   /* The local symbol table index of the symbol associated with a
00963      comdat section.  This is only meaningful to the object file format
00964      specific code; it is not an index into the list returned by
00965      bfd_canonicalize_symtab.  */
00966   long symbol;
00967 };
00968 
00969 extern struct coff_comdat_info *bfd_coff_get_comdat_section
00970   (bfd *, struct bfd_section *);
00971