From: David MacKenzie Date: Sat, 22 Jan 1994 04:28:17 +0000 (+0000) Subject: * targets.c: Add a vector of matching format names. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3b31740cb27d8255526502827f5528cf5f8e33fc;p=binutils-gdb.git * targets.c: Add a vector of matching format names. * format.c (bfd_matching_formats): New function to return it. (bfd_check_format): Set it. * bfd-in2.h: Regenerated. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6e117482e71..be286259d41 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,10 @@ Fri Jan 21 16:25:35 1994 David J. Mackenzie (djm@thepub.cygnus.com) + * targets.c: Add a vector of matching format names. + * format.c (bfd_matching_formats): New function to return it. + (bfd_check_format): Set it. + * bfd-in2.h: Regenerated. + * bfd-in.h: Remove decls of bfd_ec type and error printing functions. Remove decl of type symclass; wasn't used. * bfd.c: Document error handling, including code fragments diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index f5ca9e24f61..4f9573f77c5 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -2057,6 +2057,9 @@ bfd_target_list PARAMS ((void)); boolean bfd_check_format PARAMS ((bfd *abfd, bfd_format format)); +char ** +bfd_matching_formats PARAMS (()); + boolean bfd_set_format PARAMS ((bfd *abfd, bfd_format format)); diff --git a/bfd/format.c b/bfd/format.c index 40af1c26959..310a305c903 100644 --- a/bfd/format.c +++ b/bfd/format.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* SECTION - File Formats + File formats A format is a BFD concept of high level file contents type. The formats supported by BFD are: @@ -44,9 +44,8 @@ SECTION #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 @@ -71,18 +70,18 @@ DESCRIPTION The function returns <> on success, otherwise <> with one of the following error codes: - o invalid_operation - + o <> - if <> is not one of <>, <> or <>. - o system_call_error - + o <> - if an error occured during a read - even some file mismatches can cause system_call_errors. - o file_not_recognised - + o <> - none of the backends recognised the file format. - o file_ambiguously_recognized - + o <> - more than one backend recognised the file format. */ @@ -111,6 +110,7 @@ DEFUN(bfd_check_format,(abfd, format), save_targ = abfd->xvec; match_count = 0; + matching_vector[0] = NULL; right_targ = 0; @@ -141,13 +141,16 @@ DEFUN(bfd_check_format,(abfd, format), 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 @@ -178,6 +181,25 @@ DEFUN(bfd_check_format,(abfd, format), return false; } +/* +FUNCTION + bfd_matching_formats + +SYNOPSIS + char **bfd_matching_formats(); + +DESCRIPTION + If a call to <> returns + <>, 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 diff --git a/bfd/targets.c b/bfd/targets.c index 8f10ef3a336..9d1e58cfe63 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -185,26 +185,26 @@ Entries for byte swapping for data. These are different from the other 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 @@ -386,13 +386,9 @@ extern bfd_target m68klynx_aout_vec; 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; @@ -509,12 +505,10 @@ bfd_target *target_vector[] = { &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 @@ -579,7 +573,11 @@ bfd_target *default_vector[] = { 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]; /*