Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push last fixes #36

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions debug/gosym/pclntab.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"bytes"
"encoding/binary"
"fmt"
"math"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -352,8 +351,9 @@ func (t *LineTable) go12Funcs() []Func {
}

// avoid OOM error on corrupt binaries
// empirically gathered. Most binaries are <= UINT16_MAX, but some truly huge have >= 100000 functions
ft := t.funcTab()
if ft.Count() >= math.MaxUint16 {
if ft.Count() >= 350000 {
return make([]Func, 1)
}

Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ func main_impl(fileName string, printStdPkgs bool, printFilePaths bool, printTyp
}
}

var knownPclntabVA = uint64(0)
var knownGoTextBase = uint64(0)
restartParseWithRealTextBase:
tabs, err := file.PCLineTable(versionOverride, knownGoTextBase)
tabs, err := file.PCLineTable(versionOverride, knownPclntabVA, knownGoTextBase)
if err != nil {
return ExtractMetadata{}, fmt.Errorf("failed to read pclntab: %w", err)
}
Expand Down Expand Up @@ -223,10 +224,10 @@ restartParseWithRealTextBase:
stomppedMagicMetaConstraintsValid = tab.StompMagicCandidateMeta.SuspectedModuleDataVa == tmpModData.VA
}

if knownGoTextBase == 0 && stomppedMagicMetaConstraintsValid {
if knownGoTextBase == 0 && knownPclntabVA == 0 && stomppedMagicMetaConstraintsValid {
// assign real base and restart pclntab parsing with correct VAs!
// TODO: optimize, we should only restart pclntab parsing of the candidates we know find a moduledata
knownGoTextBase = tmpModData.TextVA
knownPclntabVA = tab.PclntabVA
goto restartParseWithRealTextBase
}

Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestWeirdBins(t *testing.T) {
})

t.Run("fmtisfun_macho", func(t *testing.T) {
testSymbolRecovery(t, "fmtisfun_macho", 0x10be128, 0x1109260, 0x10879b0)
testSymbolRecovery(t, "fmtisfun_macho", 0x10be140, 0x1109260, 0x10879b0)
})

t.Run("fmtisfun_win", func(t *testing.T) {
Expand Down