mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch 'origin/caheckman_BaseSpaceID'
This commit is contained in:
commit
9af174f9fe
28 changed files with 172 additions and 126 deletions
|
@ -544,7 +544,7 @@ public class FlowArrowPlugin extends Plugin implements MarginProvider, OptionsCh
|
||||||
if (bottomAddr != null) {
|
if (bottomAddr != null) {
|
||||||
AddressSpace testSpace = bottomAddr.getAddressSpace();
|
AddressSpace testSpace = bottomAddr.getAddressSpace();
|
||||||
validState = (program.getAddressFactory().getAddressSpace(
|
validState = (program.getAddressFactory().getAddressSpace(
|
||||||
testSpace.getUniqueSpaceID()) == testSpace);
|
testSpace.getSpaceID()) == testSpace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ public abstract class AbstractScalarOperandHover extends AbstractConfigurableHov
|
||||||
AddressSpace space = factory.getDefaultAddressSpace();
|
AddressSpace space = factory.getDefaultAddressSpace();
|
||||||
Address asAddress;
|
Address asAddress;
|
||||||
try {
|
try {
|
||||||
asAddress = factory.getAddress(space.getBaseSpaceID(), scalarLong);
|
asAddress = factory.getAddress(space.getSpaceID(), scalarLong);
|
||||||
}
|
}
|
||||||
catch (AddressOutOfBoundsException ex) {
|
catch (AddressOutOfBoundsException ex) {
|
||||||
asAddress = null; // Constant doesn't make sense as an address
|
asAddress = null; // Constant doesn't make sense as an address
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/* ###
|
/* ###
|
||||||
* IP: GHIDRA
|
* IP: GHIDRA
|
||||||
* REVIEWED: YES
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -306,7 +305,7 @@ abstract class AbstractDwarfEHDecoder implements DwarfEHDecoder {
|
||||||
|
|
||||||
long offset = decode(context);
|
long offset = decode(context);
|
||||||
|
|
||||||
return addrFactory.getAddress(ram.getBaseSpaceID(), offset);
|
return addrFactory.getAddress(ram.getSpaceID(), offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -370,7 +369,7 @@ abstract class AbstractDwarfEHDecoder implements DwarfEHDecoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isIndirect) {
|
if (isIndirect) {
|
||||||
Address toDeref = prog.getAddressFactory().getAddress(ram.getBaseSpaceID(), val);
|
Address toDeref = prog.getAddressFactory().getAddress(ram.getSpaceID(), val);
|
||||||
val = ptrval(prog, toDeref);
|
val = ptrval(prog, toDeref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class LSDAHeader extends GccAnalysisClass {
|
||||||
AddressFactory addrFactory = program.getAddressFactory();
|
AddressFactory addrFactory = program.getAddressFactory();
|
||||||
AddressSpace ram = addrFactory.getDefaultAddressSpace();
|
AddressSpace ram = addrFactory.getDefaultAddressSpace();
|
||||||
|
|
||||||
return addrFactory.getAddress(ram.getBaseSpaceID(), offset);
|
return addrFactory.getAddress(ram.getSpaceID(), offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Address createLPStartPointer(Address addr) throws MemoryAccessException {
|
private Address createLPStartPointer(Address addr) throws MemoryAccessException {
|
||||||
|
|
|
@ -602,7 +602,7 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
|
||||||
Address address = loc.getAddress();
|
Address address = loc.getAddress();
|
||||||
AddressSpace locAddressSpace = address.getAddressSpace();
|
AddressSpace locAddressSpace = address.getAddressSpace();
|
||||||
AddressSpace programAddressSpace =
|
AddressSpace programAddressSpace =
|
||||||
program.getAddressFactory().getAddressSpace(locAddressSpace.getUniqueSpaceID());
|
program.getAddressFactory().getAddressSpace(locAddressSpace.getSpaceID());
|
||||||
if (programAddressSpace != locAddressSpace) {
|
if (programAddressSpace != locAddressSpace) {
|
||||||
FieldLocation compatibleLocation =
|
FieldLocation compatibleLocation =
|
||||||
getFieldLocationForDifferingAddressSpaces(loc, program);
|
getFieldLocationForDifferingAddressSpaces(loc, program);
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class AddressIndexMapConverter extends AddressIndexMap {
|
||||||
private Address getMapAddress(Address addr) {
|
private Address getMapAddress(Address addr) {
|
||||||
AddressSpace locAddressSpace = addr.getAddressSpace();
|
AddressSpace locAddressSpace = addr.getAddressSpace();
|
||||||
AddressSpace programAddressSpace =
|
AddressSpace programAddressSpace =
|
||||||
mapProgram.getAddressFactory().getAddressSpace(locAddressSpace.getUniqueSpaceID());
|
mapProgram.getAddressFactory().getAddressSpace(locAddressSpace.getSpaceID());
|
||||||
Address mapAddress = (programAddressSpace == locAddressSpace) ? addr
|
Address mapAddress = (programAddressSpace == locAddressSpace) ? addr
|
||||||
: SimpleDiffUtility.getCompatibleAddress(otherProgram, addr, mapProgram);
|
: SimpleDiffUtility.getCompatibleAddress(otherProgram, addr, mapProgram);
|
||||||
return mapAddress;
|
return mapAddress;
|
||||||
|
|
|
@ -212,7 +212,7 @@ public class SymbolicPropogator {
|
||||||
ProgramContext newSpaceContext = new ProgramContextImpl(programContext.getRegisters());
|
ProgramContext newSpaceContext = new ProgramContextImpl(programContext.getRegisters());
|
||||||
VarnodeContext newContext = new VarnodeContext(program, newValueContext, newSpaceContext);
|
VarnodeContext newContext = new VarnodeContext(program, newValueContext, newSpaceContext);
|
||||||
newContext.setDebug(debug);
|
newContext.setDebug(debug);
|
||||||
int constantSpaceID = program.getAddressFactory().getConstantSpace().getBaseSpaceID();
|
int constantSpaceID = program.getAddressFactory().getConstantSpace().getSpaceID();
|
||||||
// copy any current registers with values into the context
|
// copy any current registers with values into the context
|
||||||
Register[] regWithVals = programContext.getRegistersWithValues();
|
Register[] regWithVals = programContext.getRegistersWithValues();
|
||||||
for (Register regWithVal : regWithVals) {
|
for (Register regWithVal : regWithVals) {
|
||||||
|
@ -834,7 +834,7 @@ public class SymbolicPropogator {
|
||||||
val1 = vContext.getValue(in[0], evaluator);
|
val1 = vContext.getValue(in[0], evaluator);
|
||||||
lval1 = vContext.getConstant(val1, evaluator);
|
lval1 = vContext.getConstant(val1, evaluator);
|
||||||
vt = vContext.getVarnode(
|
vt = vContext.getVarnode(
|
||||||
minInstrAddress.getAddressSpace().getBaseSpaceID(), lval1, 0);
|
minInstrAddress.getAddressSpace().getSpaceID(), lval1, 0);
|
||||||
makeReference(vContext, instruction, ptype, -1, vt,
|
makeReference(vContext, instruction, ptype, -1, vt,
|
||||||
instruction.getFlowType(), monitor);
|
instruction.getFlowType(), monitor);
|
||||||
}
|
}
|
||||||
|
@ -889,7 +889,7 @@ public class SymbolicPropogator {
|
||||||
!refs[0].getToAddress().equals(target)) {
|
!refs[0].getToAddress().equals(target)) {
|
||||||
makeReference(vContext, instruction, Reference.MNEMONIC,
|
makeReference(vContext, instruction, Reference.MNEMONIC,
|
||||||
// Use target in case location has shifted (external...)
|
// Use target in case location has shifted (external...)
|
||||||
target.getAddressSpace().getBaseSpaceID(),
|
target.getAddressSpace().getSpaceID(),
|
||||||
target.getAddressableWordOffset(), val1.getSize(),
|
target.getAddressableWordOffset(), val1.getSize(),
|
||||||
instruction.getFlowType(), ptype, true, monitor);
|
instruction.getFlowType(), ptype, true, monitor);
|
||||||
}
|
}
|
||||||
|
@ -1848,7 +1848,7 @@ public class SymbolicPropogator {
|
||||||
pcodeType, constant, 0, reftype);
|
pcodeType, constant, 0, reftype);
|
||||||
if (newTarget != null) {
|
if (newTarget != null) {
|
||||||
makeReference(vContext, instruction, Reference.MNEMONIC,
|
makeReference(vContext, instruction, Reference.MNEMONIC,
|
||||||
newTarget.getAddressSpace().getBaseSpaceID(), newTarget.getOffset(),
|
newTarget.getAddressSpace().getSpaceID(), newTarget.getOffset(),
|
||||||
0, reftype, pcodeType, false, monitor);
|
0, reftype, pcodeType, false, monitor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2050,7 +2050,7 @@ public class SymbolicPropogator {
|
||||||
|
|
||||||
// if only one memory space, no overlays, just return default space
|
// if only one memory space, no overlays, just return default space
|
||||||
if (memorySpaces.size() == 1) {
|
if (memorySpaces.size() == 1) {
|
||||||
return defaultSpace.getUniqueSpaceID();
|
return defaultSpace.getSpaceID();
|
||||||
}
|
}
|
||||||
|
|
||||||
int realMemSpaceCnt = 0; // count of real memory spaces that could contain the target
|
int realMemSpaceCnt = 0; // count of real memory spaces that could contain the target
|
||||||
|
@ -2069,7 +2069,7 @@ public class SymbolicPropogator {
|
||||||
|
|
||||||
// if this instruction is in an overlay space overlaying the default space, change the default space
|
// if this instruction is in an overlay space overlaying the default space, change the default space
|
||||||
if (instrSpace.isOverlaySpace() &&
|
if (instrSpace.isOverlaySpace() &&
|
||||||
instrSpace.getBaseSpaceID() == defaultSpace.getUniqueSpaceID()) {
|
((OverlayAddressSpace) instrSpace).getBaseSpaceID() == defaultSpace.getSpaceID()) {
|
||||||
defaultSpace = instrSpace;
|
defaultSpace = instrSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2109,17 +2109,17 @@ public class SymbolicPropogator {
|
||||||
|
|
||||||
// if only one memory space held a valid value, use it
|
// if only one memory space held a valid value, use it
|
||||||
if (containingMemSpaceCnt == 1 && containingAddr != null) {
|
if (containingMemSpaceCnt == 1 && containingAddr != null) {
|
||||||
return containingAddr.getAddressSpace().getUniqueSpaceID();
|
return containingAddr.getAddressSpace().getSpaceID();
|
||||||
}
|
}
|
||||||
if (symbolTargetCnt == 1 && symbolTarget != null) {
|
if (symbolTargetCnt == 1 && symbolTarget != null) {
|
||||||
return symbolTarget.getAddressSpace().getUniqueSpaceID();
|
return symbolTarget.getAddressSpace().getSpaceID();
|
||||||
}
|
}
|
||||||
|
|
||||||
// nothing to lead to one space or the other, and code/data spaces are not the same
|
// nothing to lead to one space or the other, and code/data spaces are not the same
|
||||||
if (realMemSpaceCnt != 1 && !defaultSpacesAreTheSame) {
|
if (realMemSpaceCnt != 1 && !defaultSpacesAreTheSame) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return defaultSpace.getUniqueSpaceID();
|
return defaultSpace.getSpaceID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -989,7 +989,7 @@ public class VarnodeContext implements ProcessorContext {
|
||||||
}
|
}
|
||||||
BigInteger spaceVal = getTranslatedSpaceValue(reg, fromAddr, toAddr);
|
BigInteger spaceVal = getTranslatedSpaceValue(reg, fromAddr, toAddr);
|
||||||
if (spaceVal != null) {
|
if (spaceVal != null) {
|
||||||
if (addrFactory.getConstantSpace().getBaseSpaceID() != spaceVal.intValue()) {
|
if (addrFactory.getConstantSpace().getSpaceID() != spaceVal.intValue()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1224,7 +1224,7 @@ public class VarnodeContext implements ProcessorContext {
|
||||||
if (regSpace == null) {
|
if (regSpace == null) {
|
||||||
regSpace = ((OffsetAddressFactory) addrFactory).createNewOffsetSpace(name);
|
regSpace = ((OffsetAddressFactory) addrFactory).createNewOffsetSpace(name);
|
||||||
}
|
}
|
||||||
spaceID = regSpace.getBaseSpaceID();
|
spaceID = regSpace.getSpaceID();
|
||||||
return spaceID;
|
return spaceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1242,7 +1242,7 @@ public class VarnodeContext implements ProcessorContext {
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
// degenerate case, don't need to know the value
|
// degenerate case, don't need to know the value
|
||||||
if (val1.equals(val2)) {
|
if (val1.equals(val2)) {
|
||||||
return createVarnode(0, addrFactory.getConstantSpace().getBaseSpaceID(),
|
return createVarnode(0, addrFactory.getConstantSpace().getSpaceID(),
|
||||||
val1.getSize());
|
val1.getSize());
|
||||||
}
|
}
|
||||||
int spaceID = val1.getSpace();
|
int spaceID = val1.getSpace();
|
||||||
|
@ -1430,7 +1430,7 @@ public class VarnodeContext implements ProcessorContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSymbolicSpace(AddressSpace space) {
|
public boolean isSymbolicSpace(AddressSpace space) {
|
||||||
int spaceID = space.getUniqueSpaceID();
|
int spaceID = space.getSpaceID();
|
||||||
return OffsetAddressFactory.isSymbolSpace(spaceID);
|
return OffsetAddressFactory.isSymbolSpace(spaceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/* ###
|
/* ###
|
||||||
* IP: GHIDRA
|
* IP: GHIDRA
|
||||||
* REVIEWED: YES
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -204,7 +203,7 @@ public class TableEntry extends Switch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
AddressFactory addrFactory = program.getAddressFactory();
|
AddressFactory addrFactory = program.getAddressFactory();
|
||||||
if (addrFactory.getDefaultAddressSpace().getUniqueSpaceID() != inputValues[0].getOffset()) {
|
if (addrFactory.getDefaultAddressSpace().getSpaceID() != inputValues[0].getOffset()) {
|
||||||
// TableEntryAddress class assumes default address space for tables
|
// TableEntryAddress class assumes default address space for tables
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,11 +174,11 @@ public class OverlayAddressSpaceTest extends AbstractGhidraHeadedIntegrationTest
|
||||||
AddressSpace nonOverlaySpace = space3Address.getAddressSpace();
|
AddressSpace nonOverlaySpace = space3Address.getAddressSpace();
|
||||||
Assert.assertNotEquals(overlaySpace, nonOverlaySpace);
|
Assert.assertNotEquals(overlaySpace, nonOverlaySpace);
|
||||||
|
|
||||||
int overlayBaseID = overlaySpace.getBaseSpaceID();
|
int overlayBaseID = ((OverlayAddressSpace) overlaySpace).getBaseSpaceID();
|
||||||
int spaceBaseID = space1.getBaseSpaceID();
|
int spaceBaseID = space1.getSpaceID();
|
||||||
assertEquals(overlayBaseID, spaceBaseID);
|
assertEquals(overlayBaseID, spaceBaseID);
|
||||||
|
|
||||||
int nonBaseID = nonOverlaySpace.getBaseSpaceID();
|
int nonBaseID = nonOverlaySpace.getSpaceID();
|
||||||
Assert.assertNotEquals(overlayBaseID, nonBaseID);
|
Assert.assertNotEquals(overlayBaseID, nonBaseID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.util.state;
|
package ghidra.util.state;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
@ -281,30 +280,30 @@ public class ContextStateTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
new Varnode[] { regEAX, new Varnode(addrFactory.getConstantAddress(16), 4) }, regEBX);
|
new Varnode[] { regEAX, new Varnode(addrFactory.getConstantAddress(16), 4) }, regEBX);
|
||||||
VarnodeOperation addEAX16op = new VarnodeOperation(addEAX16, addEAX16.getInputs());
|
VarnodeOperation addEAX16op = new VarnodeOperation(addEAX16, addEAX16.getInputs());
|
||||||
|
|
||||||
state1.store(addrFactory.getDefaultAddressSpace().getUniqueSpaceID(), addEAX16op,
|
state1.store(addrFactory.getDefaultAddressSpace().getSpaceID(), addEAX16op,
|
||||||
new Varnode(addrFactory.getConstantAddress(0x12345678), 4), 4);
|
new Varnode(addrFactory.getConstantAddress(0x12345678), 4), 4);
|
||||||
|
|
||||||
assertEquals(new Varnode(addrFactory.getConstantAddress(0x12345678), 4),
|
assertEquals(new Varnode(addrFactory.getConstantAddress(0x12345678), 4),
|
||||||
state1.get(addrFactory.getDefaultAddressSpace().getUniqueSpaceID(), addEAX16op, 4));
|
state1.get(addrFactory.getDefaultAddressSpace().getSpaceID(), addEAX16op, 4));
|
||||||
|
|
||||||
assertEquals(new Varnode(addrFactory.getConstantAddress(0x345678), 3),
|
assertEquals(new Varnode(addrFactory.getConstantAddress(0x345678), 3),
|
||||||
state1.get(addrFactory.getDefaultAddressSpace().getUniqueSpaceID(), addEAX16op, 3));
|
state1.get(addrFactory.getDefaultAddressSpace().getSpaceID(), addEAX16op, 3));
|
||||||
|
|
||||||
assertEquals(new Varnode(addrFactory.getConstantAddress(0x5678), 2),
|
assertEquals(new Varnode(addrFactory.getConstantAddress(0x5678), 2),
|
||||||
state1.get(addrFactory.getDefaultAddressSpace().getUniqueSpaceID(), addEAX16op, 2));
|
state1.get(addrFactory.getDefaultAddressSpace().getSpaceID(), addEAX16op, 2));
|
||||||
|
|
||||||
assertEquals(new Varnode(addrFactory.getConstantAddress(0x78), 1),
|
assertEquals(new Varnode(addrFactory.getConstantAddress(0x78), 1),
|
||||||
state1.get(addrFactory.getDefaultAddressSpace().getUniqueSpaceID(), addEAX16op, 1));
|
state1.get(addrFactory.getDefaultAddressSpace().getSpaceID(), addEAX16op, 1));
|
||||||
|
|
||||||
PcodeOp addEAX18 = new PcodeOp(addr(1000), 0, PcodeOp.INT_ADD,
|
PcodeOp addEAX18 = new PcodeOp(addr(1000), 0, PcodeOp.INT_ADD,
|
||||||
new Varnode[] { regEAX, new Varnode(addrFactory.getConstantAddress(18), 4) }, regEBX);
|
new Varnode[] { regEAX, new Varnode(addrFactory.getConstantAddress(18), 4) }, regEBX);
|
||||||
VarnodeOperation addEAX18op = new VarnodeOperation(addEAX18, addEAX18.getInputs());
|
VarnodeOperation addEAX18op = new VarnodeOperation(addEAX18, addEAX18.getInputs());
|
||||||
|
|
||||||
assertEquals(new Varnode(addrFactory.getConstantAddress(0x1234), 2),
|
assertEquals(new Varnode(addrFactory.getConstantAddress(0x1234), 2),
|
||||||
state1.get(addrFactory.getDefaultAddressSpace().getUniqueSpaceID(), addEAX18op, 2));
|
state1.get(addrFactory.getDefaultAddressSpace().getSpaceID(), addEAX18op, 2));
|
||||||
|
|
||||||
assertEquals(new Varnode(addrFactory.getConstantAddress(0x34), 1),
|
assertEquals(new Varnode(addrFactory.getConstantAddress(0x34), 1),
|
||||||
state1.get(addrFactory.getDefaultAddressSpace().getUniqueSpaceID(), addEAX18op, 1));
|
state1.get(addrFactory.getDefaultAddressSpace().getSpaceID(), addEAX18op, 1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
//
|
//
|
||||||
//@category Search
|
//@category Search
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import generic.jar.ResourceFile;
|
import generic.jar.ResourceFile;
|
||||||
import ghidra.app.decompiler.*;
|
import ghidra.app.decompiler.*;
|
||||||
import ghidra.app.decompiler.component.DecompilerUtils;
|
import ghidra.app.decompiler.component.DecompilerUtils;
|
||||||
|
@ -43,8 +45,6 @@ import ghidra.util.UndefinedFunction;
|
||||||
import ghidra.util.exception.CancelledException;
|
import ghidra.util.exception.CancelledException;
|
||||||
import ghidra.util.exception.InvalidInputException;
|
import ghidra.util.exception.InvalidInputException;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class ShowConstantUse extends GhidraScript {
|
public class ShowConstantUse extends GhidraScript {
|
||||||
private DecompInterface decomplib;
|
private DecompInterface decomplib;
|
||||||
DecompileResults lastResults = null;
|
DecompileResults lastResults = null;
|
||||||
|
@ -143,9 +143,9 @@ public class ShowConstantUse extends GhidraScript {
|
||||||
if (f == null) {
|
if (f == null) {
|
||||||
Reference[] referencesFrom =
|
Reference[] referencesFrom =
|
||||||
currentProgram.getReferenceManager().getReferencesFrom(faddr);
|
currentProgram.getReferenceManager().getReferencesFrom(faddr);
|
||||||
for (int i = 0; i < referencesFrom.length; i++) {
|
for (Reference element : referencesFrom) {
|
||||||
if (referencesFrom[i].isExternalReference()) {
|
if (element.isExternalReference()) {
|
||||||
faddr = referencesFrom[i].getToAddress();
|
faddr = element.getToAddress();
|
||||||
f = currentProgram.getFunctionManager().getFunctionAt(faddr);
|
f = currentProgram.getFunctionManager().getFunctionAt(faddr);
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
break;
|
break;
|
||||||
|
@ -437,8 +437,7 @@ public class ShowConstantUse extends GhidraScript {
|
||||||
keys = constLocs.keySet();
|
keys = constLocs.keySet();
|
||||||
Address[] keyArray = keys.toArray(new Address[0]);
|
Address[] keyArray = keys.toArray(new Address[0]);
|
||||||
Arrays.sort(keyArray);
|
Arrays.sort(keyArray);
|
||||||
for (int i = 0; i < keyArray.length; i++) {
|
for (Address loc : keyArray) {
|
||||||
Address loc = keyArray[i];
|
|
||||||
Long constant = constLocs.get(loc);
|
Long constant = constLocs.get(loc);
|
||||||
tableChooserDialog.add(new ConstUseLocation(currentProgram, loc, constant, null));
|
tableChooserDialog.add(new ConstUseLocation(currentProgram, loc, constant, null));
|
||||||
}
|
}
|
||||||
|
@ -872,7 +871,7 @@ public class ShowConstantUse extends GhidraScript {
|
||||||
if (def.getInput(0).isConstant() && def.getInput(1).isConstant()) {
|
if (def.getInput(0).isConstant() && def.getInput(1).isConstant()) {
|
||||||
long space = def.getInput(0).getOffset();
|
long space = def.getInput(0).getOffset();
|
||||||
long offset = def.getInput(1).getOffset();
|
long offset = def.getInput(1).getOffset();
|
||||||
if (space != funcEntry.getAddressSpace().getBaseSpaceID()) {
|
if (space != funcEntry.getAddressSpace().getSpaceID()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class FunctionSignatureDecompilerHover extends AbstractConfigurableHover
|
||||||
AddressFactory factory = program.getAddressFactory();
|
AddressFactory factory = program.getAddressFactory();
|
||||||
AddressSpace space = factory.getDefaultAddressSpace();
|
AddressSpace space = factory.getDefaultAddressSpace();
|
||||||
try {
|
try {
|
||||||
Address asAddress = factory.getAddress(space.getBaseSpaceID(), scalarLong);
|
Address asAddress = factory.getAddress(space.getSpaceID(), scalarLong);
|
||||||
Function function = program.getListing().getFunctionAt(asAddress);
|
Function function = program.getListing().getFunctionAt(asAddress);
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
String content = ToolTipUtils.getToolTipText(function, false);
|
String content = ToolTipUtils.getToolTipText(function, false);
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class PEUtil {
|
||||||
try {
|
try {
|
||||||
int addrAsInt = memory.getInt(addr);
|
int addrAsInt = memory.getInt(addr);
|
||||||
Address pointedToAddr =
|
Address pointedToAddr =
|
||||||
addressFactory.getAddress(defaultSpace.getBaseSpaceID(), addrAsInt);
|
addressFactory.getAddress(defaultSpace.getSpaceID(), addrAsInt);
|
||||||
return memory.contains(pointedToAddr);
|
return memory.contains(pointedToAddr);
|
||||||
}
|
}
|
||||||
catch (MemoryAccessException e) {
|
catch (MemoryAccessException e) {
|
||||||
|
@ -92,7 +92,7 @@ public class PEUtil {
|
||||||
try {
|
try {
|
||||||
int addrAsInt = memory.getInt(addr);
|
int addrAsInt = memory.getInt(addr);
|
||||||
Address pointedToAddr =
|
Address pointedToAddr =
|
||||||
addressFactory.getAddress(defaultSpace.getBaseSpaceID(), addrAsInt);
|
addressFactory.getAddress(defaultSpace.getSpaceID(), addrAsInt);
|
||||||
if (memory.contains(pointedToAddr)) {
|
if (memory.contains(pointedToAddr)) {
|
||||||
GuidInfo guidInfo = GuidUtil.getKnownGuid(program, pointedToAddr);
|
GuidInfo guidInfo = GuidUtil.getKnownGuid(program, pointedToAddr);
|
||||||
if (guidInfo != null) {
|
if (guidInfo != null) {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/* ###
|
/* ###
|
||||||
* IP: GHIDRA
|
* IP: GHIDRA
|
||||||
* REVIEWED: YES
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,11 +15,14 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.processors.generic;
|
package ghidra.app.plugin.processors.generic;
|
||||||
|
|
||||||
import ghidra.program.model.address.*;
|
import java.util.ArrayList;
|
||||||
import ghidra.program.model.mem.MemBuffer;
|
import java.util.Hashtable;
|
||||||
import ghidra.program.model.pcode.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
import ghidra.program.model.address.Address;
|
||||||
|
import ghidra.program.model.address.AddressSpace;
|
||||||
|
import ghidra.program.model.mem.MemBuffer;
|
||||||
|
import ghidra.program.model.pcode.PcodeOp;
|
||||||
|
import ghidra.program.model.pcode.Varnode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -50,7 +52,7 @@ public class BinaryExpression implements OperandValue, ExpressionValue {
|
||||||
right = r;
|
right = r;
|
||||||
wordSize = c.getSize()/8;
|
wordSize = c.getSize()/8;
|
||||||
// wordMask = c.getMaxOffset();
|
// wordMask = c.getMaxOffset();
|
||||||
spaceID = c.getBaseSpaceID();
|
spaceID = c.getSpaceID();
|
||||||
constantSpace = c;
|
constantSpace = c;
|
||||||
switch (opType) {
|
switch (opType) {
|
||||||
case ADD:
|
case ADD:
|
||||||
|
@ -65,11 +67,12 @@ public class BinaryExpression implements OperandValue, ExpressionValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpace(AddressSpace space) {
|
public void setSpace(AddressSpace space) {
|
||||||
spaceID = space.getBaseSpaceID();
|
spaceID = space.getSpaceID();
|
||||||
wordSize = space.getSize()/8;
|
wordSize = space.getSize()/8;
|
||||||
// wordMask = space.getMaxOffset();
|
// wordMask = space.getMaxOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int length(MemBuffer buf,int off) throws Exception {
|
public int length(MemBuffer buf,int off) throws Exception {
|
||||||
int leftLen = left.length(buf,off);
|
int leftLen = left.length(buf,off);
|
||||||
int rightLen = right.length(buf, off);
|
int rightLen = right.length(buf, off);
|
||||||
|
@ -77,10 +80,12 @@ public class BinaryExpression implements OperandValue, ExpressionValue {
|
||||||
return (leftLen > rightLen ? leftLen : rightLen);
|
return (leftLen > rightLen ? leftLen : rightLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ConstructorInfo getInfo(MemBuffer buf, int off) throws Exception {
|
public ConstructorInfo getInfo(MemBuffer buf, int off) throws Exception {
|
||||||
return new ConstructorInfo(length(buf,off),0);
|
return new ConstructorInfo(length(buf,off),0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public long longValue(MemBuffer buf, int off) throws Exception {
|
public long longValue(MemBuffer buf, int off) throws Exception {
|
||||||
|
|
||||||
long l = left.longValue(buf, off);
|
long l = left.longValue(buf, off);
|
||||||
|
@ -98,9 +103,12 @@ public class BinaryExpression implements OperandValue, ExpressionValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString(MemBuffer buf, int off) throws Exception {
|
public String toString(MemBuffer buf, int off) throws Exception {
|
||||||
long val = longValue(buf, off);
|
long val = longValue(buf, off);
|
||||||
if (val >= 0) return "0x" + Long.toString(val,16);
|
if (val >= 0) {
|
||||||
|
return "0x" + Long.toString(val,16);
|
||||||
|
}
|
||||||
return "-0x" + Long.toString(-val,16);
|
return "-0x" + Long.toString(-val,16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +121,7 @@ public class BinaryExpression implements OperandValue, ExpressionValue {
|
||||||
right.linkRelativeOffsets(opHash);
|
right.linkRelativeOffsets(opHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Handle getHandle(Position position, int off) throws Exception {
|
public Handle getHandle(Position position, int off) throws Exception {
|
||||||
long val = /* wordMask & */ longValue(position.buffer(),off);
|
long val = /* wordMask & */ longValue(position.buffer(),off);
|
||||||
Address a = constantSpace.getAddress(val);
|
Address a = constantSpace.getAddress(val);
|
||||||
|
@ -120,10 +129,12 @@ public class BinaryExpression implements OperandValue, ExpressionValue {
|
||||||
return new Handle(v,spaceID,wordSize);
|
return new Handle(v,spaceID,wordSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Handle getHandle(ArrayList<PcodeOp> pcode, Position position, int off) throws Exception {
|
public Handle getHandle(ArrayList<PcodeOp> pcode, Position position, int off) throws Exception {
|
||||||
return getHandle(position,off); // a binary expression never has any associated pcode
|
return getHandle(position,off); // a binary expression never has any associated pcode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void getAllHandles(ArrayList<Handle> handles,Position position,int off) throws Exception {
|
public void getAllHandles(ArrayList<Handle> handles,Position position,int off) throws Exception {
|
||||||
handles.add(getHandle(position,off));
|
handles.add(getHandle(position,off));
|
||||||
}
|
}
|
||||||
|
@ -131,6 +142,7 @@ public class BinaryExpression implements OperandValue, ExpressionValue {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see ghidra.app.plugin.processors.generic.OperandValue#toList(java.util.ArrayList, ghidra.program.model.mem.MemBuffer, int)
|
* @see ghidra.app.plugin.processors.generic.OperandValue#toList(java.util.ArrayList, ghidra.program.model.mem.MemBuffer, int)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void toList(ArrayList<Handle> list, Position position, int off) throws Exception {
|
public void toList(ArrayList<Handle> list, Position position, int off) throws Exception {
|
||||||
list.add(getHandle(position, off));
|
list.add(getHandle(position, off));
|
||||||
}
|
}
|
||||||
|
@ -138,6 +150,7 @@ public class BinaryExpression implements OperandValue, ExpressionValue {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see ghidra.app.plugin.processors.generic.OperandValue#getSize()
|
* @see ghidra.app.plugin.processors.generic.OperandValue#getSize()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return wordSize * 8;
|
return wordSize * 8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.processors.generic;
|
package ghidra.app.plugin.processors.generic;
|
||||||
|
|
||||||
import ghidra.program.model.address.Address;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import ghidra.program.model.address.Address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -101,7 +101,7 @@ public class ConstantTemplate implements Serializable {
|
||||||
|
|
||||||
case JUMP_CODESPACE:
|
case JUMP_CODESPACE:
|
||||||
Address addr = position.buffer().getAddress();
|
Address addr = position.buffer().getAddress();
|
||||||
return addr.getAddressSpace().getBaseSpaceID();
|
return addr.getAddressSpace().getSpaceID();
|
||||||
|
|
||||||
default: // Should never reach here
|
default: // Should never reach here
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -114,8 +114,9 @@ public class ConstantTemplate implements Serializable {
|
||||||
* @return long
|
* @return long
|
||||||
*/
|
*/
|
||||||
public long resolve(HashMap<Object, Handle> handles, Position position, int off) throws Exception {
|
public long resolve(HashMap<Object, Handle> handles, Position position, int off) throws Exception {
|
||||||
if (type == HANDLE)
|
if (type == HANDLE) {
|
||||||
return handles.get(op).getLong(select1,select2);
|
return handles.get(op).getLong(select1,select2);
|
||||||
|
}
|
||||||
return resolve(position,off);
|
return resolve(position,off);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,14 +127,26 @@ public class ConstantTemplate implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o.getClass() != ConstantTemplate.class) return false;
|
if (o.getClass() != ConstantTemplate.class) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
ConstantTemplate ct = (ConstantTemplate) o;
|
ConstantTemplate ct = (ConstantTemplate) o;
|
||||||
if (ct.hashCode() != hashCode) return false;
|
if (ct.hashCode() != hashCode) {
|
||||||
if (ct.type() != type) return false;
|
return false;
|
||||||
|
}
|
||||||
|
if (ct.type() != type) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (type == HANDLE) {
|
if (type == HANDLE) {
|
||||||
if (!ct.operand().equals(op)) return false;
|
if (!ct.operand().equals(op)) {
|
||||||
if (ct.select1() != select1) return false;
|
return false;
|
||||||
if (ct.select2() != select2) return false;
|
}
|
||||||
|
if (ct.select1() != select1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ct.select2() != select2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -498,7 +498,7 @@ public abstract class PcodeEmit {
|
||||||
dyncache[2].size = incache[i].size;
|
dyncache[2].size = incache[i].size;
|
||||||
AddressSpace spc = generatePointer(vn, dyncache[1]);
|
AddressSpace spc = generatePointer(vn, dyncache[1]);
|
||||||
dyncache[0].space = const_space;
|
dyncache[0].space = const_space;
|
||||||
dyncache[0].offset = spc.getBaseSpaceID();
|
dyncache[0].offset = spc.getSpaceID();
|
||||||
dyncache[0].size = 4; // Size of spaceid
|
dyncache[0].size = 4; // Size of spaceid
|
||||||
dump(startAddress, PcodeOp.LOAD, dyncache, 2, dyncache[2]);
|
dump(startAddress, PcodeOp.LOAD, dyncache, 2, dyncache[2]);
|
||||||
numOps += 1;
|
numOps += 1;
|
||||||
|
@ -529,7 +529,7 @@ public abstract class PcodeEmit {
|
||||||
dyncache[2].size = outcache.size;
|
dyncache[2].size = outcache.size;
|
||||||
AddressSpace spc = generatePointer(outvn, dyncache[1]);
|
AddressSpace spc = generatePointer(outvn, dyncache[1]);
|
||||||
dyncache[0].space = const_space;
|
dyncache[0].space = const_space;
|
||||||
dyncache[0].offset = spc.getBaseSpaceID();
|
dyncache[0].offset = spc.getSpaceID();
|
||||||
dyncache[0].size = 4; // Size of spaceid;
|
dyncache[0].size = 4; // Size of spaceid;
|
||||||
dump(startAddress, PcodeOp.STORE, dyncache, 3, null);
|
dump(startAddress, PcodeOp.STORE, dyncache, 3, null);
|
||||||
numOps += 1;
|
numOps += 1;
|
||||||
|
@ -738,7 +738,7 @@ public abstract class PcodeEmit {
|
||||||
AddressSpace space = uniqueFactory.getAddressFactory().getAddressSpace(spaceId);
|
AddressSpace space = uniqueFactory.getAddressFactory().getAddressSpace(spaceId);
|
||||||
if (space.isOverlaySpace()) {
|
if (space.isOverlaySpace()) {
|
||||||
space = ((OverlayAddressSpace) space).getOverlayedSpace();
|
space = ((OverlayAddressSpace) space).getOverlayedSpace();
|
||||||
in[0].offset = space.getBaseSpaceID();
|
in[0].offset = space.getSpaceID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < isize; ++i) {
|
for (int i = 0; i < isize; ++i) {
|
||||||
|
|
|
@ -96,14 +96,16 @@ public class ConstTpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConstSpace() {
|
public boolean isConstSpace() {
|
||||||
if (type == SPACEID)
|
if (type == SPACEID) {
|
||||||
return (value_spaceid.getType() == AddressSpace.TYPE_CONSTANT);
|
return (value_spaceid.getType() == AddressSpace.TYPE_CONSTANT);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUniqueSpace() {
|
public boolean isUniqueSpace() {
|
||||||
if (type == SPACEID)
|
if (type == SPACEID) {
|
||||||
return (value_spaceid.getType() == AddressSpace.TYPE_UNIQUE);
|
return (value_spaceid.getType() == AddressSpace.TYPE_UNIQUE);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,32 +142,38 @@ public class ConstTpl {
|
||||||
case J_CURSPACE_SIZE:
|
case J_CURSPACE_SIZE:
|
||||||
return walker.getCurSpace().getPointerSize();
|
return walker.getCurSpace().getPointerSize();
|
||||||
case J_CURSPACE:
|
case J_CURSPACE:
|
||||||
return walker.getCurSpace().getBaseSpaceID();
|
return walker.getCurSpace().getSpaceID();
|
||||||
case HANDLE: {
|
case HANDLE: {
|
||||||
FixedHandle hand = walker.getFixedHandle(handle_index);
|
FixedHandle hand = walker.getFixedHandle(handle_index);
|
||||||
switch (select) {
|
switch (select) {
|
||||||
case V_SPACE:
|
case V_SPACE:
|
||||||
if (hand.offset_space == null)
|
if (hand.offset_space == null) {
|
||||||
return hand.space.getBaseSpaceID();
|
return hand.space.getSpaceID();
|
||||||
return hand.temp_space.getBaseSpaceID();
|
}
|
||||||
|
return hand.temp_space.getSpaceID();
|
||||||
case V_OFFSET:
|
case V_OFFSET:
|
||||||
if (hand.offset_space == null)
|
if (hand.offset_space == null) {
|
||||||
return hand.offset_offset;
|
return hand.offset_offset;
|
||||||
|
}
|
||||||
return hand.temp_offset;
|
return hand.temp_offset;
|
||||||
case V_SIZE:
|
case V_SIZE:
|
||||||
return hand.size;
|
return hand.size;
|
||||||
case V_OFFSET_PLUS:
|
case V_OFFSET_PLUS:
|
||||||
if (hand.space.getType() != AddressSpace.TYPE_CONSTANT) { // If we are not a constant
|
if (hand.space.getType() != AddressSpace.TYPE_CONSTANT) { // If we are not a constant
|
||||||
if (hand.offset_space == null)
|
if (hand.offset_space == null)
|
||||||
|
{
|
||||||
return hand.offset_offset + (value_real & 0xffff); // Adjust offset by truncation amount
|
return hand.offset_offset + (value_real & 0xffff); // Adjust offset by truncation amount
|
||||||
|
}
|
||||||
return hand.temp_offset + (value_real & 0xffff);
|
return hand.temp_offset + (value_real & 0xffff);
|
||||||
}
|
}
|
||||||
// If we are a constant, shift by the truncation amount
|
// If we are a constant, shift by the truncation amount
|
||||||
long val;
|
long val;
|
||||||
if (hand.offset_space == null)
|
if (hand.offset_space == null) {
|
||||||
val = hand.offset_offset;
|
val = hand.offset_offset;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
val = hand.temp_offset;
|
val = hand.temp_offset;
|
||||||
|
}
|
||||||
val >>= 8 * (value_real >> 16);
|
val >>= 8 * (value_real >> 16);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +183,7 @@ public class ConstTpl {
|
||||||
case REAL:
|
case REAL:
|
||||||
return value_real;
|
return value_real;
|
||||||
case SPACEID:
|
case SPACEID:
|
||||||
return value_spaceid.getBaseSpaceID();
|
return value_spaceid.getSpaceID();
|
||||||
}
|
}
|
||||||
return 0; // Should never reach here
|
return 0; // Should never reach here
|
||||||
}
|
}
|
||||||
|
@ -188,8 +196,9 @@ public class ConstTpl {
|
||||||
FixedHandle hand = walker.getFixedHandle(handle_index);
|
FixedHandle hand = walker.getFixedHandle(handle_index);
|
||||||
switch (select) {
|
switch (select) {
|
||||||
case V_SPACE:
|
case V_SPACE:
|
||||||
if (hand.offset_space == null)
|
if (hand.offset_space == null) {
|
||||||
return hand.space;
|
return hand.space;
|
||||||
|
}
|
||||||
return hand.temp_space;
|
return hand.temp_space;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -272,18 +281,22 @@ public class ConstTpl {
|
||||||
type = HANDLE;
|
type = HANDLE;
|
||||||
handle_index = (short) SpecXmlUtils.decodeInt(el.getAttribute("val"));
|
handle_index = (short) SpecXmlUtils.decodeInt(el.getAttribute("val"));
|
||||||
String selstr = el.getAttribute("s");
|
String selstr = el.getAttribute("s");
|
||||||
if (selstr.equals("space"))
|
if (selstr.equals("space")) {
|
||||||
select = V_SPACE;
|
select = V_SPACE;
|
||||||
else if (selstr.equals("offset"))
|
}
|
||||||
|
else if (selstr.equals("offset")) {
|
||||||
select = V_OFFSET;
|
select = V_OFFSET;
|
||||||
else if (selstr.equals("size"))
|
}
|
||||||
|
else if (selstr.equals("size")) {
|
||||||
select = V_SIZE;
|
select = V_SIZE;
|
||||||
|
}
|
||||||
else if (selstr.equals("offset_plus")) {
|
else if (selstr.equals("offset_plus")) {
|
||||||
select = V_OFFSET_PLUS;
|
select = V_OFFSET_PLUS;
|
||||||
value_real = SpecXmlUtils.decodeLong(el.getAttribute("plus"));
|
value_real = SpecXmlUtils.decodeLong(el.getAttribute("plus"));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
throw new SleighException("Bad handle selector");
|
throw new SleighException("Bad handle selector");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (typestr.equals("start")) {
|
else if (typestr.equals("start")) {
|
||||||
type = J_START;
|
type = J_START;
|
||||||
|
@ -317,8 +330,9 @@ public class ConstTpl {
|
||||||
else if (typestr.equals("flowdest_size")) {
|
else if (typestr.equals("flowdest_size")) {
|
||||||
type = J_FLOWDEST_SIZE;
|
type = J_FLOWDEST_SIZE;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
throw new SleighException("Bad xml for ConstTpl");
|
throw new SleighException("Bad xml for ConstTpl");
|
||||||
|
}
|
||||||
parser.end(el);
|
parser.end(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class ProgramAddressFactory extends DefaultAddressFactory {
|
||||||
@Override
|
@Override
|
||||||
public Address getAddress(int spaceID, long offset) {
|
public Address getAddress(int spaceID, long offset) {
|
||||||
Address addr = super.getAddress(spaceID, offset);
|
Address addr = super.getAddress(spaceID, offset);
|
||||||
if (addr == null && spaceID == stackSpace.getUniqueSpaceID()) {
|
if (addr == null && spaceID == stackSpace.getSpaceID()) {
|
||||||
return stackSpace.getAddress(offset);
|
return stackSpace.getAddress(offset);
|
||||||
}
|
}
|
||||||
return addr;
|
return addr;
|
||||||
|
|
|
@ -282,9 +282,13 @@ abstract class AbstractAddressSpace implements AddressSpace {
|
||||||
public long subtract(Address addr1, Address addr2) {
|
public long subtract(Address addr1, Address addr2) {
|
||||||
AddressSpace space1 = addr1.getAddressSpace();
|
AddressSpace space1 = addr1.getAddressSpace();
|
||||||
AddressSpace space2 = addr2.getAddressSpace();
|
AddressSpace space2 = addr2.getAddressSpace();
|
||||||
if (!addr1.getAddressSpace().equals(addr2.getAddressSpace())) {
|
if (!space1.equals(space2)) {
|
||||||
// if the two spaces are actually based in the same space, calculate the offset
|
// if the two spaces are actually based in the same space, calculate the offset
|
||||||
if (space1.getBaseSpaceID() != space2.getBaseSpaceID()) {
|
int base1 = space1.isOverlaySpace() ? ((OverlayAddressSpace) space1).getBaseSpaceID()
|
||||||
|
: space1.getSpaceID();
|
||||||
|
int base2 = space2.isOverlaySpace() ? ((OverlayAddressSpace) space2).getBaseSpaceID()
|
||||||
|
: space2.getSpaceID();
|
||||||
|
if (base1 != base2) {
|
||||||
throw new IllegalArgumentException("Address are in different spaces " +
|
throw new IllegalArgumentException("Address are in different spaces " +
|
||||||
addr1.getAddressSpace().getName() + " != " + addr2.getAddressSpace().getName());
|
addr1.getAddressSpace().getName() + " != " + addr2.getAddressSpace().getName());
|
||||||
}
|
}
|
||||||
|
@ -478,8 +482,9 @@ abstract class AbstractAddressSpace implements AddressSpace {
|
||||||
return minAddress;
|
return minAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int compareToOverlaySpace(AddressSpace overlaySpace) {
|
private int compareAsOverlaySpace(AddressSpace overlaySpace) {
|
||||||
int baseCompare = getBaseSpaceID() - overlaySpace.getBaseSpaceID();
|
int baseCompare = ((OverlayAddressSpace) this).getBaseSpaceID() -
|
||||||
|
((OverlayAddressSpace) overlaySpace).getBaseSpaceID();
|
||||||
if (baseCompare == 0) {
|
if (baseCompare == 0) {
|
||||||
long otherMinOffset = overlaySpace.getMinAddress().getOffset();
|
long otherMinOffset = overlaySpace.getMinAddress().getOffset();
|
||||||
if (minOffset == otherMinOffset) {
|
if (minOffset == otherMinOffset) {
|
||||||
|
@ -498,7 +503,7 @@ abstract class AbstractAddressSpace implements AddressSpace {
|
||||||
if (isOverlaySpace()) {
|
if (isOverlaySpace()) {
|
||||||
if (space.isOverlaySpace()) {
|
if (space.isOverlaySpace()) {
|
||||||
// Both spaces are overlay spaces
|
// Both spaces are overlay spaces
|
||||||
return compareToOverlaySpace(space);
|
return compareAsOverlaySpace(space);
|
||||||
}
|
}
|
||||||
// I'm an overlay, other space is NOT an overlay
|
// I'm an overlay, other space is NOT an overlay
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -519,7 +524,7 @@ abstract class AbstractAddressSpace implements AddressSpace {
|
||||||
// source within a list/set of addresses from a second source.
|
// source within a list/set of addresses from a second source.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int c = getBaseSpaceID() - space.getBaseSpaceID();
|
int c = getSpaceID() - space.getSpaceID();
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
c = getClass().getName().compareTo(space.getClass().getName());
|
c = getClass().getName().compareTo(space.getClass().getName());
|
||||||
}
|
}
|
||||||
|
@ -557,12 +562,7 @@ abstract class AbstractAddressSpace implements AddressSpace {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBaseSpaceID() {
|
public int getSpaceID() {
|
||||||
return spaceID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getUniqueSpaceID() {
|
|
||||||
return spaceID;
|
return spaceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,9 +111,7 @@ public interface AddressSpace extends Comparable<AddressSpace> {
|
||||||
*
|
*
|
||||||
* @return space ID
|
* @return space ID
|
||||||
*/
|
*/
|
||||||
int getBaseSpaceID();
|
int getSpaceID();
|
||||||
|
|
||||||
int getUniqueSpaceID();
|
|
||||||
|
|
||||||
/** Returns the number of bits that are used to form the address. Thus
|
/** Returns the number of bits that are used to form the address. Thus
|
||||||
* the maximum offset for this address space will be 2^size-1.
|
* the maximum offset for this address space will be 2^size-1.
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class DefaultAddressFactory implements AddressFactory {
|
||||||
this.defaultSpace = space;
|
this.defaultSpace = space;
|
||||||
}
|
}
|
||||||
spaceNameTable.put(space.getName(), space);
|
spaceNameTable.put(space.getName(), space);
|
||||||
spaceLookup.put(space.getUniqueSpaceID(), space);
|
spaceLookup.put(space.getSpaceID(), space);
|
||||||
if (space.getType() == AddressSpace.TYPE_CONSTANT) {
|
if (space.getType() == AddressSpace.TYPE_CONSTANT) {
|
||||||
constantSpace = space;
|
constantSpace = space;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ public class DefaultAddressFactory implements AddressFactory {
|
||||||
@Override
|
@Override
|
||||||
public long getIndex(Address addr) {
|
public long getIndex(Address addr) {
|
||||||
AddressSpace space = addr.getAddressSpace();
|
AddressSpace space = addr.getAddressSpace();
|
||||||
int id = space.getUniqueSpaceID();
|
int id = space.getSpaceID();
|
||||||
if (spaceLookup.get(id) == null) {
|
if (spaceLookup.get(id) == null) {
|
||||||
spaceLookup.put(id, space);
|
spaceLookup.put(id, space);
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ public class DefaultAddressFactory implements AddressFactory {
|
||||||
}
|
}
|
||||||
spaces.add(space);
|
spaces.add(space);
|
||||||
spaceNameTable.put(space.getName(), space);
|
spaceNameTable.put(space.getName(), space);
|
||||||
spaceLookup.put(space.getUniqueSpaceID(), space);
|
spaceLookup.put(space.getSpaceID(), space);
|
||||||
|
|
||||||
if (space.isMemorySpace()) {
|
if (space.isMemorySpace()) {
|
||||||
memoryAddressSet.addRange(space.getMinAddress(), space.getMaxAddress());
|
memoryAddressSet.addRange(space.getMinAddress(), space.getMaxAddress());
|
||||||
|
@ -415,7 +415,7 @@ public class DefaultAddressFactory implements AddressFactory {
|
||||||
if (deletedSpace != null) {
|
if (deletedSpace != null) {
|
||||||
spaces.remove(deletedSpace);
|
spaces.remove(deletedSpace);
|
||||||
spaceNameTable.remove(deletedSpace.getName());
|
spaceNameTable.remove(deletedSpace.getName());
|
||||||
spaceLookup.remove(deletedSpace.getUniqueSpaceID());
|
spaceLookup.remove(deletedSpace.getSpaceID());
|
||||||
if (deletedSpace.getType() == AddressSpace.TYPE_RAM ||
|
if (deletedSpace.getType() == AddressSpace.TYPE_RAM ||
|
||||||
deletedSpace.getType() == AddressSpace.TYPE_CODE) {
|
deletedSpace.getType() == AddressSpace.TYPE_CODE) {
|
||||||
memoryAddressSet.deleteRange(deletedSpace.getMinAddress(),
|
memoryAddressSet.deleteRange(deletedSpace.getMinAddress(),
|
||||||
|
|
|
@ -96,8 +96,12 @@ public class OverlayAddressSpace extends AbstractAddressSpace {
|
||||||
public long subtract(Address addr1, Address addr2) {
|
public long subtract(Address addr1, Address addr2) {
|
||||||
AddressSpace space1 = addr1.getAddressSpace();
|
AddressSpace space1 = addr1.getAddressSpace();
|
||||||
AddressSpace space2 = addr2.getAddressSpace();
|
AddressSpace space2 = addr2.getAddressSpace();
|
||||||
if (space1.equals(this)) space1 = originalSpace;
|
if (space1.equals(this)) {
|
||||||
if (space2.equals(this)) space2 = originalSpace;
|
space1 = originalSpace;
|
||||||
|
}
|
||||||
|
if (space2.equals(this)) {
|
||||||
|
space2 = originalSpace;
|
||||||
|
}
|
||||||
if (!space1.equals(space2)) {
|
if (!space1.equals(space2)) {
|
||||||
throw new IllegalArgumentException("Address are in different spaces " +
|
throw new IllegalArgumentException("Address are in different spaces " +
|
||||||
addr1.getAddressSpace().getName() + " != " + addr2.getAddressSpace().getName());
|
addr1.getAddressSpace().getName() + " != " + addr2.getAddressSpace().getName());
|
||||||
|
@ -204,9 +208,11 @@ public class OverlayAddressSpace extends AbstractAddressSpace {
|
||||||
return new GenericAddress(originalSpace, addr.getOffset());
|
return new GenericAddress(originalSpace, addr.getOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @return the ID of the address space underlying this space
|
||||||
|
*/
|
||||||
public int getBaseSpaceID() {
|
public int getBaseSpaceID() {
|
||||||
return originalSpace.getBaseSpaceID();
|
return originalSpace.getSpaceID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class Varnode {
|
||||||
public Varnode(Address a, int sz) {
|
public Varnode(Address a, int sz) {
|
||||||
address = a;
|
address = a;
|
||||||
AddressSpace space = address.getAddressSpace();
|
AddressSpace space = address.getAddressSpace();
|
||||||
spaceID = space.getBaseSpaceID();
|
spaceID = space.getSpaceID();
|
||||||
size = sz;
|
size = sz;
|
||||||
offset = address.getOffset();
|
offset = address.getOffset();
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class Varnode {
|
||||||
* @return true if this varnode contains the specified address
|
* @return true if this varnode contains the specified address
|
||||||
*/
|
*/
|
||||||
public boolean contains(Address address) {
|
public boolean contains(Address address) {
|
||||||
if (spaceID != address.getAddressSpace().getUniqueSpaceID()) {
|
if (spaceID != address.getAddressSpace().getSpaceID()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isConstant() || isUnique() || isHash()) {
|
if (isConstant() || isUnique() || isHash()) {
|
||||||
|
@ -193,7 +193,7 @@ public class Varnode {
|
||||||
}
|
}
|
||||||
for (AddressRange range : set.getAddressRanges()) {
|
for (AddressRange range : set.getAddressRanges()) {
|
||||||
Address minAddr = range.getMinAddress();
|
Address minAddr = range.getMinAddress();
|
||||||
if (minAddr.getAddressSpace().getUniqueSpaceID() != spaceID) {
|
if (minAddr.getAddressSpace().getSpaceID() != spaceID) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Address maxAddr = range.getMaxAddress();
|
Address maxAddr = range.getMaxAddress();
|
||||||
|
@ -244,7 +244,7 @@ public class Varnode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHash() {
|
public boolean isHash() {
|
||||||
return spaceID == AddressSpace.HASH_SPACE.getUniqueSpaceID();
|
return spaceID == AddressSpace.HASH_SPACE.getSpaceID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -588,7 +588,7 @@ public class Varnode {
|
||||||
String localName = el.getName();
|
String localName = el.getName();
|
||||||
if (localName.equals("spaceid")) {
|
if (localName.equals("spaceid")) {
|
||||||
AddressSpace spc = addrFactory.getAddressSpace(el.getAttribute("name"));
|
AddressSpace spc = addrFactory.getAddressSpace(el.getAttribute("name"));
|
||||||
int spaceid = spc.getBaseSpaceID();
|
int spaceid = spc.getSpaceID();
|
||||||
spc = addrFactory.getConstantSpace();
|
spc = addrFactory.getConstantSpace();
|
||||||
return spc.getAddress(spaceid);
|
return spc.getAddress(spaceid);
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ public class Varnode {
|
||||||
AddressFactory addrFactory) {
|
AddressFactory addrFactory) {
|
||||||
if (localName.equals("spaceid")) {
|
if (localName.equals("spaceid")) {
|
||||||
AddressSpace spc = addrFactory.getAddressSpace(attr.getValue("name"));
|
AddressSpace spc = addrFactory.getAddressSpace(attr.getValue("name"));
|
||||||
int spaceid = spc.getBaseSpaceID();
|
int spaceid = spc.getSpaceID();
|
||||||
spc = addrFactory.getConstantSpace();
|
spc = addrFactory.getConstantSpace();
|
||||||
return spc.getAddress(spaceid);
|
return spc.getAddress(spaceid);
|
||||||
}
|
}
|
||||||
|
@ -658,7 +658,7 @@ public class Varnode {
|
||||||
if (nameend >= 0) {
|
if (nameend >= 0) {
|
||||||
AddressSpace spc =
|
AddressSpace spc =
|
||||||
addrfactory.getAddressSpace(addrstring.substring(attrstart, nameend));
|
addrfactory.getAddressSpace(addrstring.substring(attrstart, nameend));
|
||||||
int spaceid = spc.getBaseSpaceID();
|
int spaceid = spc.getSpaceID();
|
||||||
spc = addrfactory.getConstantSpace();
|
spc = addrfactory.getConstantSpace();
|
||||||
return spc.getAddress(spaceid);
|
return spc.getAddress(spaceid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,7 +550,7 @@ public class RefTypeFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (op.getOpcode() == PcodeOp.LOAD) {
|
else if (op.getOpcode() == PcodeOp.LOAD) {
|
||||||
if (memAddr.getAddressSpace().getUniqueSpaceID() == inputs[0].getOffset() &&
|
if (memAddr.getAddressSpace().getSpaceID() == inputs[0].getOffset() &&
|
||||||
(memOffset == inputs[1].getOffset() || inputs[1].equals(offsetVarnode))) {
|
(memOffset == inputs[1].getOffset() || inputs[1].equals(offsetVarnode))) {
|
||||||
if (refType != null && refType.isWrite()) {
|
if (refType != null && refType.isWrite()) {
|
||||||
return RefType.READ_WRITE;
|
return RefType.READ_WRITE;
|
||||||
|
|
|
@ -300,16 +300,22 @@ public class SimpleDiffUtility {
|
||||||
Program otherProgram) {
|
Program otherProgram) {
|
||||||
AddressSpace otherSpace =
|
AddressSpace otherSpace =
|
||||||
otherProgram.getAddressFactory().getAddressSpace(addrSpace.getName());
|
otherProgram.getAddressFactory().getAddressSpace(addrSpace.getName());
|
||||||
if (otherSpace != null && otherSpace.getType() == addrSpace.getType() &&
|
if (otherSpace != null && otherSpace.getType() == addrSpace.getType()) {
|
||||||
otherSpace.getBaseSpaceID() == addrSpace.getBaseSpaceID()) {
|
int id = addrSpace.isOverlaySpace() ? ((OverlayAddressSpace) addrSpace).getBaseSpaceID()
|
||||||
if (otherSpace.isOverlaySpace()) {
|
: addrSpace.getSpaceID();
|
||||||
long addrOffset = addrSpace.getMinAddress().getOffset();
|
int otherid =
|
||||||
long otherOffset = otherSpace.getMinAddress().getOffset();
|
otherSpace.isOverlaySpace() ? ((OverlayAddressSpace) otherSpace).getBaseSpaceID()
|
||||||
if (addrOffset != otherOffset) {
|
: otherSpace.getSpaceID();
|
||||||
return null; // Overlays didn't begin at same address.
|
if (id == otherid) {
|
||||||
|
if (otherSpace.isOverlaySpace()) {
|
||||||
|
long addrOffset = addrSpace.getMinAddress().getOffset();
|
||||||
|
long otherOffset = otherSpace.getMinAddress().getOffset();
|
||||||
|
if (addrOffset != otherOffset) {
|
||||||
|
return null; // Overlays didn't begin at same address.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return otherSpace;
|
||||||
}
|
}
|
||||||
return otherSpace;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,9 +111,9 @@ public class InjectPayloadJavaParameters implements InjectPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressSpace paramSpace = program.getAddressFactory().getAddressSpace("parameterSpace");
|
AddressSpace paramSpace = program.getAddressFactory().getAddressSpace("parameterSpace");
|
||||||
int paramSpaceID = paramSpace.getBaseSpaceID();
|
int paramSpaceID = paramSpace.getSpaceID();
|
||||||
AddressSpace lva = program.getAddressFactory().getAddressSpace("localVariableArray");
|
AddressSpace lva = program.getAddressFactory().getAddressSpace("localVariableArray");
|
||||||
int lvaID = lva.getBaseSpaceID();
|
int lvaID = lva.getSpaceID();
|
||||||
AddressSpace constant = program.getAddressFactory().getConstantSpace();
|
AddressSpace constant = program.getAddressFactory().getConstantSpace();
|
||||||
|
|
||||||
PcodeOp[] resOps = new PcodeOp[1 + 3*numOps];
|
PcodeOp[] resOps = new PcodeOp[1 + 3*numOps];
|
||||||
|
|
|
@ -318,7 +318,7 @@ public class MipsAddressAnalyzer extends ConstantPropagationAnalyzer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
symEval.makeReference(context, lastSetInstr, -1,
|
symEval.makeReference(context, lastSetInstr, -1,
|
||||||
instr.getMinAddress().getAddressSpace().getBaseSpaceID(),
|
instr.getMinAddress().getAddressSpace().getSpaceID(),
|
||||||
unsignedValue, 1, RefType.DATA, PcodeOp.UNIMPLEMENTED, true,
|
unsignedValue, 1, RefType.DATA, PcodeOp.UNIMPLEMENTED, true,
|
||||||
monitor);
|
monitor);
|
||||||
if (localGPAssumptionValue == null) {
|
if (localGPAssumptionValue == null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue