Skip to content

Commit

Permalink
op.h: Add additional padding to struct opslab to ensure proper alignment
Browse files Browse the repository at this point in the history
On m68k, the natural alignment is 16 bits which causes the opslab_opslot
member of struct opslab to be aligned at a 16-bit offset. Other 32-bit
and 64-bit architectures have a natural alignment of at least 32 bits, so
the offset is always guaranteed to be at least 32-bit-aligned.

Fix this by adding additional padding bytes before the opslab_opslot
member, both for cases when PERL_DEBUG_READONLY_OPS defined and not
defined to ensure the offset of oplab_slots is always 32-bit-aligned.
On architectures which have a natural alignment of at least 32 bits,
the padding does not affect the alignment, offsets or struct size.
  • Loading branch information
glaubitz committed Jun 19, 2020
1 parent 4e8bf9a commit f5e7bec
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions op.h
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,9 @@ struct opslab {
units) */
# ifdef PERL_DEBUG_READONLY_OPS
bool opslab_readonly;
U8 opslab_padding; /* padding to ensure that opslab_slots is always */
# else
U16 opslab_padding; /* located at an offset with 32-bit alignment */
# endif
OPSLOT opslab_slots; /* slots begin here */
};
Expand Down

0 comments on commit f5e7bec

Please sign in to comment.