mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-12 21:56:54 +00:00
Replace nop instructions with ud2 (#84)
This commit is contained in:
parent
e3ff13fd5e
commit
9e1a9ed36a
@ -2113,7 +2113,6 @@ bool OIDebugger::writePrologue(
|
||||
const prequest &preq, const OICompiler::RelocResult::SymTable &jitSymbols) {
|
||||
size_t off = 0;
|
||||
uint8_t newInsts[prologueLength];
|
||||
memset(newInsts, nopInst /* NOP */, sizeof(newInsts));
|
||||
|
||||
/*
|
||||
* Global probes don't have multiple arguments, but calling `getReqForArg(X)`
|
||||
@ -2136,17 +2135,6 @@ bool OIDebugger::writePrologue(
|
||||
VLOG(1) << "Generating prologue for argument '" << req.arg
|
||||
<< "', using probe at " << (void *)jitCodeStart->second;
|
||||
|
||||
/*
|
||||
* With the move to an INT3 to regain control of the target thread I'm
|
||||
* not convinced that we actually need to do any of this now. We may be
|
||||
* able to simply tack an INT3 on to the end of the JIT'd code sequence
|
||||
* (obviously we wouldn't ever execute the 'ret' there but that doesn't
|
||||
* really matter).
|
||||
*/
|
||||
/*
|
||||
* movabs is really a synthetic for a REX prefixed mov instruction.
|
||||
* The REX prefix opcode is 0x48 (REX.W == 1).
|
||||
*/
|
||||
newInsts[off++] = movabsrdi0Inst;
|
||||
newInsts[off++] = movabsrdi1Inst;
|
||||
remoteObjAddrs.emplace(std::move(jitCodeStart->first),
|
||||
@ -2177,6 +2165,11 @@ bool OIDebugger::writePrologue(
|
||||
|
||||
newInsts[off++] = int3Inst;
|
||||
|
||||
while (off <= prologueLength - sizeofUd2) {
|
||||
newInsts[off++] = ud2Inst0;
|
||||
newInsts[off++] = ud2Inst1;
|
||||
}
|
||||
|
||||
assert(off <= prologueLength);
|
||||
|
||||
return writeTargetMemory(&newInsts, (void *)segConfig.textSegBase,
|
||||
|
@ -160,6 +160,7 @@ class OIDebugger {
|
||||
uint64_t count{};
|
||||
bool sigIntHandlerActive{false};
|
||||
const int sizeofInt3 = 1;
|
||||
const int sizeofUd2 = 2;
|
||||
const int replayInstSize = 512;
|
||||
bool trapsRemoved{false};
|
||||
std::shared_ptr<SymbolService> symbols;
|
||||
|
@ -24,3 +24,5 @@ static constexpr uint8_t movabsrax1Inst = 0xb8;
|
||||
static constexpr uint8_t callRaxInst0Inst = 0xff;
|
||||
static constexpr uint8_t callRaxInst1Inst = 0xd0;
|
||||
static constexpr long syscallInsts = 0x9090909090050fcc;
|
||||
static constexpr uint8_t ud2Inst0 = 0x0f;
|
||||
static constexpr uint8_t ud2Inst1 = 0x0b;
|
||||
|
Loading…
Reference in New Issue
Block a user