[Lldb-commits] [PATCH] D26093: Limit LLDB_EXPORT_ALL_SYMBOLS to additionally export only the lldb_private namespace symbols

Todd Fiala via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 28 12:13:22 PDT 2016


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()
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26093.76229.patch
Type: text/x-patch
Size: 1409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20161028/dffe6919/attachment.bin>


More information about the lldb-commits mailing list