文件:从另一个so文件调用的函数

时间:2022-06-01 21:10:35

Lets say my executable file, MyApp, links dynamically against an so file, boost-system.so. I compile and everything works fine for a while; my calls to boost-system funcs do what they are supposed to do.

假设我的可执行文件,MyApp,动态链接到so文件,boot -system。我汇编了一段时间,一切都没问题;我对启动系统函数的调用执行它们应该执行的操作。

After a while i realize i need to link to another so file, SomeAPI.so. However, SomeAPI.so have statically linked against boost-system.a, but an older, buggy version, which has functions with exactly the same names as "my" boost-system (ofcourse). Now, ALL calls (both from MyApp and SomeAPI) will go to the version SomeAPI statically linked (or my version of boost-system, depending on link order, both are bad for me).

过了一会儿,我意识到我需要链接到另一个so文件,SomeAPI.so。然而,SomeAPI。与启动系统的静态关联也是如此。a,但是是一个老的、有bug的版本,它的函数名与“my”启动系统(当然)的名称完全相同。现在,所有调用(来自MyApp和SomeAPI)都将转到SomeAPI静态链接的版本(或者是我的启动系统版本,取决于链接顺序,这对我来说都不好)。

I would like my calls from MyApp to go to my version of boost-system, and SomeAPI to use its statically linked boost-system.a functions. On Windows this is how it works.

我想从MyApp调用我的版本的启动系统,而有些api则使用它的静态链接的启动系统。一个函数。在Windows上,这就是它的工作原理。

I realize why this is not happening, but is there any way around this except renaming the namespaces in "my" boost-system to something local?

我知道为什么不会发生这种情况,但是除了将“my”启动系统中的名称空间重命名为本地名称空间之外,还有其他方法吗?

1 个解决方案

#1


1  

Use LD version scripts to hide function names that you don't want other .so files to see.

使用LD版本脚本隐藏不希望看到其他so文件的函数名。

#1


1  

Use LD version scripts to hide function names that you don't want other .so files to see.

使用LD版本脚本隐藏不希望看到其他so文件的函数名。