force me to change it. */
/* 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 */
+#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;
+#endif
/* A pointer to a position in a file. */
/* FIXME: This should be using off_t from <sys/types.h>.
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
+ host implements 64-bit values, it defines BFD_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
+ is being used. BFD_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.
#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;
+#if defined (__GNUC__) && !defined (BFD_HOST_64_BIT)
+#define BFD_HOST_64_BIT long long
+typedef BFD_HOST_64_BIT int64_type;
+typedef unsigned BFD_HOST_64_BIT uint64_type;
#endif
#if !defined (uint64_type) && defined (__GNUC__)
#define uint64_type unsigned long long
#define int64_type long long
-#define uint64_typeLOW(x) (unsigned long)(((x) & 0xffffffff))
-#define uint64_typeHIGH(x) (unsigned long)(((x) >> 32) & 0xffffffff)
+#endif
+#ifndef uint64_typeLOW
+#define uint64_typeLOW(x) ((unsigned long)(((x) & 0xffffffff)))
+#define uint64_typeHIGH(x) ((unsigned long)(((x) >> 32) & 0xffffffff))
#endif
-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;
+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;
+#ifndef fprintf_vma
#define fprintf_vma(s,x) \
- fprintf(s,"%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x))
+ fprintf(s,"%08lx%08lx", uint64_typeHIGH(x), uint64_typeLOW(x))
#define sprintf_vma(s,x) \
- sprintf(s,"%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x))
+ sprintf(s,"%08lx%08lx", uint64_typeHIGH(x), uint64_typeLOW(x))
+#endif
#else /* not BFD64 */
/* Represent a target address. Also used as a generic unsigned type
\f
/* symbols and relocation */
+/* A count of carsyms (canonical archive symbols). */
typedef unsigned long symindex;
#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
-typedef enum bfd_symclass {
- bfd_symclass_unknown = 0,
- bfd_symclass_fcommon, /* fortran common symbols */
- bfd_symclass_global, /* global symbol, what a surprise */
- bfd_symclass_debugger, /* some debugger symbol */
- bfd_symclass_undefined /* none known */
- } symclass;
-
-
-/* general purpose part of a symbol;
- target specific parts will be found in libcoff.h, liba.out.h etc */
-
+/* General purpose part of a symbol X;
+ target specific parts are in libcoff.h, libaout.h, etc. */
#define bfd_get_section(x) ((x)->section)
#define bfd_get_output_section(x) ((x)->section->output_section)
#define bfd_asymbol_bfd(x) ((x)->the_bfd)
#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
+/* A canonical archive symbol. */
/* This is a type pun with struct ranlib on purpose! */
typedef struct carsym {
char *name;
} carsym; /* to make these you call a carsymogen */
-/* Used in generating armaps. Perhaps just a forward definition would do? */
+/* Used in generating armaps (archive tables of contents).
+ Perhaps just a forward definition would do? */
struct orl { /* output ranlib */
char **name; /* symbol name */
file_ptr pos; /* bfd* or file position */
typedef struct lineno_cache_entry {
unsigned int line_number; /* Linenumber from start of function*/
union {
- struct symbol_cache_entry *sym; /* Function name */
+ struct symbol_cache_entry *sym; /* Function name */
unsigned long offset; /* Offset into section */
} u;
} alent;
typedef struct stat stat_type;
\f
-/** Error handling */
-
-typedef enum bfd_error {
- no_error = 0, system_call_error, invalid_target,
- wrong_format, invalid_operation, no_memory,
- no_symbols, no_relocation_info,
- no_more_archived_files, malformed_archive,
- symbol_not_found, file_not_recognized,
- file_ambiguously_recognized, no_contents,
- bfd_error_nonrepresentable_section,
- no_debug_section, bad_value,
-
- /* An input file is shorter than expected. */
- file_truncated,
-
- invalid_error_code} bfd_ec;
-
-extern bfd_ec bfd_error;
-struct reloc_cache_entry;
-struct bfd_seclet;
-
-
-typedef struct bfd_error_vector {
- void (* nonrepresentable_section ) PARAMS ((CONST bfd *CONST abfd,
- CONST char *CONST name));
- void (* undefined_symbol) PARAMS ((CONST struct reloc_cache_entry *rel,
- CONST struct bfd_seclet *sec));
- void (* reloc_value_truncated) PARAMS ((CONST struct
- reloc_cache_entry *rel,
- struct bfd_seclet *sec));
-
- void (* reloc_dangerous) PARAMS ((CONST struct reloc_cache_entry *rel,
- CONST struct bfd_seclet *sec));
-
-} bfd_error_vector_type;
-
-CONST char *bfd_errmsg PARAMS ((bfd_ec error_tag));
-void bfd_perror PARAMS ((CONST char *message));
-\f
-
typedef enum bfd_print_symbol
{
bfd_print_symbol_name,
bfd_print_symbol_all
} bfd_print_symbol_type;
-\f
/* Information about a symbol that nm needs. */
typedef struct _symbol_info
{
symvalue value;
- char type; /* */
+ char type;
CONST char *name; /* Symbol name. */
char stab_other; /* Unused. */
short stab_desc; /* Info for N_TYPE. */
CONST char *stab_name;
} symbol_info;
\f
+/* Hash table routines. There is no way to free up a hash table. */
+
+/* An element in the hash table. Most uses will actually use a larger
+ structure, and an instance of this will be the first field. */
+
+struct bfd_hash_entry
+{
+ /* Next entry for this hash code. */
+ struct bfd_hash_entry *next;
+ /* String being hashed. */
+ const char *string;
+ /* Hash code. This is the full hash code, not the index into the
+ table. */
+ unsigned long hash;
+};
+
+/* A hash table. */
+
+struct bfd_hash_table
+{
+ /* The hash array. */
+ struct bfd_hash_entry **table;
+ /* The number of slots in the hash table. */
+ unsigned int size;
+ /* A function used to create new elements in the hash table. The
+ first entry is itself a pointer to an element. When this
+ function is first invoked, this pointer will be NULL. However,
+ having the pointer permits a hierarchy of method functions to be
+ built each of which calls the function in the superclass. Thus
+ each function should be written to allocate a new block of memory
+ only if the argument is NULL. */
+ struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *));
+ /* An obstack for this hash table. */
+ struct obstack memory;
+};
+
+/* Initialize a hash table. */
+extern boolean bfd_hash_table_init
+ PARAMS ((struct bfd_hash_table *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
+
+/* Initialize a hash table specifying a size. */
+extern boolean bfd_hash_table_init_n
+ PARAMS ((struct bfd_hash_table *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *),
+ unsigned int size));
+
+/* Free up a hash table. */
+extern void bfd_hash_table_free PARAMS ((struct bfd_hash_table *));
+
+/* Look up a string in a hash table. If CREATE is true, a new entry
+ will be created for this string if one does not already exist. The
+ COPY argument must be true if this routine should copy the string
+ into newly allocated memory when adding an entry. */
+extern struct bfd_hash_entry *bfd_hash_lookup
+ PARAMS ((struct bfd_hash_table *, const char *, boolean create,
+ boolean copy));
+
+/* 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 *,
+ const char *));
+
+/* Grab some space for a hash table entry. */
+extern PTR bfd_hash_allocate PARAMS ((struct bfd_hash_table *,
+ unsigned int));
+
+/* Traverse a hash table in a random order, calling a function on each
+ element. If the function returns false, the traversal stops. The
+ INFO argument is passed to the function. */
+extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *,
+ boolean (*) (struct bfd_hash_entry *,
+ 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
#define CAT3(a,b,c) a##b##c
#define CAT4(a,b,c,d) a##b##c##d
#else
-#ifdef __STDC__
+#if defined(__STDC__) || defined(ALMOST_STDC)
#define CAT(a,b) a##b
#define CAT3(a,b,c) a##b##c
#define XCAT2(a,b) CAT(a,b)
CAT(NAME,_bfd_debug_info_accumulate),\
CAT(NAME,_bfd_get_relocated_section_contents),\
CAT(NAME,_bfd_relax_section),\
-CAT(NAME,_bfd_seclet_link),\
CAT(NAME,_bfd_reloc_type_lookup),\
-CAT(NAME,_bfd_make_debug_symbol)
+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
/* Byte swapping routines. */
-bfd_vma bfd_getb64 PARAMS ((unsigned char *));
-bfd_vma bfd_getl64 PARAMS ((unsigned char *));
-bfd_signed_vma bfd_getb_signed_64 PARAMS ((unsigned char *));
-bfd_signed_vma bfd_getl_signed_64 PARAMS ((unsigned char *));
-bfd_vma bfd_getb32 PARAMS ((unsigned char *));
-bfd_vma bfd_getl32 PARAMS ((unsigned char *));
-bfd_signed_vma bfd_getb_signed_32 PARAMS ((unsigned char *));
-bfd_signed_vma bfd_getl_signed_32 PARAMS ((unsigned char *));
-bfd_vma bfd_getb16 PARAMS ((unsigned char *));
-bfd_vma bfd_getl16 PARAMS ((unsigned char *));
-bfd_signed_vma bfd_getb_signed_16 PARAMS ((unsigned char *));
-bfd_signed_vma bfd_getl_signed_16 PARAMS ((unsigned char *));
+bfd_vma bfd_getb64 PARAMS ((const unsigned char *));
+bfd_vma bfd_getl64 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getb_signed_64 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getl_signed_64 PARAMS ((const unsigned char *));
+bfd_vma bfd_getb32 PARAMS ((const unsigned char *));
+bfd_vma bfd_getl32 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getb_signed_32 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getl_signed_32 PARAMS ((const unsigned char *));
+bfd_vma bfd_getb16 PARAMS ((const unsigned char *));
+bfd_vma bfd_getl16 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getb_signed_16 PARAMS ((const unsigned char *));
+bfd_signed_vma bfd_getl_signed_16 PARAMS ((const unsigned char *));
void bfd_putb64 PARAMS ((bfd_vma, unsigned char *));
void bfd_putl64 PARAMS ((bfd_vma, unsigned char *));
void bfd_putb32 PARAMS ((bfd_vma, unsigned char *));
void bfd_putb16 PARAMS ((bfd_vma, unsigned char *));
void bfd_putl16 PARAMS ((bfd_vma, unsigned char *));
+/* ECOFF linking routines. */
+#if defined(__STDC__) || defined(ALMOST_STDC)
+struct ecoff_debug_info;
+struct ecoff_debug_swap;
+struct ecoff_extr;
+struct symbol_cache_entry;
+struct bfd_link_info;
+#endif
+extern PTR bfd_ecoff_debug_init
+ PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap,
+ struct bfd_link_info *));
+extern void bfd_ecoff_debug_free
+ PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap,
+ struct bfd_link_info *));
+extern boolean bfd_ecoff_debug_accumulate
+ PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap,
+ bfd *input_bfd, struct ecoff_debug_info *input_debug,
+ const struct ecoff_debug_swap *input_swap,
+ struct bfd_link_info *));
+extern boolean bfd_ecoff_debug_accumulate_other
+ PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
+ const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
+ struct bfd_link_info *));
+extern boolean bfd_ecoff_debug_externals
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap,
+ boolean relocateable,
+ boolean (*get_extr) (struct symbol_cache_entry *,
+ struct ecoff_extr *),
+ void (*set_index) (struct symbol_cache_entry *,
+ bfd_size_type)));
+extern boolean bfd_ecoff_debug_one_external
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap,
+ const char *name, struct ecoff_extr *esym));
+extern bfd_size_type bfd_ecoff_debug_size
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap));
+extern boolean bfd_ecoff_write_debug
+ PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap, file_ptr where));
+extern boolean bfd_ecoff_write_accumulated_debug
+ PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug,
+ const struct ecoff_debug_swap *swap,
+ struct bfd_link_info *info, file_ptr where));
+
/* And more from the source. */
void
bfd_init PARAMS ((void));
/* Byte swapping macros for user section data. */
#define bfd_put_8(abfd, val, ptr) \
- (*((unsigned char *)(ptr)) = (unsigned char)val)
+ (*((unsigned char *)(ptr)) = (unsigned char)(val))
#define bfd_put_signed_8 \
bfd_put_8
#define bfd_get_8(abfd, ptr) \
struct symbol_cache_entry *symbol;
struct symbol_cache_entry **symbol_ptr_ptr;
- struct bfd_seclet *seclets_head;
- struct bfd_seclet *seclets_tail;
+ struct bfd_link_order *link_order_head;
+ struct bfd_link_order *link_order_tail;
} asection ;
bfd_arch_h8300, /* Hitachi H8/300 */
#define bfd_mach_h8300 1
#define bfd_mach_h8300h 2
+ bfd_arch_powerpc, /* PowerPC */
bfd_arch_rs6000, /* IBM RS/6000 */
bfd_arch_hppa, /* HP PA RISC */
bfd_arch_z8k, /* Zilog Z8000 */
/* The relocation was performed, but may not be ok - presently
generated only when linking i960 coff files with i960 b.out
- symbols. */
+ symbols. If this type is returned, the error_message argument
+ to bfd_perform_relocation will be set. */
bfd_reloc_dangerous
}
bfd_reloc_status_type;
bfd_vma addend;
/* Pointer to how to perform the required relocation */
- CONST struct reloc_howto_struct *howto;
+ const struct reloc_howto_struct *howto;
} arelent;
enum complain_overflow
unsigned int rightshift;
/* The size of the item to be relocated. This is *not* a
- power-of-two measure.
- 0 : one byte
- 1 : two bytes
- 2 : four bytes
- 3 : nothing done (unless special_function is nonzero)
- 4 : eight bytes
- -2 : two bytes, result should be subtracted from the
- data instead of added
- There is currently no trivial way to extract a "number of
- bytes" from a howto pointer. */
+ power-of-two measure. To get the number of bytes operated
+ on by a type of relocation, use bfd_get_reloc_size. */
int size;
/* The number of bits in the item to be relocated. This is used
struct symbol_cache_entry *symbol,
PTR data,
asection *input_section,
- bfd *output_bfd));
+ bfd *output_bfd,
+ char **error_message));
/* The textual name of the relocation type. */
char *name;
} \
} \
}
+int
+bfd_get_reloc_size PARAMS ((const reloc_howto_type *));
+
typedef unsigned char bfd_byte;
typedef struct relent_chain {
arelent *reloc_entry,
PTR data,
asection *input_section,
- bfd *output_bfd));
+ bfd *output_bfd,
+ char **error_message));
typedef enum bfd_reloc_code_real
{
BFD_RELOC_64,
BFD_RELOC_32,
BFD_RELOC_16,
+ BFD_RELOC_14,
BFD_RELOC_8,
/* PC-relative relocations */
/* 32-bit pc-relative, shifted right 2 bits (i.e., 30-bit
word displacement, e.g. for SPARC) */
BFD_RELOC_32_PCREL_S2,
+ /* signed 16-bit pc-relative, shifted right 2 bits (e.g. for MIPS) */
+ BFD_RELOC_16_PCREL_S2,
+ /* this is used on the Alpha */
+ BFD_RELOC_23_PCREL_S2,
/* High 22 bits of 32-bit value, placed into lower 22 bits of
target word; simple reloc. */
/* Low 10 bits. */
BFD_RELOC_LO10,
+ /* For systems that allocate a Global Pointer register, these are
+ displacements off that register. These relocation types are
+ handled specially, because the value the register will have is
+ decided relatively late. */
+ BFD_RELOC_GPREL16,
+ BFD_RELOC_GPREL32,
+
/* Reloc types used for i960/b.out. */
BFD_RELOC_I960_CALLJ,
BFD_RELOC_SPARC_LO7,
/* end-sanitize-v9 */
+ /* Alpha ECOFF relocations. Some of these treat the symbol or "addend"
+ in some special way. */
+ /* For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
+ writing; when reading, it will be the absolute section symbol. The
+ addend is the displacement in bytes of the "lda" instruction from
+ the "ldah" instruction (which is at the address of this reloc). */
+ BFD_RELOC_ALPHA_GPDISP_HI16,
+ /* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
+ with GPDISP_HI16 relocs. The addend is ignored when writing the
+ relocations out, and is filled in with the file's GP value on
+ reading, for convenience. */
+ BFD_RELOC_ALPHA_GPDISP_LO16,
+
+ /* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
+ the assembler turns it into a LDQ instruction to load the address of
+ the symbol, and then fills in a register in the real instruction.
+
+ The LITERAL reloc, at the LDQ instruction, refers to the .lita
+ section symbol. The addend is ignored when writing, but is filled
+ in with the file's GP value on reading, for convenience, as with the
+ GPDISP_LO16 reloc.
+
+ The LITUSE reloc, on the instruction using the loaded address, gives
+ information to the linker that it might be able to use to optimize
+ away some literal section references. The symbol is ignored (read
+ as the absolute section symbol), and the "addend" indicates the type
+ of instruction using the register:
+ 1 - "memory" fmt insn
+ 2 - byte-manipulation (byte offset reg)
+ 3 - jsr (target of branch)
+
+ The GNU linker currently doesn't do any of this optimizing. */
+ BFD_RELOC_ALPHA_LITERAL,
+ BFD_RELOC_ALPHA_LITUSE,
+
+ /* The HINT relocation indicates a value that should be filled into the
+ "hint" field of a jmp/jsr/ret instruction, for possible branch-
+ prediction logic which may be provided on some processors. */
+ BFD_RELOC_ALPHA_HINT,
+
/* Bits 27..2 of the relocation address shifted right 2 bits;
simple reloc otherwise. */
BFD_RELOC_MIPS_JMP,
- /* signed 16-bit pc-relative, shifted right 2 bits (e.g. for MIPS) */
- BFD_RELOC_16_PCREL_S2,
-
/* High 16 bits of 32-bit value; simple reloc. */
BFD_RELOC_HI16,
/* High 16 bits of 32-bit value but the low 16 bits will be sign
/* Low 16 bits. */
BFD_RELOC_LO16,
- /* 16 bit relocation relative to the global pointer. */
- BFD_RELOC_MIPS_GPREL,
+ /* relocation relative to the global pointer. */
+#define BFD_RELOC_MIPS_GPREL BFD_RELOC_GPREL16
/* Relocation against a MIPS literal section. */
BFD_RELOC_MIPS_LITERAL,
/* MIPS ELF relocations. */
BFD_RELOC_MIPS_GOT16,
BFD_RELOC_MIPS_CALL16,
- BFD_RELOC_MIPS_GPREL32,
+#define BFD_RELOC_MIPS_GPREL32 BFD_RELOC_GPREL32
/* These are, so far, specific to HPPA processors. I'm not sure that some
don't duplicate other reloc types, such as BFD_RELOC_32 and _32_PCREL.
BFD_RELOC_386_GOTOFF,
BFD_RELOC_386_GOTPC,
+ /* PowerPC/POWER (RS/6000) relocs. */
+ /* 26 bit relative branch. Low two bits must be zero. High 24
+ bits installed in bits 6 through 29 of instruction. */
+ BFD_RELOC_PPC_B26,
+ /* 26 bit absolute branch, like BFD_RELOC_PPC_B26 but absolute. */
+ BFD_RELOC_PPC_BA26,
+ /* 16 bit TOC relative reference. */
+ BFD_RELOC_PPC_TOC16,
+
/* this must be the highest numeric value */
BFD_RELOC_UNUSED
} bfd_reloc_code_real_type;
-CONST struct reloc_howto_struct *
+const struct reloc_howto_struct *
bfd_reloc_type_lookup PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-unsigned int
-bfd_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect));
-
-unsigned int
-bfd_canonicalize_reloc
- PARAMS ((bfd *abfd,
- asection *sec,
- arelent **loc,
- asymbol **syms));
-
-void
-bfd_set_reloc
- PARAMS ((bfd *abfd, sec_ptr *sec, arelent **rel, unsigned int count)
-
- );
-
typedef struct symbol_cache_entry
{
for ELF STT_FILE symbols. */
#define BSF_FILE 0x4000
+ /* Symbol is from dynamic linking information. */
+#define BSF_DYNAMIC 0x8000
+
flagword flags;
/* A pointer to the section to which this symbol is
struct _bfd *archive_head; /* The first BFD in the archive. */
boolean has_armap;
+ /* A chain of BFD structures involved in a link. */
+ struct _bfd *link_next;
+
+ /* A field used by _bfd_generic_link_add_archive_symbols. This will
+ be used only for archive elements. */
+ int archive_pass;
+
/* Used by the back end to hold private data. */
union
struct trad_core_struct *trad_core_data;
struct som_data_struct *som_data;
struct hpux_core_struct *hpux_core_data;
+ struct hppabsd_core_struct *hppabsd_core_data;
struct sgi_core_struct *sgi_core_data;
struct lynx_core_struct *lynx_core_data;
struct osf_core_struct *osf_core_data;
/* Where all the allocated stuff under this BFD goes */
struct obstack memory;
-
- /* Is this really needed in addition to usrdata? */
- asymbol **ld_symbols;
};
+typedef enum bfd_error
+{
+ bfd_error_no_error = 0,
+ bfd_error_system_call,
+ bfd_error_invalid_target,
+ bfd_error_wrong_format,
+ bfd_error_invalid_operation,
+ bfd_error_no_memory,
+ bfd_error_no_symbols,
+ bfd_error_no_more_archived_files,
+ bfd_error_malformed_archive,
+ bfd_error_file_not_recognized,
+ bfd_error_file_ambiguously_recognized,
+ bfd_error_no_contents,
+ bfd_error_nonrepresentable_section,
+ bfd_error_no_debug_section,
+ bfd_error_bad_value,
+ bfd_error_file_truncated,
+ bfd_error_invalid_error_code
+} bfd_error_type;
+
+bfd_error_type
+bfd_get_error PARAMS ((void));
+
+void
+bfd_set_error PARAMS ((bfd_error_type error_tag));
+
+CONST char *
+bfd_errmsg PARAMS ((bfd_error_type error_tag));
+
+void
+bfd_perror PARAMS ((CONST char *message));
+
+unsigned int
+bfd_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect));
+
+unsigned int
+bfd_canonicalize_reloc
+ PARAMS ((bfd *abfd,
+ asection *sec,
+ arelent **loc,
+ asymbol **syms));
+
+void
+bfd_set_reloc
+ PARAMS ((bfd *abfd, asection *sec, arelent **rel, unsigned int count)
+
+ );
+
boolean
bfd_set_file_flags PARAMS ((bfd *abfd, flagword flags));
#define bfd_set_arch_mach(abfd, arch, mach)\
BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
-#define bfd_get_relocated_section_contents(abfd, seclet, data, relocateable) \
- BFD_SEND (abfd, _bfd_get_relocated_section_contents, (abfd, seclet, data, relocateable))
+#define bfd_get_relocated_section_contents(abfd, link_info, link_order, data, relocateable, symbols) \
+ BFD_SEND (abfd, _bfd_get_relocated_section_contents, \
+ (abfd, link_info, link_order, data, relocateable, symbols))
-#define bfd_relax_section(abfd, section, symbols) \
- BFD_SEND (abfd, _bfd_relax_section, (abfd, section, symbols))
+#define bfd_relax_section(abfd, section, link_info, symbols) \
+ BFD_SEND (abfd, _bfd_relax_section, \
+ (abfd, section, link_info, symbols))
+
+#define bfd_link_hash_table_create(abfd) \
+ BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
+
+#define bfd_link_add_symbols(abfd, info) \
+ BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
+
+#define bfd_final_link(abfd, info) \
+ BFD_SEND (abfd, _bfd_final_link, (abfd, info))
-#define bfd_seclet_link(abfd, data, relocateable) \
- BFD_SEND (abfd, _bfd_seclet_link, (abfd, data, relocateable))
symindex
bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym));
bfd_target_tekhex_flavour,
bfd_target_srec_flavour,
bfd_target_som_flavour};
+
+ /* Forward declaration. */
+typedef struct bfd_link_info _bfd_link_info;
+
typedef struct bfd_target
{
char *name;
char ar_pad_char;
unsigned short ar_max_namelen;
unsigned int align_power_min;
- bfd_vma (*bfd_getx64) PARAMS ((bfd_byte *));
- bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((bfd_byte *));
+ bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_getx32) PARAMS ((bfd_byte *));
- bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((bfd_byte *));
+ bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *));
void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_getx16) PARAMS ((bfd_byte *));
- bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((bfd_byte *));
+ bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *));
void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx64) PARAMS ((bfd_byte *));
- bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((bfd_byte *));
+ bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *));
void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx32) PARAMS ((bfd_byte *));
- bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((bfd_byte *));
+ bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *));
void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx16) PARAMS ((bfd_byte *));
- bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((bfd_byte *));
+ bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
+ bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
struct bfd_target * (*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
void (*_bfd_debug_info_accumulate) PARAMS ((bfd *, struct sec *));
bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
- struct bfd_seclet *, bfd_byte *data,
- boolean relocateable));
+ struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *data, boolean relocateable,
+ struct symbol_cache_entry **));
boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
- struct symbol_cache_entry **));
+ struct bfd_link_info *, struct symbol_cache_entry **));
- boolean (*_bfd_seclet_link) PARAMS ((bfd *, PTR data,
- boolean relocateable));
/* See documentation on reloc types. */
CONST struct reloc_howto_struct *
(*reloc_type_lookup) PARAMS ((bfd *abfd,
bfd *abfd,
void *ptr,
unsigned long size));
+
+ /* Create a hash table for the linker. Different backends store
+ different information in this table. */
+ struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
+
+ /* Add symbols from this object file into the hash table. */
+ boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
+
+ /* Do a link based on the link_order structures attached to each
+ section of the BFD. */
+ boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
+
PTR backend_data;
} bfd_target;
bfd_target *
boolean
bfd_check_format PARAMS ((bfd *abfd, bfd_format format));
+boolean
+bfd_check_format_matches PARAMS ((bfd *abfd, bfd_format format, char ***matching));
+
boolean
bfd_set_format PARAMS ((bfd *abfd, bfd_format format));