binutils, ld: make objdump --ctf's parameter optional

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.
This commit is contained in:
Nick Alcock 2021-10-25 11:17:02 +01:00
parent 80b56fad5c
commit 10909ea819
35 changed files with 81 additions and 35 deletions

View 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> 2021-10-25 Nick Alcock <nick.alcock@oracle.com>
* objdump.c (usage): --ctf-parent now takes a name, not a section. * objdump.c (usage): --ctf-parent now takes a name, not a section.

View File

@ -1,13 +1,15 @@
@c This file contains the entry for the --ctf, --ctf-parent, --ctf-symbols, -and @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. @c --ctf-strings options that are common to both readelf and objdump.
@item --ctf=@var{section} @item --ctf[=@var{section}]
@cindex CTF @cindex CTF
@cindex Compact Type Format @cindex Compact Type Format
Display the contents of the specified CTF section. CTF sections themselves Display the contents of the specified CTF section. CTF sections themselves
contain many subsections, all of which are displayed in order. 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} @item --ctf-parent=@var{member}

View File

@ -273,7 +273,7 @@ usage (FILE *stream, int status)
separate debuginfo files. (Implies -WK)\n")); separate debuginfo files. (Implies -WK)\n"));
#ifdef ENABLE_LIBCTF #ifdef ENABLE_LIBCTF
fprintf (stream, _("\ fprintf (stream, _("\
--ctf=SECTION Display CTF info from SECTION\n")); --ctf[=SECTION] Display CTF info from SECTION, (default `.ctf')\n"));
#endif #endif
fprintf (stream, _("\ fprintf (stream, _("\
-t, --syms Display the contents of the symbol table(s)\n")); -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'}, {"include", required_argument, NULL, 'I'},
{"dwarf", optional_argument, NULL, OPTION_DWARF}, {"dwarf", optional_argument, NULL, OPTION_DWARF},
#ifdef ENABLE_LIBCTF #ifdef ENABLE_LIBCTF
{"ctf", required_argument, NULL, OPTION_CTF}, {"ctf", optional_argument, NULL, OPTION_CTF},
{"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT}, {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT},
#endif #endif
{"stabs", no_argument, NULL, 'G'}, {"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; size_t member = 0;
int err; int err;
if (sect_name == NULL)
sect_name = ".ctf";
if ((ctfdata = read_section_stabs (abfd, sect_name, &ctfsize, NULL)) == NULL) if ((ctfdata = read_section_stabs (abfd, sect_name, &ctfsize, NULL)) == NULL)
bfd_fatal (bfd_get_filename (abfd)); bfd_fatal (bfd_get_filename (abfd));
@ -5449,7 +5451,8 @@ main (int argc, char **argv)
#ifdef ENABLE_LIBCTF #ifdef ENABLE_LIBCTF
case OPTION_CTF: case OPTION_CTF:
dump_ctf_section_info = true; dump_ctf_section_info = true;
dump_ctf_section_name = xstrdup (optarg); if (optarg)
dump_ctf_section_name = xstrdup (optarg);
seenflag = true; seenflag = true;
break; break;
case OPTION_CTF_PARENT: case OPTION_CTF_PARENT:

View 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> 2021-09-30 Dimitar Dimitrov <dimitar@dinux.eu>
* scripttempl/pru.sc (.resource_table): Align the output * scripttempl/pru.sc (.resource_table): Align the output

View File

@ -1,7 +1,7 @@
#as: #as:
#source: array-char.c #source: array-char.c
#source: array-int.c #source: array-int.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables --hash-style=sysv #ld: -shared --ctf-variables --hash-style=sysv
#name: Arrays #name: Arrays

View File

@ -4,7 +4,7 @@
#source: B.c #source: B.c
#source: B-2.c #source: B-2.c
#source: C.c #source: C.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Conflicting cycle 1.B-1 #name: Conflicting cycle 1.B-1

View File

@ -4,7 +4,7 @@
#source: B.c #source: B.c
#source: B-2.c #source: B-2.c
#source: C.c #source: C.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Conflicting cycle 1.B-2 #name: Conflicting cycle 1.B-2

View File

@ -4,7 +4,7 @@
#source: B.c #source: B.c
#source: B-2.c #source: B-2.c
#source: C.c #source: C.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Conflicting cycle 1.parent #name: Conflicting cycle 1.parent

View File

@ -6,7 +6,7 @@
#source: B-2.c #source: B-2.c
#source: C.c #source: C.c
#source: C-2.c #source: C-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Conflicting cycle 2.A-1 #name: Conflicting cycle 2.A-1

View File

@ -6,7 +6,7 @@
#source: B-2.c #source: B-2.c
#source: C.c #source: C.c
#source: C-2.c #source: C-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Conflicting cycle 2.A-2 #name: Conflicting cycle 2.A-2

View File

@ -6,7 +6,7 @@
#source: B-2.c #source: B-2.c
#source: C.c #source: C.c
#source: C-2.c #source: C-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Conflicting cycle 2.parent #name: Conflicting cycle 2.parent

View File

@ -5,7 +5,7 @@
#source: B-2.c #source: B-2.c
#source: C.c #source: C.c
#source: C-2.c #source: C-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Conflicting cycle 3.C-1 #name: Conflicting cycle 3.C-1

View File

@ -5,7 +5,7 @@
#source: B-2.c #source: B-2.c
#source: C.c #source: C.c
#source: C-2.c #source: C-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Conflicting cycle 3.C-2 #name: Conflicting cycle 3.C-2

View File

@ -5,7 +5,7 @@
#source: B-2.c #source: B-2.c
#source: C.c #source: C.c
#source: C-2.c #source: C-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared #ld: -shared
#name: Conflicting cycle 3 #name: Conflicting cycle 3

View File

@ -1,7 +1,7 @@
#as: #as:
#source: enum.c #source: enum.c
#source: enum-2.c #source: enum-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared #ld: -shared
#name: Conflicting Enums #name: Conflicting Enums

View File

@ -1,7 +1,7 @@
#as: #as:
#source: typedef-int.c #source: typedef-int.c
#source: typedef-long.c #source: typedef-long.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared #ld: -shared
#name: Conflicting Typedefs #name: Conflicting Typedefs

View File

@ -3,7 +3,7 @@
#as: #as:
#source: cross-tu-cyclic-1.c #source: cross-tu-cyclic-1.c
#source: cross-tu-cyclic-2.c #source: cross-tu-cyclic-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared #ld: -shared
#name: cross-TU-cyclic-conflicting #name: cross-TU-cyclic-conflicting

View File

@ -5,7 +5,7 @@
#as: #as:
#source: cross-tu-2.c #source: cross-tu-2.c
#source: cross-tu-cyclic-1.c #source: cross-tu-cyclic-1.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: cross-TU-cyclic-nonconflicting #name: cross-TU-cyclic-nonconflicting

View File

@ -7,7 +7,7 @@
#as: #as:
#source: cross-tu-cyclic-3.c #source: cross-tu-cyclic-3.c
#source: cross-tu-cyclic-4.c #source: cross-tu-cyclic-4.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: cross-TU-into-cycle #name: cross-TU-into-cycle

View File

@ -3,7 +3,7 @@
#as: #as:
#source: cross-tu-1.c #source: cross-tu-1.c
#source: cross-tu-2.c #source: cross-tu-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: cross-TU-noncyclic #name: cross-TU-noncyclic

View File

@ -3,7 +3,7 @@
#source: A.c #source: A.c
#source: B.c #source: B.c
#source: C.c #source: C.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Cycle 1 #name: Cycle 1

View File

@ -2,7 +2,7 @@
#source: A.c #source: A.c
#source: B.c #source: B.c
#source: C.c #source: C.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Cycle 2.A #name: Cycle 2.A

View File

@ -2,7 +2,7 @@
#source: A.c #source: A.c
#source: B.c #source: B.c
#source: C.c #source: C.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Cycle 2.B #name: Cycle 2.B

View File

@ -2,7 +2,7 @@
#source: A.c #source: A.c
#source: B.c #source: B.c
#source: C.c #source: C.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Cycle 2.C #name: Cycle 2.C

View File

@ -1,7 +1,7 @@
#as: #as:
#source: data-func-1.c #source: data-func-1.c
#source: data-func-2.c #source: data-func-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared -s #ld: -shared -s
#name: Conflicted data syms, partially indexed, stripped #name: Conflicted data syms, partially indexed, stripped

View File

@ -1,6 +1,6 @@
#as: #as:
#source: diag-cttname-null.s #source: diag-cttname-null.s
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Diagnostics - Null type name #name: Diagnostics - Null type name

View File

@ -1,6 +1,6 @@
#as: #as:
#source: diag-cuname.s #source: diag-cuname.s
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Diagnostics - Invalid CU name offset #name: Diagnostics - Invalid CU name offset

View File

@ -1,6 +1,6 @@
#as: #as:
#source: diag-parlabel.s #source: diag-parlabel.s
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Diagnostics - Non-zero parlabel in parent #name: Diagnostics - Non-zero parlabel in parent

View File

@ -1,6 +1,6 @@
#as: #as:
#source: enum-forward.c #source: enum-forward.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared #ld: -shared
#name: Forwards to enums #name: Forwards to enums

View File

@ -1,6 +1,6 @@
#as: #as:
#source: enums.c #source: enums.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared #ld: -shared
#name: Enumerated types #name: Enumerated types

View File

@ -1,6 +1,6 @@
#as: #as:
#source: forward.c #source: forward.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared #ld: -shared
#name: Forwards #name: Forwards

View File

@ -1,6 +1,6 @@
#as: #as:
#source: function.c #source: function.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared #ld: -shared
#name: Function #name: Function

View File

@ -1,7 +1,7 @@
#as: #as:
#source: nonrepresentable-1.c #source: nonrepresentable-1.c
#source: nonrepresentable-2.c #source: nonrepresentable-2.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared #ld: -shared
#name: Nonrepresentable types #name: Nonrepresentable types

View File

@ -1,6 +1,6 @@
#as: #as:
#source: slice.c #source: slice.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared --ctf-variables #ld: -shared --ctf-variables
#name: Slice #name: Slice

View File

@ -1,6 +1,6 @@
#as: #as:
#source: super-sub-cycles.c #source: super-sub-cycles.c
#objdump: --ctf=.ctf #objdump: --ctf
#ld: -shared #ld: -shared
#name: Super- and sub-cycles #name: Super- and sub-cycles