mirror of
https://github.com/corda/corda.git
synced 2025-01-05 20:54:13 +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) {
|
||||
unsigned excess = (targetStaticOffset % targetSize)
|
||||
% TargetBytesPerWord;
|
||||
if (excess) {
|
||||
targetStaticOffset += TargetBytesPerWord - excess;
|
||||
while (targetStaticOffset % targetSize) {
|
||||
++ targetStaticOffset;
|
||||
}
|
||||
|
||||
buildStaticOffset = fieldOffset(t, field);
|
||||
|
@ -1164,9 +1164,8 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
||||
|
||||
unsigned size = fieldSize(t, code);
|
||||
if (flags & ACC_STATIC) {
|
||||
unsigned excess = (staticOffset % size) % BytesPerWord;
|
||||
if (excess) {
|
||||
staticOffset += BytesPerWord - excess;
|
||||
while (staticOffset % size) {
|
||||
++ 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) {
|
||||
unsigned size = fieldSize(t, RUNTIME_ARRAY_BODY(staticTypes)[i]);
|
||||
unsigned excess = offset % size;
|
||||
if (excess) {
|
||||
offset += BytesPerWord - excess;
|
||||
while (offset % size) {
|
||||
++ offset;
|
||||
}
|
||||
|
||||
unsigned value = intArrayBody(t, staticValueTable, i);
|
||||
|
Loading…
Reference in New Issue
Block a user