Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1PKfs5-0001VT-Sl for mharc-grub-devel@gnu.org; Mon, 22 Nov 2010 18:32:29 -0500 Received: from [140.186.70.92] (port=53296 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKfs0-0001Ri-0I for grub-devel@gnu.org; Mon, 22 Nov 2010 18:32:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PKfrN-0006Pw-8s for grub-devel@gnu.org; Mon, 22 Nov 2010 18:32:23 -0500 Received: from smarthost01.mail.zen.net.uk ([212.23.3.140]:55318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PKfrN-0006Pj-08 for grub-devel@gnu.org; Mon, 22 Nov 2010 18:31:45 -0500 Received: from [82.69.40.219] (helo=riva.pelham.vpn.ucam.org) by smarthost01.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1PKfrL-0005uU-CR for grub-devel@gnu.org; Mon, 22 Nov 2010 23:31:43 +0000 Received: from cjwatson by riva.pelham.vpn.ucam.org with local (Exim 3.36 #1 (Debian)) for grub-devel@gnu.org id 1PKfrJ-0007SO-00; Mon, 22 Nov 2010 23:31:41 +0000 Date: Mon, 22 Nov 2010 23:31:40 +0000 From: Colin Watson To: grub-devel@gnu.org Message-ID: <20101122233140.GC21862@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Originating-Smarthost01-IP: [82.69.40.219] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [PATCH] Fix GPT build failure on big-endian architectures X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Nov 2010 23:32:28 -0000 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 * 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]