Skip to content

Commit

Permalink
Ignore debug symbols in Mach-O files
Browse files Browse the repository at this point in the history
My team has encountered an issue where `goversion` can no longer
recognize our builds (see issue #12) due to a symbolic debugging entry
for `_runtime.buildVersion`.

If we omit such entries from the symbol list before looking for
`_runtime.BuildVersion`, then `goversion` works for our builds once
again.
  • Loading branch information
logan committed May 28, 2020
1 parent 597212e commit 5f05606
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion version/exe.go
Expand Up @@ -288,7 +288,13 @@ func (x *machoExe) ReadData(addr, size uint64) ([]byte, error) {
func (x *machoExe) Symbols() ([]sym, error) {
var out []sym
for _, s := range x.f.Symtab.Syms {
out = append(out, sym{s.Name, s.Value, 0})
if (s.Type & 0xe0) != 0 {
// Symbol type with any of the bits in 0xe0 set are debugging symbols.
// We won't be able to use this kind of entry to read the symbol's value,
// so ignore it.
continue
}
out = append(out, sym{s.Name, s.Value, 0})
}
return out, nil
}
Expand Down

0 comments on commit 5f05606

Please sign in to comment.