summaryrefslogtreecommitdiffstats
path: root/usr.bin/nm
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-09-24 09:59:43 +0000
committerpeter <peter@FreeBSD.org>1996-09-24 09:59:43 +0000
commit142a5685e6c7ef39f8ac45884dbfea7d126e9ad2 (patch)
treed4adb080d93177cc6626c28558d7ea3fcf9b4dff /usr.bin/nm
parent86c863abe8f56df1d8eb4b0ff115423a0f055a44 (diff)
downloadFreeBSD-src-142a5685e6c7ef39f8ac45884dbfea7d126e9ad2.zip
FreeBSD-src-142a5685e6c7ef39f8ac45884dbfea7d126e9ad2.tar.gz
Rudimentry support for viewing weak symbols. There are two types that
this deals with, the N_INDR indirect symbols done with .stabs operations, and those done with .weak that have an extra field in n_other.
Diffstat (limited to 'usr.bin/nm')
-rw-r--r--usr.bin/nm/nm.110
-rw-r--r--usr.bin/nm/nm.1aout10
-rw-r--r--usr.bin/nm/nm.c36
3 files changed, 45 insertions, 11 deletions
diff --git a/usr.bin/nm/nm.1 b/usr.bin/nm/nm.1
index 907b3b1..7f2a691 100644
--- a/usr.bin/nm/nm.1
+++ b/usr.bin/nm/nm.1
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)nm.1 8.1 (Berkeley) 6/6/93
-.\" $Id$
+.\" $Id: nm.1,v 1.3 1996/08/29 18:06:05 wosch Exp $
.\"
.Dd June 6, 1993
.Dt NM 1
@@ -40,7 +40,7 @@
.Nd display name list (symbol table)
.Sh SYNOPSIS
.Nm nm
-.Op Fl agnoprtuw
+.Op Fl agnoprtuwW
.Ar
.Sh DESCRIPTION
The symbol table (name list) of each object in
@@ -80,6 +80,8 @@ Display undefined symbols only.
Warn about non-object archive members.
Normally, nm will silently ignore all archive members which are not
object files.
+.It Fl W
+Include an extra column in the output with a ``W'' indicating weak symbols.
.El
.Pp
Each symbol name is preceded by its value (a blank field if the symbol
@@ -100,10 +102,14 @@ common symbol
data segment symbol
.It Li f
file name
+.It Li I
+indirect reference symbol
.It Li T
text segment symbol
.It Li U
undefined
+.It Li W
+warn if next symbol is referenced
.El
.Pp
If the symbol is local (non-external) the type letter is in lower case.
diff --git a/usr.bin/nm/nm.1aout b/usr.bin/nm/nm.1aout
index 907b3b1..7f2a691 100644
--- a/usr.bin/nm/nm.1aout
+++ b/usr.bin/nm/nm.1aout
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)nm.1 8.1 (Berkeley) 6/6/93
-.\" $Id$
+.\" $Id: nm.1,v 1.3 1996/08/29 18:06:05 wosch Exp $
.\"
.Dd June 6, 1993
.Dt NM 1
@@ -40,7 +40,7 @@
.Nd display name list (symbol table)
.Sh SYNOPSIS
.Nm nm
-.Op Fl agnoprtuw
+.Op Fl agnoprtuwW
.Ar
.Sh DESCRIPTION
The symbol table (name list) of each object in
@@ -80,6 +80,8 @@ Display undefined symbols only.
Warn about non-object archive members.
Normally, nm will silently ignore all archive members which are not
object files.
+.It Fl W
+Include an extra column in the output with a ``W'' indicating weak symbols.
.El
.Pp
Each symbol name is preceded by its value (a blank field if the symbol
@@ -100,10 +102,14 @@ common symbol
data segment symbol
.It Li f
file name
+.It Li I
+indirect reference symbol
.It Li T
text segment symbol
.It Li U
undefined
+.It Li W
+warn if next symbol is referenced
.El
.Pp
If the symbol is local (non-external) the type letter is in lower case.
diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c
index e7e7e7d..42fb923 100644
--- a/usr.bin/nm/nm.c
+++ b/usr.bin/nm/nm.c
@@ -62,6 +62,7 @@ int print_only_external_symbols;
int print_only_undefined_symbols;
int print_all_symbols;
int print_file_each_line;
+int print_weak_symbols;
int fcount;
int rev, table;
@@ -72,6 +73,7 @@ int (*sfunc)() = fname;
#define IS_DEBUGGER_SYMBOL(x) ((x) & N_STAB)
#define IS_EXTERNAL(x) ((x) & N_EXT)
#define SYMBOL_TYPE(x) ((x) & (N_TYPE | N_STAB))
+#define SYMBOL_BIND(x) (((x) >> 4) & 0xf)
void *emalloc();
void usage __P(( void ));
@@ -79,6 +81,7 @@ int process_file __P(( char * ));
int show_archive __P(( char *, FILE * ));
int show_objfile __P(( char *, FILE * ));
void print_symbol __P(( char *, struct nlist * ));
+char typeletter __P((u_char));
/*
* main()
@@ -93,7 +96,7 @@ main(argc, argv)
extern int optind;
int ch, errors;
- while ((ch = getopt(argc, argv, "agnoprtuw")) != EOF) {
+ while ((ch = getopt(argc, argv, "agnoprtuwW")) != EOF) {
switch (ch) {
case 'a':
print_all_symbols = 1;
@@ -122,6 +125,9 @@ main(argc, argv)
case 'w':
ignore_bad_archive_entries = 0;
break;
+ case 'W':
+ print_weak_symbols = 1;
+ break;
case '?':
default:
usage();
@@ -471,7 +477,7 @@ print_symbol(objname, sym)
char *objname;
register struct nlist *sym;
{
- char *typestring(), typeletter();
+ char *typestring();
if (table) {
printf("%s|", objname);
@@ -481,8 +487,12 @@ print_symbol(objname, sym)
if (IS_DEBUGGER_SYMBOL(sym->n_type))
(void)printf("-|%02x %04x %5s|", sym->n_other,
sym->n_desc&0xffff, typestring(sym->n_type));
- else
- (void)printf("%c|", typeletter(sym->n_type));
+ else {
+ putchar(typeletter(sym->n_type));
+ if (print_weak_symbols && SYMBOL_BIND(sym->n_other)== 2)
+ putchar('W');
+ putchar('|');
+ }
/* print the symbol's name */
(void)printf("%s\n",sym->n_un.n_name);
@@ -510,8 +520,17 @@ print_symbol(objname, sym)
if (IS_DEBUGGER_SYMBOL(sym->n_type))
(void)printf(" - %02x %04x %5s ", sym->n_other,
sym->n_desc&0xffff, typestring(sym->n_type));
- else
- (void)printf(" %c ", typeletter(sym->n_type));
+ else {
+ putchar(' ');
+ putchar(typeletter(sym->n_type));
+ if (print_weak_symbols) {
+ if (SYMBOL_BIND(sym->n_other) == 2)
+ putchar('W');
+ else
+ putchar(' ');
+ }
+ putchar(' ');
+ }
/* print the symbol's name */
(void)puts(sym->n_un.n_name);
@@ -590,7 +609,10 @@ typeletter(type)
case N_DATA:
return(IS_EXTERNAL(type) ? 'D' : 'd');
case N_FN:
- return(IS_EXTERNAL(type) ? 'F' : 'f');
+ /* This one is overloaded. EXT = Warn, INT = filename */
+ return(IS_EXTERNAL(type) ? 'W' : 'f');
+ case N_INDR:
+ return(IS_EXTERNAL(type) ? 'I' : 'i');
case N_TEXT:
return(IS_EXTERNAL(type) ? 'T' : 't');
case N_UNDF:
OpenPOWER on IntegriCloud