Commit f48120ef authored by Russ Cox's avatar Russ Cox

cmd/nm: minor cleanup from previous CL

I forgot to apply Ian's suggestions before submitting CL 40600043.

R=iant
CC=golang-dev
https://golang.org/cl/43560045
parent b758d870
......@@ -13,6 +13,8 @@
//
// T text (code) segment symbol
// t static text segment symbol
// R read-only data segment symbol
// r static read-only data segment symbol
// D data segment symbol
// d static data segment symbol
// B bss segment symbol
......
......@@ -47,6 +47,9 @@ func elfSymbols(f *os.File) []Sym {
sym.Code = 'D'
}
}
if elf.ST_BIND(s.Info) == elf.STB_LOCAL {
sym.Code += 'a' - 'A'
}
syms = append(syms, sym)
}
......
......@@ -42,7 +42,7 @@ func goobjSymbols(f *os.File) []Sym {
case goobj.SBSS, goobj.SNOPTRBSS, goobj.STLSBSS:
sym.Code = 'B'
case goobj.SXREF, goobj.SMACHOSYMSTR, goobj.SMACHOSYMTAB, goobj.SMACHOINDIRECTPLT, goobj.SMACHOINDIRECTGOT, goobj.SFILE, goobj.SFILEPATH, goobj.SCONST, goobj.SDYNIMPORT, goobj.SHOSTOBJ:
sym.Code = 'X'
sym.Code = 'X' // should not see
}
if s.Version != 0 {
sym.Code += 'a' - 'A'
......
......@@ -24,6 +24,8 @@ var (
sortOrder = flag.String("sort", "name", "")
printSize = flag.Bool("size", false, "")
printType = flag.Bool("type", false, "")
filePrefix = false
)
func init() {
......@@ -64,6 +66,7 @@ func main() {
}
args := flag.Args()
filePrefix = len(args) > 1
if len(args) == 0 {
flag.Usage()
}
......@@ -136,6 +139,9 @@ HaveSyms:
w := bufio.NewWriter(os.Stdout)
for _, sym := range syms {
if filePrefix {
fmt.Fprintf(w, "%s:\t", file)
}
if sym.Code == 'U' {
fmt.Fprintf(w, "%8s", "")
} else {
......@@ -153,16 +159,6 @@ HaveSyms:
w.Flush()
}
func filter(syms []Sym, ok func(Sym) bool) []Sym {
out := syms[:0]
for _, sym := range syms {
if ok(sym) {
out = append(out, sym)
}
}
return out
}
type byAddr []Sym
func (x byAddr) Len() int { return len(x) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment