diff options
author | phk <phk@FreeBSD.org> | 1995-12-19 08:12:07 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-12-19 08:12:07 +0000 |
commit | 7fd77d5502ae16410a00260dd8669da71d530702 (patch) | |
tree | acb85f0ec60f6c925cab18c08c6df887bca1cd4c /usr.bin/nm | |
parent | 6fb31f3d8c2056be1dd893fd047b3a816a69498e (diff) | |
download | FreeBSD-src-7fd77d5502ae16410a00260dd8669da71d530702.zip FreeBSD-src-7fd77d5502ae16410a00260dd8669da71d530702.tar.gz |
Add -t option which prints output in tabular format.
Diffstat (limited to 'usr.bin/nm')
-rw-r--r-- | usr.bin/nm/nm.1 | 4 | ||||
-rw-r--r-- | usr.bin/nm/nm.1aout | 4 | ||||
-rw-r--r-- | usr.bin/nm/nm.c | 28 |
3 files changed, 29 insertions, 7 deletions
diff --git a/usr.bin/nm/nm.1 b/usr.bin/nm/nm.1 index ff7cdb2..1059953 100644 --- a/usr.bin/nm/nm.1 +++ b/usr.bin/nm/nm.1 @@ -39,7 +39,7 @@ .Nd display name list (symbol table) .Sh SYNOPSIS .Nm nm -.Op Fl agnopruw +.Op Fl agnoprtuw .Ar .Sh DESCRIPTION The symbol table (name list) of each object in @@ -71,6 +71,8 @@ Display full path or library name of object on every line. Do not sort at all. .It Fl r Reverse order sort. +.It Fl t +Output in tabular format more suitable for other programs digestive system. .It Fl u Display undefined symbols only. .It Fl w diff --git a/usr.bin/nm/nm.1aout b/usr.bin/nm/nm.1aout index ff7cdb2..1059953 100644 --- a/usr.bin/nm/nm.1aout +++ b/usr.bin/nm/nm.1aout @@ -39,7 +39,7 @@ .Nd display name list (symbol table) .Sh SYNOPSIS .Nm nm -.Op Fl agnopruw +.Op Fl agnoprtuw .Ar .Sh DESCRIPTION The symbol table (name list) of each object in @@ -71,6 +71,8 @@ Display full path or library name of object on every line. Do not sort at all. .It Fl r Reverse order sort. +.It Fl t +Output in tabular format more suitable for other programs digestive system. .It Fl u Display undefined symbols only. .It Fl w diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c index 931cbf0..2dc00c3 100644 --- a/usr.bin/nm/nm.c +++ b/usr.bin/nm/nm.c @@ -64,7 +64,7 @@ int print_all_symbols; int print_file_each_line; int fcount; -int rev; +int rev, table; int fname(), rname(), value(); int (*sfunc)() = fname; @@ -87,7 +87,7 @@ main(argc, argv) extern int optind; int ch, errors; - while ((ch = getopt(argc, argv, "agnopruw")) != EOF) { + while ((ch = getopt(argc, argv, "agnoprtuw")) != EOF) { switch (ch) { case 'a': print_all_symbols = 1; @@ -107,6 +107,9 @@ main(argc, argv) case 'r': rev = 1; break; + case 't': + table = 1; + break; case 'u': print_only_undefined_symbols = 1; break; @@ -153,7 +156,7 @@ process_file(fname) return(1); } - if (fcount > 1) + if (fcount > 1 && !table) (void)printf("\n%s:\n", fname); /* @@ -270,7 +273,7 @@ show_archive(fname, fp) */ p = name; *p = 0; - if (print_file_each_line) + if (print_file_each_line && !table) { p = scat(p, fname); p = scat(p, ":"); @@ -293,7 +296,7 @@ show_archive(fname, fp) } else { (void)fseek(fp, (long)-sizeof(exec_head), SEEK_CUR); - if (!print_file_each_line) + if (!print_file_each_line && !table) (void)printf("\n%s:\n", name); rval |= show_objfile(name, fp); } @@ -460,6 +463,21 @@ print_symbol(objname, sym) { char *typestring(), typeletter(); + if (table) { + printf("%s|", objname); + if (SYMBOL_TYPE(sym->n_type) != N_UNDF) + (void)printf("%08lx", sym->n_value); + (void)printf("|"); + 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)); + + /* print the symbol's name */ + (void)printf("%s\n",sym->n_un.n_name); + return; + } if (print_file_each_line) (void)printf("%s:", objname); |