You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
garble/testdata/scripts
Daniel Martí e33179d480
reverse: support unexported names and package paths (#233)
Unexported names are a bit tricky, since they are not listed in the
export data file. Perhaps unsurprisingly, it's only meant to expose
exported objects.

One option would be to go back to adding an extra header to the export
data file, containing the unexported methods in a map[string]T or
[]string. However, we have an easier route: just parse the Go files and
look up the names directly.

This does mean that we parse the Go files every time "reverse" runs,
even if the build cache is warm, but that should not be an issue.
Parsing Go files without any typechecking is very cheap compared to
everything else we do. Plus, we save having to load go/types information
from the build cache, or having to load extra headers from export files.

It should be noted that the obfuscation process does need type
information, mainly to be careful about which names can be obfuscated
and how they should be obfuscated. Neither is a worry here; all names
belong to a single package, and it doesn't matter if some aren't
actually obfuscated, since the string replacements would simply never
trigger in practice.

The test includes an unexported func, to test the new feature. We also
start reversing the obfuscation of import paths. Now, the test's reverse
output is as follows:

	goroutine 1 [running]:
	runtime/debug.Stack(0x??, 0x??, 0x??)
		runtime/debug/stack.go:24 +0x??
	test/main/lib.ExportedLibFunc(0x??, 0x??, 0x??, 0x??)
		p.go:6 +0x??
	main.unexportedMainFunc(...)
		C.go:2
	main.main()
		z.go:3 +0x??

The only major missing feature is positions and filenames. A follow-up
PR will take care of those.

Updates #5.
3 years ago
..
asm.txt testdata: don't let tests rely on rewriting mod files 4 years ago
basic.txt obfuscate unexported names like exported ones (#227) 3 years ago
cgo.txt testdata: don't let tests rely on rewriting mod files 4 years ago
debugdir.txt testdata: don't let tests rely on rewriting mod files 4 years ago
goprivate.txt obfuscate fewer std packages (#196) 4 years ago
goversion.txt testdata: simplify goversion test (#232) 3 years ago
help.txt include a "garble version" test (#221) 3 years ago
implement.txt testdata: don't let tests rely on rewriting mod files 4 years ago
imports.txt make the handling of import paths more robust 3 years ago
init.txt testdata: add test case for init funcs in many files (#208) 4 years ago
ldflags.txt testdata: don't let tests rely on rewriting mod files 4 years ago
linkname.txt fixed some bugs related to additional linkname corner cases (#210) 3 years ago
literals.txt do not try to obfuscate huge literals (#204) 4 years ago
modinfo.txt testdata: don't let tests rely on rewriting mod files 4 years ago
plugin.txt testdata: don't let tests rely on rewriting mod files 4 years ago
reverse.txt reverse: support unexported names and package paths (#233) 3 years ago
seed.txt testdata: don't let tests rely on rewriting mod files 4 years ago
syntax.txt make the handling of import paths more robust 3 years ago
test.txt testdata: don't let tests rely on rewriting mod files 4 years ago
tiny.txt testdata: don't let tests rely on rewriting mod files 4 years ago