tfiala created this revision.
tfiala added reviewers: labath, tberghammer.
tfiala added a subscriber: lldb-commits.
Herald added a subscriber: mgorny.

My original implementation of this last year was to just export everything from 
liblldb.so.  As lldb-mi recently started including a separate copy of llvm, 
exporting everything from liblldb.so has the side effect of allowing the Linux 
dynamic linker to resolve liblldb.so and lldb-mi's two copies of llvm to the 
same underlying storage.  This means any global constructors in LLVM (e.g. the 
'debug' command line option that triggered this change when NDEBUG is not 
defined) have side-effects applied twice to the same underlying data.

This change adjusts the -DLLDB_EXPORT_ALL_SYMBOLS flag's implementation, 
limiting exports to the normal exports plus the lldb_private namespace symbols. 
 This filters out exporting any of the LLVM symbols for the copy inside 
liblldb.so, maintaining the firewall between the separate copies of llvm. 
preventing two sets of global constructors from both occurring on the same 
underlying data.


https://reviews.llvm.org/D26093

Files:
  API/CMakeLists.txt
  API/liblldb-private.exports


Index: API/liblldb-private.exports
===================================================================
--- /dev/null
+++ API/liblldb-private.exports
@@ -0,0 +1,6 @@
+_ZN4lldb*
+_ZNK4lldb*
+_ZN12lldb_private*
+_ZNK12lldb_private*
+init_lld*
+PyInit__lldb*
Index: API/CMakeLists.txt
===================================================================
--- API/CMakeLists.txt
+++ API/CMakeLists.txt
@@ -103,16 +103,13 @@
     # If we're not exporting all symbols, we'll want to explicitly set
     # the exported symbols here.  This prevents 'log enable --stack ...'
     # from working on some systems but limits the liblldb size.
-    MESSAGE("-- Symbols (liblldb): only exporting liblldb.exports symbols")
+    MESSAGE("-- Symbols (liblldb): only exporting symbols in lldb namespace")
     add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
   else()
     # Don't use an explicit export.  Instead, tell the linker to
     # export all symbols.
-    MESSAGE("-- Symbols (liblldb): exporting all symbols")
-    # Darwin linker doesn't need this extra step.
-    if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
-      lldb_append_link_flags(liblldb "-Wl,--export-dynamic")
-    endif()
+    MESSAGE("-- Symbols (liblldb): exporting symbols from lldb and 
lldb_private namespace")
+    add_llvm_symbol_exports(liblldb 
${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
   endif()
 endif()
 


Index: API/liblldb-private.exports
===================================================================
--- /dev/null
+++ API/liblldb-private.exports
@@ -0,0 +1,6 @@
+_ZN4lldb*
+_ZNK4lldb*
+_ZN12lldb_private*
+_ZNK12lldb_private*
+init_lld*
+PyInit__lldb*
Index: API/CMakeLists.txt
===================================================================
--- API/CMakeLists.txt
+++ API/CMakeLists.txt
@@ -103,16 +103,13 @@
     # If we're not exporting all symbols, we'll want to explicitly set
     # the exported symbols here.  This prevents 'log enable --stack ...'
     # from working on some systems but limits the liblldb size.
-    MESSAGE("-- Symbols (liblldb): only exporting liblldb.exports symbols")
+    MESSAGE("-- Symbols (liblldb): only exporting symbols in lldb namespace")
     add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
   else()
     # Don't use an explicit export.  Instead, tell the linker to
     # export all symbols.
-    MESSAGE("-- Symbols (liblldb): exporting all symbols")
-    # Darwin linker doesn't need this extra step.
-    if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
-      lldb_append_link_flags(liblldb "-Wl,--export-dynamic")
-    endif()
+    MESSAGE("-- Symbols (liblldb): exporting symbols from lldb and lldb_private namespace")
+    add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
   endif()
 endif()
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to