mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-3148 More join space overlaps
This commit is contained in:
parent
2a5816cd3b
commit
74e1bbdb57
12 changed files with 168 additions and 69 deletions
|
@ -124,8 +124,62 @@ public class ParamEntry {
|
|||
return spaceid;
|
||||
}
|
||||
|
||||
public Varnode[] getJoinRecord() {
|
||||
return joinrec;
|
||||
/**
|
||||
* Collect pieces from the join list, in endian order, until the given size is covered.
|
||||
* The last piece is trimmed to match the size exactly. If the size is too big to be
|
||||
* covered by this ParamEntry, null is returned.
|
||||
* @param sz is the given size
|
||||
* @return the collected array of Varnodes or null
|
||||
*/
|
||||
public Varnode[] getJoinPieces(int sz) {
|
||||
int num = 0;
|
||||
int first, replace;
|
||||
Varnode vn = null;
|
||||
Varnode[] res;
|
||||
if (isBigEndian()) {
|
||||
first = 0;
|
||||
while (sz > 0) {
|
||||
if (num >= joinrec.length) {
|
||||
return null;
|
||||
}
|
||||
vn = joinrec[num];
|
||||
if (vn.getSize() > sz) {
|
||||
num += 1;
|
||||
break;
|
||||
}
|
||||
sz -= vn.getSize();
|
||||
num += 1;
|
||||
}
|
||||
replace = num - 1;
|
||||
}
|
||||
else {
|
||||
while (sz > 0) {
|
||||
if (num >= joinrec.length) {
|
||||
return null;
|
||||
}
|
||||
vn = joinrec[joinrec.length - 1 - num];
|
||||
if (vn.getSize() > sz) {
|
||||
num += 1;
|
||||
break;
|
||||
}
|
||||
sz -= vn.getSize();
|
||||
num += 1;
|
||||
}
|
||||
first = joinrec.length - num;
|
||||
replace = first;
|
||||
}
|
||||
if (sz == 0 && num == joinrec.length) {
|
||||
return joinrec;
|
||||
}
|
||||
res = new Varnode[num];
|
||||
for (int i = 0; i < num; ++i) {
|
||||
res[i] = joinrec[first + i];
|
||||
}
|
||||
if (sz > 0) {
|
||||
res[replace] = new Varnode(vn.getAddress(), sz);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -118,8 +118,13 @@ public class ParamListStandard implements ParamList {
|
|||
VariableStorage store;
|
||||
try {
|
||||
if (res.space.getType() == AddressSpace.TYPE_JOIN) {
|
||||
Varnode[] pieces = element.getJoinRecord();
|
||||
store = new DynamicVariableStorage(program, false, pieces);
|
||||
Varnode[] pieces = element.getJoinPieces(sz);
|
||||
if (pieces != null) {
|
||||
store = new DynamicVariableStorage(program, false, pieces);
|
||||
}
|
||||
else {
|
||||
store = DynamicVariableStorage.getUnassignedDynamicStorage(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Address addr = res.space.getAddress(res.offset);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue