[PATCH] D38993: [XRay] [compiler-rt] [DSO] start deciding which symbols to hide/export
Martin Pelikán via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 01:56:47 PDT 2017
pelikan created this revision.
Herald added a subscriber: mgorny.
Since a running application will only have one set of XRay handlers, its
C++ function pointers all trampolines go to need to be explicitly put to
.dynsym for the runtime dynamic loader to find them. In contrast, local
symbols like the instrumentation map demarcation points, trampolines and
DSOContext must *not* be visible outside whatever we're linking, because
the world is full of broken software (libtool) instructing the toolchain
to apply broad policies on all symbols (-z defs, --export-dynamic) which
might confuse the loader into treating one DSO's instrumentation map for
other one's, for example, because the wrong visibilities have been set.
Therefore we'll maintain an explicit list of interfaces we want to share
and later (when this won't break any tests and I verify the install rule
does what I want in Gentoo's llvm-9999.ebuild) we'll instruct the driver
in Clang to pass these files as --dynamic-list and --version-script into
the final linker invocation. It will use the same /usr/lib/clang/6.0.0/
path as the XRay .a (+all sanitizers with their own .syms) currently do.
Obviously, this list will probably be expanded later.
https://reviews.llvm.org/D38993
Files:
lib/xray/CMakeLists.txt
lib/xray/xray.syms
lib/xray/xray.vers
Index: lib/xray/xray.vers
===================================================================
--- /dev/null
+++ lib/xray/xray.vers
@@ -0,0 +1,23 @@
+{
+global:
+ extern "C++" {
+ __xray::XRayPatchedCustomEvent;
+ __xray::XRayPatchedFunction;
+ __xray::XRayArgLogger;
+ };
+ XRayInitialized;
+local:
+ extern "C++" {
+ __xray::DSOContext;
+ };
+ __start_xray_instr_map;
+ __start_xray_fn_index;
+ __stop_xray_instr_map;
+ __stop_xray_fn_index;
+ __xray_ArgLoggerEntry;
+ __xray_FunctionEntry;
+ __xray_FunctionExit;
+ __xray_FunctionTailExit;
+ __xray_CustomEvent;
+ __xray_patch;
+};
Index: lib/xray/xray.syms
===================================================================
--- /dev/null
+++ lib/xray/xray.syms
@@ -0,0 +1,8 @@
+{
+ extern "C++" {
+ __xray::XRayPatchedCustomEvent;
+ __xray::XRayPatchedFunction;
+ __xray::XRayArgLogger;
+ };
+ XRayInitialized;
+};
Index: lib/xray/CMakeLists.txt
===================================================================
--- lib/xray/CMakeLists.txt
+++ lib/xray/CMakeLists.txt
@@ -86,6 +86,18 @@
DEFS ${XRAY_COMMON_DEFINITIONS}
OBJECT_LIBS ${XRAY_COMMON_RUNTIME_OBJECT_LIBS}
PARENT_TARGET xray)
+ set(syms ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/libclang_rt.xray-${arch}.a.syms)
+ set(vers ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/libclang_rt.xray-${arch}.a.vers)
+ add_custom_command(TARGET xray
+ COMMAND /bin/cp xray.syms ${syms}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ VERBATIM)
+ add_custom_command(TARGET xray
+ COMMAND /bin/cp xray.vers ${vers}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ VERBATIM)
+ install(FILES ${syms} ${vers}
+ DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
endif()
endforeach()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38993.119269.patch
Type: text/x-patch
Size: 1740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171017/4798ba49/attachment.bin>
More information about the llvm-commits
mailing list