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

查看:647
本文介绍了如何将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天全站免登陆