diff options
author | Alan Modra <amodra@gmail.com> | 2013-05-23 03:35:59 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2013-05-23 03:35:59 +0000 |
commit | 03ae2d5e4fc9d1b19a13237be3d9e4081b865a33 (patch) | |
tree | d032e71368a5bceb6f2932f4ac0ce36811ab74a2 /bfd | |
parent | 2c573464eb31ba4ac974ee7949ad481d7e7be808 (diff) | |
download | fsf-binutils-gdb-03ae2d5e4fc9d1b19a13237be3d9e4081b865a33.zip fsf-binutils-gdb-03ae2d5e4fc9d1b19a13237be3d9e4081b865a33.tar.gz fsf-binutils-gdb-03ae2d5e4fc9d1b19a13237be3d9e4081b865a33.tar.bz2 |
* format.c (bfd_check_format_matches): Don't match a target in
targ_selvecs if some other target is a better match. If
targets implement match priority, fall back to the first of
the best matches.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/format.c | 22 |
2 files changed, 28 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e4c87be..d01e687 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2013-05-23 Alan Modra <amodra@gmail.com> + + * format.c (bfd_check_format_matches): Don't match a target in + targ_selvecs if some other target is a better match. If + targets implement match priority, fall back to the first of + the best matches. + 2013-05-22 Eric Herman <eric@freesa.org> PR binutils/15462 diff --git a/bfd/format.c b/bfd/format.c index e2afa3b..b8f39ca 100644 --- a/bfd/format.c +++ b/bfd/format.c @@ -376,6 +376,9 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) } } + /* We have more than one equally good match. If any of the best + matches is a target in config.bfd targ_defvec or targ_selvecs, + choose it. */ if (match_count > 1) { const bfd_target * const *assoc = bfd_associated_vector; @@ -385,7 +388,8 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) int i = match_count; while (--i >= 0) - if (matching_vector[i] == right_targ) + if (matching_vector[i] == right_targ + && right_targ->match_priority <= best_match) break; if (i >= 0) @@ -396,6 +400,22 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) } } + /* We still have more than one equally good match, and at least some + of the targets support match priority. Choose the first of the + best matches. */ + if (match_count > 1 && best_count != match_count) + { + int i; + + for (i = 0; i < match_count; i++) + { + right_targ = matching_vector[i]; + if (right_targ->match_priority <= best_match) + break; + } + match_count = 1; + } + /* There is way too much undoing of half-known state here. We really shouldn't iterate on live bfd's. Note that saving the whole bfd and restoring it would be even worse; the first thing |