Fix calls to linkname functions (#314)

pull/316/head
lu4p 3 years ago committed by GitHub
parent 3afc993266
commit 1a9fdb4e8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -622,9 +622,15 @@ func transformCompile(args []string) ([]string, error) {
}
newPaths := make([]string, 0, len(files))
for i, file := range files {
for _, file := range files {
// Process directives before obfuscating any names of the package,
// this is needed for functions which are linknamed to another package,
// but also used in the package declaring them.
tf.handleDirectives(file.Comments)
}
for i, file := range files {
origName := filepath.Base(paths[i])
name := origName
switch {

@ -16,6 +16,18 @@ cmp stderr main.stderr
module test/main
go 1.16
-- a.go --
package main
// Call a function which is linknamed to another symbol.
// What's special here is that we obfuscate this call before the function declaration.
// If we decide not to obfuscate the name in the function declaration,
// we shouldn't obfuscate the name here either.
func linknameCalledInPkg() {
println(obfuscatedFunc())
}
-- main.go --
package main
@ -49,6 +61,7 @@ func main() {
println(obfuscatedFunc())
println(renamedFunc())
println(imported.ByteIndex("01234", '3'))
linknameCalledInPkg()
}
-- imported/imported.go --
package imported
@ -76,3 +89,4 @@ false
obfuscated func
renamed func
3
obfuscated func

Loading…
Cancel
Save