Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From 563b1da6e6ae7af46cc8354cadb5dab416989f0a Mon Sep 17 00:00:00 2001 |
| 2 | From: Michael Chang <mchang@suse.com> |
| 3 | Date: Mon, 26 Mar 2018 16:52:34 +0800 |
| 4 | Subject: Fix packed-not-aligned error on GCC 8 |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | When building with GCC 8, there are several errors regarding packed-not-aligned. |
| 10 | |
| 11 | ./include/grub/gpt_partition.h:79:1: error: alignment 1 of ‘struct grub_gpt_partentry’ is less than 8 [-Werror=packed-not-aligned] |
| 12 | |
| 13 | This patch fixes the build error by cleaning up the ambiguity of placing |
| 14 | aligned structure in a packed one. In "struct grub_btrfs_time" and "struct |
| 15 | grub_gpt_part_type", the aligned attribute seems to be superfluous, and also |
| 16 | has to be packed, to ensure the structure is bit-to-bit mapped to the format |
| 17 | laid on disk. I think we could blame to copy and paste error here for the |
| 18 | mistake. In "struct efi_variable", we have to use grub_efi_packed_guid_t, as |
| 19 | the name suggests. :) |
| 20 | |
| 21 | Signed-off-by: Michael Chang <mchang@suse.com> |
| 22 | Tested-by: Michael Chang <mchang@suse.com> |
| 23 | Tested-by: Paul Menzel <paulepanter@users.sourceforge.net> |
| 24 | Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> |
| 25 | |
| 26 | Upstream-Status: Backport http://git.savannah.gnu.org/cgit/grub.git/commit/?id=563b1da6e6ae7af46cc8354cadb5dab416989f0a |
| 27 | --- |
| 28 | grub-core/fs/btrfs.c | 2 +- |
| 29 | include/grub/efiemu/runtime.h | 2 +- |
| 30 | include/grub/gpt_partition.h | 2 +- |
| 31 | 3 files changed, 3 insertions(+), 3 deletions(-) |
| 32 | |
| 33 | diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c |
| 34 | index 4849c1c..be19544 100644 |
| 35 | --- a/grub-core/fs/btrfs.c |
| 36 | +++ b/grub-core/fs/btrfs.c |
| 37 | @@ -175,7 +175,7 @@ struct grub_btrfs_time |
| 38 | { |
| 39 | grub_int64_t sec; |
| 40 | grub_uint32_t nanosec; |
| 41 | -} __attribute__ ((aligned (4))); |
| 42 | +} GRUB_PACKED; |
| 43 | |
| 44 | struct grub_btrfs_inode |
| 45 | { |
| 46 | diff --git a/include/grub/efiemu/runtime.h b/include/grub/efiemu/runtime.h |
| 47 | index 9b6b729..36d2ded 100644 |
| 48 | --- a/include/grub/efiemu/runtime.h |
| 49 | +++ b/include/grub/efiemu/runtime.h |
| 50 | @@ -29,7 +29,7 @@ struct grub_efiemu_ptv_rel |
| 51 | |
| 52 | struct efi_variable |
| 53 | { |
| 54 | - grub_efi_guid_t guid; |
| 55 | + grub_efi_packed_guid_t guid; |
| 56 | grub_uint32_t namelen; |
| 57 | grub_uint32_t size; |
| 58 | grub_efi_uint32_t attributes; |
| 59 | diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h |
| 60 | index 1b32f67..9668a68 100644 |
| 61 | --- a/include/grub/gpt_partition.h |
| 62 | +++ b/include/grub/gpt_partition.h |
| 63 | @@ -28,7 +28,7 @@ struct grub_gpt_part_type |
| 64 | grub_uint16_t data2; |
| 65 | grub_uint16_t data3; |
| 66 | grub_uint8_t data4[8]; |
| 67 | -} __attribute__ ((aligned(8))); |
| 68 | +} GRUB_PACKED; |
| 69 | typedef struct grub_gpt_part_type grub_gpt_part_type_t; |
| 70 | |
| 71 | #define GRUB_GPT_PARTITION_TYPE_EMPTY \ |
| 72 | -- |
| 73 | cgit v1.0-41-gc330 |
| 74 | |