mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-22 19:09:31 +08:00
* format.c (bfd_check_format_matches): New function.
(bfd_check_format): Call it. (bfd_matching_formats): Function removed. * targets.c: Replace the vector added on Jan 21 with a count of entries in default_vector. * bfd-in2.h: Regenerated.
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
Mon Jan 24 14:41:23 1994 David J. Mackenzie (djm@thepub.cygnus.com)
|
||||||
|
|
||||||
|
* format.c (bfd_check_format_matches): New function.
|
||||||
|
(bfd_check_format): Call it.
|
||||||
|
(bfd_matching_formats): Function removed.
|
||||||
|
* targets.c: Replace the vector added on Jan 21 with a count of
|
||||||
|
entries in default_vector.
|
||||||
|
* bfd-in2.h: Regenerated.
|
||||||
|
|
||||||
Mon Jan 24 12:38:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
|
Mon Jan 24 12:38:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
|
||||||
|
|
||||||
* elf32-hppa.c (hppa_elf_gen_reloc_type): Typo (== for =).
|
* elf32-hppa.c (hppa_elf_gen_reloc_type): Typo (== for =).
|
||||||
|
@ -2057,8 +2057,8 @@ bfd_target_list PARAMS ((void));
|
|||||||
boolean
|
boolean
|
||||||
bfd_check_format PARAMS ((bfd *abfd, bfd_format format));
|
bfd_check_format PARAMS ((bfd *abfd, bfd_format format));
|
||||||
|
|
||||||
char **
|
boolean
|
||||||
bfd_matching_formats PARAMS (());
|
bfd_check_format_matches PARAMS ((bfd *abfd, bfd_format format, char ***matching));
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
bfd_set_format PARAMS ((bfd *abfd, bfd_format format));
|
bfd_set_format PARAMS ((bfd *abfd, bfd_format format));
|
||||||
|
107
bfd/format.c
107
bfd/format.c
@ -45,7 +45,7 @@ SECTION
|
|||||||
#include "libbfd.h"
|
#include "libbfd.h"
|
||||||
|
|
||||||
/* IMPORT from targets.c. */
|
/* IMPORT from targets.c. */
|
||||||
extern char *matching_vector[];
|
extern CONST size_t bfd_default_vector_entries;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FUNCTION
|
FUNCTION
|
||||||
@ -83,15 +83,43 @@ DESCRIPTION
|
|||||||
|
|
||||||
o <<file_ambiguously_recognized>> -
|
o <<file_ambiguously_recognized>> -
|
||||||
more than one backend recognised the file format.
|
more than one backend recognised the file format.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
DEFUN(bfd_check_format,(abfd, format),
|
bfd_check_format (abfd, format)
|
||||||
bfd *abfd AND
|
bfd *abfd;
|
||||||
bfd_format format)
|
bfd_format format;
|
||||||
|
{
|
||||||
|
return bfd_check_format_matches (abfd, format, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
FUNCTION
|
||||||
|
bfd_check_format_matches
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
boolean bfd_check_format_matches(bfd *abfd, bfd_format format, char ***matching);
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
Like <<bfd_check_format>>, except when it returns false with
|
||||||
|
<<bfd_errno>> set to <<file_ambiguously_recognized>>. In that
|
||||||
|
case, if @var{matching} is not NULL, it will be filled in with
|
||||||
|
a NULL-terminated list of the names of the formats that matched,
|
||||||
|
allocated with <<malloc>>.
|
||||||
|
Then the user may choose a format and try again.
|
||||||
|
|
||||||
|
When done with the list that @var{matching} points to, the caller
|
||||||
|
should free it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean
|
||||||
|
bfd_check_format_matches (abfd, format, matching)
|
||||||
|
bfd *abfd;
|
||||||
|
bfd_format format;
|
||||||
|
char ***matching;
|
||||||
{
|
{
|
||||||
bfd_target **target, *save_targ, *right_targ;
|
bfd_target **target, *save_targ, *right_targ;
|
||||||
|
char **matching_vector;
|
||||||
int match_count;
|
int match_count;
|
||||||
|
|
||||||
if (!bfd_read_p (abfd) ||
|
if (!bfd_read_p (abfd) ||
|
||||||
@ -110,7 +138,13 @@ DEFUN(bfd_check_format,(abfd, format),
|
|||||||
|
|
||||||
save_targ = abfd->xvec;
|
save_targ = abfd->xvec;
|
||||||
match_count = 0;
|
match_count = 0;
|
||||||
matching_vector[0] = NULL;
|
if (matching)
|
||||||
|
{
|
||||||
|
*matching = matching_vector =
|
||||||
|
bfd_xmalloc_by_size_t (sizeof (char *) *
|
||||||
|
(bfd_default_vector_entries + 1));
|
||||||
|
matching_vector[0] = NULL;
|
||||||
|
}
|
||||||
right_targ = 0;
|
right_targ = 0;
|
||||||
|
|
||||||
|
|
||||||
@ -125,6 +159,8 @@ DEFUN(bfd_check_format,(abfd, format),
|
|||||||
right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
|
right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
|
||||||
if (right_targ) {
|
if (right_targ) {
|
||||||
abfd->xvec = right_targ; /* Set the target as returned */
|
abfd->xvec = right_targ; /* Set the target as returned */
|
||||||
|
if (matching)
|
||||||
|
free (matching_vector);
|
||||||
return true; /* File position has moved, BTW */
|
return true; /* File position has moved, BTW */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,16 +177,23 @@ DEFUN(bfd_check_format,(abfd, format),
|
|||||||
temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
|
temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
|
||||||
if (temp) { /* This format checks out as ok! */
|
if (temp) { /* This format checks out as ok! */
|
||||||
right_targ = temp;
|
right_targ = temp;
|
||||||
matching_vector[match_count++] = temp->name;
|
match_count++;
|
||||||
matching_vector[match_count] = NULL;
|
if (matching)
|
||||||
|
{
|
||||||
|
matching_vector[match_count] = temp->name;
|
||||||
|
matching_vector[match_count] = NULL;
|
||||||
|
}
|
||||||
/* If this is the default target, accept it, even if other targets
|
/* If this is the default target, accept it, even if other targets
|
||||||
might match. People who want those other targets have to set
|
might match. People who want those other targets have to set
|
||||||
the GNUTARGET variable. */
|
the GNUTARGET variable. */
|
||||||
if (temp == default_vector[0])
|
if (temp == default_vector[0])
|
||||||
{
|
{
|
||||||
match_count = 1;
|
match_count = 1;
|
||||||
matching_vector[0] = temp->name;
|
if (matching)
|
||||||
matching_vector[1] = NULL;
|
{
|
||||||
|
matching_vector[0] = temp->name;
|
||||||
|
matching_vector[1] = NULL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef GNU960
|
#ifdef GNU960
|
||||||
@ -165,42 +208,32 @@ DEFUN(bfd_check_format,(abfd, format),
|
|||||||
} else if (bfd_error != wrong_format) {
|
} else if (bfd_error != wrong_format) {
|
||||||
abfd->xvec = save_targ;
|
abfd->xvec = save_targ;
|
||||||
abfd->format = bfd_unknown;
|
abfd->format = bfd_unknown;
|
||||||
|
if (matching && bfd_error != file_ambiguously_recognized)
|
||||||
|
free (matching_vector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match_count == 1) {
|
if (match_count == 1) {
|
||||||
abfd->xvec = right_targ; /* Change BFD's target permanently */
|
abfd->xvec = right_targ; /* Change BFD's target permanently */
|
||||||
|
if (matching)
|
||||||
|
free (matching_vector);
|
||||||
return true; /* File position has moved, BTW */
|
return true; /* File position has moved, BTW */
|
||||||
}
|
}
|
||||||
|
|
||||||
abfd->xvec = save_targ; /* Restore original target type */
|
abfd->xvec = save_targ; /* Restore original target type */
|
||||||
abfd->format = bfd_unknown; /* Restore original format */
|
abfd->format = bfd_unknown; /* Restore original format */
|
||||||
bfd_error = ((match_count == 0) ? file_not_recognized :
|
if (match_count == 0)
|
||||||
file_ambiguously_recognized);
|
{
|
||||||
|
bfd_error = file_not_recognized;
|
||||||
|
if (matching)
|
||||||
|
free (matching_vector);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
bfd_error = file_ambiguously_recognized;
|
||||||
return false;
|
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
|
FUNCTION
|
||||||
bfd_set_format
|
bfd_set_format
|
||||||
@ -217,9 +250,9 @@ DESCRIPTION
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
DEFUN(bfd_set_format,(abfd, format),
|
bfd_set_format (abfd, format)
|
||||||
bfd *abfd AND
|
bfd *abfd;
|
||||||
bfd_format format)
|
bfd_format format;
|
||||||
{
|
{
|
||||||
|
|
||||||
if (bfd_read_p (abfd) ||
|
if (bfd_read_p (abfd) ||
|
||||||
@ -258,8 +291,8 @@ DESCRIPTION
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
CONST char *
|
CONST char *
|
||||||
DEFUN(bfd_format_string,(format),
|
bfd_format_string (format)
|
||||||
bfd_format format)
|
bfd_format format;
|
||||||
{
|
{
|
||||||
if (((int)format <(int) bfd_unknown)
|
if (((int)format <(int) bfd_unknown)
|
||||||
|| ((int)format >=(int) bfd_type_end))
|
|| ((int)format >=(int) bfd_type_end))
|
||||||
|
@ -573,12 +573,10 @@ bfd_target *default_vector[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* When there is an ambiguous match, bfd_check_format puts the names
|
/* When there is an ambiguous match, bfd_check_format_ambig puts the names
|
||||||
of the matching targets in this array.
|
of the matching targets in an array. This variable is the maximum
|
||||||
It is declared here so we can give it the same number of entries
|
number of entries that array could possibly need. */
|
||||||
(+ a terminating NULL) as the number of possible targets. */
|
CONST size_t bfd_default_vector_entries = sizeof(target_vector)/sizeof(*target_vector);
|
||||||
char *matching_vector[sizeof(target_vector)/sizeof(*target_vector) + 1];
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FUNCTION
|
FUNCTION
|
||||||
|
Reference in New Issue
Block a user