Skip to content

Commit c6f09c1

Browse files
committed
Add -Bsymbolic link option to avoid symbol interposition (apache#432)
### Motivation There is a case that `libpulsar.so` could unexpectedly call functions from other dependencies. For example, assuming the application depends on two libraries: - `libpulsar.so`, which includes the symbols from `libcurl.a` 8.4.0 - `libfoo.so`, which includes the symbols from `libcurl.a` 7.82.0 If the link order is `libfoo.so` first, then the libcurl definitions from 7.82.0 will also be used by `libpulsar.so` and then the application might crash due to the incompatibility. This is an issue specifically with Linux ELF format. ### Modifications Add the `-Wl,-Bsymbolic` link option for GCC. (cherry picked from commit d736a1b)
1 parent 1c725b4 commit c6f09c1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ if (BUILD_DYNAMIC_LIB)
7070
target_include_directories(pulsarShared PRIVATE ${dlfcn-win32_INCLUDE_DIRS})
7171
target_link_options(pulsarShared PRIVATE $<$<CONFIG:DEBUG>:/NODEFAULTLIB:MSVCRT>)
7272
endif()
73+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
74+
target_link_options(pulsarShared PRIVATE -Wl,-Bsymbolic)
75+
endif ()
7376
endif()
7477

7578
include(CheckCXXSymbolExists)

0 commit comments

Comments
 (0)