commit 0f0c36b22b74b2025d717b65bf183f3b9ce14821
parent 2c3357ebb1c99941b60c8f7013e78e2155296c39
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 4 Jan 2019 14:14:28 +0000
[nm] Print name of the object file
Nm must print the name of the file when there are multiple
object files in the command line.
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/nm/nm.c b/src/nm/nm.c
@@ -12,7 +12,7 @@ static char sccsid[] = "@(#) ./nm/main.c";
#include <scc/mach.h>
char *argv0;
-static int status;
+static int status, multi;
static int radix = 16;
static int Pflag;
static int Aflag;
@@ -72,6 +72,9 @@ printsyms(Obj *obj)
qsort(sym, nsym, sizeof(*sym), cmp);
+ if (multi)
+ printf("%s:\n", (membname) ? membname : filename);
+
for (sym = obj->symtbl; nsym--; sym++) {
int type = sym->type;
char *fmt;
@@ -151,6 +154,7 @@ newmember(FILE *fp, char *name, void *data)
{
int t;
+ multi = 1;
membname = name;
if ((t = objtest(fp, NULL)) != -1)
newobject(fp, t);
@@ -231,6 +235,8 @@ main(int argc, char *argv[])
if (argc == 0) {
nm("a.out");
} else {
+ if (argc > 1)
+ multi = 1;
for ( ; *argv; ++argv)
nm(*argv);
}