]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/pcre2/0001-fix-heapframe-alignment.patch
pcre2: add patch fixing a build issue on m68k
[coffee/buildroot.git] / package / pcre2 / 0001-fix-heapframe-alignment.patch
1 src/pcre2_intmodedep.h: fix alignment of fields in struct heapframe
2
3 pcre2_intmodedep.h has a check to verify that the size of the struct
4 heapframe is a multiple of 4 bytes. On most architectures this works
5 fine, but not on m68k. Indeed, when building the 16-bit variant of
6 pcre2, the heapframe structure contains:
7
8  PCRE2_UCHAR occu[2];
9  PCRE2_SPTR  eptr;
10
11 Where PCRE2_UCHAR is a 16-bit data type, and PCRE2_SPTR is a
12 pointer. The occu[] array starts at byte 0x32, so not aligned on a
13 32-bit boundary. With 2 x 16-bit, the occur[] array ends at byte 0x36.
14
15 Now, on most architectures, the alignment required for a pointer will
16 make the eptr field start at 0x38 (on 32 bit architectures). However,
17 on m68k, it is fine to have a pointer aligned only on a 16-bit
18 boundary, and the eptr pointer will be at offset 0x36.
19
20 This doesn't cause a problem per-se, but breaks the check that
21 heapframe should be a multiple of 4 bytes.
22
23 To fix this, we make sure eptr is aligned by introducing an unused
24 field of 16 bits after the occu[] array (in the 16-bit variant) or
25 after the occu[] array (in the 32-bit variant). These choices have
26 been made to keep the structure layout unchanged.
27
28 Fixes the following build failure on m68k:
29
30 src/pcre2_intmodedep.h:818:14: error: size of array 'check_heapframe_size' is negative
31  typedef char check_heapframe_size[
32               ^~~~~~~~~~~~~~~~~~~~
33
34 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
35 Upstream: https://bugs.exim.org/show_bug.cgi?id=2247
36
37 Index: src/pcre2_intmodedep.h
38 ===================================================================
39 --- a/src/pcre2_intmodedep.h    (revision 923)
40 +++ b/src/pcre2_intmodedep.h    (working copy)
41 @@ -797,7 +797,9 @@
42    PCRE2_UCHAR occu[6];       /* Used for other case code units */
43  #elif PCRE2_CODE_UNIT_WIDTH == 16
44    PCRE2_UCHAR occu[2];       /* Used for other case code units */
45 +  uint8_t     unused[2];     /* Ensure 32 bit alignment */
46  #else
47 +  uint8_t     unused[2];     /* Ensure 32 bit alignment */
48    PCRE2_UCHAR occu[1];       /* Used for other case code units */
49  #endif