[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Fix GPT build failure on big-endian architectures
From: |
Colin Watson |
Subject: |
[PATCH] Fix GPT build failure on big-endian architectures |
Date: |
Mon, 22 Nov 2010 23:31:40 +0000 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Big-endian (powerpc or sparc) builds of current trunk fail as follows:
gcc-4.4 -DHAVE_CONFIG_H -I. -I../.. -Wall -W -I./include
-DGRUB_UTIL=1 -DGRUB_LIBDIR=\"/usr/lib/grub\" -DLOCALEDIR=\"/usr/share/locale\"
-DGRUB_MACHINE_IEEE1275=1 -DGRUB_MACHINE_SPARC64=1
-DGRUB_MACHINE=SPARC64_IEEE1275 -DGRUB_FILE=\"grub-core/partmap/gpt.c\" -I.
-I../.. -I. -I../.. -I../../include -I./include
-I../../grub-core/lib/libgcrypt_wrap -I../../contrib/zfs/include
-g -Wall -O2 -Wno-error -Wno-missing-field-initializers
-c -o grub-core/partmap/libgrubmods_a-gpt.o `test -f 'grub-core/partmap/gpt.c'
|| echo '../../'`grub-core/partmap/gpt.c
../../grub-core/partmap/gpt.c:36: error: initializer element is not constant
../../grub-core/partmap/gpt.c:36: error: (near initialization for
'grub_gpt_partition_type_bios_boot.data1')
../../grub-core/partmap/gpt.c:36: error: braced-group within expression
allowed only inside a function
../../grub-core/partmap/gpt.c:36: error: braced-group within expression
allowed only inside a function
make[4]: *** [grub-core/partmap/libgrubmods_a-gpt.o] Error 1
I think a reasonable approach would be to do the byte-swapping at module
initialisation time. Does this patch look OK?
2010-11-22 Colin Watson <address@hidden>
* include/grub/gpt_partition.h (GRUB_GPT_PARTITION_TYPE_BIOS_BOOT):
Remove byte-swapping function calls, which are not valid in
structure initialisers.
* grub-core/partmap/gpt.c (grub_gpt_partition_type_bios_boot): Make
non-const.
(GRUB_MOD_INIT): Byte-swap data1, data2, and data3 fields of
grub_gpt_partition_type_bios_boot.
=== modified file 'grub-core/partmap/gpt.c'
--- grub-core/partmap/gpt.c 2010-09-24 12:05:47 +0000
+++ grub-core/partmap/gpt.c 2010-11-22 17:21:51 +0000
@@ -33,7 +33,7 @@ static grub_uint8_t grub_gpt_magic[8] =
static const grub_gpt_part_type_t grub_gpt_partition_type_empty =
GRUB_GPT_PARTITION_TYPE_EMPTY;
#ifdef GRUB_UTIL
-static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot =
GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
+static grub_gpt_part_type_t grub_gpt_partition_type_bios_boot =
GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
#endif
/* 512 << 7 = 65536 byte sectors. */
@@ -198,6 +198,14 @@ static struct grub_partition_map grub_gp
GRUB_MOD_INIT(part_gpt)
{
grub_partition_map_register (&grub_gpt_partition_map);
+#ifdef GRUB_UTIL
+ grub_gpt_partition_type_bios_boot.data1 =
+ grub_cpu_to_le32 (grub_gpt_partition_type_bios_boot.data1);
+ grub_gpt_partition_type_bios_boot.data2 =
+ grub_cpu_to_le32 (grub_gpt_partition_type_bios_boot.data2);
+ grub_gpt_partition_type_bios_boot.data3 =
+ grub_cpu_to_le32 (grub_gpt_partition_type_bios_boot.data3);
+#endif
}
GRUB_MOD_FINI(part_gpt)
=== modified file 'include/grub/gpt_partition.h'
--- include/grub/gpt_partition.h 2009-04-19 20:38:46 +0000
+++ include/grub/gpt_partition.h 2010-11-22 17:21:21 +0000
@@ -36,7 +36,7 @@ typedef struct grub_gpt_part_type grub_g
}
#define GRUB_GPT_PARTITION_TYPE_BIOS_BOOT \
- { grub_cpu_to_le32 (0x21686148), grub_cpu_to_le16 (0x6449), grub_cpu_to_le16
(0x6e6f), \
+ { 0x21686148, 0x6449, 0x6e6f, \
{ 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } \
}
--
Colin Watson address@hidden
- [PATCH] Fix GPT build failure on big-endian architectures,
Colin Watson <=