最近、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.
-fvisibility=hidden
これは、参照された関数を他の共有オブジェクトにエクスポートするのを防ぐ代わりに、その関数へのライブラリ内部の参照が別の共有オブジェクトのエクスポートされた関数にバインドされるのを防ぐという点で、GCC オプションの逆のようです。関数の PLT エントリの作成を防ぐことができると自分-Bsymbolic-functions
に言い聞かせましたが、これは良い副作用です。
-Bsymbolic
しかし、ライブラリの個々の関数定義を上書きするなど、これをより細かく制御できるかどうか疑問に思っていました。を使用する際の落とし穴に注意する必要があり
-Bsymbolic-functions
ますか? は例外を壊すので、私はそれのみを使用する予定です-Bsymbolic
(typeinfoオブジェクトへの参照が統一されないようにするだろうと思います)。
ありがとう!