]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/pprof: ignore symbols with address 0 and size 0
authorIan Lance Taylor <iant@golang.org>
Fri, 24 Jun 2016 20:19:46 +0000 (13:19 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 24 Jun 2016 22:52:15 +0000 (22:52 +0000)
Handling a symbol with address 0 and size 0, such as an ELF STT_FILE
symbols, was causing us to disassemble the entire program.  We started
adding STT_FILE symbols to help fix issue #13247.

Fixes #16154.

Change-Id: I174b9614e66ddc3d65801f7c1af7650f291ac2af
Reviewed-on: https://go-review.googlesource.com/24460
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
src/cmd/pprof/pprof.go

index 5c243d2a587bf2991325e13c423d5798d79a15e3..feccd1227b75059a7a031994dee69ce7d415f70e 100644 (file)
@@ -308,6 +308,11 @@ func (f *file) Symbols(r *regexp.Regexp, addr uint64) ([]*plugin.Sym, error) {
        }
        var out []*plugin.Sym
        for _, s := range f.sym {
+               // Ignore a symbol with address 0 and size 0.
+               // An ELF STT_FILE symbol will look like that.
+               if s.Addr == 0 && s.Size == 0 {
+                       continue
+               }
                if (r == nil || r.MatchString(s.Name)) && (addr == 0 || s.Addr <= addr && addr < s.Addr+uint64(s.Size)) {
                        out = append(out, &plugin.Sym{
                                Name:  []string{s.Name},