22#include " LinkTimeRelocationsStep.hpp"
33#include < cstdint>
44#include < limits>
5+ #include < dobby.h>
56#include " jet/live/DataTypes.hpp"
67#include " jet/live/LiveContext.hpp"
78#include " jet/live/Utility.hpp"
@@ -46,7 +47,7 @@ namespace jet
4647 continue ;
4748 }
4849
49- auto relocAddressVal = targetSymbol->runtimeAddress + reloc.relocationOffsetRelativeTargetSymbolAddress ;
50+ auto relocAddress = targetSymbol->runtimeAddress + reloc.relocationOffsetRelativeTargetSymbolAddress ;
5051 auto distance = std::abs (static_cast <intptr_t >(oldVar->runtimeAddress - relocSymbol->runtimeAddress ));
5152 int64_t maxAllowedDistance = 0 ;
5253 if (reloc.size == sizeof (int32_t )) {
@@ -64,17 +65,22 @@ namespace jet
6465 continue ;
6566 }
6667
67- auto relocAddress = reinterpret_cast <void *>(relocAddressVal);
68- if (!unprotect (relocAddress, reloc.size )) {
69- context->events ->addLog (LogSeverity::kError , " 'unprotect' failed" );
70- continue ;
68+ auto relocAddressPtr = reinterpret_cast <void *>(relocAddress);
7169 }
7270 if (reloc.size == sizeof (int32_t )) {
73- *reinterpret_cast <int32_t *>(relocAddress ) +=
71+ int32_t buf = *reinterpret_cast <int32_t *>(relocAddressPtr ) +
7472 static_cast <int32_t >(oldVar->runtimeAddress ) - static_cast <int32_t >(relocSymbol->runtimeAddress );
73+ if (DobbyCodePatch (relocAddressPtr, reinterpret_cast <uint8_t *>(&buf), sizeof (buf)) != 0 ) {
74+ context->events ->addLog (LogSeverity::kError , " relocation code patch failed" );
75+ continue ;
76+ }
7577 } else if (reloc.size == sizeof (int64_t )) {
76- *reinterpret_cast <int64_t *>(relocAddress ) +=
78+ int64_t buf = *reinterpret_cast <int64_t *>(relocAddressPtr ) +
7779 static_cast <int32_t >(oldVar->runtimeAddress ) - static_cast <int32_t >(relocSymbol->runtimeAddress );
80+ if (DobbyCodePatch (relocAddressPtr, reinterpret_cast <uint8_t *>(&buf), sizeof (buf)) != 0 ) {
81+ context->events ->addLog (LogSeverity::kError , " relocation code patch failed" );
82+ continue ;
83+ }
7884 }
7985 context->events ->addLog (LogSeverity::kDebug , relocSymbol->name + " was relocated" );
8086
0 commit comments