Skip to content

Commit

Permalink
fix: Add a linker script to enforce exported symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem authored and supervacuus committed Jan 26, 2023
1 parent 4d8627e commit ae515f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
"$<$<OR:$<PLATFORM_ID:Linux>,$<PLATFORM_ID:Android>>:-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
"$<$<OR:$<PLATFORM_ID:Linux>,$<PLATFORM_ID:Android>>:-Wl,-E,--build-id=sha1>")
"$<$<OR:$<PLATFORM_ID:Linux>,$<PLATFORM_ID:Android>>:-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
Expand Down
4 changes: 4 additions & 0 deletions src/exports.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
global: sentry_*;
local: *;
};

0 comments on commit ae515f3

Please sign in to comment.