From aa02037b08312eece5c06e1e98b2ce8b30993c5c Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 11 May 2022 13:54:30 +0100 Subject: [PATCH] nm: use -U as an alias for --defines-only, in line with llvm-nm --- binutils/doc/binutils.texi | 47 +++++++++++++++++++++----------------- binutils/nm.c | 22 +++++++++++------- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index 2c234c682aa..292588c241d 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -817,10 +817,9 @@ nm [@option{-A}|@option{-o}|@option{--print-file-name}] [@option{-s}|@option{--print-armap}] [@option{-t} @var{radix}|@option{--radix=}@var{radix}] [@option{-u}|@option{--undefined-only}] - [@option{-U} @var{method}] [@option{--unicode=}@var{method}] + [@option{-U}|@option{--defined-only}] [@option{-V}|@option{--version}] [@option{-X 32_64}] - [@option{--defined-only}] [@option{--no-demangle}] [@option{--no-recurse-limit}|@option{--recurse-limit}]] [@option{--plugin} @var{name}] @@ -828,6 +827,7 @@ nm [@option{-A}|@option{-o}|@option{--print-file-name}] [@option{--special-syms}] [@option{--synthetic}] [@option{--target=}@var{bfdname}] + [@option{--unicode=}@var{method}] [@option{--with-symbol-versions}] [@option{--without-symbol-versions}] [@var{objfile}@dots{}] @@ -1137,21 +1137,14 @@ Use @var{radix} as the radix for printing the symbol values. It must be @cindex external symbols @cindex undefined symbols Display only undefined symbols (those external to each object file). +By default both defined and undefined symbols are displayed. -@item -U @var{[d|i|l|e|x|h]} -@itemx --unicode=@var{[default|invalid|locale|escape|hex|highlight]} -Controls the display of UTF-8 encoded multibyte characters in strings. -The default (@option{--unicode=default}) is to give them no special -treatment. The @option{--unicode=locale} option displays the sequence -in the current locale, which may or may not support them. The options -@option{--unicode=hex} and @option{--unicode=invalid} display them as -hex byte sequences enclosed by either angle brackets or curly braces. - -The @option{--unicode=escape} option displays them as escape sequences -(@var{\uxxxx}) and the @option{--unicode=highlight} option displays -them as escape sequences highlighted in red (if supported by the -output device). The colouring is intended to draw attention to the -presence of unicode sequences where they might not be expected. +@item -U +@itemx --defined-only +@cindex external symbols +@cindex undefined symbols +Display only defined symbols for each object file. +By default both defined and undefined symbols are displayed. @item -V @itemx --version @@ -1163,11 +1156,6 @@ This option is ignored for compatibility with the AIX version of @option{32_64}. The default mode of AIX @command{nm} corresponds to @option{-X 32}, which is not supported by @sc{gnu} @command{nm}. -@item --defined-only -@cindex external symbols -@cindex undefined symbols -Display only defined symbols for each object file. - @item --plugin @var{name} @cindex plugins Load the plugin called @var{name} to add support for extra target @@ -1196,6 +1184,9 @@ with the next higher value. If the @code{bsd} output format is used the size of the symbol is printed, rather than the value, and @samp{-S} must be used in order both size and value to be printed. +Note - this option does not work if @option{--undefined-only} has been +enabled as undefined symbols have no size. + @item --special-syms Display symbols which have a target-specific special meaning. These symbols are usually used by the target for some special processing and @@ -1208,6 +1199,20 @@ Include synthetic symbols in the output. These are special symbols created by the linker for various purposes. They are not shown by default since they are not part of the binary's original source code. +@item --unicode=@var{[default|invalid|locale|escape|hex|highlight]} +Controls the display of UTF-8 encoded multibyte characters in strings. +The default (@option{--unicode=default}) is to give them no special +treatment. The @option{--unicode=locale} option displays the sequence +in the current locale, which may or may not support them. The options +@option{--unicode=hex} and @option{--unicode=invalid} display them as +hex byte sequences enclosed by either angle brackets or curly braces. + +The @option{--unicode=escape} option displays them as escape sequences +(@var{\uxxxx}) and the @option{--unicode=highlight} option displays +them as escape sequences highlighted in red (if supported by the +output device). The colouring is intended to draw attention to the +presence of unicode sequences where they might not be expected. + @item --with-symbol-versions @item --without-symbol-versions Enables or disables the display of symbol version information. The diff --git a/binutils/nm.c b/binutils/nm.c index c8ea75f34f4..9edaa8d26b0 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -242,6 +242,7 @@ enum long_option_values OPTION_RECURSE_LIMIT, OPTION_NO_RECURSE_LIMIT, OPTION_IFUNC_CHARS, + OPTION_UNICODE, OPTION_QUIET }; @@ -276,9 +277,9 @@ static struct option long_options[] = {"special-syms", no_argument, &allow_special_symbols, 1}, {"synthetic", no_argument, &show_synthetic, 1}, {"target", required_argument, 0, OPTION_TARGET}, - {"defined-only", no_argument, &defined_only, 1}, - {"undefined-only", no_argument, &undefined_only, 1}, - {"unicode", required_argument, NULL, 'U'}, + {"defined-only", no_argument, 0, 'U'}, + {"undefined-only", no_argument, 0, 'u'}, + {"unicode", required_argument, NULL, OPTION_UNICODE}, {"version", no_argument, &show_version, 1}, {"with-symbol-versions", no_argument, &with_symbol_versions, 1}, {"without-symbol-versions", no_argument, &with_symbol_versions, 0}, @@ -311,8 +312,6 @@ usage (FILE *stream, int status) --no-recurse-limit Disable a demangling recursion limit.\n")); fprintf (stream, _("\ -D, --dynamic Display dynamic symbols instead of normal symbols\n")); - fprintf (stream, _("\ - --defined-only Display only defined symbols\n")); fprintf (stream, _("\ -e (ignored)\n")); fprintf (stream, _("\ @@ -361,8 +360,10 @@ usage (FILE *stream, int status) fprintf (stream, _("\ -u, --undefined-only Display only undefined symbols\n")); fprintf (stream, _("\ - -U {d|s|i|x|e|h} Specify how to treat UTF-8 encoded unicode characters\n\ - --unicode={default|show|invalid|hex|escape|highlight}\n")); + -U, --defined-only Display only defined symbols\n")); + fprintf (stream, _("\ + --unicode={default|show|invalid|hex|escape|highlight}\n\ + Specify how to treat UTF-8 encoded unicode characters\n")); fprintf (stream, _("\ --with-symbol-versions Display version strings after symbol names\n")); fprintf (stream, _("\ @@ -2143,9 +2144,14 @@ main (int argc, char **argv) break; case 'u': undefined_only = 1; + defined_only = 0; break; - case 'U': + defined_only = 1; + undefined_only = 0; + break; + + case OPTION_UNICODE: if (streq (optarg, "default") || streq (optarg, "d")) unicode_display = unicode_default; else if (streq (optarg, "locale") || streq (optarg, "l")) -- 2.30.2