]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/nm: make -S listing a bit more accurate
authorRuss Cox <rsc@golang.org>
Tue, 17 Sep 2013 00:27:57 +0000 (20:27 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 17 Sep 2013 00:27:57 +0000 (20:27 -0400)
Hide container symbols like text and etext so that
the individual pieces inside are shown instead.
For example, if text and main.init have the same
address, it was a toss-up which name was printed.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13722046

src/cmd/nm/nm.c

index b5e1ca0b6b7adbec73659cf12efdfc3de57c54e8..8209424269e6d301e9738f2e786b4ce64b2e85f9 100644 (file)
@@ -299,6 +299,37 @@ psym(Sym *s, void* p)
        symptr[nsym++] = s;
 }
 
+const char *skipnames[] = {
+       "bss",
+       "data",
+       "ebss",
+       "edata",
+       "egcbss",
+       "egcdata",
+       "enoptrbss",
+       "enoptrdata",
+       "epclntab",
+       "erodata",
+       "esymtab",
+       "etext",
+       "etypelink",
+       "noptrbss",
+       "noptrdata",
+       "rodata",
+       "text",
+};
+
+int
+skipsize(char *name)
+{
+       int i;
+       
+       for(i=0; i<nelem(skipnames); i++)
+               if(strcmp(skipnames[i], name) == 0)
+                       return 1;
+       return 0;
+}
+
 void
 printsyms(Sym **symptr, long nsym)
 {
@@ -332,12 +363,12 @@ printsyms(Sym **symptr, long nsym)
                        Bprint(&bout, "%*llux ", wid, s->value);
                else
                        Bprint(&bout, "%*s ", wid, "");
-               if(Sflag) {
+               if(Sflag && !skipsize(cp)) {
                        vlong siz;
 
                        siz = 0;
                        for(j=i+1; j<nsym; j++) {
-                               if(symptr[j]->type != 'a' && symptr[j]->type != 'p') {
+                               if(!skipsize(symptr[j]->name) && symptr[j]->type != 'a' && symptr[j]->type != 'p') {
                                        siz = symptr[j]->value - s->value;
                                        break;
                                }