|
|
7ac858 |
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/BPatch_addressSpace.C.orig 2019-05-16 14:40:05.000000000 -0400
|
|
|
7ac858 |
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/BPatch_addressSpace.C 2019-11-06 10:20:08.567523510 -0500
|
|
|
7ac858 |
--- BPatch_addressSpace.C.orig 2019-05-16 14:40:05.000000000 -0400
|
|
|
7ac858 |
+++ BPatch_addressSpace.C 2019-11-15 18:10:31.186122654 -0500
|
|
|
7ac858 |
@@ -1050,5 +1050,2 @@
|
|
|
7ac858 |
return true;
|
|
|
7ac858 |
-
|
|
|
7ac858 |
- regs = registers_;
|
|
|
7ac858 |
- return true;
|
|
|
7ac858 |
}
|
|
|
7ac858 |
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/emit-aarch64.C.orig 2019-05-16 14:40:05.000000000 -0400
|
|
|
7ac858 |
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/emit-aarch64.C 2019-11-06 10:20:08.567523510 -0500
|
|
|
7ac858 |
@@ -276,9 +276,2 @@
|
|
|
7ac858 |
|
|
|
7ac858 |
- if (register_num == REG_SP) {
|
|
|
7ac858 |
- insnCodeGen::generateAddSubImmediate(gen, insnCodeGen::Add, 0,
|
|
|
7ac858 |
- TRAMP_FRAME_SIZE_64, destination, REG_SP, true);
|
|
|
7ac858 |
-
|
|
|
7ac858 |
- return;
|
|
|
7ac858 |
- }
|
|
|
7ac858 |
-
|
|
|
7ac858 |
if (src->spilledState == registerSlot::unspilled)
|
|
|
7ac858 |
@@ -293,3 +286,3 @@
|
|
|
7ac858 |
// its on the stack so load it.
|
|
|
7ac858 |
- insnCodeGen::restoreRegister(gen, destination, offset + (register_num * gen.width()),
|
|
|
7ac858 |
+ insnCodeGen::restoreRegister(gen, destination, offset + (src->encoding() * gen.width()),
|
|
|
7ac858 |
insnCodeGen::Offset);
|
|
|
7ac858 |
@@ -298 +291,7 @@
|
|
|
7ac858 |
|
|
|
7ac858 |
+bool EmitterAARCH64::emitMoveRegToReg(Register src, Register dest, codeGen &gen)
|
|
|
7ac858 |
+{
|
|
|
7ac858 |
+ insnCodeGen::generateMove(gen, dest, src);
|
|
|
7ac858 |
+ return true;
|
|
|
7ac858 |
+}
|
|
|
7ac858 |
+
|
|
|
7ac858 |
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/emit-aarch64.h.orig 2019-05-16 14:40:05.000000000 -0400
|
|
|
7ac858 |
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/emit-aarch64.h 2019-11-06 10:20:08.567523510 -0500
|
|
|
7ac858 |
@@ -107,6 +107,3 @@
|
|
|
7ac858 |
|
|
|
7ac858 |
- virtual bool emitMoveRegToReg(Register, Register, codeGen &) {
|
|
|
7ac858 |
- assert(0);
|
|
|
7ac858 |
- return 0;
|
|
|
7ac858 |
- }
|
|
|
7ac858 |
+ virtual bool emitMoveRegToReg(Register, Register, codeGen &);
|
|
|
7ac858 |
|
|
|
7ac858 |
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/inst-aarch64.C.orig 2019-05-16 14:40:05.000000000 -0400
|
|
|
7ac858 |
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/inst-aarch64.C 2019-11-06 10:20:08.567523510 -0500
|
|
|
7ac858 |
@@ -108,2 +108,4 @@
|
|
|
7ac858 |
registers.push_back(new registerSlot(r30, "r30", true, registerSlot::liveAlways, registerSlot::GPR));
|
|
|
7ac858 |
+ // SP is r31, but also could be considered special. But now it's being added as GPR
|
|
|
7ac858 |
+ registers.push_back(new registerSlot(sp, "r31", true, registerSlot::liveAlways, registerSlot::GPR));
|
|
|
7ac858 |
|
|
|
7ac858 |
@@ -111,3 +113,3 @@
|
|
|
7ac858 |
registers.push_back(new registerSlot(lr, "lr", true, registerSlot::liveAlways, registerSlot::SPR));
|
|
|
7ac858 |
- registers.push_back(new registerSlot(sp, "sp", true, registerSlot::liveAlways, registerSlot::SPR));
|
|
|
7ac858 |
+ //registers.push_back(new registerSlot(sp, "sp", true, registerSlot::liveAlways, registerSlot::SPR));
|
|
|
7ac858 |
registers.push_back(new registerSlot(pstate, "nzcv", true, registerSlot::liveAlways, registerSlot::SPR));
|
|
|
7ac858 |
@@ -183,9 +185,16 @@
|
|
|
7ac858 |
registerSlot *reg = theRegSpace->GPRs()[idx];
|
|
|
7ac858 |
- // We always save FP and LR for stack walking out of instrumentation
|
|
|
7ac858 |
- if (reg->liveState == registerSlot::live || reg->number == REG_FP || reg->number == REG_LR) {
|
|
|
7ac858 |
+ // We always save FP and LR for stack walking out of instrumentation
|
|
|
7ac858 |
+ //if (reg->liveState == registerSlot::live || reg->number == REG_FP || reg->number == REG_LR) {
|
|
|
7ac858 |
int offset_from_sp = offset + (reg->encoding() * gen.width());
|
|
|
7ac858 |
- insnCodeGen::saveRegister(gen, reg->number, offset_from_sp);
|
|
|
7ac858 |
+ if(reg->number != registerSpace::sp)
|
|
|
7ac858 |
+ insnCodeGen::saveRegister(gen, reg->number, offset_from_sp);
|
|
|
7ac858 |
+ else{
|
|
|
7ac858 |
+ // mov SP to x0
|
|
|
7ac858 |
+ insnCodeGen::generateAddSubImmediate(gen, insnCodeGen::Add, 0,
|
|
|
7ac858 |
+ TRAMP_FRAME_SIZE_64, REG_SP, 0, true);
|
|
|
7ac858 |
+ insnCodeGen::saveRegister(gen, 0, offset_from_sp);
|
|
|
7ac858 |
+ }
|
|
|
7ac858 |
theRegSpace->markSavedRegister(reg->number, offset_from_sp);
|
|
|
7ac858 |
ret++;
|
|
|
7ac858 |
- }
|
|
|
7ac858 |
+ //}
|
|
|
7ac858 |
}
|
|
|
7ac858 |
@@ -283,2 +292,4 @@
|
|
|
7ac858 |
if(reg->liveState == registerSlot::spilled) {
|
|
|
7ac858 |
+ if(reg->number == registerSpace::sp)
|
|
|
7ac858 |
+ continue;
|
|
|
7ac858 |
//#sasha this should be GPRSIZE_64 and not gen.width
|
|
|
7ac858 |
@@ -602,4 +613,2 @@
|
|
|
7ac858 |
{
|
|
|
7ac858 |
- //#sasha This function implementation is experimental.
|
|
|
7ac858 |
-
|
|
|
7ac858 |
if (op != callOp) {
|
|
|
7ac858 |
@@ -623,4 +632,2 @@
|
|
|
7ac858 |
vector<int> savedRegs;
|
|
|
7ac858 |
-
|
|
|
7ac858 |
- // save r0-r7
|
|
|
7ac858 |
for(size_t id = 0; id < gen.rs()->numGPRs(); id++)
|
|
|
7ac858 |
@@ -653,2 +660,6 @@
|
|
|
7ac858 |
assert(reg!=REG_NULL);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ // mark reg offLimits so getScratchRegister won't use it
|
|
|
7ac858 |
+ registerSlot *regS = gen.rs()->GPRs()[id];
|
|
|
7ac858 |
+ regS->offLimits = true;
|
|
|
7ac858 |
}
|
|
|
7ac858 |
@@ -691,3 +702,2 @@
|
|
|
7ac858 |
|
|
|
7ac858 |
- // r7-r0
|
|
|
7ac858 |
for (signed int ui = savedRegs.size()-1; ui >= 0; ui--) {
|
|
|
7ac858 |
@@ -697,2 +707,9 @@
|
|
|
7ac858 |
|
|
|
7ac858 |
+ // Making operand's reg not offLimits again
|
|
|
7ac858 |
+ for(size_t id = 0; id < operands.size(); id++)
|
|
|
7ac858 |
+ {
|
|
|
7ac858 |
+ registerSlot *reg = gen.rs()->GPRs()[id];
|
|
|
7ac858 |
+ reg->offLimits = false;
|
|
|
7ac858 |
+ }
|
|
|
7ac858 |
+
|
|
|
7ac858 |
return 0;
|
|
|
7ac858 |
@@ -1426,4 +1443,53 @@
|
|
|
7ac858 |
bool EmitterAARCH64Stat::emitPLTCall(func_instance *callee, codeGen &gen) {
|
|
|
7ac858 |
- assert(0); //Not implemented
|
|
|
7ac858 |
- return emitPLTCommon(callee, true, gen);
|
|
|
7ac858 |
+ /*
|
|
|
7ac858 |
+ Address dest = getInterModuleFuncAddr(callee, gen);
|
|
|
7ac858 |
+ //Register scr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ //Register lr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ //Address pc = emitMovePCToReg(scr, gen);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ Address varOffset = dest - gen.currAddr();
|
|
|
7ac858 |
+ //printf("VarOffset = %d\n", varOffset);
|
|
|
7ac858 |
+ //emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ insnCodeGen::generateBranch(gen, gen.currAddr(), dest, true);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ return true;
|
|
|
7ac858 |
+ */
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ Address dest = getInterModuleFuncAddr(callee, gen);
|
|
|
7ac858 |
+ Register scr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ Register lr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ //Register scr = gen.rs()->getRegByName("r2");
|
|
|
7ac858 |
+ //Register lr = gen.rs()->getRegByName("r3");
|
|
|
7ac858 |
+ emitMovePCToReg(scr, gen);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ Address varOffset = dest - gen.currAddr() + 4;
|
|
|
7ac858 |
+ //printf("VarOffset = %d\n", varOffset);
|
|
|
7ac858 |
+ emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
|
|
|
7ac858 |
+ insnCodeGen::generateMemAccess(gen, insnCodeGen::Load, lr, lr, 0, 8, insnCodeGen::Offset);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ // indirect branch
|
|
|
7ac858 |
+ instruction branchInsn;
|
|
|
7ac858 |
+ branchInsn.clear();
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ //Set bits which are 0 for both BR and BLR
|
|
|
7ac858 |
+ INSN_SET(branchInsn, 0, 4, 0);
|
|
|
7ac858 |
+ INSN_SET(branchInsn, 10, 15, 0);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ //Set register
|
|
|
7ac858 |
+ INSN_SET(branchInsn, 5, 9, lr);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ //Set other bits. Basically, these are the opcode bits.
|
|
|
7ac858 |
+ //The only difference between BR and BLR is that bit 21 is 1 for BLR.
|
|
|
7ac858 |
+ INSN_SET(branchInsn, 16, 31, BRegOp);
|
|
|
7ac858 |
+ INSN_SET(branchInsn, 21, 21, 1);
|
|
|
7ac858 |
+ insnCodeGen::generate(gen, branchInsn);
|
|
|
7ac858 |
+ //insnCodeGen::generateBranch(gen, gen.currAddr(), lr, true);
|
|
|
7ac858 |
+ //insnCodeGen::generateBranch(gen, gen.currAddr(), gen.currAddr() +varOffset, true);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ return true;
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ //assert(0); //Not implemented
|
|
|
7ac858 |
+ //return emitPLTCommon(callee, true, gen);
|
|
|
7ac858 |
}
|
|
|
7ac858 |
@@ -1431,4 +1497,81 @@
|
|
|
7ac858 |
bool EmitterAARCH64Stat::emitPLTJump(func_instance *callee, codeGen &gen) {
|
|
|
7ac858 |
- assert(0); //Not implemented
|
|
|
7ac858 |
- return emitPLTCommon(callee, false, gen);
|
|
|
7ac858 |
+ /*
|
|
|
7ac858 |
+ Address dest = getInterModuleFuncAddr(callee, gen);
|
|
|
7ac858 |
+ //Register scr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ //Register lr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ Register scr = gen.rs()->getRegByName("r2");
|
|
|
7ac858 |
+ Register lr = gen.rs()->getRegByName("r3");
|
|
|
7ac858 |
+ //Address pc = emitMovePCToReg(scr, gen);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ Address varOffset = dest - gen.currAddr();
|
|
|
7ac858 |
+ //printf("VarOffset = %d\n", varOffset);
|
|
|
7ac858 |
+ emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
|
|
|
7ac858 |
+ insnCodeGen::generateMemAccess(gen, insnCodeGen::Load, lr, lr, 0, 8, insnCodeGen::Offset);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ insnCodeGen::generateBranch(gen, gen.currAddr(), lr, false);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ return true;
|
|
|
7ac858 |
+ */
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ /*
|
|
|
7ac858 |
+ Address dest = getInterModuleFuncAddr(callee, gen);
|
|
|
7ac858 |
+ Register scr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ Register lr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ Address pc = emitMovePCToReg(scr, gen);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ Address varOffset = dest - pc;
|
|
|
7ac858 |
+ printf("VarOffset = %d\n", varOffset);
|
|
|
7ac858 |
+ emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ insnCodeGen::generateBranch(gen, gen.currAddr(), lr, false);
|
|
|
7ac858 |
+ return true;
|
|
|
7ac858 |
+ */
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ /*
|
|
|
7ac858 |
+ Address dest = getInterModuleFuncAddr(callee, gen);
|
|
|
7ac858 |
+ Register scr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ Register lr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ Address varOffset = dest - gen.currAddr();
|
|
|
7ac858 |
+ emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
|
|
|
7ac858 |
+ insnCodeGen::generateBranch(gen, gen.currAddr(), gen.currAddr() +varOffset, false);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ return true;
|
|
|
7ac858 |
+ */
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ Address dest = getInterModuleFuncAddr(callee, gen);
|
|
|
7ac858 |
+ Register scr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ Register lr = gen.rs()->getScratchRegister(gen);
|
|
|
7ac858 |
+ //Register scr = gen.rs()->getRegByName("r2");
|
|
|
7ac858 |
+ //Register lr = gen.rs()->getRegByName("r3");
|
|
|
7ac858 |
+ emitMovePCToReg(scr, gen);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ Address varOffset = dest - gen.currAddr() + 4;
|
|
|
7ac858 |
+ //printf("VarOffset = %d\n", varOffset);
|
|
|
7ac858 |
+ emitLoadRelative(lr, varOffset, scr, gen.width(), gen);
|
|
|
7ac858 |
+ insnCodeGen::generateMemAccess(gen, insnCodeGen::Load, lr, lr, 0, 8, insnCodeGen::Offset);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ // indirect branch
|
|
|
7ac858 |
+ instruction branchInsn;
|
|
|
7ac858 |
+ branchInsn.clear();
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ //Set bits which are 0 for both BR and BLR
|
|
|
7ac858 |
+ INSN_SET(branchInsn, 0, 4, 0);
|
|
|
7ac858 |
+ INSN_SET(branchInsn, 10, 15, 0);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ //Set register
|
|
|
7ac858 |
+ INSN_SET(branchInsn, 5, 9, lr);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ //Set other bits. Basically, these are the opcode bits.
|
|
|
7ac858 |
+ //The only difference between BR and BLR is that bit 21 is 1 for BLR.
|
|
|
7ac858 |
+ INSN_SET(branchInsn, 16, 31, BRegOp);
|
|
|
7ac858 |
+ INSN_SET(branchInsn, 21, 21, 0);
|
|
|
7ac858 |
+ insnCodeGen::generate(gen, branchInsn);
|
|
|
7ac858 |
+ //insnCodeGen::generateBranch(gen, gen.currAddr(), lr, true);
|
|
|
7ac858 |
+ //insnCodeGen::generateBranch(gen, gen.currAddr(), gen.currAddr() +varOffset, true);
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ return true;
|
|
|
7ac858 |
+
|
|
|
7ac858 |
+ //assert(0); //Not implemented
|
|
|
7ac858 |
+ //return emitPLTCommon(callee, false, gen);
|
|
|
7ac858 |
}
|
|
|
7ac858 |
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/inst-aarch64.h.orig 2019-05-16 14:40:05.000000000 -0400
|
|
|
7ac858 |
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/inst-aarch64.h 2019-11-06 10:20:08.567523510 -0500
|
|
|
7ac858 |
@@ -74,3 +74,3 @@
|
|
|
7ac858 |
//TODO Fix for ARM
|
|
|
7ac858 |
-#define GPRSAVE_64 (31*GPRSIZE_64)
|
|
|
7ac858 |
+#define GPRSAVE_64 (32*GPRSIZE_64)
|
|
|
7ac858 |
#define FPRSAVE_64 (32*FPRSIZE_64)
|
|
|
7ac858 |
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/registerSpace.C.orig 2019-05-16 14:40:05.000000000 -0400
|
|
|
7ac858 |
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/registerSpace.C 2019-11-06 10:20:08.567523510 -0500
|
|
|
7ac858 |
@@ -110,2 +110,4 @@
|
|
|
7ac858 |
#elif defined(arch_aarch64)
|
|
|
7ac858 |
+ if(number == registerSpace::sp)
|
|
|
7ac858 |
+ return REG_SP;
|
|
|
7ac858 |
switch (type) {
|
|
|
7ac858 |
@@ -342,3 +344,3 @@
|
|
|
7ac858 |
|
|
|
7ac858 |
- reg->markUsed(true);
|
|
|
7ac858 |
+ //reg->markUsed(true);
|
|
|
7ac858 |
gen.markRegDefined(reg->number);
|
|
|
7ac858 |
|
|
|
7ac858 |
--- dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/dynProcess.C.orig
|
|
|
7ac858 |
+++ dyninst-10.1.0/dyninst-10.1.0/dyninstAPI/src/dynProcess.C
|
|
|
7ac858 |
@@ -3243,25 +3243,13 @@ bool PCProcess::continueSyncRPCThreads() {
|
|
|
7ac858 |
}
|
|
|
7ac858 |
|
|
|
7ac858 |
void PCProcess::addTrap(Address from, Address to, codeGen &gen) {
|
|
|
7ac858 |
- map<Address, Breakpoint::ptr>::iterator breakIter =
|
|
|
7ac858 |
- installedCtrlBrkpts.find(from);
|
|
|
7ac858 |
-
|
|
|
7ac858 |
- if( breakIter != installedCtrlBrkpts.end() ) {
|
|
|
7ac858 |
- if( !pcProc_->rmBreakpoint(from, breakIter->second) ) {
|
|
|
7ac858 |
- // Oops?
|
|
|
7ac858 |
- }
|
|
|
7ac858 |
- installedCtrlBrkpts.erase(breakIter);
|
|
|
7ac858 |
- }
|
|
|
7ac858 |
-
|
|
|
7ac858 |
- Breakpoint::ptr newBreak = Breakpoint::newTransferBreakpoint(to);
|
|
|
7ac858 |
- newBreak->setSuppressCallbacks(true);
|
|
|
7ac858 |
-
|
|
|
7ac858 |
- if( !pcProc_->addBreakpoint(from, newBreak) ) {
|
|
|
7ac858 |
- // Oops?
|
|
|
7ac858 |
- }
|
|
|
7ac858 |
-
|
|
|
7ac858 |
- installedCtrlBrkpts.insert(make_pair(from, newBreak));
|
|
|
7ac858 |
- gen.invalidate();
|
|
|
7ac858 |
+ gen.invalidate();
|
|
|
7ac858 |
+ gen.allocate(4);
|
|
|
7ac858 |
+ gen.setAddrSpace(this);
|
|
|
7ac858 |
+ gen.setAddr(from);
|
|
|
7ac858 |
+ insnCodeGen::generateTrap(gen);
|
|
|
7ac858 |
+ trapMapping.addTrapMapping(from, to, true);
|
|
|
7ac858 |
+ springboard_cerr << "Generated springboard trap " << hex << from << "->" << to << dec << endl;
|
|
|
7ac858 |
}
|
|
|
7ac858 |
|
|
|
7ac858 |
void PCProcess::removeTrap(Address from) {
|