nmdump: support .dylib/.so
This commit is contained in:
@@ -33,7 +33,9 @@ func main() {
|
|||||||
items, err := nm.List(os.Args[1])
|
items, err := nm.List(os.Args[1])
|
||||||
check(err)
|
check(err)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
fmt.Printf("\n%s:\n", item.File)
|
if item.File != "" {
|
||||||
|
fmt.Printf("\n%s:\n", item.File)
|
||||||
|
}
|
||||||
for _, sym := range item.Symbols {
|
for _, sym := range item.Symbols {
|
||||||
if sym.FAddr {
|
if sym.FAddr {
|
||||||
fmt.Printf("%016x %c %s\n", sym.Addr, sym.Type, sym.Name)
|
fmt.Printf("%016x %c %s\n", sym.Addr, sym.Type, sym.Name)
|
||||||
|
|||||||
10
x/nm/nm.go
10
x/nm/nm.go
@@ -87,10 +87,14 @@ func (p *Cmd) List(arfile string) (items []*ObjectFile, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func listOutput(data []byte) (items []*ObjectFile, err error) {
|
func listOutput(data []byte) (items []*ObjectFile, err error) {
|
||||||
var item *ObjectFile
|
sep := []byte{'\n'}
|
||||||
var sep = []byte{'\n'}
|
item := &ObjectFile{}
|
||||||
for _, line := range bytes.Split(data, sep) {
|
lines := bytes.Split(data, sep)
|
||||||
|
for _, line := range lines {
|
||||||
if len(line) == 0 {
|
if len(line) == 0 {
|
||||||
|
if item.File == "" && len(item.Symbols) > 0 {
|
||||||
|
items = append(items, item)
|
||||||
|
}
|
||||||
item = nil
|
item = nil
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user