* [PATCH] Fix GPT build failure on big-endian architectures
@ 2010-11-22 23:31 Colin Watson
2010-11-23 10:49 ` Colin Watson
0 siblings, 1 reply; 2+ messages in thread
From: Colin Watson @ 2010-11-22 23:31 UTC (permalink / raw)
To: grub-devel
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 <cjwatson@ubuntu.com>
* 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 [cjwatson@ubuntu.com]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix GPT build failure on big-endian architectures
2010-11-22 23:31 [PATCH] Fix GPT build failure on big-endian architectures Colin Watson
@ 2010-11-23 10:49 ` Colin Watson
0 siblings, 0 replies; 2+ messages in thread
From: Colin Watson @ 2010-11-23 10:49 UTC (permalink / raw)
To: grub-devel
On Mon, Nov 22, 2010 at 11:31:40PM +0000, Colin Watson wrote:
> @@ -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)
>
Of course the second and third of these should have been
grub_cpu_to_le16.
I've gone ahead and applied this, with that correction; please do
correct me if you notice anything else wrong with it.
--
Colin Watson [cjwatson@ubuntu.com]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-23 10:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-22 23:31 [PATCH] Fix GPT build failure on big-endian architectures Colin Watson
2010-11-23 10:49 ` Colin Watson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).