如何将 32 位编译后的二进制文件转换为 64 位 [英] How to convert 32-bit compiled binary to 64-bit

查看:61
本文介绍了如何将 32 位编译后的二进制文件转换为 64 位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我们已经获得了一个软件产品,它可以在 Visual Studio 中构建为 32 位 Windows 应用程序.我们希望将此应用程序移植到 64 位.

Background: We have acquired a software product that builds to a 32-bit Windows application in Visual Studio. We wish to port this application to 64-bit.

此代码的一个关键任务组件是一个黑盒静态库(.a 文件),最初由第三方使用 gFortran 构建.最初的开发人员已经去世了,我们能够获得的 Fortran 源代码是不完整的,而不是构建这个库的版本(并且包含编译库中不存在的关键错误).他们没有使用 VCS.

A mission-critical component of this code is a black-box static library (.a file) originally built using gFortran by a third party. The original developer has since passed away, and the Fortran source we were able to get was incomplete and not the version this library was built off of (and contains critical bugs not present in the compiled library). They did not use a VCS.

问题:我想创建一个 64 位静态库,其代码在功能上等同于我们拥有的 32 位静态库.

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

我的尝试:

  • 使用 Snowman 反编译器获取 C++ 源代码以在 64 位中重新编译.这被证明是不可能的,因为生成的代码使用了似乎特定于 gcc 的低级内部函数.它可能无论如何都行不通,因为这样的内在函数会编译为在 64 位中功能不等效的代码.我可能需要一个更好的反编译器.
  • 显然 x86 程序集是有效的 x86_64 程序集,所以我简要地研究了为什么我不能通过 64 位汇编器运行该程序集.事实证明,ABI 在 64 位中是不同的,因此调用约定将不匹配.也许我可以手动将函数调用转换为正确的约定,而其余部分保持不变,但这可能是一个棘手的问题.意见?

推荐答案

您可以保留 32 位二进制库,但将其加载到 32 位主机进程中,并使用某种 IPC(共享内存、命名管道、本地环回网络连接等)来向/从您的 64 位进程传输数据.

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

这种方法的另一个优点是,如果 Fortran 代码崩溃,它只会关闭子主机进程,而不是您的主应用程序,您的程序可以立即再次启动它;如果它是一个单线程 Fortran 程序,那么您可以启动多个实例以实现多核并行.

Another advantage to this approach is that if the Fortran code crashes then it will only bring down the child host process, not your main application and your program can instantly fire it up again; and if it's a single-threaded Fortran program then you could spin up several instances for multi-core parallelism.

这篇关于如何将 32 位编译后的二进制文件转换为 64 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆