/*
SECTION
- File Formats
+ File formats
A format is a BFD concept of high level file contents type. The
formats supported by BFD are:
#include "sysdep.h"
#include "libbfd.h"
-extern bfd_target *target_vector[];
-extern bfd_target *default_vector[];
-
+/* IMPORT from targets.c. */
+extern char *matching_vector[];
/*
FUNCTION
The function returns <<true>> on success, otherwise <<false>>
with one of the following error codes:
- o invalid_operation -
+ o <<invalid_operation>> -
if <<format>> is not one of <<bfd_object>>, <<bfd_archive>> or
<<bfd_core>>.
- o system_call_error -
+ o <<system_call_error>> -
if an error occured during a read - even some file mismatches
can cause system_call_errors.
- o file_not_recognised -
+ o <<file_not_recognised>> -
none of the backends recognised the file format.
- o file_ambiguously_recognized -
+ o <<file_ambiguously_recognized>> -
more than one backend recognised the file format.
*/
save_targ = abfd->xvec;
match_count = 0;
+ matching_vector[0] = NULL;
right_targ = 0;
temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
if (temp) { /* This format checks out as ok! */
right_targ = temp;
- match_count++;
+ matching_vector[match_count++] = temp->name;
+ matching_vector[match_count] = NULL;
/* If this is the default target, accept it, even if other targets
might match. People who want those other targets have to set
the GNUTARGET variable. */
if (temp == default_vector[0])
{
match_count = 1;
+ matching_vector[0] = temp->name;
+ matching_vector[1] = NULL;
break;
}
#ifdef GNU960
return false;
}
+/*
+FUNCTION
+ bfd_matching_formats
+
+SYNOPSIS
+ char **bfd_matching_formats();
+
+DESCRIPTION
+ If a call to <<bfd_check_format>> returns
+ <<file_ambiguously_recognized>>, you can call this function
+ afterward to return a NULL-terminated list of the names of
+ the formats that matched.
+ Then you can choose one and try again. */
+
+char **
+bfd_matching_formats ()
+{
+ return &matching_vector[0];
+}
/*
FUNCTION
entry points, since they don't take a BFD asthe first argument.
Certain other handlers could do the same.
-. 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 *));
Byte swapping for the headers
-. 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 *));
Format dependent routines: these are vectors of entry points
extern bfd_target m68klynx_coff_vec;
extern bfd_target m88kbcs_vec;
extern bfd_target newsos3_vec;
-extern bfd_target nlm32_big_generic_vec;
extern bfd_target nlm32_i386_vec;
extern bfd_target nlm32_sparc_vec;
extern bfd_target nlm32_alpha_vec;
-extern bfd_target nlm32_little_generic_vec;
-extern bfd_target nlm64_big_generic_vec;
-extern bfd_target nlm64_little_generic_vec;
extern bfd_target oasys_vec;
extern bfd_target rs6000coff_vec;
extern bfd_target shcoff_vec;
&m68klynx_coff_vec,
&m88kbcs_vec,
&newsos3_vec,
- &nlm32_big_generic_vec,
&nlm32_i386_vec,
&nlm32_sparc_vec,
#ifdef BFD64
- &nlm64_big_generic_vec,
- &nlm64_little_generic_vec,
+ &nlm32_alpha_vec,
#endif
#if 0
/* We have no oasys tools anymore, so we can't test any of this
NULL
};
-
+/* When there is an ambiguous match, bfd_check_format puts the names
+ of the matching targets in this array.
+ It is declared here so we can give it the same number of entries
+ (+ a terminating NULL) as the number of possible targets. */
+char *matching_vector[sizeof(target_vector)/sizeof(*target_vector) + 1];
/*