使用 -Bsymbolic-functions 有缺点吗? [英] Is there a downside to using -Bsymbolic-functions?

查看:44
本文介绍了使用 -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.

  1. 但我想知道是否有对此进行更细粒度的控制,例如为库的各个函数定义覆盖 -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).

谢谢!

推荐答案

回答我自己的问题,因为我刚刚为它赢得了 Tumbleweed 徽章......后来我发现了

Answering my own question because I just earned a Tumbleweed badge for it... and I found out subsequently

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

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 正是这样做的

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆