GP-3873 Data-type alignment support in decompiler

This commit is contained in:
caheckman 2023-09-22 16:08:18 +00:00
parent 6508088623
commit 64a58bdeab
29 changed files with 456 additions and 149 deletions

View file

@ -342,10 +342,11 @@ public class ParamEntry {
* there are not enough slots left
* @param slotnum number of slots already assigned
* @param sz number of bytes to being assigned
* @param typeAlign required byte alignment for the parameter
* @param res the final storage address
* @return slotnum plus the number of slots used
*/
public int getAddrBySlot(int slotnum, int sz, VarnodeData res) {
public int getAddrBySlot(int slotnum, int sz, int typeAlign, VarnodeData res) {
res.space = null; // Start with an invalid result
int spaceused;
if (sz < minsize) {
@ -366,6 +367,12 @@ public class ParamEntry {
}
}
else {
if (typeAlign > alignment) {
int tmp = (slotnum * alignment) % typeAlign;
if (tmp != 0) {
slotnum += (typeAlign - tmp) / alignment; // Waste slots to achieve typeAlign
}
}
int slotsused = sz / alignment; // How many slots does a -sz- byte object need
if ((sz % alignment) != 0) {
slotsused += 1;

View file

@ -98,7 +98,8 @@ public class ParamListStandard implements ParamList {
}
VarnodeData res = new VarnodeData();
status[grp] = element.getAddrBySlot(status[grp], tp.getLength(), res);
status[grp] =
element.getAddrBySlot(status[grp], tp.getAlignedLength(), tp.getAlignment(), res);
if (res.space == null) {
continue; // -tp- does not fit in this entry
}