From 33e574685bb84850f9e9ef7638f640815af42775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sat, 26 Jul 2025 16:43:42 +0100 Subject: [PATCH] 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. --- cache_shared.go | 3 ++- reverse.go | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cache_shared.go b/cache_shared.go index a42ed1c..276f632 100644 --- a/cache_shared.go +++ b/cache_shared.go @@ -152,7 +152,8 @@ type listedPackage struct { Standard bool Dir string - CompiledGoFiles []string + CompiledGoFiles []string // all .go files to build + SFiles []string // all .s (asm) files to build Imports []string Error *packageError // to report package loading errors to the user diff --git a/reverse.go b/reverse.go index 85d751e..95136fd 100644 --- a/reverse.go +++ b/reverse.go @@ -68,6 +68,14 @@ One can reverse a captured panic stack trace as follows: // Package paths are obfuscated, too. 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) if err != nil { return err