Relink a shared library to a different version of libc

随声附和 提交于 2019-12-02 04:48:04

问题


I have a linux shared library (.so) compiled with a specific version of libc (GLIBC2.4) and I need to use it on a system with different version of libc. I do not have sources for the library in question so I cannot recompile for the new system. Is it somehow possible to change the dependencies in that library to a different libc?


回答1:


If you need the .so on a system with an older glibc, you would need the source code and recompile/relink it with the older glibc. The alternative is to install the required glibc on the old system in a non-default location and adjust the LD_LIBRARY_PATH for the executable that needs this .so

If there's a newer glibc rather, it should normally not be a problem as glibc tend to be backwards compatible.




回答2:


Unless your library really uses interfaces that changed (unlikely), you can just hexedit the references to versions in the resulting .so file. They're all text anyway.




回答3:


Best you can do is compile the old glibc version for your system and then build your application with that glibc and your shared library. Ugly though ...



来源:https://stackoverflow.com/questions/2071325/relink-a-shared-library-to-a-different-version-of-libc

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