[PATCH] D37202: [XRay][compiler-rt] Return the pointer associated with the function instead of the sled

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 27 20:35:18 PDT 2017


dberris created this revision.

XRay has erroneously been returning the address of the first sled in the
instrumentation map for a function id instead of the (runtime-relocated)
functison address. This causes confusion and issues for applications
where:

- The first sled in the function may not be an entry sled (due to re-ordering or some other reason).
- The caller attempts to find a symbol associated with the pointer at runtime, because the sled may not be exactly where the function's known address is (in case of inlined functions or those that have an external definition for symbols).

This fixes http://llvm.org/PR34340.


https://reviews.llvm.org/D37202

Files:
  lib/xray/xray_interface.cc


Index: lib/xray/xray_interface.cc
===================================================================
--- lib/xray/xray_interface.cc
+++ lib/xray/xray_interface.cc
@@ -331,7 +331,7 @@
   __sanitizer::SpinMutexLock Guard(&XRayInstrMapMutex);
   if (FuncId <= 0 || static_cast<size_t>(FuncId) > XRayInstrMap.Functions)
     return 0;
-  return XRayInstrMap.SledsIndex[FuncId - 1].Begin->Address
+  return XRayInstrMap.SledsIndex[FuncId - 1].Begin->Function
 // On PPC, function entries are always aligned to 16 bytes. The beginning of a
 // sled might be a local entry, which is always +8 based on the global entry.
 // Always return the global entry.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37202.112849.patch
Type: text/x-patch
Size: 650 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170828/364c09c9/attachment.bin>


More information about the llvm-commits mailing list