gpt4 book ai didi

linker - 使用 -Bsymbolic-functions 有缺点吗?

转载 作者:行者123 更新时间:2023-12-01 16:48:58 26 4
gpt4 key购买 nike

我最近在 GNU ld 中发现了链接器选项“-Bsymbolic-functions”:

-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 的反面,因为它不是阻止将引用的函数导出到其他共享对象,而是阻止库内部对该函数的引用避免绑定(bind)到不同共享对象的导出函数。我告诉自己,-Bsymbolic-functions 将阻止为函数创建 PLT 条目,这是一个很好的副作用。

  1. 但我想知道是否可以对此进行更细粒度的控制,例如覆盖库的各个函数定义的 -Bsymbolic

  2. 我应该注意使用 -Bsymbolic-functions 的任何陷阱吗?我打算只使用它,因为我认为 -Bsymbolic 会中断异常(我认为它会使对 typeinfo 对象的引用不统一)。

谢谢!

最佳答案

回答我自己的问题,因为我刚刚为此获得了风滚草徽章......我随后发现了

But I was wondering whether there is perhaps a finer-grained control over this, like overwriting -Bsymbolic for individual function definitions of a library.

是的,有一个选项--dynamic-list可以做到这一点

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使用它或者默认使用它,似乎它会导致与某些软件包发生冲突。但总的来说,我期望它应该工作得很好。

关于linker - 使用 -Bsymbolic-functions 有缺点吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7216973/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com