* Makefile.in ($(NM_PROG)): Depend on demangle.o.

(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.
This commit is contained in:
David MacKenzie 1993-08-13 00:02:25 +00:00
parent 8b46d73404
commit d6a4c37569
3 changed files with 35 additions and 16 deletions

View File

@ -197,8 +197,8 @@ $(STRINGS_PROG): $(ADDL_LIBS) strings.o $(BFD)
$(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)
@ -220,7 +220,12 @@ underscore.c:
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
@ -292,7 +297,7 @@ nm.o: nm.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)/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 \

View File

@ -639,7 +639,8 @@ The GNU linker @code{ld} is now described in a separate manual.
@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 ]
@ -716,7 +717,15 @@ listed.
@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}
@ -1188,7 +1197,7 @@ archives, @samp{strip -v} lists all members of the archive.
@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
@ -1204,20 +1213,15 @@ dollars, or periods) seen in the input is a potential label. If the
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 -_

View File

@ -17,6 +17,8 @@ nm\(em\&list symbols from object files.
.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 "\|]"
@ -71,6 +73,14 @@ The same as
.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'',