mirror of
https://github.com/golang/go
synced 2024-11-24 07:40:17 -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:
parent
b758d8703a
commit
f48120ef51
@ -13,6 +13,8 @@
|
|||||||
//
|
//
|
||||||
// T text (code) segment symbol
|
// T text (code) segment symbol
|
||||||
// t static text 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 data segment symbol
|
||||||
// d static data segment symbol
|
// d static data segment symbol
|
||||||
// B bss segment symbol
|
// B bss segment symbol
|
||||||
|
@ -47,6 +47,9 @@ func elfSymbols(f *os.File) []Sym {
|
|||||||
sym.Code = 'D'
|
sym.Code = 'D'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if elf.ST_BIND(s.Info) == elf.STB_LOCAL {
|
||||||
|
sym.Code += 'a' - 'A'
|
||||||
|
}
|
||||||
syms = append(syms, sym)
|
syms = append(syms, sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ func goobjSymbols(f *os.File) []Sym {
|
|||||||
case goobj.SBSS, goobj.SNOPTRBSS, goobj.STLSBSS:
|
case goobj.SBSS, goobj.SNOPTRBSS, goobj.STLSBSS:
|
||||||
sym.Code = 'B'
|
sym.Code = 'B'
|
||||||
case goobj.SXREF, goobj.SMACHOSYMSTR, goobj.SMACHOSYMTAB, goobj.SMACHOINDIRECTPLT, goobj.SMACHOINDIRECTGOT, goobj.SFILE, goobj.SFILEPATH, goobj.SCONST, goobj.SDYNIMPORT, goobj.SHOSTOBJ:
|
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 {
|
if s.Version != 0 {
|
||||||
sym.Code += 'a' - 'A'
|
sym.Code += 'a' - 'A'
|
||||||
|
@ -24,6 +24,8 @@ var (
|
|||||||
sortOrder = flag.String("sort", "name", "")
|
sortOrder = flag.String("sort", "name", "")
|
||||||
printSize = flag.Bool("size", false, "")
|
printSize = flag.Bool("size", false, "")
|
||||||
printType = flag.Bool("type", false, "")
|
printType = flag.Bool("type", false, "")
|
||||||
|
|
||||||
|
filePrefix = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -64,6 +66,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args := flag.Args()
|
args := flag.Args()
|
||||||
|
filePrefix = len(args) > 1
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
}
|
}
|
||||||
@ -136,6 +139,9 @@ HaveSyms:
|
|||||||
|
|
||||||
w := bufio.NewWriter(os.Stdout)
|
w := bufio.NewWriter(os.Stdout)
|
||||||
for _, sym := range syms {
|
for _, sym := range syms {
|
||||||
|
if filePrefix {
|
||||||
|
fmt.Fprintf(w, "%s:\t", file)
|
||||||
|
}
|
||||||
if sym.Code == 'U' {
|
if sym.Code == 'U' {
|
||||||
fmt.Fprintf(w, "%8s", "")
|
fmt.Fprintf(w, "%8s", "")
|
||||||
} else {
|
} else {
|
||||||
@ -153,16 +159,6 @@ HaveSyms:
|
|||||||
w.Flush()
|
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
|
type byAddr []Sym
|
||||||
|
|
||||||
func (x byAddr) Len() int { return len(x) }
|
func (x byAddr) Len() int { return len(x) }
|
||||||
|
Loading…
Reference in New Issue
Block a user