aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2024-06-15 07:43:08 +0930
committerAlan Modra <amodra@gmail.com>2024-06-17 15:57:50 +0930
commit2df6e967098a2f48a83a2ec6000a9c53b493c737 (patch)
tree017940ba576877fdaec378e5f7d3708dc791886a
parentc3d23f753daaac52ee6c788090845ff0f359cf27 (diff)
downloadbinutils-2df6e967098a2f48a83a2ec6000a9c53b493c737.zip
binutils-2df6e967098a2f48a83a2ec6000a9c53b493c737.tar.gz
binutils-2df6e967098a2f48a83a2ec6000a9c53b493c737.tar.bz2
Error messages emitted during bfd_check_format_matches
Error/warning messages are only printed for the target that successfully matched, which makes sense for warnings, but not so much for errors where the errors cause no target to match. I noticed this when looking at the pr20520 testcase again with objdump, which just reports "file format not recognized" omitting the five "SHT_GROUP section [index n] has no SHF_GROUP sections" messages. They are omitted because multiple ELF targets match the object file. This is going to be true for all ELF objects due to at least the proper ELF target and the generic ELF target matching. * format.c (print_and_clear_messages): Print messages if all targets with messages have exactly the same set of messages.
-rw-r--r--bfd/format.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/bfd/format.c b/bfd/format.c
index 443fc6d..d0af388 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -282,20 +282,40 @@ clear_warnmsg (struct per_xvec_message **list)
/* Free all the storage in LIST. Note that the first element of LIST
is special and is assumed to be stack-allocated. TARG is used for
re-issuing warning messages. If TARG is PER_XVEC_NO_TARGET, then
- it acts like a sort of wildcard -- messages are only reissued if
- they are all associated with a single BFD target, regardless of
- which one it is. If TARG is anything else, then only messages
- associated with TARG are emitted. */
+ it acts like a sort of wildcard -- messages are reissued if all
+ targets with messages have identical messages. One copy of the
+ messages are then reissued. If TARG is anything else, then only
+ messages associated with TARG are emitted. */
static void
print_and_clear_messages (struct per_xvec_messages *list,
const bfd_target *targ)
{
- struct per_xvec_messages *iter = list;
+ struct per_xvec_messages *iter;
- if (targ == PER_XVEC_NO_TARGET && list->next == NULL)
- print_warnmsg (&list->messages);
+ if (targ == PER_XVEC_NO_TARGET)
+ {
+ iter = list->next;
+ while (iter != NULL)
+ {
+ struct per_xvec_message *msg1 = list->messages;
+ struct per_xvec_message *msg2 = iter->messages;
+ do
+ {
+ if (strcmp (msg1->message, msg2->message))
+ break;
+ msg1 = msg1->next;
+ msg2 = msg2->next;
+ } while (msg1 && msg2);
+ if (msg1 || msg2)
+ break;
+ iter = iter->next;
+ }
+ if (iter == NULL)
+ targ = list->targ;
+ }
+ iter = list;
while (iter != NULL)
{
struct per_xvec_messages *next = iter->next;