mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-5295 Refactor HighCodeSymbol instantiation for consistency and
correct use of improperly sized VariableStorage
This commit is contained in:
parent
3bfcb8695f
commit
f68246ec17
2 changed files with 32 additions and 41 deletions
|
@ -87,18 +87,7 @@ public class GlobalSymbolMap {
|
||||||
}
|
}
|
||||||
HighSymbol highSym = null;
|
HighSymbol highSym = null;
|
||||||
if (symbol instanceof CodeSymbol) {
|
if (symbol instanceof CodeSymbol) {
|
||||||
if (dataType == null) {
|
highSym = new HighCodeSymbol((CodeSymbol) symbol, func);
|
||||||
Object dataObj = symbol.getObject();
|
|
||||||
if (dataObj instanceof Data) {
|
|
||||||
dataType = ((Data) dataObj).getDataType();
|
|
||||||
sz = dataType.getLength();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dataType = DataType.DEFAULT;
|
|
||||||
sz = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
highSym = new HighCodeSymbol((CodeSymbol) symbol, dataType, sz, func);
|
|
||||||
}
|
}
|
||||||
else if (symbol instanceof FunctionSymbol) {
|
else if (symbol instanceof FunctionSymbol) {
|
||||||
highSym = new HighFunctionShellSymbol(id, symbol.getName(), symbol.getAddress(),
|
highSym = new HighFunctionShellSymbol(id, symbol.getName(), symbol.getAddress(),
|
||||||
|
@ -127,15 +116,7 @@ public class GlobalSymbolMap {
|
||||||
}
|
}
|
||||||
HighSymbol highSym;
|
HighSymbol highSym;
|
||||||
if (symbol instanceof CodeSymbol) {
|
if (symbol instanceof CodeSymbol) {
|
||||||
Data dataAt = program.getListing().getDataAt(addr);
|
highSym = new HighCodeSymbol((CodeSymbol) symbol, func);
|
||||||
DataType dataType = DataType.DEFAULT;
|
|
||||||
int sz = 1;
|
|
||||||
if (dataAt != null) {
|
|
||||||
dataType = dataAt.getDataType();
|
|
||||||
sz = dataAt.getLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
highSym = new HighCodeSymbol((CodeSymbol) symbol, dataType, sz, func);
|
|
||||||
}
|
}
|
||||||
else if (symbol instanceof FunctionSymbol) {
|
else if (symbol instanceof FunctionSymbol) {
|
||||||
highSym = new HighFunctionShellSymbol(symbol.getID(), symbol.getName(),
|
highSym = new HighFunctionShellSymbol(symbol.getID(), symbol.getName(),
|
||||||
|
|
|
@ -40,30 +40,40 @@ public class HighCodeSymbol extends HighSymbol {
|
||||||
* @param sz is the storage size, in bytes, of the symbol
|
* @param sz is the storage size, in bytes, of the symbol
|
||||||
* @param func is the decompiler function model owning the new HighSymbol
|
* @param func is the decompiler function model owning the new HighSymbol
|
||||||
*/
|
*/
|
||||||
public HighCodeSymbol(CodeSymbol sym, DataType dataType, int sz, HighFunction func) {
|
public HighCodeSymbol(CodeSymbol sym, HighFunction func) {
|
||||||
super(sym.getID(), sym.getName(), dataType, func);
|
super(sym.getID(), sym.getName(), null, func);
|
||||||
symbol = sym;
|
symbol = sym;
|
||||||
setNameLock(true);
|
setNameLock(true);
|
||||||
setTypeLock(true);
|
setTypeLock(true);
|
||||||
Data data = null;
|
|
||||||
|
SymbolEntry entry;
|
||||||
|
|
||||||
|
// NOTE: Use of symbol.getObject return Data at the symbol address if it is at the start
|
||||||
|
// of a Data code unit, the lowest level non-composite/primitive DataComponent, or null
|
||||||
|
// if offcut or non-data
|
||||||
Object dataObj = symbol.getObject();
|
Object dataObj = symbol.getObject();
|
||||||
if (dataObj instanceof Data) {
|
if (dataObj instanceof Data data) {
|
||||||
data = (Data) dataObj;
|
data = (Data) dataObj;
|
||||||
|
type = data.getDataType();
|
||||||
|
int size = type.getLength();
|
||||||
|
if (size <= 0) {
|
||||||
|
size = data.getLength();
|
||||||
}
|
}
|
||||||
VariableStorage store;
|
|
||||||
|
VariableStorage store = VariableStorage.UNASSIGNED_STORAGE;
|
||||||
try {
|
try {
|
||||||
store = new VariableStorage(symbol.getProgram(), symbol.getAddress(), sz);
|
store = new VariableStorage(symbol.getProgram(), symbol.getAddress(), size);
|
||||||
}
|
}
|
||||||
catch (InvalidInputException e) {
|
catch (InvalidInputException e) {
|
||||||
store = VariableStorage.UNASSIGNED_STORAGE;
|
// ignore
|
||||||
}
|
}
|
||||||
SymbolEntry entry;
|
|
||||||
if (data != null) {
|
|
||||||
entry = new MappedDataEntry(this, store, data);
|
entry = new MappedDataEntry(this, store, data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
entry = new MappedEntry(this, store, null);
|
type = DataType.DEFAULT;
|
||||||
|
entry = new MappedEntry(this, VariableStorage.UNASSIGNED_STORAGE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
addMapEntry(entry);
|
addMapEntry(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue