mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-4505 Added writable mutability setting
This commit is contained in:
parent
8ee5734927
commit
616bf82426
8 changed files with 47 additions and 10 deletions
|
@ -544,6 +544,11 @@ public class PseudoData extends PseudoCodeUnit implements Data {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVolatile() {
|
||||
return false;
|
||||
|
|
|
@ -130,7 +130,7 @@ class DataDB extends CodeUnitDB implements Data {
|
|||
|
||||
private void computeLength() {
|
||||
// NOTE: Data intentionally does not use aligned-length
|
||||
length = dataType.getLength();
|
||||
length = dataType.getLength();
|
||||
|
||||
// undefined will never change their size
|
||||
if (dataType instanceof Undefined) {
|
||||
|
@ -367,6 +367,11 @@ class DataDB extends CodeUnitDB implements Data {
|
|||
return hasMutability(MutabilitySettingsDefinition.CONSTANT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return hasMutability(MutabilitySettingsDefinition.WRITABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVolatile() {
|
||||
return hasMutability(MutabilitySettingsDefinition.VOLATILE);
|
||||
|
|
|
@ -27,9 +27,10 @@ public class MutabilitySettingsDefinition implements EnumSettingsDefinition {
|
|||
public static final int NORMAL = 0;
|
||||
public static final int VOLATILE = 1;
|
||||
public static final int CONSTANT = 2;
|
||||
public static final int WRITABLE = 3;
|
||||
|
||||
//NOTE: if these strings change, the XML needs to changed also...
|
||||
private static final String[] choices = { "normal", "volatile", "constant" };
|
||||
private static final String[] choices = { "normal", "volatile", "constant", "writable" };
|
||||
public static final String MUTABILITY = "mutability";
|
||||
|
||||
public static final MutabilitySettingsDefinition DEF = new MutabilitySettingsDefinition();
|
||||
|
@ -51,7 +52,7 @@ public class MutabilitySettingsDefinition implements EnumSettingsDefinition {
|
|||
return NORMAL;
|
||||
}
|
||||
int mode = (int) value.longValue();
|
||||
if ((mode < 0) || (mode > CONSTANT)) {
|
||||
if ((mode < 0) || (mode > WRITABLE)) {
|
||||
mode = NORMAL;
|
||||
}
|
||||
return mode;
|
||||
|
@ -69,7 +70,7 @@ public class MutabilitySettingsDefinition implements EnumSettingsDefinition {
|
|||
|
||||
@Override
|
||||
public void setChoice(Settings settings, int value) {
|
||||
if (value < 0 || value > CONSTANT) {
|
||||
if (value < 0 || value > WRITABLE) {
|
||||
settings.clearSetting(MUTABILITY);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -54,14 +54,26 @@ public interface Data extends CodeUnit, Settings {
|
|||
public boolean hasStringValue();
|
||||
|
||||
/**
|
||||
* @return true if data is constant.
|
||||
* If true, isConstant will always be false
|
||||
* Determine if this data has explicitly been marked as constant.
|
||||
* NOTE: This is based upon explicit {@link Data} and {@link DataType} mutability settings
|
||||
* and does not reflect independent memory block or processor specification settings.
|
||||
* @return true if data is constant, else false.
|
||||
*/
|
||||
public boolean isConstant();
|
||||
|
||||
/**
|
||||
* @return true if data is volatile.
|
||||
* If true, isVolatile will always be false
|
||||
* Determine if this data has explicitly been marked as writable.
|
||||
* NOTE: This is based upon explicit {@link Data} and {@link DataType} mutability settings
|
||||
* and does not reflect independent memory block or processor specification settings.
|
||||
* @return true if data is writable, else false.
|
||||
*/
|
||||
public boolean isWritable();
|
||||
|
||||
/**
|
||||
* Determine if this data has explicitly been marked as volatile.
|
||||
* NOTE: This is based upon explicit {@link Data} and {@link DataType} mutability settings
|
||||
* and does not reflect independent memory block or processor specification settings.
|
||||
* @return true if data is volatile, else false.
|
||||
*/
|
||||
public boolean isVolatile();
|
||||
|
||||
|
@ -285,4 +297,5 @@ public interface Data extends CodeUnit, Settings {
|
|||
* @return the prefix
|
||||
*/
|
||||
public String getDefaultLabelPrefix(DataTypeDisplayOptions options);
|
||||
|
||||
}
|
||||
|
|
|
@ -392,6 +392,11 @@ public class DataStub implements Data {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVolatile() {
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -58,6 +58,9 @@ public class MappedDataEntry extends MappedEntry {
|
|||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
if (data.isWritable()) {
|
||||
return false;
|
||||
}
|
||||
if (data.isConstant()) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue