Program specific, user-defined, cspec extensions

Documentation for spec extensions

Handle extensions with parse errors
Export button for spec extensions
Pop-up dialog for parse errors in user-defined specification extensions
GP-653 corrected some minor issues and established new ProgramDB version
make incremental initialization constructor for AddressSized private
Make AddressSized fields private
More adjustments to AddressSized
Review fixes for BasicCompilerSpec
Take restoreXml out of DataOrganization interface
Remove restoreXml from BitFieldPacking interface
More review fixes
Prevent callotherfixup extension with non-existent target
Suggested export name
More documentation for SpecExtension
Support for undo/redo with spec extensions
Documentation for ConstructTpl
Split out ProgramCompilerSpec and other changes for review
Changes after next round of reviews
This commit is contained in:
caheckman 2021-02-02 13:07:54 -05:00 committed by ghidra1
parent 27fbe7278d
commit a5d4ca3cab
108 changed files with 7997 additions and 1997 deletions

View file

@ -101,8 +101,8 @@ public class CallFixupAnalyzer extends AbstractAnalyzer {
if (mustFix) {
PcodeInjectLibrary snippetLibrary =
program.getCompilerSpec().getPcodeInjectLibrary();
InjectPayload callFixup = snippetLibrary.getPayload(InjectPayload.CALLFIXUP_TYPE,
callFixupApplied, program, null);
InjectPayload callFixup =
snippetLibrary.getPayload(InjectPayload.CALLFIXUP_TYPE, callFixupApplied);
boolean isfallthru = true;
if (callFixup != null) {
isfallthru = callFixup.isFallThru();
@ -405,8 +405,8 @@ public class CallFixupAnalyzer extends AbstractAnalyzer {
}
}
program.getBookmarkManager().removeBookmarks(repairedCallLocations, BookmarkType.ERROR,
monitor);
program.getBookmarkManager()
.removeBookmarks(repairedCallLocations, BookmarkType.ERROR, monitor);
if (!clearInstSet.isEmpty()) {
// entries including data flow referenced from instructions will be repaired
@ -449,7 +449,7 @@ public class CallFixupAnalyzer extends AbstractAnalyzer {
String[] callFixupNames = snippetLibrary.getCallFixupNames();
for (String fixupName : callFixupNames) {
InjectPayload payload =
snippetLibrary.getPayload(InjectPayload.CALLFIXUP_TYPE, fixupName, program, null);
snippetLibrary.getPayload(InjectPayload.CALLFIXUP_TYPE, fixupName);
List<String> callFixupTargets = ((InjectPayloadCallfixup) payload).getTargets();
for (String name : callFixupTargets) {
cachedTargetFixupMap.put(name, fixupName);

View file

@ -359,6 +359,9 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
}
private JComponent createCallFixupComboPanel() {
JPanel panel = new JPanel();
callFixupComboBox = new GComboBox<>();
String[] callFixupNames = model.getCallFixupNames();
@ -377,7 +380,8 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
callFixupComboBox.setEnabled(false);
}
return callFixupComboBox;
panel.add(callFixupComboBox);
return panel;
}
private Component buildTable() {

View file

@ -405,8 +405,9 @@ public class SymbolicPropogator {
canceled = false;
// only stop flowing on unknown bad calls when the stack depth could be unknown
boolean callCouldCauseBadStackDepth =
program.getCompilerSpec().getDefaultCallingConvention().getExtrapop() == PrototypeModel.UNKNOWN_EXTRAPOP;
boolean callCouldCauseBadStackDepth = program.getCompilerSpec()
.getDefaultCallingConvention()
.getExtrapop() == PrototypeModel.UNKNOWN_EXTRAPOP;
while (!contextStack.isEmpty()) {
monitor.checkCanceled();
@ -834,8 +835,8 @@ public class SymbolicPropogator {
try {
val1 = vContext.getValue(in[0], evaluator);
lval1 = vContext.getConstant(val1, evaluator);
vt = vContext.getVarnode(
minInstrAddress.getAddressSpace().getSpaceID(), lval1, 0);
vt = vContext.getVarnode(minInstrAddress.getAddressSpace().getSpaceID(),
lval1, 0);
makeReference(vContext, instruction, ptype, -1, vt,
instruction.getFlowType(), monitor);
}
@ -873,8 +874,8 @@ public class SymbolicPropogator {
if (val1.isConstant()) {
// indirect target - assume single code space (same as instruction)
target = instruction.getAddress().getNewTruncatedAddress(
val1.getOffset(), true);
target = instruction.getAddress()
.getNewTruncatedAddress(val1.getOffset(), true);
}
else if (val1.isAddress()) {
// TODO: could this also occur if a memory location was copied ??
@ -957,8 +958,8 @@ public class SymbolicPropogator {
case PcodeOp.CALLOTHER:
// HACK ALERT!
// if this is a segment op, emulate the segmenting for now.
String opName = this.program.getLanguage().getUserDefinedOpName(
(int) in[0].getOffset());
String opName = this.program.getLanguage()
.getUserDefinedOpName((int) in[0].getOffset());
if (opName.equals("segment") && in.length > 2) {
checkSegmented(out, in[1], in[2], mustClearAll);
}
@ -1074,8 +1075,8 @@ public class SymbolicPropogator {
}
else if (!evaluator.followFalseConditionalBranches()) {
// pcode addresses are raw addresses, make sure address is in same instruction space
nextAddr = minInstrAddress.getAddressSpace().getOverlayAddress(
in[0].getAddress());
nextAddr = minInstrAddress.getAddressSpace()
.getOverlayAddress(in[0].getAddress());
pcodeIndex = ops.length; // break out of the processing
}
}
@ -1202,8 +1203,8 @@ public class SymbolicPropogator {
case PcodeOp.INT_RIGHT:
val1 = vContext.getValue(in[0], false, evaluator);
val2 = vContext.getValue(in[1], false, evaluator);
lresult = vContext.getConstant(val1,
evaluator) >> vContext.getConstant(val2, evaluator);
lresult = vContext.getConstant(val1, evaluator) >> vContext
.getConstant(val2, evaluator);
result = vContext.createConstantVarnode(lresult, val1.getSize());
vContext.putValue(out, result, mustClearAll);
break;
@ -1211,8 +1212,8 @@ public class SymbolicPropogator {
case PcodeOp.INT_SRIGHT:
val1 = vContext.getValue(in[0], true, evaluator);
val2 = vContext.getValue(in[1], false, evaluator);
lresult = vContext.getConstant(val1,
evaluator) >>> vContext.getConstant(val2, evaluator);
lresult = vContext.getConstant(val1, evaluator) >>> vContext
.getConstant(val2, evaluator);
result = vContext.createConstantVarnode(lresult, val1.getSize());
vContext.putValue(out, result, mustClearAll);
break;
@ -1315,8 +1316,8 @@ public class SymbolicPropogator {
val2 = vContext.getValue(in[1], true, evaluator);
lval1 = vContext.getConstant(val1, evaluator);
lval2 = vContext.getConstant(val2, evaluator);
lresult = (vContext.getConstant(val1,
evaluator) < vContext.getConstant(val2, evaluator)) ? 1 : 0;
lresult = (vContext.getConstant(val1, evaluator) < vContext
.getConstant(val2, evaluator)) ? 1 : 0;
result = vContext.createConstantVarnode(lresult, val1.getSize());
vContext.putValue(out, result, mustClearAll);
break;
@ -1334,8 +1335,8 @@ public class SymbolicPropogator {
case PcodeOp.INT_SLESSEQUAL:
val1 = vContext.getValue(in[0], true, evaluator);
val2 = vContext.getValue(in[1], true, evaluator);
lresult = (vContext.getConstant(val1,
evaluator) <= vContext.getConstant(val2, evaluator)) ? 1 : 0;
lresult = (vContext.getConstant(val1, evaluator) <= vContext
.getConstant(val2, evaluator)) ? 1 : 0;
result = vContext.createConstantVarnode(lresult, val1.getSize());
vContext.putValue(out, result, mustClearAll);
break;
@ -1344,8 +1345,8 @@ public class SymbolicPropogator {
val1 = vContext.getValue(in[0], false, evaluator);
val2 = vContext.getValue(in[1], false, evaluator);
lresult = (vContext.getConstant(val1,
evaluator) == vContext.getConstant(val2, evaluator)) ? 1 : 0;
lresult = (vContext.getConstant(val1, evaluator) == vContext
.getConstant(val2, evaluator)) ? 1 : 0;
result = vContext.createConstantVarnode(lresult, val1.getSize());
vContext.putValue(out, result, mustClearAll);
break;
@ -1353,8 +1354,8 @@ public class SymbolicPropogator {
case PcodeOp.INT_NOTEQUAL:
val1 = vContext.getValue(in[0], false, evaluator);
val2 = vContext.getValue(in[1], false, evaluator);
lresult = (vContext.getConstant(val1,
evaluator) != vContext.getConstant(val2, evaluator)) ? 1 : 0;
lresult = (vContext.getConstant(val1, evaluator) != vContext
.getConstant(val2, evaluator)) ? 1 : 0;
result = vContext.createConstantVarnode(lresult, val1.getSize());
vContext.putValue(out, result, mustClearAll);
break;
@ -1571,7 +1572,7 @@ public class SymbolicPropogator {
PcodeInjectLibrary snippetLibrary = prog.getCompilerSpec().getPcodeInjectLibrary();
InjectPayload payload =
snippetLibrary.getPayload(InjectPayload.CALLFIXUP_TYPE, callFixupName, prog, null);
snippetLibrary.getPayload(InjectPayload.CALLFIXUP_TYPE, callFixupName);
if (payload == null) {
return null;
}
@ -1598,7 +1599,7 @@ public class SymbolicPropogator {
PcodeInjectLibrary snippetLibrary = prog.getCompilerSpec().getPcodeInjectLibrary();
InjectPayload payload =
snippetLibrary.getPayload(InjectPayload.CALLMECHANISM_TYPE, injectionName, prog, null);
snippetLibrary.getPayload(InjectPayload.CALLMECHANISM_TYPE, injectionName);
if (payload == null) {
return null;
}
@ -1843,14 +1844,14 @@ public class SymbolicPropogator {
// } else
if (!vContext.isStackSymbolicSpace(refLocation) && evaluator != null) {
Address constant = program.getAddressFactory().getAddress(
(int) targetSpaceID.getOffset(), offset);
Address constant = program.getAddressFactory()
.getAddress((int) targetSpaceID.getOffset(), offset);
Address newTarget = evaluator.evaluateConstant(vContext, instruction,
pcodeType, constant, 0, reftype);
if (newTarget != null) {
makeReference(vContext, instruction, Reference.MNEMONIC,
newTarget.getAddressSpace().getSpaceID(), newTarget.getOffset(),
0, reftype, pcodeType, false, monitor);
newTarget.getAddressSpace().getSpaceID(), newTarget.getOffset(), 0,
reftype, pcodeType, false, monitor);
return;
}
}