使用-Bsymbolic-functions有不利之处吗? [英] Is there a downside to using -Bsymbolic-functions?
问题描述
我最近在GNU ld中发现了链接器选项"-Bsymbolic-functions":
I recently discovered the linker option "-Bsymbolic-functions" in GNU ld:
-Bsymbolic
When creating a shared library, bind references to global symbols to the
definition within the shared library, if any. Normally, it is possible
for a program linked against a shared library to override the definition
within the shared library.
This option is only meaningful on ELF platforms which support shared libraries.
-Bsymbolic-functions
When creating a shared library, bind references to global function symbols
to the definition within the shared library, if any.
This option is only meaningful on ELF platforms which support shared libraries.
这似乎是GCC选项-fvisibility=hidden
的反函数,它不是阻止将引用函数导出到其他共享库,而是防止了对该函数的库内部引用绑定到导出函数不同的共享对象.我告诉自己,-Bsymbolic-functions
将阻止创建该功能的PLT条目,这是一个很好的副作用.
This seems to be the inverse of the GCC option -fvisibility=hidden
, in that instead of preventing the export of the referenced function to other shared objects, it prevents library-internal references to that function from being bound to an an exported function of a different shared object. I informed myself that -Bsymbolic-functions
will prevent the creation of PLT entries for the functions, which is a nice side effect.
-
但是我想知道是否可能对此进行更细粒度的控制,例如为库的单个函数定义覆盖
-Bsymbolic
.
我是否应该知道使用-Bsymbolic-functions
的任何陷阱?我打算只使用它,因为我认为-Bsymbolic
会打破异常(我认为这样做会使得对typeinfo对象的引用不统一).
Should I be aware of any pitfalls of using -Bsymbolic-functions
? I plan to only use that, because the -Bsymbolic
will break exceptions, I think (it will make it so that references to typeinfo objects are not unified, I think).
谢谢!
推荐答案
回答我自己的问题,因为我刚刚为此获得了风滚草徽章...后来我发现了
Answering my own question because I just earned a Tumbleweed badge for it... and I found out subsequently
但是我想知道是否可以对此进行更细粒度的控制,例如为库的单个函数定义覆盖
-Bsymbolic
.
是的,有一个选项--dynamic-list
可以做到这一点
Yes, there is the option --dynamic-list
which does exactly that
我应该知道使用
-Bsymbolic-functions
有什么陷阱吗?我打算只使用它,因为我认为-Bsymbolic会打破异常(我认为这样做是为了使对typeinfo对象的引用不统一).
Should I be aware of any pitfalls of using
-Bsymbolic-functions
? I plan to only use that, because the -Bsymbolic will break exceptions, I think (it will make it so that references to typeinfo objects are not unified, I think).
我仔细研究了一下,看来没有问题. libstdc ++库显然是这样做的,或者至少是考虑过的,他们只需要添加--dynamic-list-cpp-new
即可使operator new
保持统一(以防止程序中多个分配器/解除分配器混合在一起的问题,但我认为这样的程序已损坏反正). Ubuntu使用它或默认使用它,似乎它与某些软件包引起冲突.但总体而言,我期望它应该能很好地工作.
I looked more into it, and it seems there is no issue. The libstdc++ library apparently does it or at least did consider it and they only had to add --dynamic-list-cpp-new
to still have operator new
unified (to prevent issues with multiple allocator / deallocators mixing up in a program but I would argue such programs are broken anyway). Ubuntu uses it or used it by default, and it seems it causes conflicts with some packages. But overall it should work nicely I expect.
这篇关于使用-Bsymbolic-functions有不利之处吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!