From 5fddfe1e61cd7df1eac5ea34ba42c06ebb8ef577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sat, 3 Jun 2023 12:47:31 +0100 Subject: [PATCH] rename func and update docs on handleDirectives We've been obfuscating all linknamed names for a while now, so the part in the docs about "recording" is no longer true. All it does is transform the directives to use obfuscated names. Give it a better name and rewrite the docs. --- main.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index c584951..aadd2e2 100644 --- a/main.go +++ b/main.go @@ -968,7 +968,7 @@ func transformCompile(args []string) ([]string, error) { updateEntryOffset(file, entryOffKey()) } } - tf.handleDirectives(file.Comments) + tf.transformDirectives(file.Comments) file = tf.transformGoFile(file) // newPkgPath might be the original ImportPath in some edge cases like // compilerIntrinsics; we don't want to use slashes in package names. @@ -1017,12 +1017,9 @@ func transformCompile(args []string) ([]string, error) { return append(flags, newPaths...), nil } -// handleDirectives looks at all the comments in a file containing build -// directives, and does the necessary for the obfuscation process to work. -// -// Right now, this means recording what local names are used with go:linkname, -// and rewriting those directives to use obfuscated name from other packages. -func (tf *transformer) handleDirectives(comments []*ast.CommentGroup) { +// transformDirectives rewrites //go:linkname toolchain directives in comments +// to replace names with their obfuscated versions. +func (tf *transformer) transformDirectives(comments []*ast.CommentGroup) { for _, group := range comments { for _, comment := range group.List { if !strings.HasPrefix(comment.Text, "//go:linkname ") {