[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Creating sparc64 installation images



    
    So, I just started right away with silo from git and the build initially
    failed with "-m32" which was still in the debian package's
    configuration. I used the most recent silo package for "sparc" and
    updated the source from git. Then enabled the build for "sparc64" and
    removed "-m32" and got this far:
    
    > https://people.debian.org/~glaubitz/silo_1.4.14+git20141019-1.build
    
    gcc -Os -Wall -I. -I../include -fomit-frame-pointer -fno-strict-aliasing
    -DSMALL_RELOC=0x280000 -DLARGE_RELOC=0x380000 -fno-stack-protector -c
    divdi3.S
    divdi3.S: Assembler messages:
    divdi3.S:105: Error: detected global register use not covered by
    .register pseudo-op
    
    Any suggestions?

Please make sure you have all the patches below applied.  They not only
port the assembly from v8+ to v9, but also fix some runtime problems
with sign extensions, structure packing and others.

diff -u -r silo-1.4.14/Rules.make silo-1.4.14-foo/Rules.make
--- silo-1.4.14/Rules.make	2013-05-14 14:06:46.302000002 +0200
+++ silo-1.4.14-foo/Rules.make	2013-05-14 14:07:44.057000002 +0200
@@ -2,9 +2,9 @@
 IMGVERSION=0.99
 SHELL=/bin/bash
 RM=rm -f
-# We want to force 32-bit builds
-CC=gcc -static -m32
-LD=ld -static -m elf32_sparc
+# We want to force 64-bit builds
+CC=gcc
+LD=ld -m elf64_sparc
 AS=as
 STRIP=strip
 NM=nm
diff -r -u silo-1.4.14/common/jmp.S silo-1.4.14-bias/common/jmp.S
--- silo-1.4.14/common/jmp.S	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14-bias/common/jmp.S	2013-05-22 15:09:54.465000000 +0200
@@ -18,7 +18,13 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */
 
-#define _SV save %sp, -0x40, %sp
+#if __WORDSIZE == 32
+# define STACK_BIAS 0
+#else	
+# define STACK_BIAS 2047
+#endif
+	
+#define _SV save %sp, -STACK_BIAS-0x40, %sp
 #define _RV restore
 #define FLUSH_ALL_WINDOWS \
 	_SV; _SV; _SV; _SV; _SV; _SV; _SV; \
@@ -46,7 +52,7 @@
 	FLUSH_ALL_WINDOWS
 	ld [%o0], %o7		/* Return PC.  */
 	ld [%o0 + 4], %fp	/* Saved SP.  */
-	sub %fp, 64, %sp	/* Allocate a register save area.  */
+	sub %fp, 64+STACK_BIAS, %sp	/* Allocate a register save area.  */
 	tst %o1
 	be,a 1f
 	mov 1, %o1
diff -r -u silo-1.4.14/common/divdi3.S silo-1.4.14-bias/common/divdi3.S
--- silo-1.4.14/common/divdi3.S	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14-bias/common/divdi3.S	2013-05-22 15:09:47.457000000 +0200
@@ -17,9 +17,18 @@
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#if __WORDSIZE == 32
+# define STACK_BIAS 0
+#else	
+#define STACK_BIAS 2047
+#endif
+	
 	.data
 	.align 8
 	.globl	__clz_tab
+	.register %g2,#scratch
+	.register %g3,#scratch
+
 __clz_tab:
 	.byte	0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
 	.byte	6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6
@@ -36,7 +45,7 @@
 	.align 4
 	.globl __divdi3
 __divdi3:
-	save %sp,-104,%sp
+	save %sp,-STACK_BIAS-104,%sp
 	cmp %i0,0
 	bge .LL40
 	mov 0,%l4
diff -r -u silo-1.4.14/common/udivdi3.S silo-1.4.14-bias/common/udivdi3.S
--- silo-1.4.14/common/udivdi3.S	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14-bias/common/udivdi3.S	2013-05-22 15:09:36.701000000 +0200
@@ -17,11 +17,19 @@
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#if __WORDSIZE == 32
+# define STACK_BIAS 0
+#else	
+# define STACK_BIAS 2047
+#endif
 	.text
 	.align 4
 	.globl __udivdi3
+	.register %g2,#scratch
+	.register %g3,#scratch
+
 __udivdi3:
-	save %sp,-104,%sp
+	save %sp,STACK_BIAS-104,%sp
 	mov %i3,%o3
 	cmp %i2,0
 	bne .LL40
diff -r -u silo-1.4.14/second/muldi3.S silo-1.4.14-bias/second/muldi3.S
--- silo-1.4.14/second/muldi3.S	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14-bias/second/muldi3.S	2013-05-22 14:32:12.011000000 +0200
@@ -17,11 +17,19 @@
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#if __WORDSIZE == 32
+# define STACK_BIAS 0
+#else	
+# define STACK_BIAS 2047
+#endif	
+
 	.text
 	.align 4
 	.globl __muldi3
+	.register %g2,#scratch
+	.register %g3,#scratch
 __muldi3:
-	save  %sp, -104, %sp
+	save  %sp, -STACK_BIAS-104, %sp
 	wr  %g0, %i1, %y
 	sra  %i3, 0x1f, %g2
 	and  %i1, %g2, %g2
diff -r -u silo-1.4.14/second/crt0.S silo-1.4.14-bias/second/crt0.S
--- silo-1.4.14/second/crt0.S	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14-bias/second/crt0.S	2013-05-22 15:34:57.235000000 +0200
@@ -21,6 +21,12 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */
 
+#if __WORDSIZE == 32
+# define STACK_BIAS 0
+#else	
+# define STACK_BIAS 2047
+#endif	
+	
 #define COPY	jmpl	%o7 + (copy - _start), %l7
 
 	.text
@@ -82,7 +88,11 @@
 	sub	%l0, 16, %l0
 	sethi	%hi(gzminpi), %l1
 	add	%l1, %i3, %l1
+#if __WORDSIZE == 32
 	st	%l0, [%l1 + %lo(gzminpi)]
+#else
+	stx	%l0, [%l1 + %lo(gzminpi)]
+#endif
 
 	/* Jump to relocated code */
 	sethi	%hi(_end), %l0
@@ -121,12 +131,15 @@
 
 	! Set up a stack
 setup_stack:
-	save	%i0,-120,%sp
-
+	save	%i0,-STACK_BIAS-120,%sp
 	tst	%i4
 	be	0f
 	 sethi	%hi(gzminpi+0x100000), %l0
+#if __WORDSIZE == 32
 	ld	[%l0 + %lo(gzminpi)], %l1
+#else
+	ldx	[%l0 + %lo(gzminpi)], %l1
+#endif	
 	sethi	%hi(LARGE_RELOC), %l2
 1:	lduh	[%l1], %l3
 	add	%l1, 2, %l1
@@ -147,7 +160,11 @@
 	add	%l3, 16, %l3
 	ba	3b
 	 stb	%l3, [%l2]
+#if __WORDSIZE == 32
 4:	st	%l1, [%l0 + %lo(gzminpi)]
+#else
+4:	stx	%l1, [%l0 + %lo(gzminpi)]
+#endif
 
 	! Call my_main() to start the whole thingie up
 
diff -u -r silo-1.4.14-orig/common/console.c silo-1.4.14/common/console.c
--- silo-1.4.14-orig/common/console.c	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14/common/console.c	2013-05-03 15:57:14.419000002 +0200
@@ -27,7 +27,7 @@
 			i = inc;
 		break;
 	case PROM_P1275:
-		if (p1275_cmd ("read", 3, prom_stdin, &inc, 1) == 1)
+		if (p1275_cmd ("read", 3, (unsigned int) prom_stdin, &inc, 1) == 1)
 			i = inc;
 		break;
 	}
@@ -55,7 +55,7 @@
 		break;
 	case PROM_P1275:
 		outc = c;
-		if (p1275_cmd ("write", 3, prom_stdout, &outc, 1) == 1)
+		if (p1275_cmd ("write", 3, (unsigned int) prom_stdout, &outc, 1) == 1)
 			i = 0;
 		break;
 	}
@@ -93,7 +93,7 @@
 		(*(romvec->pv_v2devops).v2_dev_write)(prom_stdout, s, len);
 		break;
 	case PROM_P1275:
-		p1275_cmd ("write", 3, prom_stdout, s, len);
+		p1275_cmd ("write", 3, (unsigned int) prom_stdout, s, len);
 		break;
 	}
 }
diff -u -r silo-1.4.14-orig/common/prom.c silo-1.4.14/common/prom.c
--- silo-1.4.14-orig/common/prom.c	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14/common/prom.c	2013-05-03 16:51:48.214000002 +0200
@@ -196,7 +196,7 @@
 			    P1275_ARG_64B(3) | P1275_ARG_64B(4) |
 			    P1275_ARG_64B(6) | 7,
 			    "map",
-			    prom_get_mmu_ihandle(),
+			    (unsigned int) prom_get_mmu_ihandle(),
 			    mode,
 			    size,
 			    vaddr,
@@ -211,7 +211,7 @@
 	p1275_cmd("call-method",
 		  P1275_ARG_64B(2) | P1275_ARG_64B(3) | 4,
 		  "unmap",
-		  prom_get_mmu_ihandle(),
+		  (unsigned int) prom_get_mmu_ihandle(),
 		  size,
 		  vaddr);
 }
diff -u -r silo-1.4.14-orig/common/tree.c silo-1.4.14/common/tree.c
--- silo-1.4.14-orig/common/tree.c	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14/common/tree.c	2013-05-03 15:58:48.773000002 +0200
@@ -22,7 +22,7 @@
 	if (prom_vers != PROM_P1275)
 		cnode = prom_nodeops->no_child(node);
 	else
-		cnode = p1275_cmd ("child", 1, node);
+		cnode = p1275_cmd ("child", 1, (unsigned int) node);
 		
 	if (cnode == 0 || cnode == -1)
 		return 0;
@@ -43,7 +43,7 @@
 	if (prom_vers != PROM_P1275)
 		sibnode = prom_nodeops->no_nextnode(node);
 	else
-		sibnode = p1275_cmd ("peer", 1, node);
+		sibnode = p1275_cmd ("peer", 1, (unsigned int) node);
 		
 	if (sibnode == 0 || sibnode == -1)
 		return 0;
@@ -64,7 +64,7 @@
 		if (prom_vers != PROM_P1275)
 			ret = prom_nodeops->no_proplen(node, prop);
 		else
-			ret = p1275_cmd ("getproplen", 2, node, prop);
+			ret = p1275_cmd ("getproplen", 2, (unsigned int) node, prop);
 	}
 	return ret;
 }
@@ -85,7 +85,7 @@
 		if (prom_vers != PROM_P1275)
 			ret = prom_nodeops->no_getprop(node, prop, buffer);
 		else
-			ret = p1275_cmd ("getprop", 4, node, prop, buffer, bufsize);
+			ret = p1275_cmd ("getprop", 4, (unsigned int) node, prop, buffer, bufsize);
 	}
 	return ret;
 }
diff -u -r silo-1.4.14/second/file.c silo-1.4.14-hack/second/file.c
--- silo-1.4.14/second/file.c	2013-05-13 20:29:47.933000002 +0200
+++ silo-1.4.14-hack/second/file.c	2013-05-13 20:15:19.583000002 +0200
@@ -193,7 +193,7 @@
                 }
                 last_blockcnt = -1;
             }
-            if ((char *)filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {
+            if ((unsigned int)filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {
                 silo_fatal("Image too large to fit in destination");
                 return BLOCK_ABORT;
             }
diff -r -u silo-1.4.14/first-isofs/crt0.S silo-1.4.14-bias/first-isofs/crt0.S
--- silo-1.4.14/first-isofs/crt0.S	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14-bias/first-isofs/crt0.S	2013-05-22 14:33:09.908000000 +0200
@@ -21,6 +21,12 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */
 
+#if __WORDSIZE == 32
+# define STACK_BIAS 0
+#else	
+# define STACK_BIAS 2047
+#endif
+	
 #define COPY	jmpl	%o7 + (copy - _start), %l7
 
 	.text
@@ -76,7 +82,7 @@
 	! Set up a stack
 setup_stack:
 	set	0x400000, %l1
-	save	%l1, -64, %sp
+	save	%l1, -STACK_BIAS-64, %sp
 
 	! Call cd_main() to start the whole thingie up
 
diff -u -r silo-1.4.14-orig/first-isofs/isofs.c silo-1.4.14/first-isofs/isofs.c
--- silo-1.4.14-orig/first-isofs/isofs.c	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14/first-isofs/isofs.c	2013-05-03 17:05:03.463000002 +0200
@@ -114,7 +114,7 @@
 		break;
 
 	case PROM_P1275:
-		p1275_cmd("close", 1, fd);
+		p1275_cmd("close", 1, (unsigned)fd);
 		break;
 	};
 }
@@ -141,7 +141,7 @@
 
 		if (seekp != offset) {
 			if (prom_vers == PROM_P1275) {
-				if (p1275_cmd("seek", P1275_ARG_64B(2) | 3, fd, 0, offset) == -1)
+				if (p1275_cmd("seek", P1275_ARG_64B(2) | 3, (unsigned)fd, 0, offset) == -1)
 					return -1;
 			} else {
 				if ((*romvec->pv_v2devops.v2_dev_seek)
@@ -152,7 +152,7 @@
 		}
 
 		if (prom_vers == PROM_P1275)
-			ret = p1275_cmd ("read", 3, fd, data, size);
+			ret = p1275_cmd ("read", 3, (unsigned)fd, data, size);
 		else
 			ret = (*romvec->pv_v2devops.v2_dev_read) (fd, data, size);
 
diff -u -r silo-1.4.14-orig/second/disk.c silo-1.4.14/second/disk.c
--- silo-1.4.14-orig/second/disk.c	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14/second/disk.c	2013-05-06 15:18:07.303000002 +0200
@@ -79,7 +79,7 @@
 
         	fd = p1275_cmd ("open", 1, device);
         	if ((unsigned)(fd + 1) > 1) {
-		    node = p1275_cmd ("instance-to-package", 1, fd);
+		    node = p1275_cmd ("instance-to-package", 1, (unsigned)fd);
                     /*
                      * Don't use our argument due to devalias.
                      * Alas, flash has no device_type property.
@@ -301,7 +301,7 @@
 	    }
 	    if (seekp != offset) {
 	    	if (prom_vers == PROM_P1275) {
-		        if ((rc = p1275_cmd ("seek", P1275_ARG_64B(2) | 3, fd, 0, offset)) == -1)
+		        if ((rc = p1275_cmd ("seek", P1275_ARG_64B(2) | 3, (unsigned) fd, 0, offset)) == -1)
 			    return -1;
 	    	} else {
 		        if ((*romvec->pv_v2devops.v2_dev_seek) (fd, (unsigned)(offset >> 32), (unsigned)offset) == -1)
@@ -311,7 +311,7 @@
 	    }
 	}
 	if (prom_vers == PROM_P1275) {
-		rc = p1275_cmd ("read", 3, fd, buff, size);
+		rc = p1275_cmd ("read", 3, (unsigned) fd, buff, size);
 	} else {
 		int i;
 		for (i = 0; i < 2; i++) {
@@ -355,7 +355,7 @@
 	case PROM_V3:
 	    (*romvec->pv_v2devops.v2_dev_close) (fd); break;
 	case PROM_P1275:
-	    p1275_cmd ("close", 1, fd); break;
+	    p1275_cmd ("close", 1, (unsigned) fd); break;
 	}
     }
     *currentdevice = 0;
diff -u -r silo-1.4.14/silo/silo.c silo-1.4.14-struct/silo/silo.c
--- silo-1.4.14/silo/silo.c	2012-12-06 04:09:00.000000000 +0100
+++ silo-1.4.14-struct/silo/silo.c	2013-05-24 14:18:26.564000002 +0200
@@ -107,14 +107,14 @@
 
 /* This is just so that we don't have to fight with incompatible ufs_fs.h headers */
 #define SILO_UFS_MAGIC 0x00011954
-struct silo_ufs_super_block {
+struct __attribute__((packed)) silo_ufs_super_block {
 	unsigned char xxx1[36];
 	unsigned int fs_fsize;
 	unsigned char xxx2[1332];
 	unsigned int fs_magic;
 };
                                 
-struct sun_disklabel {
+struct __attribute__((packed)) sun_disklabel {
     unsigned char info[128];	/* Informative text string */
     unsigned char spare[292];	/* Boot information etc. */
     unsigned short rspeed;	/* Disk rotational speed */
@@ -127,9 +127,9 @@
     unsigned short ntrks;	/* Tracks per cylinder */
     unsigned short nsect;	/* Sectors per track */
     unsigned char spare3[4];	/* Even more magic... */
-    struct sun_partition {
-	unsigned long start_cylinder;
-	unsigned long num_sectors;
+    struct __attribute__((packed)) sun_partition {
+	unsigned int start_cylinder;
+	unsigned int num_sectors;
     } partitions[8];
     unsigned short magic;	/* Magic number */
     unsigned short csum;	/* Label xor'd checksum */
@@ -205,7 +205,7 @@
 {
     struct silo_ufs_super_block ufs;
     struct ext2_super_block sb;	/* Super Block Info */
-    struct romfs_super_block {
+    struct __attribute__((packed)) romfs_super_block {
 	__u32 word0;
 	__u32 word1;
 	__u32 size;


Reply to: