Skip to content

Ghidra is a software reverse engineering (SRE) framework

global symbol map for HighFunction

caheckmanc886f0158718
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameVariableAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameVariableAction.java
index 368759e32b..8982e208d0 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameVariableAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameVariableAction.java
@@ -27,7 +27,8 @@ import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSpace;
import ghidra.program.model.data.*;
-import ghidra.program.model.listing.*;
+import ghidra.program.model.listing.Function;
+import ghidra.program.model.listing.Program;
import ghidra.program.model.pcode.*;
import ghidra.program.model.symbol.SourceType;
import ghidra.util.Msg;
@@ -83,7 +84,6 @@ public class RenameVariableAction extends AbstractDecompilerAction {
public static HighVariable forgeHighVariable(Address addr, DecompilerController controller) {
HighVariable res = null;
- Program program = controller.getProgram();
HighFunction hfunc = controller.getDecompileData().getHighFunction();
if (addr.isStackAddress()) {
LocalSymbolMap lsym = hfunc.getLocalSymbolMap();
@@ -93,16 +93,10 @@ public class RenameVariableAction extends AbstractDecompilerAction {
}
}
else {
- Data data = program.getListing().getDataAt(addr);
- if (data != null) {
- DataType dt = data.getDataType();
- try {
- res = new HighGlobal(data.getLabel(), dt, new Varnode(addr, dt.getLength()),
- null, hfunc);
- }
- catch (InvalidInputException e) {
- Msg.error(RenameVariableAction.class, e.getMessage());
- }
+ GlobalSymbolMap gsym = hfunc.getGlobalSymbolMap();
+ HighSymbol hsym = gsym.getSymbol(addr);
+ if (hsym != null) {
+ res = hsym.getHighVariable();
}
}
return res;
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/GlobalSymbolMap.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/GlobalSymbolMap.java
new file mode 100644
index 0000000000..b07a0c336e
--- /dev/null
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/GlobalSymbolMap.java
@@ -0,0 +1,106 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.program.model.pcode;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import ghidra.program.database.symbol.CodeSymbol;
+import ghidra.program.model.address.Address;
+import ghidra.program.model.data.DataType;
+import ghidra.program.model.listing.Program;
+import ghidra.program.model.symbol.Symbol;
+import ghidra.program.model.symbol.SymbolTable;
+
+public class GlobalSymbolMap {
+ private Program program;
+ private HighFunction func;
+ private SymbolTable symbolTable;
+ private HashMap<Address, HighCodeSymbol> addrMappedSymbols; // Hashed by addr
+ private HashMap<Long, HighCodeSymbol> symbolMap; // Hashed by unique key
+ private long uniqueSymbolId; // Next available symbol id
+
+ public GlobalSymbolMap(HighFunction f) {
+ program = f.getFunction().getProgram();
+ func = f;
+ symbolTable = program.getSymbolTable();
+ addrMappedSymbols = new HashMap<Address, HighCodeSymbol>();
+ symbolMap = new HashMap<Long, HighCodeSymbol>();
+ uniqueSymbolId = 0;
+ }
+
+ private void insertSymbol(HighCodeSymbol sym, Address addr) {
+ long uniqueId = sym.getId();
+ if ((uniqueId >> 56) == (HighSymbol.ID_BASE >> 56)) {
+ long val = uniqueId & 0x7fffffff;
+ if (val > uniqueSymbolId) {
+ uniqueSymbolId = val;
+ }
+ }
+ symbolMap.put(uniqueId, sym);
+ addrMappedSymbols.put(addr, sym);
+ }
+
+ /**
+ * Create a HighCodeSymbol based on the id of the underlying CodeSymbol. The CodeSymbol
+ * is looked up in the SymbolTable and then a HighSymbol is created with the name and
+ * dataType associated with the CodeSymbol. If a CodeSymbol cannot be found, null is returned.
+ * @param id is the database id of the CodeSymbol
+ * @param dataType is the recovered data-type of the symbol
+ * @param sz is the size in bytes of the desired symbol
+ * @return the CodeSymbol wrapped as a HighSymbol or null
+ */
+ public HighCodeSymbol populateSymbol(long id, DataType dataType, int sz) {
+ if ((id >> 56) == (HighSymbol.ID_BASE >> 56)) {
+ return null; // This is an internal id, not a database key
+ }
+ Symbol symbol = symbolTable.getSymbol(id);
+ if (symbol == null || !(symbol instanceof CodeSymbol)) {
+ return null;
+ }
+ HighCodeSymbol highSym = new HighCodeSymbol((CodeSymbol) symbol, dataType, sz, func);
+ insertSymbol(highSym, symbol.getAddress());
+ return highSym;
+ }
+
+ /**
+ * Create a HighSymbol corresponding to an underlying Data object. The name of the symbol is
+ * generated dynamically. A symbol is always returned unless the address is invalid,
+ * in which case null is returned.
+ * @param id is the id to associate with the new symbol
+ * @param addr is the address of the Data object
+ * @param dataType is the recovered data-type of the symbol
+ * @param sz is the size in bytes of the symbol
+ * @return the new HighSymbol or null
+ */
+ public HighCodeSymbol newSymbol(long id, Address addr, DataType dataType, int sz) {
+ HighCodeSymbol symbol = new HighCodeSymbol(id, addr, dataType, sz, func);
+ insertSymbol(symbol, addr);
+ return symbol;
+ }
+
+ public HighCodeSymbol getSymbol(long id) {
+ return symbolMap.get(id);
+ }
+
+ public HighCodeSymbol getSymbol(Address addr) {
+ return addrMappedSymbols.get(addr);
+ }
+
+ public Iterator<HighCodeSymbol> getSymbols() {
+ return symbolMap.values().iterator();
+ }
+}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighCodeSymbol.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighCodeSymbol.java
new file mode 100644
index 0000000000..fea400be3f
--- /dev/null
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighCodeSymbol.java
@@ -0,0 +1,71 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.program.model.pcode;
+
+import ghidra.program.database.symbol.CodeSymbol;
+import ghidra.program.model.address.Address;
+import ghidra.program.model.data.DataType;
+import ghidra.program.model.listing.Data;
+import ghidra.program.model.symbol.SymbolUtilities;
+import ghidra.xml.XmlPullParser;
+
+/**
+ * Symbol returned by the decompiler that wraps a CodeSymbol
+ */
+public class HighCodeSymbol extends HighSymbol {
+
+ private CodeSymbol symbol;
+ private Data data;
+
+ public HighCodeSymbol(CodeSymbol sym, DataType dataType, int sz, HighFunction func) {
+ super(sym.getID(), sym.getName(), dataType, sz, null, func);
+ symbol = sym;
+ data = null;
+ }
+
+ public HighCodeSymbol(long id, Address addr, DataType dataType, int sz, HighFunction func) {
+ super(id, SymbolUtilities.getDynamicName(func.getFunction().getProgram(), addr), dataType,
+ sz, null, func);
+ symbol = null;
+ data = func.getFunction().getProgram().getListing().getDataAt(addr);
+ }
+
+ public CodeSymbol getCodeSymbol() {
+ return symbol;
+ }
+
+ public Data getData() {
+ if (data == null) {
+ Object dataObj = symbol.getObject();
+ if (dataObj instanceof Data) {
+ data = (Data) dataObj;
+ }
+ }
+ return data;
+ }
+
+ @Override
+ public String buildXML() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void restoreXML(XmlPullParser parser, HighFunction func) throws PcodeXMLException {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighConstant.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighConstant.java
index 91d8365f29..95d6d32c70 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighConstant.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighConstant.java
@@ -19,7 +19,6 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.data.AbstractIntegerDataType;
import ghidra.program.model.data.DataType;
import ghidra.program.model.scalar.Scalar;
-import ghidra.util.exception.InvalidInputException;
/**
*
@@ -38,10 +37,8 @@ public class HighConstant extends HighVariable {
* @param vn constant varnode
* @param pc code unit address where constant is used
* @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) {
super(name, type, vn, null, func);
pcaddr = pc;
}
@@ -53,18 +50,14 @@ public class HighConstant extends HighVariable {
* @param vn constant varnode
* @param pc code unit address where constant is used
* @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) {
this(name, type, vn, pc, sym.getHighFunction());
symbol = sym;
}
- /**
- * @return associated dynamic symbol or null
- */
- public DynamicSymbol getSymbol() {
+ @Override
+ public HighSymbol getSymbol() {
return symbol;
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunction.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunction.java
index a52ab82305..a567d939f5 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunction.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunction.java
@@ -48,6 +48,7 @@ public class HighFunction extends PcodeSyntaxTree {
private CompilerSpec compilerSpec;
private FunctionPrototype proto; // The high-level prototype associated with the function
private LocalSymbolMap localSymbols;
+ private GlobalSymbolMap globalSymbols;
private List<JumpTable> jumpTables;
private List<DataTypeSymbol> protoOverrides;
private boolean showNamespace = true;
@@ -67,6 +68,7 @@ public class HighFunction extends PcodeSyntaxTree {
this.compilerSpec = compilerSpec;
this.showNamespace = showNamespace;
localSymbols = new LocalSymbolMap(this, "stack");
+ globalSymbols = new GlobalSymbolMap(this);
proto = new FunctionPrototype(localSymbols, function);
jumpTables = null;
protoOverrides = null;
@@ -115,6 +117,13 @@ public class HighFunction extends PcodeSyntaxTree {
return localSymbols;
}
+ /**
+ * @return a map describing global variables accessed by this function
+ */
+ public GlobalSymbolMap getGlobalSymbolMap() {
+ return globalSymbols;
+ }
+
public HighSymbol getMappedSymbol(Address addr, Address pcaddr) {
return localSymbols.findLocal(addr, pcaddr);
}
@@ -202,7 +211,7 @@ public class HighFunction extends PcodeSyntaxTree {
private void readHighXML(XmlPullParser parser) throws PcodeXMLException {
XmlElement el = parser.start("high");
String classstring = el.getAttribute("class");
- int symref = SpecXmlUtils.decodeInt(el.getAttribute("symref"));
+ long symref = SpecXmlUtils.decodeLong(el.getAttribute("symref"));
int repref = SpecXmlUtils.decodeInt(el.getAttribute("repref"));
Varnode rep = getRef(repref);
if (rep == null) {
@@ -320,75 +329,84 @@ public class HighFunction extends PcodeSyntaxTree {
parser.end(el);
}
- private HighVariable newHigh(int symref, DataType tp, int sz, Varnode[] inst, Varnode rep,
+ private HighVariable newHigh(long symref, DataType tp, int sz, Varnode[] inst, Varnode rep,
String classstring) throws PcodeXMLException {
- try {
- HighVariable var = null;
- if (classstring.equals("local")) {
- HighSymbol sym = null;
- if (symref != 0) {
- sym = localSymbols.getSymbol(symref);
+ HighVariable var = null;
+ if (classstring.equals("local")) {
+ HighSymbol sym = null;
+ if (symref != 0) {
+ sym = localSymbols.getSymbol(symref);
+ }
+ if (sym != null) {
+ var = sym.getHighVariable();
+ }
+ if (var == null) {
+ if (sym instanceof DynamicSymbol) {
+ // establish HighLocal for DynamicSymbol
+ var = new HighLocal(tp, rep, inst, sym.getPCAddress(), sym);
+ sym.setHighVariable(var);
+ }
+ else {
+ // The variable may be a partial, in which case
+ // we treat it as special
+ var = new HighOther(tp, rep, inst, getPCAddress(rep), this);
}
+ }
+ }
+ else if (classstring.equals("constant")) {
+ HighSymbol sym = null;
+ if (symref != 0) {
+ sym = localSymbols.getSymbol(symref);
if (sym != null) {
var = sym.getHighVariable();
}
- if (var == null) {
- if (sym instanceof DynamicSymbol) {
- // establish HighLocal for DynamicSymbol
- var = new HighLocal(tp, rep, inst, sym.getPCAddress(), sym);
- sym.setHighVariable(var);
- }
- else {
- // The variable may be a partial, in which case
- // we treat it as special
- var = new HighOther(tp, rep, inst, getPCAddress(rep), this);
- }
- }
}
- else if (classstring.equals("constant")) {
- HighSymbol sym = null;
- if (symref != 0) {
- sym = localSymbols.getSymbol(symref);
- if (sym != null) {
- var = sym.getHighVariable();
- }
+ if (var == null) {
+ if (sym instanceof DynamicSymbol) {
+ var = new HighConstant(sym.getName(), tp, rep, getPCAddress(rep),
+ (DynamicSymbol) sym);
+ sym.setHighVariable(var);
}
- if (var == null) {
- if (sym instanceof DynamicSymbol) {
- var = new HighConstant(sym.getName(), tp, rep, getPCAddress(rep),
- (DynamicSymbol) sym);
- sym.setHighVariable(var);
- }
- else {
- var = new HighConstant(null, tp, rep, getPCAddress(rep), this);
- }
+ else {
+ var = new HighConstant(null, tp, rep, getPCAddress(rep), this);
}
}
- else if (classstring.equals("global")) {
-// TODO: should we have access to global symbols
- var = new HighGlobal(null, tp, rep, inst, this);
- }
- else if (classstring.equals("other")) {
-// TODO: How do these compare with local ??
- var = new HighOther(tp, rep, inst, getPCAddress(rep), this);
- }
- else {
- throw new PcodeXMLException("Bad class string: " + classstring);
- }
- if (rep.getSize() == var.getSize()) {
- var.attachInstances(inst, rep);
+ }
+ else if (classstring.equals("global")) {
+ HighCodeSymbol sym = null;
+ if (symref != 0) {
+ sym = globalSymbols.getSymbol(symref);
}
- else { // Make sure varnodes are linked to HighVariable even if not formal instances, why do we do this???
- for (Varnode element : inst) {
- ((VarnodeAST) element).setHigh(var);
+ if (sym == null) {
+ sym = globalSymbols.populateSymbol(symref, tp, sz);
+ if (sym == null) {
+ sym = globalSymbols.newSymbol(symref, rep.getAddress(), tp, sz);
+ if (sym == null) {
+ throw new PcodeXMLException(
+ "Bad global storage: " + rep.getAddress().toString());
+ }
}
}
- var.setHighOnInstances();
- return var;
+ var = new HighGlobal(sym, rep, inst);
+ sym.setHighVariable(var);
}
- catch (InvalidInputException e) {
- throw new PcodeXMLException("Bad storage node", e);
+ else if (classstring.equals("other")) {
+// TODO: How do these compare with local ??
+ var = new HighOther(tp, rep, inst, getPCAddress(rep), this);
+ }
+ else {
+ throw new PcodeXMLException("Bad class string: " + classstring);
+ }
+ if (rep.getSize() == var.getSize()) {
+ var.attachInstances(inst, rep);
+ }
+ else { // Make sure varnodes are linked to HighVariable even if not formal instances, why do we do this???
+ for (Varnode element : inst) {
+ ((VarnodeAST) element).setHigh(var);
+ }
}
+ var.setHighOnInstances();
+ return var;
}
private Address getPCAddress(Varnode rep) {
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighGlobal.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighGlobal.java
index 303abdc29e..f5f3608df1 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighGlobal.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighGlobal.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +15,6 @@
*/
package ghidra.program.model.pcode;
-import ghidra.program.model.data.DataType;
-import ghidra.util.exception.InvalidInputException;
-
/**
*
*
@@ -26,16 +22,15 @@ import ghidra.util.exception.InvalidInputException;
*/
public class HighGlobal extends HighVariable {
- /**
- * @param name name of global variable
- * @param type data type of variable
- * @param vn global variable storage
- * @param func the associated high function
- * @throws InvalidInputException
- */
- public HighGlobal(String name, DataType type, Varnode vn, Varnode[] inst, HighFunction func)
- throws InvalidInputException {
- super(name, type, vn, inst, func);
+ private HighCodeSymbol symbol;
+
+ public HighGlobal(HighCodeSymbol sym, Varnode vn, Varnode[] inst) {
+ super(sym.getName(), sym.getDataType(), vn, inst, sym.getHighFunction());
+ symbol = sym;
}
+ @Override
+ public HighSymbol getSymbol() {
+ return symbol;
+ }
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighLocal.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighLocal.java
index b91d5ed5e9..0573fd6b5a 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighLocal.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighLocal.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,39 +35,11 @@ public class HighLocal extends HighVariable {
symbol = sym;
}
+ @Override
public HighSymbol getSymbol() {
return symbol;
}
-// @Override
-// public void retype(DataType newtype, SourceType srctype) throws InvalidInputException {
-// Function f = getHighFunction().getFunction();
-// Varnode rep = getRepresentative();
-// Program program = f.getProgram();
-// newtype = newtype.clone(program.getDataTypeManager());
-// VariableStorage storage = rep.getStorage(program);
-// VariableStorage newStorage =
-// VariableUtilities.resizeStorage(storage, newtype, true, getHighFunction().getFunction());
-// Varnode newrep = getHighFunction().createFromPieces(newStorage);
-// Varnode[] inst = getInstances();
-// int pos;
-// for (pos = 0; pos < inst.length; ++pos)
-// if (inst[pos] == rep) {
-// inst[pos] = newrep;
-// break;
-// }
-// attachInstances(inst, newrep);
-// try {
-// super.retype(newtype, srctype);
-// }
-// catch (InvalidInputException e) {
-// if (pos < inst.length)
-// inst[pos] = rep;
-// attachInstances(inst, rep); // Restore original varnode
-// throw e;
-// }
-// }
-
/**
* @return instruction address the variable comes into scope within the function
*/
@@ -77,36 +48,12 @@ public class HighLocal extends HighVariable {
}
protected int getFirstUseOffset() {
- Address pcaddr = getPCAddress();
if (pcaddr == null || getRepresentative().getAddress().isStackAddress()) {
return 0;
}
return (int) pcaddr.subtract(getHighFunction().getFunction().getEntryPoint());
}
-// static DataType getUndefinedType(DataType originalType) {
-//
-// // handle pointer conversion
-// if (originalType instanceof Pointer) {
-// Pointer ptr = (Pointer) originalType;
-// DataType innerDt = ptr.getDataType();
-// DataType replacementDt = innerDt;
-// if (!(originalType instanceof Undefined)) {
-// replacementDt = getUndefinedType(innerDt);
-// }
-// if (replacementDt != innerDt) {
-// return new PointerDataType(replacementDt, ptr.getLength(), ptr.getDataTypeManager());
-// }
-// return originalType;
-// }
-//
-// int size = originalType.getLength();
-// if (size <= 8) {
-// return Undefined.getUndefinedDataType(size);
-// }
-// return originalType; // too big for undefined type
-// }
-
@Override
public VariableStorage getStorage() {
@@ -114,9 +61,9 @@ public class HighLocal extends HighVariable {
Varnode represent = getRepresentative();
if (symbol instanceof DynamicSymbol || represent.isUnique()) {
- long hash = buildDynamicHash();
+ long ourHash = buildDynamicHash();
try {
- return new VariableStorage(program, AddressSpace.HASH_SPACE.getAddress(hash),
+ return new VariableStorage(program, AddressSpace.HASH_SPACE.getAddress(ourHash),
represent.getSize());
}
catch (InvalidInputException e) {
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighOther.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighOther.java
index 2eebf27900..4d23124553 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighOther.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighOther.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +17,6 @@ package ghidra.program.model.pcode;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.DataType;
-import ghidra.util.exception.InvalidInputException;
/**
*
@@ -34,13 +32,12 @@ public class HighOther extends HighVariable {
/**
* Construct a unique high NOT associated with a symbol
* @param type data type of variable
- * @param vn variable storage
+ * @param vn is the representative Varnode
+ * @param inst is the list of Varnodes making up the variable
* @param pc code unit address where unique is first assigned (first-use)
* @param func the associated high function
- * @throws InvalidInputException
*/
- public HighOther(DataType type, Varnode vn, Varnode[] inst, Address pc, HighFunction func)
- throws InvalidInputException {
+ public HighOther(DataType type, Varnode vn, Varnode[] inst, Address pc, HighFunction func) {
super(null, type, vn, inst, func);
pcaddr = pc;
}
@@ -48,6 +45,7 @@ public class HighOther extends HighVariable {
/**
* @return associated dynamic symbol or null
*/
+ @Override
public DynamicSymbol getSymbol() {
return symbol;
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighParam.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighParam.java
index 0d42cc4ba7..6dd6e8d818 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighParam.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighParam.java
@@ -28,7 +28,7 @@ public class HighParam extends HighLocal {
/**
* @param tp data type of variable
- * @param rep represented varnode
+ * @param rep is the representative input Varnode
* @param pc null or Address of PcodeOp which defines the representative
* @param slot parameter index starting at 0
* @param sym associated symbol
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighVariable.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighVariable.java
index f5d44f39ca..ae24433b4c 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighVariable.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighVariable.java
@@ -46,9 +46,10 @@ public abstract class HighVariable {
* Link Varnodes directly to this HighVariable
*/
protected void setHighOnInstances() {
- for(int i=0;i<instances.length;++i) {
- if (instances[i] instanceof VarnodeAST)
- ((VarnodeAST)instances[i]).setHigh(this);
+ for (Varnode instance : instances) {
+ if (instance instanceof VarnodeAST) {
+ ((VarnodeAST)instance).setHigh(this);
+ }
}
}
@@ -97,6 +98,12 @@ public abstract class HighVariable {
return instances;
}
+ /**
+ * Retrieve any underlying HighSymbol
+ * @return the HighSymbol
+ */
+ public abstract HighSymbol getSymbol();
+
/**
* Attach an instance or additional location the variable can be found in.
*
@@ -109,8 +116,9 @@ public abstract class HighVariable {
instances = new Varnode[1];
instances[0] = rep;
}
- else
+ else {
instances = inst;
+ }
}
public VariableStorage getStorage() {