Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obfuscate fewer std packages #196

Merged
merged 1 commit into from
Nov 14, 2020
Merged

obfuscate fewer std packages #196

merged 1 commit into from
Nov 14, 2020

Conversation

mvdan
Copy link
Member

@mvdan mvdan commented Nov 10, 2020

(see commit message)

@capnspacehook
Copy link
Contributor

Looks like internal/syscall/windows/sysdll also needs to be included on Windows

@mvdan
Copy link
Member Author

mvdan commented Nov 11, 2020

Yeah, it looks like I need another dozen tries to get this right. My annoyance at that is why I filed golang/go#42504.

main.go Show resolved Hide resolved
testdata/scripts/goprivate.txt Outdated Show resolved Hide resolved
Previously, we were never obfuscating runtime and its direct
dependencies. Unfortunately, due to linkname, the runtime package is
actually closely related to dozens of other std packages as well.

Until we can obfuscate the runtime and properly support go:linkname
directives, obfuscating fewer std packages is a better outcome than
breaking and not producing any obfuscated code at all.

The added test case is building runtime/pprof, which used to cause
failures:

	# runtime/pprof
	/go/src/runtime/pprof/label.go:27:21: undefined: context.Context
	/go/src/runtime/pprof/label.go:59:21: undefined: context.Context
	/go/src/runtime/pprof/label.go:93:16: undefined: context.Context
	/go/src/runtime/pprof/label.go:101:20: undefined: context.Context

The net package was also very close to obfuscating properly thanks to
this change, so its test is now run as well. The only other remaining
fix was to not obfuscate fields on cgo types, since those aren't
obfuscated at the moment.

The map is pretty long, but it's only a temporary solution and the
command to obtain the list again is included. Never obfuscating the
entire std library is also an option, but it's a bit unnecessary.

Fixes #134.
@mvdan
Copy link
Member Author

mvdan commented Nov 14, 2020

The script now returns a full list for Linux, Mac, and Windows.

The net package obfuscates properly now, too.

PTAL

@mvdan
Copy link
Member Author

mvdan commented Nov 14, 2020

Also, if someone wants to add a direct test case of cgo struct fields to cgo.txt, I think that could be a good idea. For now I skipped that because it's already covered by net, and I'm not familiar enough with cgo.

@lu4p lu4p merged commit c9deff8 into burrowers:master Nov 14, 2020
@mvdan mvdan deleted the goprivate-std-conservative branch November 14, 2020 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants