[PATCH] D38990: [XRay] [compiler-rt] [DSO] introduce a context for patching/unpatching

Martin Pelikán via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 01:08:43 PDT 2017


pelikan created this revision.

For the upcoming DSO support, we want to reuse code between the "static"
version of XRay, already within the main binary and possibly initialized
at startup, and the "dynamic" part bundled with .so libraries which will
need to communicate with it.  Wherever patching/unpatching happens needs
to be clearly defined for the patching code to recognize which memory is
it actually operating on.

This diff introduces an "always visible" pointer (*DSOContext), which is
local for each DSO, only visible within its own "copy" of XRay.  Whoever
initializes that context (xray_init.cc in the main binary or xray_dso.cc
in a DSO during dlopen(3)) will populate that pointer.  The advantage of
having a pointer instead of scattered functions and variables is:

- we have something to identify a DSO (it will have a numeric ID soon)
- it is easier to add per-DSO behaviour later, and control it globally
- it is clearer for the reader which C++ code is intended to be shared

When this is in, it is easy to take xray_interface{.cc,_internal.h} and
build a DSO version of the XRay runtime with it.


https://reviews.llvm.org/D38990

Files:
  lib/xray/xray_init.cc
  lib/xray/xray_interface.cc
  lib/xray/xray_interface_internal.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38990.119264.patch
Type: text/x-patch
Size: 4722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171017/a4f6340c/attachment.bin>


More information about the llvm-commits mailing list