diff options
Diffstat (limited to 'src/cmd/nm/nm.go')
| -rw-r--r-- | src/cmd/nm/nm.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cmd/nm/nm.go b/src/cmd/nm/nm.go index d369a4ab54..fdf6ef673e 100644 --- a/src/cmd/nm/nm.go +++ b/src/cmd/nm/nm.go @@ -58,7 +58,7 @@ func main() { flag.Parse() switch *sortOrder { - case "address", "name", "none": + case "address", "name", "none", "size": // ok default: fmt.Fprintf(os.Stderr, "nm: unknown sort order %q\n", *sortOrder) @@ -135,6 +135,8 @@ HaveSyms: sort.Sort(byAddr(syms)) case "name": sort.Sort(byName(syms)) + case "size": + sort.Sort(bySize(syms)) } w := bufio.NewWriter(os.Stdout) @@ -170,3 +172,9 @@ type byName []Sym func (x byName) Len() int { return len(x) } func (x byName) Swap(i, j int) { x[i], x[j] = x[j], x[i] } func (x byName) Less(i, j int) bool { return x[i].Name < x[j].Name } + +type bySize []Sym + +func (x bySize) Len() int { return len(x) } +func (x bySize) Swap(i, j int) { x[i], x[j] = x[j], x[i] } +func (x bySize) Less(i, j int) bool { return x[i].Size > x[j].Size } |
