How to convert 32-bit compiled binaries to 64-bit

Background: We purchased a software product that is built on a 32-bit Windows application in Visual Studio. We want to port this application to 64-bit.

A critical component of this code is the static black box library (.a file) originally created with gFortran by a third party. The original developer has passed away since then, and the Fortran source we received was incomplete, not the version from which this library was built (and contains critical errors that are missing from the compiled library). They did not use VCS.

Problem: I would like to create a 64-bit static library whose code is functionally equivalent to the 32-bit static library that we have.

What I tried:

  • Using a Snowman decompiler to get C ++ source code to recompile in a 64-bit version. This turned out to be impossible, because the generated code uses low-level internal functions that seem gcc-specific. This probably won't work because such built-in tools will compile for code that is not functionally equivalent in 64-bit. I probably need a better decompiler.
  • Obviously, the x86 assembly is a valid x86_64 assembly, so I briefly looked at why I couldn’t just run the assembly through the 64-bit assembler. It turns out that the ABI is different in 64-bit, so the calling convention will not match. MAYBE I could manually convert function calls to the correct convention and leave everything else the same, but this can be an insoluble problem. Opinions?
+7
c ++ assembly x86-64 32bit-64bit decompiler
source share
1 answer

You can store a 32-bit binary library, but load it into a 32-bit host process and use some kind of IPC (shared memory, named pipes, network connection with a local loop, etc.) to transfer data to / from your 64-bit process.

Another advantage of this approach is that if Fortran code works, it will crash the process of the child node and not your main application, and your program can instantly start it again; and if it's a single-threaded Fortran program, you can deploy multiple instances for multi-core parallelism.

+7
source share

All Articles