/* Generic target-file-type support for the BFD library.
- Copyright (C) 1990-1991 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* $Id$ */
-
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
o If the target string is still NULL, or the target string is
<<default>>, then the first item in the target vector is used
- as the target type. @xref{bfd_target}.
+ as the target type, and <<target_defaulted>> is set to
+ cause <<bfd_check_format>> to loop through all the targets.
+ @xref{bfd_target}. @xref{Formats}.
o Otherwise, the elements in the target vector are inspected
one by one, until a match on target name is found. When found,
Once the BFD has been opened and the target selected, the file
format may be determined. This is done by calling
- <<bfd_check_format>> on the BFD with a suggested format. The
+ <<bfd_check_format>> on the BFD with a suggested format.
+ If <<target_defaulted>> has been set, each possible target
+ type is tried to see if it recognizes the specified format. The
routine returns <<true>> when the application guesses right.
@menu
@* bfd_target::
INODE
bfd_target, , Targets, Targets
-
+DOCDD
SUBSECTION
bfd_target
Every BFD points to a target structure with its <<xvec>>
member.
- Shortcut for declaring fields which are prototyped function
- pointers, while avoiding anguish on compilers that don't
- support protos.
-
-.#define SDEF(ret, name, arglist) \
-. PROTO(ret,(*name),arglist)
-.#define SDEF_FMT(ret, name, arglist) \
-. PROTO(ret,(*name[bfd_type_end]),arglist)
-
These macros are used to dispatch to functions through the
bfd_target vector. They are used in a number of macros further
down in @file{bfd.h}, and are also used when calling various
. bfd_target_unknown_flavour,
. bfd_target_aout_flavour,
. bfd_target_coff_flavour,
+. bfd_target_ecoff_flavour,
. bfd_target_elf_flavour,
. bfd_target_ieee_flavour,
+. bfd_target_nlm_flavour,
. bfd_target_oasys_flavour,
. bfd_target_tekhex_flavour,
. bfd_target_srec_flavour,
. flagword section_flags;
+The character normally found at the front of a symbol
+(if any), perhaps _.
+
+. char symbol_leading_char;
+
The pad character for filenames within an archive header.
. char ar_pad_char;
The maximum number of characters in an archive header.
-. unsigned short ar_max_namelen;
+. unsigned short ar_max_namelen;
The minimum alignment restriction for any section.
entry points, since they don't take BFD as first arg. Certain other handlers
could do the same.
-. SDEF (bfd_vma, bfd_getx64, (bfd_byte *));
-. SDEF (void, bfd_putx64, (bfd_vma, bfd_byte *));
-. SDEF (bfd_vma, bfd_getx32, (bfd_byte *));
-. SDEF (void, bfd_putx32, (bfd_vma, bfd_byte *));
-. SDEF (bfd_vma, bfd_getx16, (bfd_byte *));
-. SDEF (void, bfd_putx16, (bfd_vma, bfd_byte *));
+. bfd_vma (*bfd_getx64) PARAMS ((bfd_byte *));
+. bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((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 *));
+. 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 *));
+. void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
Byte swapping for the headers
-. SDEF (bfd_vma, bfd_h_getx64, (bfd_byte *));
-. SDEF (void, bfd_h_putx64, (bfd_vma, bfd_byte *));
-. SDEF (bfd_vma, bfd_h_getx32, (bfd_byte *));
-. SDEF (void, bfd_h_putx32, (bfd_vma, bfd_byte *));
-. SDEF (bfd_vma, bfd_h_getx16, (bfd_byte *));
-. SDEF (void, bfd_h_putx16, (bfd_vma, bfd_byte *));
+. bfd_vma (*bfd_h_getx64) PARAMS ((bfd_byte *));
+. bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((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 *));
+. 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 *));
+. void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
-Format dependent routines, these turn into vectors of entry points
-within the target vector structure; one for each format to check.
+Format dependent routines: these are vectors of entry points
+within the target vector structure, one for each format to check.
Check the format of a file being read. Return bfd_target * or zero.
-. SDEF_FMT (struct bfd_target *, _bfd_check_format, (bfd *));
+. struct bfd_target * (*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
Set the format of a file being written.
-. SDEF_FMT (boolean, _bfd_set_format, (bfd *));
+. boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
Write cached information into a file being written, at bfd_close.
-. SDEF_FMT (boolean, _bfd_write_contents, (bfd *));
+. boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
The following functions are defined in <<JUMP_TABLE>>. The idea is
that the back end writer of <<foo>> names all the routines
Core file entry points
-. SDEF (char *, _core_file_failing_command, (bfd *));
-. SDEF (int, _core_file_failing_signal, (bfd *));
-. SDEF (boolean, _core_file_matches_executable_p, (bfd *, bfd *));
+. char * (*_core_file_failing_command) PARAMS ((bfd *));
+. int (*_core_file_failing_signal) PARAMS ((bfd *));
+. boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *));
Archive entry points
-. SDEF (boolean, _bfd_slurp_armap, (bfd *));
-. SDEF (boolean, _bfd_slurp_extended_name_table, (bfd *));
-. SDEF (void, _bfd_truncate_arname, (bfd *, CONST char *, char *));
-. SDEF (boolean, write_armap, (bfd *arch,
+. boolean (*_bfd_slurp_armap) PARAMS ((bfd *));
+. boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
+. void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
+. boolean (*write_armap) PARAMS ((bfd *arch,
. unsigned int elength,
. struct orl *map,
. unsigned int orl_count,
Standard stuff.
-. SDEF (boolean, _close_and_cleanup, (bfd *));
-. SDEF (boolean, _bfd_set_section_contents, (bfd *, sec_ptr, PTR,
+. boolean (*_close_and_cleanup) PARAMS ((bfd *));
+. boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
. file_ptr, bfd_size_type));
-. SDEF (boolean, _bfd_get_section_contents, (bfd *, sec_ptr, PTR,
+. boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
. file_ptr, bfd_size_type));
-. SDEF (boolean, _new_section_hook, (bfd *, sec_ptr));
+. boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
Symbols and relocations
-. SDEF (unsigned int, _get_symtab_upper_bound, (bfd *));
-. SDEF (unsigned int, _bfd_canonicalize_symtab,
-. (bfd *, struct symbol_cache_entry **));
-. SDEF (unsigned int, _get_reloc_upper_bound, (bfd *, sec_ptr));
-. SDEF (unsigned int, _bfd_canonicalize_reloc, (bfd *, sec_ptr, arelent **,
-. struct symbol_cache_entry**));
-. SDEF (struct symbol_cache_entry *, _bfd_make_empty_symbol, (bfd *));
-. SDEF (void, _bfd_print_symbol, (bfd *, PTR, struct symbol_cache_entry *,
+. unsigned int (*_get_symtab_upper_bound) PARAMS ((bfd *));
+. unsigned int (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
+. struct symbol_cache_entry **));
+. unsigned int (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
+. unsigned int (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
+. struct symbol_cache_entry **));
+. struct symbol_cache_entry *
+. (*_bfd_make_empty_symbol) PARAMS ((bfd *));
+. void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
+. struct symbol_cache_entry *,
. bfd_print_symbol_type));
.#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
-. SDEF (alent *, _get_lineno, (bfd *, struct symbol_cache_entry *));
-.
-. SDEF (boolean, _bfd_set_arch_mach, (bfd *, enum bfd_architecture,
-. unsigned long));
-.
-. SDEF (bfd *, openr_next_archived_file, (bfd *arch, bfd *prev));
-. SDEF (boolean, _bfd_find_nearest_line,
-. (bfd *abfd, struct sec *section,
-. struct symbol_cache_entry **symbols,bfd_vma offset,
-. CONST char **file, CONST char **func, unsigned int *line));
-. SDEF (int, _bfd_stat_arch_elt, (bfd *, struct stat *));
-.
-. SDEF (int, _bfd_sizeof_headers, (bfd *, boolean));
-.
-. SDEF (void, _bfd_debug_info_start, (bfd *));
-. SDEF (void, _bfd_debug_info_end, (bfd *));
-. SDEF (void, _bfd_debug_info_accumulate, (bfd *, struct sec *));
-. SDEF (bfd_byte *, _bfd_get_relocated_section_contents, (bfd*,struct bfd_seclet_struct *, bfd_byte *data));
-. SDEF (boolean,_bfd_relax_section,(bfd *, struct sec *, struct symbol_cache_entry **));
-Special entry points for gdb to swap in coff symbol table parts
-
-. SDEF(void, _bfd_coff_swap_aux_in,(
-. bfd *abfd ,
-. PTR ext,
-. int type,
-. int class ,
-. PTR in));
-.
-. SDEF(void, _bfd_coff_swap_sym_in,(
-. bfd *abfd ,
-. PTR ext,
-. PTR in));
-.
-. SDEF(void, _bfd_coff_swap_lineno_in, (
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-.
-
-Special entry points for gas to swap coff parts
+. void (*_bfd_get_symbol_info) PARAMS ((bfd *,
+. struct symbol_cache_entry *,
+. symbol_info *));
+.#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e))
-. SDEF(unsigned int, _bfd_coff_swap_aux_out,(
-. bfd *abfd,
-. PTR in,
-. int type,
-. int class,
-. PTR ext));
+. alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
.
-. SDEF(unsigned int, _bfd_coff_swap_sym_out,(
-. bfd *abfd,
-. PTR in,
-. PTR ext));
+. boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
+. unsigned long));
.
-. SDEF(unsigned int, _bfd_coff_swap_lineno_out,(
-. bfd *abfd,
-. PTR in,
-. PTR ext));
+. bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
+.
+. boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd,
+. struct sec *section, struct symbol_cache_entry **symbols,
+. bfd_vma offset, CONST char **file, CONST char **func,
+. unsigned int *line));
+.
+. int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
.
-. SDEF(unsigned int, _bfd_coff_swap_reloc_out,(
-. bfd *abfd,
-. PTR src,
-. PTR dst));
+. int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
.
-. SDEF(unsigned int, _bfd_coff_swap_filehdr_out,(
-. bfd *abfd,
-. PTR in,
-. PTR out));
+. void (*_bfd_debug_info_start) PARAMS ((bfd *));
+. void (*_bfd_debug_info_end) PARAMS ((bfd *));
+. void (*_bfd_debug_info_accumulate) PARAMS ((bfd *, struct sec *));
.
-. SDEF(unsigned int, _bfd_coff_swap_aouthdr_out,(
-. bfd *abfd,
-. PTR in,
-. PTR out));
+. bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
+. struct bfd_seclet *, bfd_byte *data,
+. boolean relocateable));
.
-. SDEF(unsigned int, _bfd_coff_swap_scnhdr_out,(
-. bfd *abfd,
-. PTR in,
-. PTR out));
+. boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
+. struct symbol_cache_entry **));
.
+. boolean (*_bfd_seclet_link) PARAMS ((bfd *, PTR data,
+. boolean relocateable));
+
. {* See documentation on reloc types. *}
-. SDEF (CONST struct reloc_howto_struct *,
-. reloc_type_lookup,
-. (bfd *abfd, bfd_reloc_code_real_type code));
+. CONST struct reloc_howto_struct *
+. (*reloc_type_lookup) PARAMS ((bfd *abfd,
+. bfd_reloc_code_real_type code));
.
-. {* Complete and utter crock, currently used for the assembler
+. {* Back-door to allow format-aware applications to create debug symbols
+. while using BFD for everything else. Currently used by the assembler
. when creating COFF files. *}
-. SDEF (asymbol *, _bfd_make_debug_symbol, (
+. asymbol * (*_bfd_make_debug_symbol) PARAMS ((
. bfd *abfd,
. void *ptr,
. unsigned long size));
-Data for use by back-end routines; e.g., for a.out, includes whether
-this particular target maps ZMAGIC files contiguously or with text and
-data separated. Could perhaps also be used to eliminate some of the
-above COFF-specific fields.
+Data for use by back-end routines, which isn't generic enough to belong
+in this structure.
. PTR backend_data;
.} bfd_target;
#if MINIMIZE && defined(DEFAULT_VECTOR) && !defined(SELECT_VECS)
#ifdef TRAD_CORE
#define SELECT_VECS &DEFAULT_VECTOR,&trad_core_vec
-#else
+#endif
+#ifdef SCO_CORE
+#define SELECT_VECS &DEFAULT_VECTOR,&sco_core_vec
+#endif
+#ifdef AIX386_CORE
+#define SELECT_VECS &DEFAULT_VECTOR,&aix386_core_vec
+#endif
+#ifdef HPUX_CORE
+#define SELECT_VECS &DEFAULT_VECTOR,&hpux_core_vec
+#endif
+#ifndef SELECT_VECS
#define SELECT_VECS &DEFAULT_VECTOR
#endif
#endif
/* All known xvecs. They are listed a second time below, since
we can't intermix extern's and initializers. */
+extern bfd_target i386lynx_vec;
extern bfd_target ecoff_little_vec;
extern bfd_target ecoff_big_vec;
+extern bfd_target aout_mips_little_vec;
+extern bfd_target aout_mips_big_vec;
extern bfd_target sunos_big_vec;
extern bfd_target demo_64_vec;
extern bfd_target srec_vec;
+extern bfd_target symbolsrec_vec;
extern bfd_target tekhex_vec;
+extern bfd_target a_out_adobe_vec;
extern bfd_target b_out_vec_little_host;
extern bfd_target b_out_vec_big_host;
extern bfd_target icoff_little_vec;
extern bfd_target icoff_big_vec;
-extern bfd_target elf_little_vec;
-extern bfd_target elf_big_vec;
+extern bfd_target bfd_elf32_sparc_vec;
+extern bfd_target bfd_elf32_i386_vec;
+extern bfd_target bfd_elf32_m68k_vec;
+extern bfd_target bfd_elf32_i860_vec;
+extern bfd_target bfd_elf32_m88k_vec;
+extern bfd_target bfd_elf32_bigmips_vec;
+extern bfd_target bfd_elf32_littlemips_vec;
+extern bfd_target bfd_elf32_big_generic_vec;
+extern bfd_target bfd_elf32_little_generic_vec;
+extern bfd_target bfd_elf64_big_generic_vec;
+extern bfd_target bfd_elf64_little_generic_vec;
+extern bfd_target bfd_nlm32_big_generic_vec;
+extern bfd_target bfd_nlm32_little_generic_vec;
+extern bfd_target bfd_nlm64_big_generic_vec;
+extern bfd_target bfd_nlm64_little_generic_vec;
extern bfd_target ieee_vec;
extern bfd_target oasys_vec;
extern bfd_target m88kbcs_vec;
extern bfd_target m68kcoff_vec;
+extern bfd_target m68kcoffun_vec;
extern bfd_target i386coff_vec;
extern bfd_target i386aout_vec;
+extern bfd_target i386linux_vec;
extern bfd_target a29kcoff_big_vec;
extern bfd_target trad_core_vec;
+extern bfd_target sco_core_vec;
+extern bfd_target aix386_core_vec;
+extern bfd_target hpux_core_vec;
extern bfd_target rs6000coff_vec;
extern bfd_target h8300coff_vec;
-#ifdef hp9000s800
+extern bfd_target h8500coff_vec;
+extern bfd_target z8kcoff_vec;
+extern bfd_target we32kcoff_vec;
+extern bfd_target shcoff_vec;
+extern bfd_target hp300hpux_vec;
+
+#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD)
extern bfd_target hppa_vec;
#endif
extern bfd_target DEFAULT_VECTOR;
#endif
+bfd_target *target_vector[] = {
+
#ifdef SELECT_VECS
-bfd_target *target_vector[] = {
SELECT_VECS,
- 0
-};
-
-#else
-bfd_target *target_vector[] = {
+#else /* not SELECT_VECS */
#ifdef DEFAULT_VECTOR
&DEFAULT_VECTOR,
&i386coff_vec,
&i386aout_vec,
+ &i386lynx_vec,
&ecoff_little_vec,
&ecoff_big_vec,
+ &aout_mips_little_vec,
+ &aout_mips_big_vec,
&ieee_vec,
-#if 1
+#if 0
/* We have no oasys tools anymore, so we can't test any of this
anymore. If you want to test the stuff yourself, go ahead...
- steve@cygnus.com */
+ steve@cygnus.com
+ Worse, since there is no magic number for archives, there
+ can annoying target mis-matches. */
&oasys_vec,
#endif
&sunos_big_vec,
-#ifdef HOST_64_BIT
+#ifdef BFD64
&demo_64_vec, /* Only compiled if host has long-long support */
#endif
&h8300coff_vec,
+ &z8kcoff_vec,
&m88kbcs_vec,
&srec_vec,
+ &symbolsrec_vec,
/* &tekhex_vec,*/
&icoff_little_vec,
&icoff_big_vec,
- &elf_little_vec,
- &elf_big_vec,
+ &bfd_elf32_sparc_vec,
+ &bfd_elf32_i386_vec,
+ &bfd_elf32_m68k_vec,
+ &bfd_elf32_i860_vec,
+ &bfd_elf32_m88k_vec,
+ &bfd_elf32_littlemips_vec,
+ &bfd_elf32_bigmips_vec,
+ &bfd_elf32_little_generic_vec,
+ &bfd_elf32_big_generic_vec,
+ &bfd_nlm32_little_generic_vec,
+ &bfd_nlm32_big_generic_vec,
+#ifdef BFD64
+ &bfd_elf64_little_generic_vec,
+ &bfd_elf64_big_generic_vec,
+ &bfd_nlm64_little_generic_vec,
+ &bfd_nlm64_big_generic_vec,
+#endif
+ &a_out_adobe_vec,
&b_out_vec_little_host,
&b_out_vec_big_host,
&m68kcoff_vec,
+ &m68kcoffun_vec,
&a29kcoff_big_vec,
&rs6000coff_vec,
-#ifdef hp9000s800
+#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD)
&hppa_vec,
#endif
+ &hp300hpux_vec,
+ &we32kcoff_vec,
#ifdef TRAD_CORE
&trad_core_vec,
#endif
+#ifdef SCO_CORE
+ &sco_core_vec,
+#endif
+#ifdef AIX386_CORE
+ &aix386_core_vec,
+#endif
+#ifdef HPUX_CORE
+ &hpux_core_vec,
+#endif
+
+#endif /* not SELECT_VECS */
NULL, /* end of list marker */
};
-#endif
-
/* default_vector[0] contains either the address of the default vector,
if there is one, or zero if there isn't. */
DEFUN_VOID(bfd_target_list)
{
int vec_length= 0;
- bfd_target **target;
+#ifdef NATIVE_HPPAHPUX_COMPILER
+ /* The native compiler on the HP9000/700 has a bug which causes it
+ to loop endlessly when compiling this file. This avoids it. */
+ volatile
+#endif
+ bfd_target **target;
CONST char **name_list, **name_ptr;
for (target = &target_vector[0]; *target != NULL; target++)