binutils, ld: make objdump --ctf's parameter optional
authorNick Alcock <nick.alcock@oracle.com>
Mon, 25 Oct 2021 10:17:02 +0000 (11:17 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 25 Oct 2021 10:17:03 +0000 (11:17 +0100)
ld by default (and always, unless adjusted with a hand-rolled linker
script) emits deduplicated CTF into the .ctf section.  But viewing
it needs you to explicitly tell objdump this: it doesn't default
its argument, even though what you always end up typing is
--ctf=.ctf.

This is annoying, so make the argument optional.

binutils/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

* objdump.c (usage): --ctf now has an optional argument.
(main): Adjust accordingly.
(dump_ctf): Default it.
* doc/ctf.options.texi: Adjust.

ld/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

* testsuite/ld-ctf/array.d: Change --ctf=.ctf to --ctf.
* testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-enums.d: Likewise.
* testsuite/ld-ctf/conflicting-typedefs.d: Likewise.
* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
* testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d: Likewise.
* testsuite/ld-ctf/cross-tu-into-cycle.d: Likewise.
* testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
* testsuite/ld-ctf/cycle-1.d: Likewise.
* testsuite/ld-ctf/cycle-2.A.d: Likewise.
* testsuite/ld-ctf/cycle-2.B.d: Likewise.
* testsuite/ld-ctf/cycle-2.C.d: Likewise.
* testsuite/ld-ctf/data-func-conflicted.d: Likewise.
* testsuite/ld-ctf/diag-cttname-null.d: Likewise.
* testsuite/ld-ctf/diag-cuname.d: Likewise.
* testsuite/ld-ctf/diag-parlabel.d: Likewise.
* testsuite/ld-ctf/enum-forward.d: Likewise.
* testsuite/ld-ctf/enums.d: Likewise.
* testsuite/ld-ctf/forward.d: Likewise.
* testsuite/ld-ctf/function.d: Likewise.
* testsuite/ld-ctf/nonrepresentable.d: Likewise.
* testsuite/ld-ctf/slice.d: Likewise.
* testsuite/ld-ctf/super-sub-cycles.d: Likewise.

35 files changed:
binutils/ChangeLog
binutils/doc/ctf.options.texi
binutils/objdump.c
ld/ChangeLog
ld/testsuite/ld-ctf/array.d
ld/testsuite/ld-ctf/conflicting-cycle-1.B-1.d
ld/testsuite/ld-ctf/conflicting-cycle-1.B-2.d
ld/testsuite/ld-ctf/conflicting-cycle-1.parent.d
ld/testsuite/ld-ctf/conflicting-cycle-2.A-1.d
ld/testsuite/ld-ctf/conflicting-cycle-2.A-2.d
ld/testsuite/ld-ctf/conflicting-cycle-2.parent.d
ld/testsuite/ld-ctf/conflicting-cycle-3.C-1.d
ld/testsuite/ld-ctf/conflicting-cycle-3.C-2.d
ld/testsuite/ld-ctf/conflicting-cycle-3.parent.d
ld/testsuite/ld-ctf/conflicting-enums.d
ld/testsuite/ld-ctf/conflicting-typedefs.d
ld/testsuite/ld-ctf/cross-tu-cyclic-conflicting.d
ld/testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d
ld/testsuite/ld-ctf/cross-tu-into-cycle.d
ld/testsuite/ld-ctf/cross-tu-noncyclic.d
ld/testsuite/ld-ctf/cycle-1.d
ld/testsuite/ld-ctf/cycle-2.A.d
ld/testsuite/ld-ctf/cycle-2.B.d
ld/testsuite/ld-ctf/cycle-2.C.d
ld/testsuite/ld-ctf/data-func-conflicted.d
ld/testsuite/ld-ctf/diag-cttname-null.d
ld/testsuite/ld-ctf/diag-cuname.d
ld/testsuite/ld-ctf/diag-parlabel.d
ld/testsuite/ld-ctf/enum-forward.d
ld/testsuite/ld-ctf/enums.d
ld/testsuite/ld-ctf/forward.d
ld/testsuite/ld-ctf/function.d
ld/testsuite/ld-ctf/nonrepresentable.d
ld/testsuite/ld-ctf/slice.d
ld/testsuite/ld-ctf/super-sub-cycles.d

index ea9cfe4314652eae8e50bcb5f4f81f11e130df1e..efde928b3f092da6d2a7311e37045fc9ad73af4e 100644 (file)
@@ -1,3 +1,10 @@
+2021-10-25  Nick Alcock  <nick.alcock@oracle.com>
+
+       * objdump.c (usage): --ctf now has an optional argument.
+       (main): Adjust accordingly.
+       (dump_ctf): Default it.
+       * doc/ctf.options.texi: Adjust.
+
 2021-10-25  Nick Alcock  <nick.alcock@oracle.com>
 
        * objdump.c (usage): --ctf-parent now takes a name, not a section.
index 34451f9221ab313761239d4c060b91f05accc1c4..2820946f2c06b08110c1812d4cba39aa6ac07685 100644 (file)
@@ -1,13 +1,15 @@
 @c This file contains the entry for the --ctf, --ctf-parent, --ctf-symbols, -and
 @c --ctf-strings options that are common to both readelf and objdump.
 
-@item --ctf=@var{section}
+@item --ctf[=@var{section}]
 @cindex CTF
 @cindex Compact Type Format
 
 Display the contents of the specified CTF section.  CTF sections themselves
 contain many subsections, all of which are displayed in order.
 
+By default, display the name of the section named @var{.ctf}, which is the
+name emitted by @command{ld}.
 
 @item --ctf-parent=@var{member}
 
index 43472e19e259ac3c25e5057532d03c085c8f626a..356e3ecd853ab16deb1cefd83a201783e66492f3 100644 (file)
@@ -273,7 +273,7 @@ usage (FILE *stream, int status)
                             separate debuginfo files.  (Implies -WK)\n"));
 #ifdef ENABLE_LIBCTF
   fprintf (stream, _("\
-      --ctf=SECTION        Display CTF info from SECTION\n"));
+      --ctf[=SECTION]      Display CTF info from SECTION, (default `.ctf')\n"));
 #endif
   fprintf (stream, _("\
   -t, --syms               Display the contents of the symbol table(s)\n"));
@@ -460,7 +460,7 @@ static struct option long_options[]=
   {"include", required_argument, NULL, 'I'},
   {"dwarf", optional_argument, NULL, OPTION_DWARF},
 #ifdef ENABLE_LIBCTF
-  {"ctf", required_argument, NULL, OPTION_CTF},
+  {"ctf", optional_argument, NULL, OPTION_CTF},
   {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT},
 #endif
   {"stabs", no_argument, NULL, 'G'},
@@ -4218,6 +4218,8 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name)
   size_t member = 0;
   int err;
 
+  if (sect_name == NULL)
+    sect_name = ".ctf";
 
   if ((ctfdata = read_section_stabs (abfd, sect_name, &ctfsize, NULL)) == NULL)
       bfd_fatal (bfd_get_filename (abfd));
@@ -5449,7 +5451,8 @@ main (int argc, char **argv)
 #ifdef ENABLE_LIBCTF
        case OPTION_CTF:
          dump_ctf_section_info = true;
-         dump_ctf_section_name = xstrdup (optarg);
+         if (optarg)
+           dump_ctf_section_name = xstrdup (optarg);
          seenflag = true;
          break;
        case OPTION_CTF_PARENT:
index 808191bd14e7e2ac239b495c7e25c29db870ff43..470e446ad5f07aa8ffea184e70707affd104c067 100644 (file)
@@ -1,3 +1,37 @@
+2021-10-25  Nick Alcock  <nick.alcock@oracle.com>
+
+       * testsuite/ld-ctf/array.d: Change --ctf=.ctf to --ctf.
+       * testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise.
+       * testsuite/ld-ctf/conflicting-enums.d: Likewise.
+       * testsuite/ld-ctf/conflicting-typedefs.d: Likewise.
+       * testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
+       * testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d: Likewise.
+       * testsuite/ld-ctf/cross-tu-into-cycle.d: Likewise.
+       * testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
+       * testsuite/ld-ctf/cycle-1.d: Likewise.
+       * testsuite/ld-ctf/cycle-2.A.d: Likewise.
+       * testsuite/ld-ctf/cycle-2.B.d: Likewise.
+       * testsuite/ld-ctf/cycle-2.C.d: Likewise.
+       * testsuite/ld-ctf/data-func-conflicted.d: Likewise.
+       * testsuite/ld-ctf/diag-cttname-null.d: Likewise.
+       * testsuite/ld-ctf/diag-cuname.d: Likewise.
+       * testsuite/ld-ctf/diag-parlabel.d: Likewise.
+       * testsuite/ld-ctf/enum-forward.d: Likewise.
+       * testsuite/ld-ctf/enums.d: Likewise.
+       * testsuite/ld-ctf/forward.d: Likewise.
+       * testsuite/ld-ctf/function.d: Likewise.
+       * testsuite/ld-ctf/nonrepresentable.d: Likewise.
+       * testsuite/ld-ctf/slice.d: Likewise.
+       * testsuite/ld-ctf/super-sub-cycles.d: Likewise.
+
 2021-09-30  Dimitar Dimitrov  <dimitar@dinux.eu>
 
        * scripttempl/pru.sc (.resource_table): Align the output
index 142f9e9fa947d548a85d8409c6ea228fa65941a5..0fe675e2c5dec005656521540b3eab0a5f89aa27 100644 (file)
@@ -1,7 +1,7 @@
 #as:
 #source: array-char.c
 #source: array-int.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables --hash-style=sysv
 #name: Arrays
 
index 27273c5386fb4e36dc2e55228b0ded439c21d518..2ed3ce19401b24beccd4c52943f987e796092f1b 100644 (file)
@@ -4,7 +4,7 @@
 #source: B.c
 #source: B-2.c
 #source: C.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Conflicting cycle 1.B-1
 
index 28a92f4a73edd8744a31d6ed130e4d193ee09ff3..3b9b7f627d2232d9f7bc4b31f2bbebe1fe336ca4 100644 (file)
@@ -4,7 +4,7 @@
 #source: B.c
 #source: B-2.c
 #source: C.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Conflicting cycle 1.B-2
 
index a9755e88db76e69310ff8ee0f6481b97b3d8a29f..83c56fe145c697d9b098285692bf99e2723520fc 100644 (file)
@@ -4,7 +4,7 @@
 #source: B.c
 #source: B-2.c
 #source: C.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Conflicting cycle 1.parent
 
index 33ed6e843ce1c06953675bd08f2e5e2041a79c26..6a07d368b7497777f14f1d003077804de65e8389 100644 (file)
@@ -6,7 +6,7 @@
 #source: B-2.c
 #source: C.c
 #source: C-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Conflicting cycle 2.A-1
 
index a98b66c267e750f4303c9847ca26fdd2c1404d1a..677542199b0954bd9b257841b18749bf3c2de2b7 100644 (file)
@@ -6,7 +6,7 @@
 #source: B-2.c
 #source: C.c
 #source: C-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Conflicting cycle 2.A-2
 
index 87ec41d69e4fbfb1c5468e4dd12964390a5e85ce..30be9b03ee42517b37d7576a52eea435d02643a3 100644 (file)
@@ -6,7 +6,7 @@
 #source: B-2.c
 #source: C.c
 #source: C-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Conflicting cycle 2.parent
 
index ac750a776dbe110dd1cfc712d2475830b6b741cc..b60768fc7a798839c307f1a5deaa3d33b36c5273 100644 (file)
@@ -5,7 +5,7 @@
 #source: B-2.c
 #source: C.c
 #source: C-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Conflicting cycle 3.C-1
 
index 603432f05ad0f90f82f825d253094606c5751bc7..590d37348878e64f08c8aa3639a3e6ba4db39c49 100644 (file)
@@ -5,7 +5,7 @@
 #source: B-2.c
 #source: C.c
 #source: C-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Conflicting cycle 3.C-2
 
index 24f080004cdd59580ff027c5d824cc321730eb7b..dbe2e46786f9e04090c7e75370bb2f3d7b0ced2b 100644 (file)
@@ -5,7 +5,7 @@
 #source: B-2.c
 #source: C.c
 #source: C-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared
 #name: Conflicting cycle 3
 
index 5eeae7a13edc344ec9f552da2fea0c5f7e62cc0a..4f8cf812ee486422c18c173091756fe5ecaab1d0 100644 (file)
@@ -1,7 +1,7 @@
 #as:
 #source: enum.c
 #source: enum-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared
 #name: Conflicting Enums
 
index 72082ba553b26b090ed0ef3ec3827a0369900a27..4ae8de413640dd63ffbc490488cabd1da19ecc8b 100644 (file)
@@ -1,7 +1,7 @@
 #as:
 #source: typedef-int.c
 #source: typedef-long.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared
 #name: Conflicting Typedefs
 
index 6d5e869bfbef65e1491cb4f25fa572793ca6b69e..0fba1b494cafda6a6407d97f845d164eedabb513 100644 (file)
@@ -3,7 +3,7 @@
 #as:
 #source: cross-tu-cyclic-1.c
 #source: cross-tu-cyclic-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared
 #name: cross-TU-cyclic-conflicting
 
index 1a714846d329b9a199791d0824c383e0214f5155..c83789a996583a62c2da77f606fd3f4f8d426da8 100644 (file)
@@ -5,7 +5,7 @@
 #as:
 #source: cross-tu-2.c
 #source: cross-tu-cyclic-1.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: cross-TU-cyclic-nonconflicting
 
index 7f3aebc54b7271695654ab81b1e75ee03d2c9ffc..903dedbb389e961b7a1d53e702127f9c9d4245ca 100644 (file)
@@ -7,7 +7,7 @@
 #as:
 #source: cross-tu-cyclic-3.c
 #source: cross-tu-cyclic-4.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: cross-TU-into-cycle
 
index 3ebc52dcb3bb9c0b0d9318947e61afed8bf85685..28c2eb424595344a13af06aa12fc896db1033ec3 100644 (file)
@@ -3,7 +3,7 @@
 #as:
 #source: cross-tu-1.c
 #source: cross-tu-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: cross-TU-noncyclic
 
index e64608e757112e59f6eb1cf4c4b5d986f6e1e219..379f12f57cd75ac7d16ddd160692df58cad42fec 100644 (file)
@@ -3,7 +3,7 @@
 #source: A.c
 #source: B.c
 #source: C.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Cycle 1
 
index 39d48c14c4ba6da61b493bb400a75d258aab0f86..ab3876c17d998cc63e49193eb99425da2d85ffe4 100644 (file)
@@ -2,7 +2,7 @@
 #source: A.c
 #source: B.c
 #source: C.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Cycle 2.A
 
index 4babd97bffe58aaebb36262c3453865d6bb5e7cf..65d702ec0366585b7addbcf8dfd7768f23c9ebee 100644 (file)
@@ -2,7 +2,7 @@
 #source: A.c
 #source: B.c
 #source: C.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Cycle 2.B
 
index 757483ca7e2db267620f9cbf5455950ae881eb80..81aa6dd71b22873ba5426d3b3b70c2f075d3ba22 100644 (file)
@@ -2,7 +2,7 @@
 #source: A.c
 #source: B.c
 #source: C.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Cycle 2.C
 
index f4f4fdd0e48c45946cee1c028868f6f5eaa045a7..7a1b2d722345d3788fdae67f1383f446589dcd57 100644 (file)
@@ -1,7 +1,7 @@
 #as:
 #source: data-func-1.c
 #source: data-func-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared -s
 #name: Conflicted data syms, partially indexed, stripped
 
index d1ca0b10c15548ab6a197cd841c56b540ed64bb0..511908ea211e1010c2fdece8cb235dbd2e854db2 100644 (file)
@@ -1,6 +1,6 @@
 #as:
 #source: diag-cttname-null.s
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Diagnostics - Null type name
 
index e4d49267a2a55ee20f676d83bea5c7bb49076243..d858b5fa400085f551b55111d2b3634d35c3fc52 100644 (file)
@@ -1,6 +1,6 @@
 #as:
 #source: diag-cuname.s
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Diagnostics - Invalid CU name offset
 
index 9d2c0860997e0215774251909a8a7337c38f4257..892970b2fb6de8aec57fe58408abce2393f47686 100644 (file)
@@ -1,6 +1,6 @@
 #as:
 #source: diag-parlabel.s
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Diagnostics - Non-zero parlabel in parent
 
index a83651eb4b8edfec8f152ba3cfb9f53ca2999629..c53364e16fdea9ad73f107a569c7f53a7fe5888b 100644 (file)
@@ -1,6 +1,6 @@
 #as:
 #source: enum-forward.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared
 #name: Forwards to enums
 
index d36c7e19f7fd457a30851c112ca460190cd02162..501c18f0b2c8ad4d2d061027bbe1a9c87fa1a09b 100644 (file)
@@ -1,6 +1,6 @@
 #as:
 #source: enums.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared
 #name: Enumerated types
 
index bb929612125a8a3b15e744647f4549bcf6d34d6e..5998ecb99bd5cf9fdc6a737e909a0bac1de828d1 100644 (file)
@@ -1,6 +1,6 @@
 #as:
 #source: forward.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared
 #name: Forwards
 
index e6cb20951f48681bf210e4685337db9da50f07f7..66c67eb18b46f0957191ecc597b335c83f9f0472 100644 (file)
@@ -1,6 +1,6 @@
 #as:
 #source: function.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared
 #name: Function
 
index 8461b54deadc4f8dd53d52406583bf6ec7f8f9f4..610558f6605cbe8ca70ce6debb407acf6dda4d9f 100644 (file)
@@ -1,7 +1,7 @@
 #as:
 #source: nonrepresentable-1.c
 #source: nonrepresentable-2.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared
 #name: Nonrepresentable types
 
index 8973dcf05e134a5ef2168bfcc41dfa6e8226ae0f..838607fae731401e54d95719902d426923923c86 100644 (file)
@@ -1,6 +1,6 @@
 #as:
 #source: slice.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared --ctf-variables
 #name: Slice
 
index 67fa358bc542c9aadbcb5b001b97fb8d67bed238..4eb009d0225080afd7abbc73f38c7716fb82dd16 100644 (file)
@@ -1,6 +1,6 @@
 #as:
 #source: super-sub-cycles.c
-#objdump: --ctf=.ctf
+#objdump: --ctf
 #ld: -shared
 #name: Super- and sub-cycles