• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisão0942c7ab94e554657c3e11ab85ae7f15373ee80d (tree)
Hora2020-07-02 19:30:52
AutorNick Clifton <nickc@redh...>
CommiterNick Clifton

Mensagem de Log

Change readelf's display of symbol names (when not in --wide mode) so that if they are going to be truncated then "[...]" is displayed at the end. Add a comment line option to disable this enhancement and restore the old behaviour.

PR 26028
binutils* readelf.c (print_symbol): Handle truncation of symbol names.
(options): Add -T/--silent-truncation option.
(parse_args): Handle the option.
(print_dynamic_symbol): Correct calculation of width available to
display symbol name.
* doc/binutils.texi: Document the -T option to readelf.
* NEWS: Mention the new feature.

gas * testsuite/gas/ia64/group-2.d: Add -T option to readelf
command line.
* testsuite/gas/ia64/unwind.d: Likewise.
* testsuite/gas/mmix/bspec-1.d: Likewise.
* testsuite/gas/mmix/bspec-2.d: Likewise.
* testsuite/gas/mmix/comment-1.d: Likewise.
* testsuite/gas/tic6x/scomm-directive-4.d: Likewise.

ld * testsuite/ld-powerpc/powerpc.exp: Add -T option to readelf
command line when running some tests.
* testsuite/ld-arm/arm-elf.exp: Likewise.
* testsuite/ld-mips-elf/mips-elf.exp: Likewise.
* testsuite/ld-mmix/local1.d: Likewise.
* testsuite/ld-mmix/local3.d: Likewise.
* testsuite/ld-mmix/local5.d: Likewise.
* testsuite/ld-mmix/local7.d: Likewise.
* testsuite/ld-powerpc/powerpc.exp: Likewise.

Mudança Sumário

Diff

--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,14 @@
1+2020-07-02 Nick Clifton <nickc@redhat.com>
2+
3+ PR 26028
4+ * readelf.c (print_symbol): Handle truncation of symbol names.
5+ (options): Add -T/--silent-truncation option.
6+ (parse_args): Handle the option.
7+ (print_dynamic_symbol): Correct calculation of width available to
8+ display symbol name.
9+ * doc/binutils.texi: Document the -T option to readelf.
10+ * NEWS: Mention the new feature.
11+
112 2020-06-30 H.J. Lu <hongjiu.lu@intel.com>
213
314 * NEWS: Mention x86 NaCl target support removal.
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -1,5 +1,11 @@
11 -*- text -*-
22
3+* Changed readelf's display of symbol names when wide mode is not enabled.
4+ If the name is too long it will be truncated and the last five characters
5+ replaced with "[...]". The old behaviour of displaying 5 more characters but
6+ not indicating that truncation has happened can be restored by the use of the
7+ -T or --silent-truncation options.
8+
39 * X86 NaCl target support is removed.
410
511 * The readelf tool now has a -L or --lint or --enable-checks option which turns
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -4726,6 +4726,7 @@ readelf [@option{-a}|@option{--all}]
47264726 [@option{-I}|@option{--histogram}]
47274727 [@option{-v}|@option{--version}]
47284728 [@option{-W}|@option{--wide}]
4729+ [@option{-T}|@option{--silent-truncation}]
47294730 [@option{-H}|@option{--help}]
47304731 @var{elffile}@dots{}
47314732 @c man end
@@ -4939,6 +4940,15 @@ Don't break output lines to fit into 80 columns. By default
49394940 @command{readelf} to print each section header resp. each segment one a
49404941 single line, which is far more readable on terminals wider than 80 columns.
49414942
4943+@item -T
4944+@itemx --silent-truncation
4945+Normally when readelf is displaying a symbol name, and it has to
4946+truncate the name to fit into an 80 column display, it will add a
4947+suffix of @code{[...]} to the name. This command line option
4948+disables this behaviour, allowing 5 more characters of the name to be
4949+displayed and restoring the old behaviour of readelf (prior to release
4950+2.35).
4951+
49424952 @item -H
49434953 @itemx --help
49444954 Display the command-line options understood by @command{readelf}.
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -234,6 +234,7 @@ static bfd_boolean do_archive_index = FALSE;
234234 static bfd_boolean check_all = FALSE;
235235 static bfd_boolean is_32bit_elf = FALSE;
236236 static bfd_boolean decompress_dumps = FALSE;
237+static bfd_boolean do_not_show_symbol_truncation = FALSE;
237238
238239 static char *dump_ctf_parent_name;
239240 static char *dump_ctf_symtab_name;
@@ -533,15 +534,19 @@ print_vma (bfd_vma vma, print_mode mode)
533534
534535 Display at most abs(WIDTH) characters, truncating as necessary, unless do_wide is true.
535536
537+ If truncation will happen and do_not_show_symbol_truncation is FALSE then display
538+ abs(WIDTH) - 5 characters followed by "[...]".
539+
536540 If WIDTH is negative then ensure that the output is at least (- WIDTH) characters,
537541 padding as necessary.
538542
539543 Returns the number of emitted characters. */
540544
541545 static unsigned int
542-print_symbol (signed int width, const char *symbol)
546+print_symbol (signed int width, const char * symbol)
543547 {
544548 bfd_boolean extra_padding = FALSE;
549+ bfd_boolean do_dots = FALSE;
545550 signed int num_printed = 0;
546551 #ifdef HAVE_MBSTATE_T
547552 mbstate_t state;
@@ -562,7 +567,17 @@ print_symbol (signed int width, const char *symbol)
562567 This simplifies the code below. */
563568 width_remaining = INT_MAX;
564569 else
565- width_remaining = width;
570+ {
571+ width_remaining = width;
572+ if (! do_not_show_symbol_truncation
573+ && (int) strlen (symbol) > width)
574+ {
575+ width_remaining -= 5;
576+ if ((int) width_remaining < 0)
577+ width_remaining = 0;
578+ do_dots = TRUE;
579+ }
580+ }
566581
567582 #ifdef HAVE_MBSTATE_T
568583 /* Initialise the multibyte conversion state. */
@@ -618,6 +633,9 @@ print_symbol (signed int width, const char *symbol)
618633 }
619634 }
620635
636+ if (do_dots)
637+ num_printed += printf ("[...]");
638+
621639 if (extra_padding && num_printed < width)
622640 {
623641 /* Fill in the remaining spaces. */
@@ -4512,6 +4530,7 @@ static struct option options[] =
45124530
45134531 {"version", no_argument, 0, 'v'},
45144532 {"wide", no_argument, 0, 'W'},
4533+ {"silent-truncation",no_argument, 0, 'T'},
45154534 {"help", no_argument, 0, 'H'},
45164535 {0, no_argument, 0, 0}
45174536 };
@@ -4579,6 +4598,7 @@ usage (FILE * stream)
45794598 fprintf (stream, _("\
45804599 -I --histogram Display histogram of bucket list lengths\n\
45814600 -W --wide Allow output width to exceed 80 characters\n\
4601+ -T --silent-truncation If a symbol name is truncated, do not add a suffix [...]\n\
45824602 @<file> Read options from <file>\n\
45834603 -H --help Display this information\n\
45844604 -v --version Display the version number of readelf\n"));
@@ -4673,7 +4693,7 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
46734693 usage (stderr);
46744694
46754695 while ((c = getopt_long
4676- (argc, argv, "ADHILNR:SVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
4696+ (argc, argv, "ADHILNR:STVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
46774697 {
46784698 switch (c)
46794699 {
@@ -4832,6 +4852,9 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
48324852 case 'W':
48334853 do_wide = TRUE;
48344854 break;
4855+ case 'T':
4856+ do_not_show_symbol_truncation = TRUE;
4857+ break;
48354858 default:
48364859 /* xgettext:c-format */
48374860 error (_("Invalid option '-%c'\n"), c);
@@ -12032,7 +12055,7 @@ print_dynamic_symbol (Filedata *filedata, unsigned long si,
1203212055 enum versioned_symbol_info sym_info;
1203312056 unsigned short vna_other;
1203412057 Elf_Internal_Sym *psym = symtab + si;
12035-
12058+
1203612059 printf ("%6ld: ", si);
1203712060 print_vma (psym->st_value, LONG_HEX);
1203812061 putchar (' ');
@@ -12053,9 +12076,10 @@ print_dynamic_symbol (Filedata *filedata, unsigned long si,
1205312076 printf (" [%s] ", get_symbol_other (filedata, psym->st_other ^ vis));
1205412077 }
1205512078 printf (" %4s ", get_symbol_index_type (filedata, psym->st_shndx));
12056- print_symbol (25, VALID_SYMBOL_NAME (strtab, strtab_size,
12057- psym->st_name)
12058- ? strtab + psym->st_name : _("<corrupt>"));
12079+
12080+ bfd_boolean is_valid = VALID_SYMBOL_NAME (strtab, strtab_size,
12081+ psym->st_name);
12082+ const char * sstr = is_valid ? strtab + psym->st_name : _("<corrupt>");
1205912083
1206012084 version_string
1206112085 = get_symbol_version_string (filedata,
@@ -12063,6 +12087,22 @@ print_dynamic_symbol (Filedata *filedata, unsigned long si,
1206312087 || section->sh_type == SHT_DYNSYM),
1206412088 strtab, strtab_size, si,
1206512089 psym, &sym_info, &vna_other);
12090+
12091+ int len_avail = 21;
12092+ if (! do_wide && version_string != NULL)
12093+ {
12094+ char buffer[256];
12095+
12096+ len_avail -= sprintf (buffer, "@%s", version_string);
12097+
12098+ if (sym_info == symbol_undefined)
12099+ len_avail -= sprintf (buffer," (%d)", vna_other);
12100+ else if (sym_info != symbol_hidden)
12101+ len_avail -= 1;
12102+ }
12103+
12104+ print_symbol (len_avail, sstr);
12105+
1206612106 if (version_string)
1206712107 {
1206812108 if (sym_info == symbol_undefined)
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,14 @@
1+2020-07-02 Nick Clifton <nickc@redhat.com>
2+
3+ PR 26028
4+ * testsuite/gas/ia64/group-2.d: Add -T option to readelf
5+ command line.
6+ * testsuite/gas/ia64/unwind.d: Likewise.
7+ * testsuite/gas/mmix/bspec-1.d: Likewise.
8+ * testsuite/gas/mmix/bspec-2.d: Likewise.
9+ * testsuite/gas/mmix/comment-1.d: Likewise.
10+ * testsuite/gas/tic6x/scomm-directive-4.d: Likewise.
11+
112 2020-07-01 Alan Modra <amodra@gmail.com>
213
314 * config/tc-xc16x.c (md_apply_fix): Add FIXME.
--- a/gas/testsuite/gas/ia64/group-2.d
+++ b/gas/testsuite/gas/ia64/group-2.d
@@ -1,4 +1,4 @@
1-#readelf: -Sg
1+#readelf: -Sg -T
22 #as: -x
33 #name: ia64 unwind group
44
--- a/gas/testsuite/gas/ia64/unwind.d
+++ b/gas/testsuite/gas/ia64/unwind.d
@@ -1,4 +1,4 @@
1-#readelf: -S
1+#readelf: -S -T
22 #name: ia64 unwind section
33
44 There are 9 section headers, starting at offset .*:
--- a/gas/testsuite/gas/mmix/bspec-1.d
+++ b/gas/testsuite/gas/mmix/bspec-1.d
@@ -1,4 +1,4 @@
1-#readelf: -Ssr -x1 -x4
1+#readelf: -Ssr -T -x1 -x4
22 There are 9 section headers, starting at offset .*:
33 #...
44 +\[ 4\] \.MMIX\.spec_data\.2 +PROGBITS +0+ +0+44
--- a/gas/testsuite/gas/mmix/bspec-2.d
+++ b/gas/testsuite/gas/mmix/bspec-2.d
@@ -1,4 +1,4 @@
1-#readelf: -Sr -x1 -x4
1+#readelf: -Sr -T -x1 -x4
22 There are 11 section headers, starting at offset .*:
33 #...
44 \[ 4\] \.MMIX\.spec_data\.2 PROGBITS 0+ 0+48
--- a/gas/testsuite/gas/mmix/comment-1.d
+++ b/gas/testsuite/gas/mmix/comment-1.d
@@ -1,5 +1,5 @@
11 #as: -no-expand
2-#readelf: -Ssrx1 -x6
2+#readelf: -Ssrx1 -T -x6
33 There are 10 section headers, starting at offset 0x...:
44 #...
55 +\[ 5\] \.MMIX\.spec_data\.4 +PROGBITS +0+ +0+c4
--- a/gas/testsuite/gas/tic6x/scomm-directive-4.d
+++ b/gas/testsuite/gas/tic6x/scomm-directive-4.d
@@ -1,7 +1,7 @@
11 #name: C6X .scomm directive 4
22 #as:
33 #source: scomm-directive-4.s
4-#readelf: -Ss
4+#readelf: -Ss -T
55
66 There are 8 section headers, starting at offset .*:
77
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,16 @@
1+2020-07-02 Nick Clifton <nickc@redhat.com>
2+
3+ PR 26028
4+ * testsuite/ld-powerpc/powerpc.exp: Add -T option to readelf
5+ command line when running some tests.
6+ * testsuite/ld-arm/arm-elf.exp: Likewise.
7+ * testsuite/ld-mips-elf/mips-elf.exp: Likewise.
8+ * testsuite/ld-mmix/local1.d: Likewise.
9+ * testsuite/ld-mmix/local3.d: Likewise.
10+ * testsuite/ld-mmix/local5.d: Likewise.
11+ * testsuite/ld-mmix/local7.d: Likewise.
12+ * testsuite/ld-powerpc/powerpc.exp: Likewise.
13+
114 2020-06-30 H.J. Lu <hongjiu.lu@intel.com>
215
316 * Makefile.am (ALL_EMULATION_SOURCES): Remove eelf_i386_nacl.c,
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -794,7 +794,7 @@ set armeabitests_nonacl {
794794 "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-implib.lib --cmse-implib" ""
795795 "-march=armv8-m.base -mthumb --defsym VER=1"
796796 {cmse-implib.s}
797- {{readelf {-s tmpdir/cmse-implib.lib} cmse-implib.rd}
797+ {{readelf {-s --wide tmpdir/cmse-implib.lib} cmse-implib.rd}
798798 {readelf {-h tmpdir/cmse-implib.lib} cmse-implib.type}}
799799 "cmse-implib"}
800800 {"Input secure gateway import library"
@@ -802,7 +802,7 @@ set armeabitests_nonacl {
802802 "-march=armv8-m.base -mthumb --defsym VER=2"
803803 {cmse-implib.s}
804804 {{ld cmse-new-implib.out}
805- {readelf {-s tmpdir/cmse-new-implib.lib} cmse-new-implib.rd}}
805+ {readelf {-s --wide tmpdir/cmse-new-implib.lib} cmse-new-implib.rd}}
806806 "cmse-new-implib"}
807807 {"Input secure gateway import library: no output import library"
808808 "--section-start .gnu.sgstubs=0x20000 --in-implib=tmpdir/cmse-implib.lib --cmse-implib" ""
@@ -832,7 +832,7 @@ set armeabitests_nonacl {
832832 "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-new-comeback-implib.lib --in-implib=tmpdir/cmse-implib.lib --cmse-implib" ""
833833 "-march=armv8-m.base -mthumb --defsym VER=3"
834834 {cmse-implib.s}
835- {{readelf {-s tmpdir/cmse-new-comeback-implib.lib} cmse-new-comeback-implib.rd}}
835+ {{readelf {-s --wide tmpdir/cmse-new-comeback-implib.lib} cmse-new-comeback-implib.rd}}
836836 "cmse-new-comeback-implib"}
837837 {"Input secure gateway import library: entry function change"
838838 "--section-start .gnu.sgstubs=0x20000 --out-implib=tmpdir/cmse-new-wrong-implib.lib --in-implib=tmpdir/cmse-implib.lib --cmse-implib" ""
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -29,7 +29,7 @@ if {[istarget "mips*-*-vxworks"]} {
2929 {"VxWorks executable test 1 (dynamic)" \
3030 "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic" ""
3131 "-mips2" {vxworks1.s}
32- {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
32+ {{readelf {--relocs -T} vxworks1.rd} {objdump -dr vxworks1.dd}}
3333 "vxworks1"}
3434 {"VxWorks executable test 2 (dynamic)" \
3535 "-Tvxworks1.ld -q --force-dynamic" ""
@@ -1575,7 +1575,7 @@ proc run_mips_undefweak_test { name abi args } {
15751575 [list \
15761576 [list objdump -d pr21375${objsuf}.dd] \
15771577 [list readelf -A pr21375${rdesuf}.gd] \
1578- [list readelf --dyn-syms pr21375${rdesuf}${irixsuf}.sd] \
1578+ [list readelf {--dyn-syms --wide} pr21375${rdesuf}${irixsuf}.sd] \
15791579 [list readelf -h pr21375${abisuf}.hd]] \
15801580 "pr21375${binsuf}${dsosuf}"]]
15811581 }
--- a/ld/testsuite/ld-mmix/local1.d
+++ b/ld/testsuite/ld-mmix/local1.d
@@ -4,7 +4,7 @@
44 #source: regext1.s
55 #source: start.s
66 #ld: -m elf64mmix
7-#readelf: -Ssx1 -x2
7+#readelf: -Ssx1 -T -x2
88
99 # We check that the externally visible symbol ext1 is a local register
1010 # (different meaning of "local" than for symbol), which can be seen as
--- a/ld/testsuite/ld-mmix/local3.d
+++ b/ld/testsuite/ld-mmix/local3.d
@@ -4,7 +4,7 @@
44 #source: ext1.s
55 #source: start.s
66 #ld: -m elf64mmix
7-#readelf: -Ssx1 -x2
7+#readelf: -Ssx1 -T -x2
88
99 # Like local1, but ext1 is here a constant, not a global register.
1010
--- a/ld/testsuite/ld-mmix/local5.d
+++ b/ld/testsuite/ld-mmix/local5.d
@@ -5,7 +5,7 @@
55 #source: regext1.s
66 #source: start.s
77 #ld: -m elf64mmix
8-#readelf: -Ssx1 -x2
8+#readelf: -Ssx1 -T -x2
99
1010 # Like local1, but with two checks for a local register.
1111
--- a/ld/testsuite/ld-mmix/local7.d
+++ b/ld/testsuite/ld-mmix/local7.d
@@ -5,7 +5,7 @@
55 #source: ext1.s
66 #source: start.s
77 #ld: -m elf64mmix
8-#readelf: -Ssx1 -x2
8+#readelf: -Ssx1 -T -x2
99
1010 # Like local1, but ext1 is here a constant, not a global register and two
1111 # local-register checks.
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -32,13 +32,13 @@ if {[istarget "*-*-vxworks"]} {
3232 {"VxWorks shared library test 1"
3333 "-shared --hash-style=sysv -Tvxworks1.ld" ""
3434 "-mregnames" {vxworks1-lib.s}
35- {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
35+ {{readelf {--relocs -T} vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
3636 {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
3737 "libvxworks1.so"}
3838 {"VxWorks executable test 1 (dynamic)" \
3939 "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic --hash-style=sysv" ""
4040 "-mregnames" {vxworks1.s}
41- {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
41+ {{readelf {--relocs -T} vxworks1.rd} {objdump -dr vxworks1.dd}}
4242 "vxworks1"}
4343 {"VxWorks executable test 2 (dynamic)" \
4444 "-Tvxworks1.ld -q --force-dynamic --hash-style=sysv" ""
@@ -58,7 +58,7 @@ if {[istarget "*-*-vxworks"]} {
5858 {"VxWorks relocatable relax test"
5959 "-Tvxworks1.ld -r --relax -q --hash-style=sysv" ""
6060 "-mregnames" {vxworks-relax-2.s}
61- {{readelf --relocs vxworks-relax-2.rd}}
61+ {{readelf {--relocs -T} vxworks-relax-2.rd}}
6262 "vxworks-relax-2"}
6363 }
6464 run_ld_link_tests $ppcvxtests