From fe1389643ebb2763d5a944230e62cfc1eae5b06c Mon Sep 17 00:00:00 2001 From: "Artem V. Navrotskiy" Date: Wed, 6 May 2020 14:35:18 +0300 Subject: [PATCH] cmd/viewcore: ignore mapped files without executable regions This change ignores files without executable regions to avoid errors on loading debug info from this files. In our case we got confusing `bad magic number` errors on parsing files with GeoIP data. --- internal/core/process.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/core/process.go b/internal/core/process.go index d4da13e..3f2a4c4 100644 --- a/internal/core/process.go +++ b/internal/core/process.go @@ -503,6 +503,11 @@ func (p *Process) openMappedFile(fname string, m *Mapping) (*os.File, error) { return backing.f, backing.err } + if m.perm&Exec == 0 { + // Ignore mapped files without executable regions + return nil, nil + } + backing := &file{} isMainExe := m.perm&Exec != 0 && p.mainExecName == "" // first executable region @@ -638,7 +643,7 @@ func (p *Process) readDebugInfo() error { } e, err := elf.NewFile(f.f) if err != nil { - return err + return fmt.Errorf("can't open EFL file %s: %v", f.f.Name(), err) } syms, err := e.Symbols()