by api · 9y ago · 0 comments
For example, "mov eax, 0x0040137C"
Is is this an address or a numeric constant?
Should it be translated to:
1) var = 4199292;
2) var = &SomeGlobalVariable;
If you're lucky you might get a non-ambiguous answer from the relocation table embedded in your executable.
So you're probably better off writing a new backend for the Go compiler (a backend generating machine code, or C code).
The resulting program will have, by far, a lot less dangerous approximations.
Let's use a more concrete example. Let's say we write a Go program that copies a file. On Windows, this might use an API call like CopyFile:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...
If you decompile the compiled Go program into C, it'd still have the references to API calls like this. These APIs would have to be implemented on the new OS for the decompiled program to work without modification.