Skip to content

Commit

Permalink
GT-3406 Merged emteere_MIPSMultiThreadFix into patch
Browse files Browse the repository at this point in the history
  • Loading branch information
ghidra1 committed Dec 18, 2019
2 parents c799be5 + 5c1dcc6 commit c4f31ba
Showing 1 changed file with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,12 @@ public Symbol setGPSymbol(Program program, Address toAddr) {
try {
String symname = "_gp_" + index++;
// check if it already exists
Symbol existingSymbol = SymbolUtilities.getLabelOrFunctionSymbol(program, symname,
err -> { /* ignore multiple symbols, if even one exists we need to skip if it has a different address */ } );
Symbol existingSymbol =
SymbolUtilities.getLabelOrFunctionSymbol(program, symname, err -> {
/* ignore multiple symbols, if even one exists we need to skip if it has a different address */ });
if (existingSymbol != null) {
if (existingSymbol.getAddress().equals(toAddr)) {
return existingSymbol;
return existingSymbol;
}
continue; // can't use this one, look for the next free gp_<x> symbol
}
Expand All @@ -223,14 +224,16 @@ public AddressSetView flowConstants(final Program program, Address flowStart,

final AddressSet coveredSet = new AddressSet();

Address currentGPAssumptionValue = gp_assumption_value;

if (func != null) {
flowStart = func.getEntryPoint();
if (gp_assumption_value != null) {
if (currentGPAssumptionValue != null) {
ProgramContext programContext = program.getProgramContext();
RegisterValue gpVal = programContext.getRegisterValue(gp, flowStart);
if (gpVal == null || !gpVal.hasValue()) {
gpVal =
new RegisterValue(gp, BigInteger.valueOf(gp_assumption_value.getOffset()));
gpVal = new RegisterValue(gp,
BigInteger.valueOf(currentGPAssumptionValue.getOffset()));
try {
program.getProgramContext().setRegisterValue(func.getEntryPoint(),
func.getEntryPoint(), gpVal);
Expand All @@ -245,6 +248,7 @@ public AddressSetView flowConstants(final Program program, Address flowStart,
// follow all flows building up context
// use context to fill out addresses on certain instructions
ContextEvaluator eval = new ConstantPropagationContextEvaluator(trustWriteMemOption) {
private Address localGPAssumptionValue = currentGPAssumptionValue;

private boolean mustStopNow = false; // if something discovered in processing, mustStop flag

Expand Down Expand Up @@ -297,8 +301,8 @@ public boolean evaluateContext(VarnodeContext context, Instruction instr) {
if (registerValue != null) {
BigInteger value = registerValue.getUnsignedValue();
long unsignedValue = value.longValue();
if (gp_assumption_value == null ||
!(unsignedValue == gp_assumption_value.getOffset())) {
if (localGPAssumptionValue == null ||
!(unsignedValue == localGPAssumptionValue.getOffset())) {
synchronized (gp) {
Address gpRefAddr =
instr.getMinAddress().getNewAddress(unsignedValue);
Expand All @@ -317,18 +321,18 @@ public boolean evaluateContext(VarnodeContext context, Instruction instr) {
instr.getMinAddress().getAddressSpace().getBaseSpaceID(),
unsignedValue, 1, RefType.DATA, PcodeOp.UNIMPLEMENTED, true,
monitor);
if (gp_assumption_value == null) {
if (localGPAssumptionValue == null) {
program.getBookmarkManager().setBookmark(
lastSetInstr.getMinAddress(), BookmarkType.WARNING,
"GP Global Register Set",
"Global GP Register is set here.");
}
if (gp_assumption_value != null &&
!gp_assumption_value.equals(gpRefAddr)) {
gp_assumption_value = null;
if (localGPAssumptionValue != null &&
!localGPAssumptionValue.equals(gpRefAddr)) {
localGPAssumptionValue = gp_assumption_value = null;
}
else {
gp_assumption_value = gpRefAddr;
localGPAssumptionValue = gp_assumption_value = gpRefAddr;
}
}
}
Expand Down Expand Up @@ -400,10 +404,11 @@ public boolean evaluateReference(VarnodeContext context, Instruction instr, int
// if it is assumed to be set to the same value, it can lead
// to incorrect re-use of the value (non-returning functions)
context.clearRegister(reg);

// need to add the reference here, register operand will no longer have a value
instr.addOperandReference(0, addr, refType, SourceType.ANALYSIS);

instr.addOperandReference(0, addr, refType,
SourceType.ANALYSIS);

// set the register value on the target address
ProgramContext progContext = program.getProgramContext();
if (progContext.getValue(reg, addr, false) == null) {
Expand Down

0 comments on commit c4f31ba

Please sign in to comment.