mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
Added bias to resizeStackVarnode calculation, fixed big endian resizing
This commit is contained in:
parent
fdcf0744ec
commit
4c4623bbf4
1 changed files with 18 additions and 5 deletions
|
@ -446,14 +446,17 @@ public class VariableUtilities {
|
||||||
// complex data-type: always left align
|
// complex data-type: always left align
|
||||||
// simple data-type: right align within minimum number of aligned cells
|
// simple data-type: right align within minimum number of aligned cells
|
||||||
|
|
||||||
int endStackOffset = stackOffset + varnode.getSize() - 1;
|
|
||||||
int stackAlign = stackAttributes.stackAlign;
|
int stackAlign = stackAttributes.stackAlign;
|
||||||
|
|
||||||
if (endStackOffset % stackAlign != 0) {
|
if ((stackOffset + varnode.getSize() - stackAttributes.bias) % stackAlign != 0) {
|
||||||
stackAlign = 1; // was not aligned to start with
|
stackAlign = 1; // was not aligned to start with
|
||||||
}
|
}
|
||||||
|
|
||||||
newStackOffset -= newStackOffset % stackAlign; // left-alignment of start offset
|
int newAlign = (newStackOffset - stackAttributes.bias) % stackAlign;
|
||||||
|
if (newAlign < 0) {
|
||||||
|
newAlign += stackAlign;
|
||||||
|
}
|
||||||
|
newStackOffset -= newAlign; // left-alignment of start offset
|
||||||
if (!complexDt) {
|
if (!complexDt) {
|
||||||
// right-align non-complex data
|
// right-align non-complex data
|
||||||
int cellExcess = newVarnodeSize % stackAlign;
|
int cellExcess = newVarnodeSize % stackAlign;
|
||||||
|
@ -475,10 +478,12 @@ public class VariableUtilities {
|
||||||
private static class StackAttributes {
|
private static class StackAttributes {
|
||||||
|
|
||||||
final int stackAlign;
|
final int stackAlign;
|
||||||
|
final int bias;
|
||||||
final boolean rightJustify; // only applies to primitives
|
final boolean rightJustify; // only applies to primitives
|
||||||
|
|
||||||
public StackAttributes(int stackAlign, boolean rightJustify) {
|
public StackAttributes(int stackAlign, int bias, boolean rightJustify) {
|
||||||
this.stackAlign = stackAlign;
|
this.stackAlign = stackAlign;
|
||||||
|
this.bias = bias;
|
||||||
this.rightJustify = rightJustify;
|
this.rightJustify = rightJustify;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,7 +500,15 @@ public class VariableUtilities {
|
||||||
if (stackAlign < 0) {
|
if (stackAlign < 0) {
|
||||||
stackAlign = 1;
|
stackAlign = 1;
|
||||||
}
|
}
|
||||||
return new StackAttributes(stackAlign, rightJustify);
|
int bias = 0;
|
||||||
|
Long stackBase = callingConvention.getStackParameterOffset();
|
||||||
|
if (stackBase != null) {
|
||||||
|
bias = (int) (stackBase.longValue() % stackAlign);
|
||||||
|
if (bias < 0) {
|
||||||
|
bias += stackAlign;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new StackAttributes(stackAlign, bias, rightJustify);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue