Is there a downside to using -Bsymbolic-functions?

I recently discussed this this with one of the toolchain experts at SUSE. Here are his remarks:

"-Bsymbolic-functions is a thing from an old world which doesn't exist anymore. It completely bypasses everything about what ELF can provide, including visibility. When you're using it, everything is bound locally. IOW: don't use it :) Noone should use -Bsymbolic-functions, it's a too big hammer for most purposes."

How does -Bsymbolic-functions relate to library versioning (--version-script) ?

"-Bsymbolic-functions overrides anything, from linker scripts, from GCC attributes or anywhere, about symbol visibilities or anything. It makes everything bind local, always, irrespective of anything else that you might have added on command lines, or extra files, or object files. (And yes, --dynamic-list= was a mis-guided attempt to fix some of that and make -Bsymbolic* somewhat more friendly). So, yes, it takes precendence over linker script. It's a big hammer :) "

"To be extra precise: -Bsymbolic-functions is not quite that same as linker script global/local, which is probably a reason why people still use it sometimes. While -Bsymbolic-functions does bind references to definitions locally (like local: in linker scripts), it also keeps them exported (like the global: ones). In ELF speak that would be somewhat like PROTECTED visibility. Unfortunately that can't be expressed in a symbol version script right now, only via GCCs __attribute__(visibility). So, when people try to get the speed advantage of local binding (fewer symbol lookups at library load time), while still exporting all their functions from the shared lib, they unfortunately often end up first finding that -Bsymbolic-functions "does what I want", without realizing that it creates problems down the line."


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

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

Yes, there is the option --dynamic-list which does exactly that

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).

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.