Linking 32-bit library to 64-bit program

纵饮孤独 提交于 2019-11-26 11:25:47

问题


I have a 32-bit .so binary-only library and I have to generate 64-bit program that uses it. Is there a way to wrap or convert it, so it can be used with 64-bit program?


回答1:


No. You can't directly link to 32bit code inside of a 64bit program.

The best option is to compile a 32bit (standalone) program that can run on your 64bit platform (using ia32), and then use a form of inter-process communication to communicate to it from your 64bit program.




回答2:


For an example of using IPC to run 32-bit plugins from 64-bit code, look at the open source NSPluginWrapper.




回答3:


It is possible, but not without some serious magic behind the scenes and you will not like the answer. Either emulate a 32 bit CPU (no I am not kidding) or switch the main process back to 32 bit. Emulating may be slow though.

This is a proof of concept of the technique.

Then keep a table of every memory access to and from the 32 bit library and keep them in sync. It is very hard to get to a theoretical completeness, but something workable should be pretty easy, but very tedious.

In most cases, I believe two processes and then IPC between the two may actually be easiest, as suggested othwerwise.



来源:https://stackoverflow.com/questions/1943681/linking-32-bit-library-to-64-bit-program

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