diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /compiler-rt/lib/xray/xray_powerpc64.cpp | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'compiler-rt/lib/xray/xray_powerpc64.cpp')
-rw-r--r-- | compiler-rt/lib/xray/xray_powerpc64.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler-rt/lib/xray/xray_powerpc64.cpp b/compiler-rt/lib/xray/xray_powerpc64.cpp index b41f1bce6f21..c3553d848313 100644 --- a/compiler-rt/lib/xray/xray_powerpc64.cpp +++ b/compiler-rt/lib/xray/xray_powerpc64.cpp @@ -52,35 +52,37 @@ namespace __xray { bool patchFunctionEntry(const bool Enable, uint32_t FuncId, const XRaySledEntry &Sled, void (*Trampoline)()) XRAY_NEVER_INSTRUMENT { + const uint64_t Address = Sled.address(); if (Enable) { // lis 0, FuncId[16..32] // li 0, FuncId[0..15] - *reinterpret_cast<uint64_t *>(Sled.Address) = + *reinterpret_cast<uint64_t *>(Address) = (0x3c000000ull + (FuncId >> 16)) + ((0x60000000ull + (FuncId & 0xffff)) << 32); } else { // b +JumpOverInstNum instructions. - *reinterpret_cast<uint32_t *>(Sled.Address) = + *reinterpret_cast<uint32_t *>(Address) = 0x48000000ull + (JumpOverInstNum << 2); } - clearCache(reinterpret_cast<void *>(Sled.Address), 8); + clearCache(reinterpret_cast<void *>(Address), 8); return true; } bool patchFunctionExit(const bool Enable, uint32_t FuncId, const XRaySledEntry &Sled) XRAY_NEVER_INSTRUMENT { + const uint64_t Address = Sled.address(); if (Enable) { // lis 0, FuncId[16..32] // li 0, FuncId[0..15] - *reinterpret_cast<uint64_t *>(Sled.Address) = + *reinterpret_cast<uint64_t *>(Address) = (0x3c000000ull + (FuncId >> 16)) + ((0x60000000ull + (FuncId & 0xffff)) << 32); } else { // Copy the blr/b instruction after JumpOverInstNum instructions. - *reinterpret_cast<uint32_t *>(Sled.Address) = - *(reinterpret_cast<uint32_t *>(Sled.Address) + JumpOverInstNum); + *reinterpret_cast<uint32_t *>(Address) = + *(reinterpret_cast<uint32_t *>(Address) + JumpOverInstNum); } - clearCache(reinterpret_cast<void *>(Sled.Address), 8); + clearCache(reinterpret_cast<void *>(Address), 8); return true; } |