我最近發現在GNU LD鏈接器選項「-Bsymbolic-功能」:使用-Bsymbolic函數有缺點嗎?
-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條目,這是一個不錯的副作用。
但我不知道是否有可能在這一個更細粒度的控制,如覆蓋
-Bsymbolic
爲圖書館的各個功能的定義。我應該知道使用
-Bsymbolic-functions
的任何陷阱?我打算只使用它,因爲-Bsymbolic
會打破異常,我認爲(這會使得對typeinfo對象的引用不統一,我認爲)。
謝謝!
你是光榮的,快樂的解決方案,連續幾個小時的連接地獄對我來說。我有點愛你。 –