summaryrefslogtreecommitdiff
path: root/lib/xray
diff options
context:
space:
mode:
authorSerge Rogatch <srogatch@accesssoftek.com>2016-12-22 18:48:36 +0000
committerSerge Rogatch <srogatch@accesssoftek.com>2016-12-22 18:48:36 +0000
commit8527a048b7997cf1ecec35623aa952362f3756a9 (patch)
tree189372f67054a066f3714245dcf41956b17059bc /lib/xray
parent04c9e43fb71553ef2226ece3755df780eba11f7f (diff)
[XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification
Summary: This patch attempts to fix test patching-unpatching.cc . The new code flushes the instruction cache after modifying the program at runtime. Reviewers: dberris, rengolin Subscribers: llvm-commits, iid_iunknown, aemerson Differential Revision: https://reviews.llvm.org/D27996 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290354 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/xray')
-rw-r--r--lib/xray/xray_AArch64.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/xray/xray_AArch64.cc b/lib/xray/xray_AArch64.cc
index 8f24610da..12b4a6fad 100644
--- a/lib/xray/xray_AArch64.cc
+++ b/lib/xray/xray_AArch64.cc
@@ -75,8 +75,8 @@ inline static bool patchSled(const bool Enable, const uint32_t FuncId,
// B #32
uint32_t *FirstAddress = reinterpret_cast<uint32_t *>(Sled.Address);
+ uint32_t *CurAddress = FirstAddress + 1;
if (Enable) {
- uint32_t *CurAddress = FirstAddress + 1;
*CurAddress = uint32_t(PatchOpcodes::PO_LdrW0_12);
CurAddress++;
*CurAddress = uint32_t(PatchOpcodes::PO_LdrX16_12);
@@ -88,6 +88,7 @@ inline static bool patchSled(const bool Enable, const uint32_t FuncId,
*reinterpret_cast<void (**)()>(CurAddress) = TracingHook;
CurAddress += 2;
*CurAddress = uint32_t(PatchOpcodes::PO_LdpX0X30SP_16);
+ CurAddress++;
std::atomic_store_explicit(
reinterpret_cast<std::atomic<uint32_t> *>(FirstAddress),
uint32_t(PatchOpcodes::PO_StpX0X30SP_m16e), std::memory_order_release);
@@ -96,6 +97,8 @@ inline static bool patchSled(const bool Enable, const uint32_t FuncId,
reinterpret_cast<std::atomic<uint32_t> *>(FirstAddress),
uint32_t(PatchOpcodes::PO_B32), std::memory_order_release);
}
+ __clear_cache(reinterpret_cast<char*>(FirstAddress),
+ reinterpret_cast<char*>(CurAddress));
return true;
}