1
0
mirror of https://github.com/golang/go synced 2024-11-24 02:30:12 -07:00

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
This commit is contained in:
Russ Cox 2013-12-18 13:29:40 -05:00
parent b758d8703a
commit f48120ef51
4 changed files with 12 additions and 11 deletions

View File

@ -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

View File

@ -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)
}

View File

@ -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'

View File

@ -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) }