(demangle.o): New target.
(cplus-dem.o): Depend on it, to force compilation order when doing
parallel compiles.
* nm.c (print_symbol_info_{bsd,sysv,posix}): Take a bfd arg.
(struct output_fns print_symbol_info): Ditto.
(long_options, usage, main): Add -C --demangle option.
(print_symname): New function, demangling if requested.
(print_symbols, print_symbol_info_{bsd,sysv,posix}): Use it.
$(STRIP_PROG): $(ADDL_LIBS) objcopy.o is-strip.o $(BFD)
$(CC) $(LDFLAGS) -o $(STRIP_PROG) objcopy.o is-strip.o $(ADDL_LIBS) $(EXTRALIBS)
-$(NM_PROG): $(ADDL_LIBS) nm.o $(BFD)
- $(CC) $(LDFLAGS) -o $(NM_PROG) nm.o $(ADDL_LIBS) $(EXTRALIBS)
+$(NM_PROG): $(ADDL_LIBS) nm.o demangle.o $(BFD)
+ $(CC) $(LDFLAGS) -o $(NM_PROG) nm.o demangle.o $(ADDL_LIBS) $(EXTRALIBS)
$(OBJDUMP_PROG): $(ADDL_LIBS) objdump.o $(BFD) $(OPCODES)
$(CC) $(LDFLAGS) -o $(OBJDUMP_PROG) objdump.o $(OPCODES) $(ADDL_LIBS) $(EXTRALIBS)
version.o: version.c
$(CC) $(INCLUDES) $(HDEFINES) $(TDEFINES) -DVERSION='"$(VERSION)"' $(CFLAGS) -c $(srcdir)/version.c
-cplus-dem.o: $(BASEDIR)/libiberty/cplus-dem.c $(INCDIR)/getopt.h
+demangle.o: $(BASEDIR)/libiberty/cplus-dem.c
+ $(CC) -c $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CFLAGS) $(BASEDIR)/libiberty/cplus-dem.c
+ mv cplus-dem.o demangle.o
+
+# For parallel compiling, depend on demangle.o so that one gets done first.
+cplus-dem.o: $(BASEDIR)/libiberty/cplus-dem.c $(INCDIR)/getopt.h demangle.o
$(CC) -c -DMAIN $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CFLAGS) $(BASEDIR)/libiberty/cplus-dem.c
$(DEMANGLER_PROG): cplus-dem.o $(LIBIBERTY) underscore.o version.o
$(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
$(INCDIR)/fopen-same.h bucomm.h $(INCDIR)/getopt.h \
$(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
- $(INCDIR)/aout/ranlib.h
+ $(INCDIR)/aout/ranlib.h $(INCDIR)/demangle.h
ar.o: ar.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
$(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
$(INCDIR)/fopen-same.h bucomm.h $(INCDIR)/aout/ar.h \
@kindex nm
@smallexample
-nm [ -a | --debug-syms ] [ -g | --extern-only ] [ -B ]
+nm [ -a | --debug-syms ] [ -g | --extern-only ]
+ [ -B ] [ -C | --demangle ]
[ -s | --print-armap ] [ -A | -o | --print-file-name ]
[ -n | -v | --numeric-sort ] [ -p | --no-sort ]
[ -r | --reverse-sort ] [ -u | --undefined-only ]
@item -B
@cindex @code{nm} format
@cindex @code{nm} compatibility
-The same as @samp{--format=bsd}.
+The same as @samp{--format=bsd} (for compatibility with the MIPS @code{nm}).
+
+@item -C
+@itemx --demangle
+@cindex demangling C++ symbols
+Decode (@dfn{demangle}) low-level symbol names into user-level names.
+Besides removing any initial underscore prepended by the system, this
+makes C++ function names readable. @xref{c++filt}, for more information
+on demangling.
@item -f @var{format}
@itemx --format=@var{format}
@smallexample
c++filt [ -_ | --strip-underscores ]
[ -s @var{format} | --format=@var{format} ]
- [ --help ] [ --version ] [ @var{arg}@dots{} ]
+ [ --help ] [ --version ] [ @var{symbol}@dots{} ]
@end smallexample
The C++ language provides function overloading, which means that you can
label decodes into a C++ name, the C++ name replaces the low-level
name in the output.
-A typical use of @code{c++filt} is to pipe the output of @code{nm}
-though it, using @code{c++filt} as a filter:
-
-@example
-nm @var{objfile} | c++filt
-@end example
-
-You can also use @code{c++filt} to decipher individual symbols:
+You can use @code{c++filt} to decipher individual symbols:
@example
c++filt @var{symbol}
@end example
-All results are printed on the standard output.
+If no @var{symbol} arguments are given, @code{c++filt} reads symbol
+names from the standard input and writes the demangled names to the
+standard output. All results are printed on the standard output.
@table @code
@item -_
.B nm
.RB "[\|" \-a | \-\-debug\-syms "\|]"
.RB "[\|" \-g | \-\-extern\-only "\|]"
+.RB "[\|" \-B "\|]"
+.RB "[\|" \-C | \-\-demangle "\|]"
.RB "[\|" \-s | \-\-print\-armap "\|]"
.RB "[\|" \-o | \-\-print\-file\-name "\|]"
.RB "[\|" \-n | \-\-numeric\-sort "\|]"
.B \-\-format=bsd
(for compatibility with the MIPS \fBnm\fP).
+.TP
+.B \-C
+.TP
+.B \-\-demangle
+Decode (\fIdemangle\fP) low-level symbol names into user-level names.
+Besides removing any initial underscore prepended by the system, this
+makes C++ function names readable.
+
.TP
.B "\-f \fIformat"
Use the output format \fIformat\fP, which can be ``bsd'',