From 389cff23f3c99473d6ec8981a819affae87f4cb1 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 17 Jul 2017 16:22:00 +0100 Subject: [PATCH] Add linker version script to explicitly expose symbols. Refs #683 * When statically linking libstdc++ by default the symbols are all default visibility. This causes a problem if you statically link an old libstdc++ then inject librenderdoc.so, and the application starts using the old libstdc++ instead of the system's. * Really we only want to use the static one for calls from librenderdoc.so. In theory -Wl,--exclude-libs,libstdc++ should do this for us, but it starts to cause bizarre crashes. * Instead, we have to resort to a manual linker script which whitelists which symbols should be visible. Normally we can do this just for our own symbols with -fvisibility=hidden and __attribute__((visibility)) but that doesn't work for linked symbols apparently. --- renderdoc/CMakeLists.txt | 4 ++++ renderdoc/renderdoc.version | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 renderdoc/renderdoc.version diff --git a/renderdoc/CMakeLists.txt b/renderdoc/CMakeLists.txt index caa00d3d2..fb3c6d0b7 100644 --- a/renderdoc/CMakeLists.txt +++ b/renderdoc/CMakeLists.txt @@ -307,6 +307,10 @@ target_compile_definitions(renderdoc ${RDOC_DEFINITIONS}) target_include_directories(renderdoc ${RDOC_INCLUDES}) target_link_libraries(renderdoc ${RDOC_LIBRARIES}) +if(UNIX AND NOT ANDROID) + set_target_properties(renderdoc PROPERTIES LINK_FLAGS "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/renderdoc.version") +endif() + install (TARGETS renderdoc DESTINATION lib${LIB_SUFFIX}) # Copy in application API header to include diff --git a/renderdoc/renderdoc.version b/renderdoc/renderdoc.version new file mode 100644 index 000000000..4bbe89459 --- /dev/null +++ b/renderdoc/renderdoc.version @@ -0,0 +1,12 @@ +{ + global: + _init; + _fini; + gl[A-Z]*; + dlopen; + _exit; + RENDERDOC_*; + VK_LAYER_RENDERDOC_*; + local: + *; +};