diff options
author | David MacKenzie <djm@cygnus> | 1994-01-22 04:28:17 +0000 |
---|---|---|
committer | David MacKenzie <djm@cygnus> | 1994-01-22 04:28:17 +0000 |
commit | 3b31740cb27d8255526502827f5528cf5f8e33fc (patch) | |
tree | c070e5ebc6da260e818e57a03d008991f862efeb | |
parent | 0f8f509c6aece2357200af325524f53e90d3333d (diff) | |
download | gdb-3b31740cb27d8255526502827f5528cf5f8e33fc.zip gdb-3b31740cb27d8255526502827f5528cf5f8e33fc.tar.gz gdb-3b31740cb27d8255526502827f5528cf5f8e33fc.tar.bz2 |
* 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.
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 3 | ||||
-rw-r--r-- | bfd/format.c | 40 | ||||
-rw-r--r-- | bfd/targets.c | 38 |
4 files changed, 57 insertions, 29 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6e11748..be28625 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 f5ca9e2..4f9573f 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 40af1c2..310a305 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 <<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. */ @@ -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 <<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 diff --git a/bfd/targets.c b/bfd/targets.c index 8f10ef3..9d1e58c 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]; /* |