support reversing asm filenames

Which can be helpful when debugging assembly build errors
such as the one from #948.
I could not get an obfuscated binary to ever print or show its
assembly positions or filenames, so this has no test.
This commit is contained in:
Daniel Martí
2025-07-26 16:43:42 +01:00
parent 28f7a7ffbf
commit 33e574685b
2 changed files with 10 additions and 1 deletions

View File

@@ -152,7 +152,8 @@ type listedPackage struct {
Standard bool Standard bool
Dir string Dir string
CompiledGoFiles []string CompiledGoFiles []string // all .go files to build
SFiles []string // all .s (asm) files to build
Imports []string Imports []string
Error *packageError // to report package loading errors to the user Error *packageError // to report package loading errors to the user

View File

@@ -68,6 +68,14 @@ One can reverse a captured panic stack trace as follows:
// Package paths are obfuscated, too. // Package paths are obfuscated, too.
addHashedWithPackage(lpkg.ImportPath) addHashedWithPackage(lpkg.ImportPath)
// Assembly filenames are obfuscated in a simple way.
// Mirroring [transformer.transformAsm]; note the lack of a test
// as so far this has only mattered for build errors with positions.
for _, name := range lpkg.SFiles {
newName := hashWithPackage(lpkg, name) + ".s"
replaces = append(replaces, newName, name)
}
files, err := parseFiles(lpkg, lpkg.Dir, lpkg.CompiledGoFiles) files, err := parseFiles(lpkg, lpkg.Dir, lpkg.CompiledGoFiles)
if err != nil { if err != nil {
return err return err