mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
fix static field alignment calculation
The previous code caused overlap between 64-bit fields and subsequent fields under certain circumstances on 32-bit systems.
This commit is contained in:
parent
9a50e69587
commit
674c560494
@ -502,10 +502,8 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fieldFlags(t, field) & ACC_STATIC) {
|
if (fieldFlags(t, field) & ACC_STATIC) {
|
||||||
unsigned excess = (targetStaticOffset % targetSize)
|
while (targetStaticOffset % targetSize) {
|
||||||
% TargetBytesPerWord;
|
++ targetStaticOffset;
|
||||||
if (excess) {
|
|
||||||
targetStaticOffset += TargetBytesPerWord - excess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildStaticOffset = fieldOffset(t, field);
|
buildStaticOffset = fieldOffset(t, field);
|
||||||
|
@ -1164,9 +1164,8 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
|
|
||||||
unsigned size = fieldSize(t, code);
|
unsigned size = fieldSize(t, code);
|
||||||
if (flags & ACC_STATIC) {
|
if (flags & ACC_STATIC) {
|
||||||
unsigned excess = (staticOffset % size) % BytesPerWord;
|
while (staticOffset % size) {
|
||||||
if (excess) {
|
++ staticOffset;
|
||||||
staticOffset += BytesPerWord - excess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldOffset(t, field) = staticOffset;
|
fieldOffset(t, field) = staticOffset;
|
||||||
@ -1205,9 +1204,8 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
|
|
||||||
for (unsigned i = 0, offset = 0; i < staticCount; ++i) {
|
for (unsigned i = 0, offset = 0; i < staticCount; ++i) {
|
||||||
unsigned size = fieldSize(t, RUNTIME_ARRAY_BODY(staticTypes)[i]);
|
unsigned size = fieldSize(t, RUNTIME_ARRAY_BODY(staticTypes)[i]);
|
||||||
unsigned excess = offset % size;
|
while (offset % size) {
|
||||||
if (excess) {
|
++ offset;
|
||||||
offset += BytesPerWord - excess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned value = intArrayBody(t, staticValueTable, i);
|
unsigned value = intArrayBody(t, staticValueTable, i);
|
||||||
|
Loading…
Reference in New Issue
Block a user