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

gomobile and tinygo #296

Closed
gedw99 opened this issue Apr 1, 2021 · 10 comments
Closed

gomobile and tinygo #296

gedw99 opened this issue Apr 1, 2021 · 10 comments

Comments

@gedw99
Copy link

gedw99 commented Apr 1, 2021

anyone know if this in theory should work with gomobile and tinygo ?

@mvdan mvdan changed the title gomobile and tinfgo gomobile and tinygo Apr 2, 2021
@mvdan
Copy link
Member

mvdan commented Apr 2, 2021

In theory it should be possible for them to work, as we mainly manipulate Go code.

In practice they very likely don't work with garble right now, and it would depend on each particular implementation's go build alternative - it should support:

  • An alternative to go list -json -export -deps, which we need for inspecting the entire dependency tree
  • The above go list should also include build IDs, which we require for the purpose of hashing and caching
  • A go build -toolexec flag to insert garble at each asm/compile/link step

@mvdan
Copy link
Member

mvdan commented Apr 3, 2021

Some more thoughts:

I don't think it's worth it to make garble work with gomobile directly. As long as we support cgo (we do) and -buildmode=c-archive/c-shared (I think we do, but it's not tested), then it should be possible to do obfuscated builds of mobile apps in Go.

tinygo is more interesting because it has no alternative via plain go build. Unfortunately, being based on LLVM, it doesn't really work the same way that go build does, so it would take some work to adapt garble for it.

tinygo calls go list -json -deps to obtain the source code to compile, so perhaps we could replace that to instead feed the obfuscated source code. However, note that this could mean no caching of the obfuscation process, which could be costly.

Another alternative would be to use an LLVM IR obfuscator, which could in theory work directly with tinygo. That's out of scope for garble, but I seem to understand there are such obfuscators out there already.

@mvdan
Copy link
Member

mvdan commented Apr 3, 2021

-buildmode=c-archive/c-shared (I think we do, but it's not tested)

That's #297 now.

@aykevl
Copy link

aykevl commented Apr 4, 2021

tinygo calls go list -json -deps to obtain the source code to compile, so perhaps we could replace that to instead feed the obfuscated source code. However, note that this could mean no caching of the obfuscation process, which could be costly.

Note that this should be possible to made to work with caching, and perhaps even better than with the Go tooling. You can basically construct an alternative package tree and cache that for later builds, needing a single go list that you would need to run anyway. (That said, TinyGo is only now starting to implement build caching so the no-caching overhead will probably be small for now).

@gedw99
Copy link
Author

gedw99 commented Apr 5, 2021

Thanks all !

I will try about the above

@mvdan
Copy link
Member

mvdan commented Apr 5, 2021

tinygo calls go list -json -deps to obtain the source code to compile, so perhaps we could replace that to instead feed the obfuscated source code.

I've opened #298 to track a garble list feature request. I'm closing this issue for now, as it's too broad and has been superseded by the two issues linked above. Thanks all!

@mvdan mvdan closed this as completed Apr 5, 2021
@sintanial
Copy link

So, anybody understand how to use garble with go mobile ? How to run "gomobile bind" command )?

@pfarcasanu
Copy link

@mvdan @sintanial Any hints as to how to obfuscate gomobile output? Is it currently possible using garble (perhaps with extra work / workaround)?

@mvdan
Copy link
Member

mvdan commented May 9, 2022

I'd suggest following #298 or leaving a comment there. That solution should work with tinygo in principle, as per #296 (comment). I honestly don't know how gomobile builds work, but I imagine it might be similar.

@cxcel
Copy link

cxcel commented Jan 20, 2024

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants