diff --git a/CMakeLists.txt b/CMakeLists.txt index 21adb7b1c..dc9bce140 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,11 +338,19 @@ target_include_directories(sentry # as `PUBLIC`, so libraries that depend on sentry get these too: # `-E`: To have all symbols in the dynamic symbol table. # `--build-id`: To have a build-id in the ELF object. +# `--version-script`: The given script makes sure only `sentry_*` symbols are exported # FIXME: cmake 3.13 introduced target_link_options +target_link_libraries(sentry PUBLIC + "$<$,$>:-Wl,--build-id=sha1,--version-script=${PROJECT_SOURCE_DIR}/src/exports.map>") + option(SENTRY_EXPORT_SYMBOLS "Export symbols for modulefinder and symbolizer" ON) if(SENTRY_EXPORT_SYMBOLS) target_link_libraries(sentry PUBLIC - "$<$,$>:-Wl,-E,--build-id=sha1>") + "$<$,$>:-Wl,-E>") +else() + set(CMAKE_C_VISIBILITY_PRESET hidden) + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) endif() #respect CMAKE_SYSTEM_VERSION diff --git a/src/exports.map b/src/exports.map new file mode 100644 index 000000000..a361e4251 --- /dev/null +++ b/src/exports.map @@ -0,0 +1,4 @@ +{ + global: sentry_*; + local: *; +};