linux-kernel@vger.rutgers.edu

Wingerde van GR (gertjan@cs.vu.nl)
Fri, 5 Jul 1996 19:09:31 +0200 (MET DST)


Hi,

The following patch fixes some cross compilation problems in the build
program when configured to build large kernels. It corrects the values
of some constants (to form little endian values) and fixes some alignment
problems on processors with other alignment constraints than the Intel x86.
(i.e. Sparc architecture)

My own tests has showed that it at least works on native x86 compilation
and on a cross compilation on a Sparc.

Gertjan

-- start patch
diff -u linux/arch/i386/boot/tools/build.c.bak linux/arch/i386/boot/tools/build.c
--- linux/arch/i386/boot/tools/build.c.bak Thu Jul 4 13:12:33 1996
+++ linux/arch/i386/boot/tools/build.c Thu Jul 4 13:23:42 1996
@@ -19,6 +19,7 @@
/*
* Changes by tytso to allow root device specification
* High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
+ * Cross compiling fixes by Gertjan van Wingerde, July 1996
*/

#include <stdio.h> /* fprintf */
@@ -56,6 +57,7 @@
#define STRINGIFY(x) #x

typedef union {
+ int i;
long l;
short s[2];
char b[4];
@@ -72,6 +74,17 @@
return t.l;
}

+int intel_int(int i)
+{
+ conv t;
+
+ t.b[0] = i & 0xff; i >>= 8;
+ t.b[1] = i & 0xff; i >>= 8;
+ t.b[2] = i & 0xff; i >>= 8;
+ t.b[3] = i & 0xff; i >>= 8;
+ return t.i;
+}
+
short intel_short(short l)
{
conv t;
@@ -94,8 +107,8 @@

int main(int argc, char ** argv)
{
- int i,c,id, sz;
- unsigned long sys_size;
+ int i,c,id,sz,tmp_int;
+ unsigned long sys_size, tmp_long;
char buf[1024];
#ifndef __BFD__
struct exec *ex = (struct exec *)buf;
@@ -180,12 +193,17 @@
#ifdef __BIG_KERNEL__
{
if (!i) {
- if (*((long *)(&buf[2])) != 0x53726448 )
+ /* Working with memcpy because of alignment constraints
+ on Sparc - Gertjan */
+ memcpy(&tmp_long, &buf[2], sizeof(long));
+ if (tmp_long != intel_long(0x53726448) )
die("Wrong magic in loader header of 'setup'");
- if (*((int *)(&buf[6])) < 0x200 )
+ memcpy(&tmp_int, &buf[6], sizeof(int));
+ if (tmp_int < intel_int(0x200))
die("Wrong version of loader header of 'setup'");
buf[0x11] = 1; /* LOADED_HIGH */
- *((long *)(&buf[0x14])) = 0x100000; /* code32_start */
+ tmp_long = intel_long(0x100000);
+ memcpy(&buf[0x14], &tmp_long, sizeof(long)); /* code32_start */
}
#endif
if (write(1,buf,c)!=c)
-- end patch

-- 

Gertjan van Wingerde home address: Student Computer Science Vrije Universiteit J.H. Dunantstraat 44 Amsterdam 1561 BD Krommenie The Netherlands

e-mail: gertjan@cs.vu.nl URL: http://www.cs.vu.nl/~gertjan/