From 05f292a5e715f2400acdc1ca62fe8450ee78623c Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Tue, 27 Jul 2021 14:31:12 -0400 Subject: [PATCH] Let segmentop scripts follow natural parameter order --- .../Features/Decompiler/src/decompile/cpp/architecture.cc | 4 ++-- Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc | 6 +++--- Ghidra/Features/Decompiler/src/decompile/cpp/emulateutil.cc | 2 +- .../Features/Decompiler/src/decompile/cpp/ghidra_process.cc | 2 +- Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc | 2 +- Ghidra/Features/Decompiler/src/decompile/cpp/userop.cc | 6 +++--- Ghidra/Processors/HCS12/data/languages/HCS12.pspec | 2 +- Ghidra/Processors/Z80/data/languages/z80.cspec | 2 +- Ghidra/Processors/x86/data/languages/x86-16-real.pspec | 2 +- Ghidra/Processors/x86/data/languages/x86-16.pspec | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc index 56dd7f979f..54b3b01d5a 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc @@ -1363,8 +1363,8 @@ Address SegmentedResolver::resolve(uintb val,int4 sz,const Address &point,uintb uintb base = glb->context->getTrackedValue(segop->getResolve(),point); fullEncoding = (base << 8 * innersz) + (val & calc_mask(innersz)); vector seginput; - seginput.push_back(val); seginput.push_back(base); + seginput.push_back(val); val = segop->execute(seginput); return Address(spc,AddrSpace::addressToByte(val,spc->getWordSize())); } @@ -1375,8 +1375,8 @@ Address SegmentedResolver::resolve(uintb val,int4 sz,const Address &point,uintb uintb base = (val >> 8*innersz) & calc_mask(outersz); val = val & calc_mask(innersz); vector seginput; - seginput.push_back(val); seginput.push_back(base); + seginput.push_back(val); val = segop->execute(seginput); return Address(spc,AddrSpace::addressToByte(val,spc->getWordSize())); } diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc index 4d7277572c..71555482a7 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc @@ -644,12 +644,12 @@ int4 ActionSegmentize::apply(Funcdata &data) } if (segdef->getNumVariableTerms()==1) - bindlist[1] = data.newConstant(4,0); + bindlist[0] = data.newConstant(4,0); // Redefine the op as a segmentop data.opSetOpcode(segroot,CPUI_SEGMENTOP); data.opSetInput(segroot,data.newVarnodeSpace(spc),0); - data.opSetInput(segroot,bindlist[1],1); - data.opSetInput(segroot,bindlist[0],2); + data.opSetInput(segroot,bindlist[0],1); + data.opSetInput(segroot,bindlist[1],2); for(int4 j=segroot->numInput()-1;j>2;--j) // Remove anything else data.opRemoveInput(segroot,j); count += 1; diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/emulateutil.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/emulateutil.cc index 97bb840876..ea9c31c5d8 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/emulateutil.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/emulateutil.cc @@ -127,8 +127,8 @@ void EmulatePcodeOp::executeSegmentOp(void) uintb in1 = getVarnodeValue(currentOp->getIn(1)); uintb in2 = getVarnodeValue(currentOp->getIn(2)); vector bindlist; - bindlist.push_back(in2); bindlist.push_back(in1); + bindlist.push_back(in2); uintb res = segdef->execute(bindlist); setVarnodeValue(currentOp->getOut(), res); } diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.cc index 46efe6eb0f..272e4c1566 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.cc @@ -36,7 +36,7 @@ void connect_to_console(Funcdata *fd) if (remote == (RemoteSocket *)0) { remote = new RemoteSocket(); if (remote->open("/tmp/ghidrasocket")) { - ghidra_dcp = new IfaceStatus("[ghidradbg]> ",*remote->getInputStream(),*remote->getOutputStream()); + ghidra_dcp = new IfaceTerm("[ghidradbg]> ",*remote->getInputStream(),*remote->getOutputStream()); IfaceCapability::registerAllCommands(ghidra_dcp); } } diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc index a9c28db6c2..ecbebec273 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc @@ -7459,8 +7459,8 @@ int4 RuleSegment::applyOp(PcodeOp *op,Funcdata &data) if (vn1->isConstant() && vn2->isConstant()) { vector bindlist; - bindlist.push_back(vn2->getOffset()); bindlist.push_back(vn1->getOffset()); + bindlist.push_back(vn2->getOffset()); uintb val = segdef->execute(bindlist); data.opRemoveInput(op,2); data.opRemoveInput(op,1); diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/userop.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/userop.cc index 0d13d3a7b6..082c2f2825 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/userop.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/userop.cc @@ -143,13 +143,13 @@ bool SegmentOp::unify(Funcdata &data,PcodeOp *op, innervn = op->getIn(2); if (basevn->isConstant()) basevn = data.newConstant(baseinsize,basevn->getOffset()); - bindlist[1] = basevn; + bindlist[0] = basevn; } else - bindlist[1] = (Varnode *)0; + bindlist[0] = (Varnode *)0; if (innervn->isConstant()) innervn = data.newConstant(innerinsize,innervn->getOffset()); - bindlist[0] = innervn; + bindlist[1] = innervn; return true; } diff --git a/Ghidra/Processors/HCS12/data/languages/HCS12.pspec b/Ghidra/Processors/HCS12/data/languages/HCS12.pspec index 90fb9f51c1..830e243b49 100644 --- a/Ghidra/Processors/HCS12/data/languages/HCS12.pspec +++ b/Ghidra/Processors/HCS12/data/languages/HCS12.pspec @@ -8,8 +8,8 @@ - + - + - + - +