mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GT-3170 Additional refinements to handling of BooleanDataType and
AbstractIntegerDataType
This commit is contained in:
parent
9d2ab478c0
commit
38dd0c177f
8 changed files with 25 additions and 15 deletions
|
@ -23,7 +23,9 @@ import javax.swing.JMenuItem;
|
|||
import docking.action.MenuData;
|
||||
import ghidra.app.context.ListingActionContext;
|
||||
import ghidra.app.context.ListingContextAction;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.docking.settings.FormatSettingsDefinition;
|
||||
import ghidra.program.model.data.AbstractIntegerDataType;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.scalar.Scalar;
|
||||
import ghidra.program.util.OperandFieldLocation;
|
||||
|
@ -65,7 +67,11 @@ public abstract class AbstractConvertAction extends ListingContextAction {
|
|||
// unsupported data action
|
||||
return false;
|
||||
}
|
||||
DataType dataType = ((Data) cu).getBaseDataType();
|
||||
Data data = (Data) cu;
|
||||
if (!data.isDefined()) {
|
||||
return false;
|
||||
}
|
||||
DataType dataType = data.getBaseDataType();
|
||||
if (!(dataType instanceof AbstractIntegerDataType)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class ConvertCommand extends BackgroundCommand {
|
|||
DataType dt = data.getBaseDataType();
|
||||
Settings settings = data;
|
||||
Settings defaultSettings = dt.getDefaultSettings();
|
||||
if (!(dt instanceof AbstractIntegerDataType)) {
|
||||
if (Scalar.class.equals(data.getValueClass()) || !(dt instanceof AbstractIntegerDataType)) {
|
||||
msg = "Unsupported data type for convert: " + data.getDataType().getDisplayName();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -36,8 +36,7 @@ import ghidra.framework.cmd.CompoundBackgroundCommand;
|
|||
import ghidra.framework.plugintool.*;
|
||||
import ghidra.framework.plugintool.util.PluginStatus;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.data.DataTypeManager;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.data.Enum;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.scalar.Scalar;
|
||||
|
@ -165,6 +164,10 @@ public class EquatePlugin extends Plugin {
|
|||
if (!data.isDefined()) {
|
||||
return false;
|
||||
}
|
||||
DataType dataType = data.getBaseDataType();
|
||||
if (!(dataType instanceof AbstractIntegerDataType)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Equate equate = getEquate(context);
|
||||
|
|
|
@ -712,6 +712,9 @@ public class DWARFFunctionImporter {
|
|||
if (!(dataDT instanceof Enum || dataDT instanceof AbstractIntegerDataType)) {
|
||||
return false;
|
||||
}
|
||||
if (dataDT instanceof BooleanDataType) {
|
||||
return false;
|
||||
}
|
||||
if (dataDT.getLength() != enumDT.getLength()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ public class RenameConstantTask extends RenameTask {
|
|||
*/
|
||||
@Override
|
||||
public boolean runDialog() {
|
||||
// NOTE: acstion must ensure that HighConstant datatype produces Scalar value and is integer type
|
||||
// BooleanDataType and CharDataType do not produce scalar values in assembly listing.
|
||||
SetEquateDialog setEquateDialog = new SetEquateDialog(tool, program, high.getScalar());
|
||||
setEquateDialog.setHelpLocation(new HelpLocation("EquatesPlugin", "Set_Equate"));
|
||||
|
||||
|
|
|
@ -323,9 +323,6 @@ class DataDB extends CodeUnitDB implements Data {
|
|||
if (obj instanceof Scalar) {
|
||||
return (Scalar) obj;
|
||||
}
|
||||
else if (obj instanceof Boolean) {
|
||||
return new Scalar(getLength() * 8, ((Boolean) obj).booleanValue() ? 1 : 0);
|
||||
}
|
||||
else if (obj instanceof Address) {
|
||||
Address addrObj = (Address) obj;
|
||||
long offset = addrObj.getAddressableWordOffset();
|
||||
|
|
|
@ -103,8 +103,7 @@ public class BooleanDataType extends AbstractIntegerDataType {
|
|||
|
||||
@Override
|
||||
public String getRepresentation(BigInteger bigInt, Settings settings, int bitLength) {
|
||||
return bigInt.testBit(0) ? "TRUE" : "FALSE";
|
||||
|
||||
return BigInteger.ZERO.equals(bigInt) ? "FALSE" : "TRUE";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,8 +40,8 @@ public class HighConstant extends HighVariable {
|
|||
* @param func the associated high function
|
||||
* @throws InvalidInputException
|
||||
*/
|
||||
public HighConstant(String name, DataType type, Varnode vn, Address pc,
|
||||
HighFunction func) throws InvalidInputException {
|
||||
public HighConstant(String name, DataType type, Varnode vn, Address pc, HighFunction func)
|
||||
throws InvalidInputException {
|
||||
super(name, type, vn, null, func);
|
||||
pcaddr = pc;
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ public class HighConstant extends HighVariable {
|
|||
* @param sym associated dynamic symbol
|
||||
* @throws InvalidInputException
|
||||
*/
|
||||
public HighConstant(String name, DataType type, Varnode vn, Address pc,
|
||||
DynamicSymbol sym) throws InvalidInputException {
|
||||
public HighConstant(String name, DataType type, Varnode vn, Address pc, DynamicSymbol sym)
|
||||
throws InvalidInputException {
|
||||
this(name, type, vn, pc, sym.getHighFunction());
|
||||
symbol = sym;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class HighConstant extends HighVariable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns constant as a scalar object
|
||||
* @return constant as a scalar object
|
||||
*/
|
||||
public Scalar getScalar() {
|
||||
boolean signed = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue