Decompiling a compiled program with Go

会有一股神秘感。 提交于 2019-12-17 22:45:04

问题


I have built a simple executable program with Go.

I've compiled the code into a static binary program.

I want to decompile the output binary file and get the Go source code.

Is this possible or not?


回答1:


There is no tool to do that and as Go programs are compiled into machine code, they do not contain enough information to translate them back into Go code. Standard disassembly techniques are still possible though.




回答2:


There is no known tool which currently decompiles to Go sources.

Go is a native language compiler, unlike Java and similar languages, which rely on a Class Loader, uses a linker in order to produce its executables. Therefore just reconstructing the call tree is, as in C and similar languages, a lot harder.

Debug information such as symbols are normally stripped off the Go executable.

There exists very little even in terms of Symbolic debugging of Golang code.

GDB for instance is AFAIK in its current state not aligned with Go architecture and is practically not functional in terms of Golang symbolic debugging. Go GDB has been dropped off IntelliJ ide for this very reason.

There are experimental efforts trying to regain GDB functionality by some users, but these require Go sources to have been compiled with special nonstandard provisions in order to support debugging. e.g.: http://blog.securitymouse.com/2014/10/golang-debugging-turning-pennies-into-gs.html Other symbolic debuggers for Go also need insertion of non-standard code in order to support the debugger, e.g. Hopwatch

Therefore, if you need to reverse engineer a Go program, you are better off with traditional, lower level reverse engineering tools such as IDA PRO. This is definitely possible, but at most you will get something resembling pseudo-code C, or ASM, never Go sources.

Some feature of the language are non existing in other languages, e.g. channels, and these require some study and a non trivial approach. E.g.: http://jolmos.blogspot.nl/2014/09/inbincible-writeup-golang-binary.html



来源:https://stackoverflow.com/questions/25034065/decompiling-a-compiled-program-with-go

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!