On 6/19/20 8:37 AM, John Paul Adrian Glaubitz wrote: > On 6/19/20 8:22 AM, John Paul Adrian Glaubitz wrote: >> The attached patch fixes the problem by adding an additional 16 bits padding >> before the opslot member which causes the alignment of opslot to be 32 bits. > > Attaching a patch with a better commit message for explanation.
Third version of the patch which includes Laurent's and Geert's feedback and which is hopefully the version that gets merged upstream. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - [email protected] `. `' Freie Universitaet Berlin - [email protected] `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
>From 89acf85c3c8943081b5dcd5d3c8bcc2384d8f8b7 Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz <[email protected]> Date: Fri, 19 Jun 2020 16:40:38 +0200 Subject: [PATCH] op.h: Add additional padding to struct opslab to ensure proper alignment 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. --- AUTHORS | 1 + op.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/AUTHORS b/AUTHORS index 1a4680027f..e4ea405d98 100644 --- a/AUTHORS +++ b/AUTHORS @@ -651,6 +651,7 @@ John Macdonald <[email protected]> John Malmberg <[email protected]> John Nolan <[email protected]> John P. Linderman <[email protected]> +John Paul Adrian Glaubitz <[email protected]> John Peacock <[email protected]> John Pfuntner <[email protected]> John Poltorak <[email protected]> diff --git a/op.h b/op.h index fc21f03cda..b9f6da82c9 100644 --- a/op.h +++ b/op.h @@ -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 */ }; -- 2.27.0

