diff options
author | H. Peter Anvin <hpa@zytor.com> | 2012-02-29 02:36:21 -0500 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2012-02-29 02:40:56 -0500 |
commit | a51f4047758d2bcd099ea113b833ed380f4024ba (patch) | |
tree | 43864a956b592934bc3ba1775c2d7d6aec539d97 /arch/x86/boot | |
parent | b8d43cb504a94f1070159a37c8cb23008276eff3 (diff) |
x86, build: Fix portability issues when cross-building
It would appear that we never actually generated a correct CRC when
building on a bigendian machine. Depending on the word size, we would
either generate an all-zero CRC (64-bit machine) or a byte-swapped
CRC (32-bit machine.) Fix the types used so we don't arbitrarily use
a 64-bit word to hold 32-bit numbers, and pass the CRC through
put_unaligned_le32() like all the other numbers.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Matt Fleming <matt@console-pimps.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Bowler <nbowler@elliptictech.com>
Link: http://lkml.kernel.org/r/20120229111322.9eb4b23ff1672e8853ad3b3b@canb.auug.org.au
Diffstat (limited to 'arch/x86/boot')
-rw-r--r-- | arch/x86/boot/tools/build.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index f3bd2e676d2a..ed549767a231 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c | |||
@@ -36,7 +36,7 @@ | |||
36 | 36 | ||
37 | typedef unsigned char u8; | 37 | typedef unsigned char u8; |
38 | typedef unsigned short u16; | 38 | typedef unsigned short u16; |
39 | typedef unsigned long u32; | 39 | typedef unsigned int u32; |
40 | 40 | ||
41 | #define DEFAULT_MAJOR_ROOT 0 | 41 | #define DEFAULT_MAJOR_ROOT 0 |
42 | #define DEFAULT_MINOR_ROOT 0 | 42 | #define DEFAULT_MINOR_ROOT 0 |
@@ -247,8 +247,9 @@ int main(int argc, char ** argv) | |||
247 | } | 247 | } |
248 | 248 | ||
249 | /* Write the CRC */ | 249 | /* Write the CRC */ |
250 | fprintf(stderr, "CRC %lx\n", crc); | 250 | fprintf(stderr, "CRC %x\n", crc); |
251 | if (fwrite(&crc, 1, 4, stdout) != 4) | 251 | put_unaligned_le32(crc, buf); |
252 | if (fwrite(buf, 1, 4, stdout) != 4) | ||
252 | die("Writing CRC failed"); | 253 | die("Writing CRC failed"); |
253 | 254 | ||
254 | close(fd); | 255 | close(fd); |