CMakeLists.txt            |   17 +++++++++++++++--
 poppler/libpoppler.map.in |    4 ++++
 2 files changed, 19 insertions(+), 2 deletions(-)

New commits:
commit 823de0858dff673f4ecdbad3386a702b5e0ec3b8
Author: Sune Vuorela <[email protected]>
Date:   Thu Jul 6 09:07:28 2023 +0200

    Version symbols in poppler core
    
    This prevents crashes and collisions in the case where two poppler core
    libraries are in the same process.
    
    The likely case is if an application is linked to both poppler core
    and a stable frontend, and poppler is updated and the application
    is not yet recompiled against the newer poppler core, then the newer
    frontend pulls in newer poppler core while the application pulls in the
    older poppler core and that leads to crashes. In general, this can be
    fixed by versioning the symbols to prevent mix and match of symbols.
    
    Patch by Andreas Metzler <[email protected]>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 48c5b6e3..a468bf81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -616,10 +616,17 @@ ADD_GPERF_FILE(TimesItalicWidths)
 ADD_GPERF_FILE(TimesRomanWidths)
 ADD_GPERF_FILE(ZapfDingbatsWidths)
 
+set(POPPLER_SOVERSION_NUMBER "130")
+
+set(LINKER_SCRIPT "${CMAKE_BINARY_DIR}/libpoppler.map")
+configure_file(
+    "${CMAKE_SOURCE_DIR}/poppler/libpoppler.map.in"
+    ${LINKER_SCRIPT})
+
 if(MSVC)
 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
 endif()
-add_library(poppler ${poppler_SRCS})
+add_library(poppler ${poppler_SRCS} ${LINKER_SCRIPT})
 if (OpenJPEG_FOUND)
   # check if we can remove this when we depend on newer openjpeg versions, 2.5 
seems fixed
   # target openjp2 may lack interface include directories
@@ -629,7 +636,13 @@ if(USE_CMS)
   target_include_directories(poppler SYSTEM PRIVATE ${LCMS2_INCLUDE_DIR})
 endif()
 generate_export_header(poppler BASE_NAME poppler-private EXPORT_FILE_NAME 
"${CMAKE_CURRENT_BINARY_DIR}/poppler_private_export.h")
-set_target_properties(poppler PROPERTIES VERSION 130.0.0 SOVERSION 130)
+set_target_properties(poppler PROPERTIES
+                              VERSION ${POPPLER_SOVERSION_NUMBER}.0.0
+                              SOVERSION ${POPPLER_SOVERSION_NUMBER})
+
+if(UNIX AND (NOT APPLE))
+       set_target_properties(poppler PROPERTIES LINK_OPTIONS 
LINKER:--version-script=${LINKER_SCRIPT})
+endif()
 if(MINGW AND BUILD_SHARED_LIBS)
     get_target_property(POPPLER_SOVERSION poppler SOVERSION)
     set_target_properties(poppler PROPERTIES SUFFIX 
"-${POPPLER_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
diff --git a/poppler/libpoppler.map.in b/poppler/libpoppler.map.in
new file mode 100644
index 00000000..8a0ee016
--- /dev/null
+++ b/poppler/libpoppler.map.in
@@ -0,0 +1,4 @@
+POPPLER_@POPPLER_SOVERSION_NUMBER@ {
+  global:
+    *;
+};

Reply via email to