]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
objdump: get CTF parent importing right
authorNick Alcock <nick.alcock@oracle.com>
Fri, 2 Aug 2019 23:41:05 +0000 (00:41 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 3 Oct 2019 16:04:56 +0000 (17:04 +0100)
The linker emits CTF into a single section named .ctf, which is a CTF
archive where the default member (itself named ".ctf", or simply NULL)
is the parent of all other members.  Teach objdump to look for this by
default, rather than only trying to do it if a specific CTF parent
section was specified.  (If no parent name is specified, we get the .ctf
member from the same section as everything else, which matches what the
linker generates.)

binutils/
* objdump.c (dump_ctf): Use the default CTF archive member as the
parent even when no parent section is specified.
(dump_ctf_archive_member): Only import from the parent
if this is not the default ".ctf" member.

binutils/ChangeLog
binutils/doc/ctf.options.texi
binutils/objdump.c

index 3fba18e5cee7da4545a71a4b50cf77420c0d10d9..50eeb5cf4d0d41e4a4b65d51cd65985bfb34dddc 100644 (file)
@@ -1,3 +1,10 @@
+2019-08-03  Nick Alcock  <nick.alcock@oracle.com>
+
+       * objdump.c (dump_ctf): Use the default CTF archive member as the
+       parent even when no parent section is specified.
+       (dump_ctf_archive_member): Only import from the parent
+       if this is not the default ".ctf" member.
+
 2019-09-23  Nick Alcock  <nick.alcock@oracle.com>
 
        * Makefile.am (LIBCTF): Mention the .la file.
index cf0528044a5a50b5fc468ac642e213086d6fb31d..bb9946a80081142c04858c15d026baec9e89e864 100644 (file)
@@ -10,5 +10,6 @@ contain many subsections, all of which are displayed in order.
 
 @item --ctf-parent=@var{section}
 
-Specify the name of another section from which the CTF file can inherit
-types.
+Specify the name of another section from which the CTF dictionary can inherit
+types.  (If none is specified, we assume the CTF dictionary inherits types
+from the default-named member of the archive contained within this section.)
index d5a45ae5cb9b8d9f38a341785a7e7d1e0a98fa68..ae50d871082b86bbcd5a69e2451141a058012a1a 100644 (file)
@@ -3290,11 +3290,18 @@ dump_ctf_archive_member (ctf_file_t *ctf, const char *name, void *arg)
 
   /* Only print out the name of non-default-named archive members.
      The name .ctf appears everywhere, even for things that aren't
-     really archives, so printing it out is liable to be confusing.  */
+     really archives, so printing it out is liable to be confusing.
+
+     The parent, if there is one, is the default-owned archive member:
+     avoid importing it into itself.  (This does no harm, but looks
+     confusing.)  */
+
   if (strcmp (name, ".ctf") != 0)
-    printf (_("\nCTF archive member: %s:\n"), sanitize_string (name));
+    {
+      printf (_("\nCTF archive member: %s:\n"), sanitize_string (name));
+      ctf_import (ctf, parent);
+    }
 
-  ctf_import (ctf, parent);
   for (i = 0, thing = things; *thing[0]; thing++, i++)
     {
       ctf_dump_state_t *s = NULL;
@@ -3323,7 +3330,7 @@ dump_ctf_archive_member (ctf_file_t *ctf, const char *name, void *arg)
 static void
 dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
 {
-  ctf_archive_t *ctfa, *parenta = NULL;
+  ctf_archive_t *ctfa, *parenta = NULL, *lookparent;
   bfd_byte *ctfdata, *parentdata = NULL;
   bfd_size_type ctfsize, parentsize;
   ctf_sect_t ctfsect;
@@ -3356,14 +3363,18 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
          bfd_fatal (bfd_get_filename (abfd));
        }
 
-      /* Assume that the applicable parent archive member is the default one.
-        (This is what all known implementations are expected to do, if they
-        put CTFs and their parents in archives together.)  */
-      if ((parent = ctf_arc_open_by_name (parenta, NULL, &err)) == NULL)
-       {
-         non_fatal (_("CTF open failure: %s\n"), ctf_errmsg (err));
-         bfd_fatal (bfd_get_filename (abfd));
-       }
+      lookparent = parenta;
+    }
+  else
+    lookparent = ctfa;
+
+  /* Assume that the applicable parent archive member is the default one.
+     (This is what all known implementations are expected to do, if they
+     put CTFs and their parents in archives together.)  */
+  if ((parent = ctf_arc_open_by_name (lookparent, NULL, &err)) == NULL)
+    {
+      non_fatal (_("CTF open failure: %s\n"), ctf_errmsg (err));
+      bfd_fatal (bfd_get_filename (abfd));
     }
 
   printf (_("Contents of CTF section %s:\n"), sanitize_string (sect_name));