/* Main header file for the bfd library -- portable access to object files.
- Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
Contributed by Cygnus Support.
** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them;
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* bfd.h -- The only header file required by users of the bfd library
#ifndef __BFD_H_SEEN__
#define __BFD_H_SEEN__
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "ansidecl.h"
#include "obstack.h"
-#define BFD_VERSION "2.2"
-
+/* These two lines get substitutions done by commands in Makefile.in. */
+#define BFD_VERSION "@VERSION@"
#define BFD_ARCH_SIZE @WORDSIZE@
+#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
#if BFD_ARCH_SIZE >= 64
#define BFD64
#endif
#endif
-/* 64-bit type definition (if any) from bfd's sysdep.h goes here */
-
-
/* forward declaration */
typedef struct _bfd bfd;
/* typedef enum boolean {false, true} boolean; */
/* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h> -fnf */
/* It gets worse if the host also defines a true/false enum... -sts */
+/* And even worse if your compiler has built-in boolean types... -law */
+#if defined (__GNUG__) && (__GNUC_MINOR__ > 5)
+#define TRUE_FALSE_ALREADY_DEFINED
+#endif
#ifndef TRUE_FALSE_ALREADY_DEFINED
typedef enum bfd_boolean {false, true} boolean;
#define BFD_TRUE_FALSE
#else
-typedef enum bfd_boolean {bfd_false, bfd_true} boolean;
+/* Use enum names that will appear nowhere else. */
+typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
#endif
/* A pointer to a position in a file. */
/* typedef off_t file_ptr; */
typedef long int file_ptr;
-/* Support for different sizes of target format ints and addresses. If the
- host implements 64-bit values, it defines HOST_64_BIT to be the appropriate
- type. Otherwise, this code will fall back on gcc's "long long" type if gcc
- is being used. HOST_64_BIT must be defined in such a way as to be a valid
- type name by itself or with "unsigned" prefixed. It should be a signed
- type by itself.
+/* Support for different sizes of target format ints and addresses.
+ If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
+ set to 1 above. Otherwise, if gcc is being used, this code will
+ use gcc's "long long" type. Otherwise, the compilation will fail
+ if 64-bit targets are requested. */
- If neither is the case, then compilation will fail if 64-bit targets are
- requested. If you don't request any 64-bit targets, you should be safe. */
+#ifdef BFD64
-#ifdef BFD64
-
-#if defined (__GNUC__) && !defined (HOST_64_BIT)
-#define HOST_64_BIT long long
-typedef HOST_64_BIT int64_type;
-typedef unsigned HOST_64_BIT uint64_type;
-#endif
+#ifndef BFD_HOST_64_BIT
+#if BFD_HOST_64BIT_LONG
+#define BFD_HOST_64_BIT long
+#else
+#ifdef __GNUC__
+#define BFD_HOST_64_BIT long long
+#endif /* defined (__GNUC__) */
+#endif /* ! BFD_HOST_64BIT_LONG */
+#endif /* ! defined (BFD_HOST_64_BIT) */
-#if !defined (uint64_type) && defined (__GNUC__)
-#define uint64_type unsigned long long
-#define int64_type long long
-#endif
-#ifndef uint64_typeLOW
-#define uint64_typeLOW(x) ((unsigned long)(((x) & 0xffffffff)))
-#define uint64_typeHIGH(x) ((unsigned long)(((x) >> 32) & 0xffffffff))
-#endif
+typedef unsigned BFD_HOST_64_BIT bfd_vma;
+typedef BFD_HOST_64_BIT bfd_signed_vma;
+typedef unsigned BFD_HOST_64_BIT bfd_size_type;
+typedef unsigned BFD_HOST_64_BIT symvalue;
-typedef unsigned HOST_64_BIT bfd_vma;
-typedef HOST_64_BIT bfd_signed_vma;
-typedef unsigned HOST_64_BIT bfd_size_type;
-typedef unsigned HOST_64_BIT symvalue;
#ifndef fprintf_vma
+#if BFD_HOST_64BIT_LONG
+#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
+#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
+#else
+#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
+#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
#define fprintf_vma(s,x) \
- fprintf(s,"%08lx%08lx", uint64_typeHIGH(x), uint64_typeLOW(x))
+ fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
#define sprintf_vma(s,x) \
- sprintf(s,"%08lx%08lx", uint64_typeHIGH(x), uint64_typeLOW(x))
+ sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
#endif
+#endif
+
#else /* not BFD64 */
/* Represent a target address. Also used as a generic unsigned type
#define printf_vma(x) fprintf_vma(stdout,x)
typedef unsigned int flagword; /* 32 bits of flags */
+typedef unsigned char bfd_byte;
\f
/** File formats */
#define D_PAGED 0x100
/* BFD is relaxable (this means that bfd_relax_section may be able to
- do something). */
+ do something) (sometimes bfd_relax_section can do something even if
+ this is not set). */
#define BFD_IS_RELAXABLE 0x200
+
+/* This may be set before writing out a BFD to request using a
+ traditional format. For example, this is used to request that when
+ writing out an a.out object the symbols not be hashed to eliminate
+ duplicates. */
+#define BFD_TRADITIONAL_FORMAT 0x400
\f
/* symbols and relocation */
/* A count of carsyms (canonical archive symbols). */
typedef unsigned long symindex;
+/* How to perform a relocation. */
+typedef const struct reloc_howto_struct reloc_howto_type;
+
#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
/* General purpose part of a symbol X;
file_ptr pos; /* bfd* or file position */
int namidx; /* index into string table */
};
-
\f
/* Linenumber stuff */
\f
/* object and core file sections */
-
#define align_power(addr, align) \
( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = true), true)
+#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
PARAMS ((struct bfd_hash_table *, const char *, boolean create,
boolean copy));
+/* Replace an entry in a hash table. */
+extern void bfd_hash_replace
+ PARAMS ((struct bfd_hash_table *, struct bfd_hash_entry *old,
+ struct bfd_hash_entry *nw));
+
/* Base method for creating a hash table entry. */
extern struct bfd_hash_entry *bfd_hash_newfunc
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
PTR),
PTR info));
\f
-/* The code that implements targets can initialize a jump table with this
- macro. It must name all its routines the same way (a prefix plus
- the standard routine suffix), or it must #define the routines that
- are not so named, before calling JUMP_TABLE in the initializer. */
-
/* Semi-portable string concatenation in cpp.
The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors.
The problem is, "32_" is not a valid preprocessing token, and we don't
#endif
#endif
-#define JUMP_TABLE(NAME)\
-CAT(NAME,_core_file_failing_command),\
-CAT(NAME,_core_file_failing_signal),\
-CAT(NAME,_core_file_matches_executable_p),\
-CAT(NAME,_slurp_armap),\
-CAT(NAME,_slurp_extended_name_table),\
-CAT(NAME,_truncate_arname),\
-CAT(NAME,_write_armap),\
-CAT(NAME,_close_and_cleanup),\
-CAT(NAME,_set_section_contents),\
-CAT(NAME,_get_section_contents),\
-CAT(NAME,_new_section_hook),\
-CAT(NAME,_get_symtab_upper_bound),\
-CAT(NAME,_get_symtab),\
-CAT(NAME,_get_reloc_upper_bound),\
-CAT(NAME,_canonicalize_reloc),\
-CAT(NAME,_make_empty_symbol),\
-CAT(NAME,_print_symbol),\
-CAT(NAME,_get_symbol_info),\
-CAT(NAME,_get_lineno),\
-CAT(NAME,_set_arch_mach),\
-CAT(NAME,_openr_next_archived_file),\
-CAT(NAME,_find_nearest_line),\
-CAT(NAME,_generic_stat_arch_elt),\
-CAT(NAME,_sizeof_headers),\
-CAT(NAME,_bfd_debug_info_start),\
-CAT(NAME,_bfd_debug_info_end),\
-CAT(NAME,_bfd_debug_info_accumulate),\
-CAT(NAME,_bfd_get_relocated_section_contents),\
-CAT(NAME,_bfd_relax_section),\
-CAT(NAME,_bfd_reloc_type_lookup),\
-CAT(NAME,_bfd_make_debug_symbol),\
-CAT(NAME,_bfd_link_hash_table_create),\
-CAT(NAME,_bfd_link_add_symbols),\
-CAT(NAME,_bfd_final_link)
-
#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table
-
\f
/* User program access to BFD facilities */
+/* Direct I/O routines, for programs which know more about the object
+ file than BFD does. Use higher level routines if possible. */
+
+extern bfd_size_type bfd_read
+ PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
+extern bfd_size_type bfd_write
+ PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
+extern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction));
+extern long bfd_tell PARAMS ((bfd *abfd));
+extern int bfd_flush PARAMS ((bfd *abfd));
+extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
+
+
/* Cast from const char * to char * so that caller can assign to
a char * without a warning. */
#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
-#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (bool)), true)
+#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean)(bool)), true)
/* Byte swapping routines. */
void bfd_putl32 PARAMS ((bfd_vma, unsigned char *));
void bfd_putb16 PARAMS ((bfd_vma, unsigned char *));
void bfd_putl16 PARAMS ((bfd_vma, unsigned char *));
+\f
+/* Externally visible ECOFF routines. */
-/* ECOFF linking routines. */
#if defined(__STDC__) || defined(ALMOST_STDC)
struct ecoff_debug_info;
struct ecoff_debug_swap;
struct symbol_cache_entry;
struct bfd_link_info;
#endif
+extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd));
+extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value));
+extern boolean bfd_ecoff_set_regmasks
+ PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask,
+ unsigned long *cprmask));
extern PTR bfd_ecoff_debug_init
PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug,
const struct ecoff_debug_swap *output_swap,
PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug,
const struct ecoff_debug_swap *swap,
struct bfd_link_info *info, file_ptr where));
+extern boolean bfd_mips_ecoff_create_embedded_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
+ char **));
+
+/* Externally visible ELF routines. */
+
+extern boolean bfd_elf32_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
+extern boolean bfd_elf64_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
+struct bfd_elf_link_needed_list
+{
+ struct bfd_elf_link_needed_list *next;
+ bfd *by;
+ const char *name;
+};
+extern struct bfd_elf_link_needed_list *bfd_elf_get_needed_list
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean bfd_elf32_size_dynamic_sections
+ PARAMS ((bfd *, const char *, const char *, boolean,
+ struct bfd_link_info *, struct sec **));
+extern boolean bfd_elf64_size_dynamic_sections
+ PARAMS ((bfd *, const char *, const char *, boolean,
+ struct bfd_link_info *, struct sec **));
+extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *));
+
+/* SunOS shared library support routines for the linker. */
+
+extern boolean bfd_sunos_record_link_assignment
+ PARAMS ((bfd *, struct bfd_link_info *, const char *));
+extern boolean bfd_sunos_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *, struct sec **, struct sec **,
+ struct sec **));
+
+/* Linux shared library support routines for the linker. */
+
+extern boolean bfd_linux_size_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
/* And more from the source. */