objdump, readelf: Report errors from CTF archive iteration
authorNick Alcock <nick.alcock@oracle.com>
Fri, 20 Nov 2020 13:34:04 +0000 (13:34 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 20 Nov 2020 13:34:06 +0000 (13:34 +0000)
We were failing to report errors from ctf_archive_iter, which results in
silent early termination if (for example) one CTF archive member in a
.ctf section is corrupted and cannot be opened.  Report the error in the
usual fashion instead.

binutils/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

* objdump.c (dump_ctf): Report errors from ctf_archive_iter.
* readelf.c (dump_section_as_ctf): Likewise.

binutils/ChangeLog
binutils/objdump.c
binutils/readelf.c

index 8b7cba02859bf11ccf29762332495410f3601666..6555615fbfef6a24892a612ca510d46727d9d2a8 100644 (file)
@@ -1,3 +1,8 @@
+2020-11-20  Nick Alcock  <nick.alcock@oracle.com>
+
+       * objdump.c (dump_ctf): Report errors from ctf_archive_iter.
+       * readelf.c (dump_section_as_ctf): Likewise.
+
 2020-11-20  Nick Alcock  <nick.alcock@oracle.com>
 
        * objdump.c (dump_ctf): Use ctf_dict_open, not
index bf8234987f02ed4276d7c739e34277b0f4f80007..0d4092d4f3aab606c0f439652c88ad69516b4321 100644 (file)
@@ -4203,7 +4203,12 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
 
   printf (_("Contents of CTF section %s:\n"), sanitize_string (sect_name));
 
-  ctf_archive_iter (ctfa, dump_ctf_archive_member, parent);
+  if ((err = ctf_archive_iter (ctfa, dump_ctf_archive_member, parent)) != 0)
+    {
+      dump_ctf_errs (NULL);
+      non_fatal (_("CTF archive member open failure: %s"), ctf_errmsg (err));
+      bfd_fatal (bfd_get_filename (abfd));
+    }
   ctf_dict_close (parent);
   ctf_close (ctfa);
   ctf_close (parenta);
index a79f29548a1bab8e9fe90688c05d007071af5596..4d484dbe5f76a3bc4469744d7e6f8bbde7bd7f22 100644 (file)
@@ -14787,8 +14787,12 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
   printf (_("\nDump of CTF section '%s':\n"),
          printable_section_name (filedata, section));
 
-  if (ctf_archive_iter (ctfa, dump_ctf_archive_member, parent) != 0)
-    ret = FALSE;
+  if ((err = ctf_archive_iter (ctfa, dump_ctf_archive_member, parent)) != 0)
+    {
+      dump_ctf_errs (NULL);
+      error (_("CTF member open failure: %s\n"), ctf_errmsg (err));
+      ret = FALSE;
+    }
 
  fail:
   ctf_dict_close (parent);