Sun Jan 4 17:10:47 2009 UTC ()
Support PIC for inclusion in librump.  (m68k untested)


(pooka)
diff -r1.4 -r1.5 src/sys/lib/libkern/arch/i386/random.S
diff -r1.2 -r1.3 src/sys/lib/libkern/arch/m68k/random.S
diff -r1.1 -r1.2 src/sys/lib/libkern/arch/sparc/random.S
diff -r1.1.1.1 -r1.2 src/sys/lib/libkern/arch/sparc64/random.S

cvs diff -r1.4 -r1.5 src/sys/lib/libkern/arch/i386/random.S (expand / switch to context diff)
--- src/sys/lib/libkern/arch/i386/random.S 2008/04/28 20:24:06 1.4
+++ src/sys/lib/libkern/arch/i386/random.S 2009/01/04 17:10:46 1.5
@@ -1,4 +1,4 @@
-/*	$NetBSD: random.S,v 1.4 2008/04/28 20:24:06 martin Exp $	*/
+/*	$NetBSD: random.S,v 1.5 2009/01/04 17:10:46 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -77,14 +77,20 @@
 	.text
 ENTRY(random)
 	movl	$16807,%eax
-	imull	randseed
+	PIC_PROLOGUE
+	imull	PIC_GOTOFF(randseed)
+	PIC_EPILOGUE
 	shld	$1,%eax,%edx
 	andl	$0x7fffffff,%eax
 	addl	%edx,%eax
 	js	1f
-	movl	%eax,randseed
+	PIC_PROLOGUE
+	movl	%eax,PIC_GOTOFF(randseed)
+	PIC_EPILOGUE
 	ret
 1:
 	subl	$0x7fffffff,%eax
-	movl	%eax,randseed
+	PIC_PROLOGUE
+	movl	%eax,PIC_GOTOFF(randseed)
+	PIC_EPILOGUE
 	ret

cvs diff -r1.2 -r1.3 src/sys/lib/libkern/arch/m68k/random.S (expand / switch to context diff)
--- src/sys/lib/libkern/arch/m68k/random.S 1999/11/11 01:53:46 1.2
+++ src/sys/lib/libkern/arch/m68k/random.S 2009/01/04 17:10:46 1.3
@@ -1,4 +1,4 @@
-/*	$NetBSD: random.S,v 1.2 1999/11/11 01:53:46 thorpej Exp $	*/
+/*	$NetBSD: random.S,v 1.3 2009/01/04 17:10:46 pooka Exp $	*/
 
 /*
  * Copyright (c) 1990,1993 The Regents of the University of California.
@@ -48,12 +48,21 @@
 
 ENTRY(random)
 	movl	#16807, %d0
+#ifdef PIC
+	lea	%pc@(_GLOBAL_OFFSET_TABLE_@GOTPC), %a0
+	mulsl	_ASM_LABEL(randseed)@GOT(%a0), %d1:%d0
+#else
 	mulsl	_ASM_LABEL(randseed), %d1:%d0
+#endif
 	lsll	#1, %d0
 	roxll	#2, %d1
 	addl	%d1, %d0
 	moveql	#1, %d1
 	addxl	%d1, %d0
 	lsrl	#1, %d0
+#ifdef PIC
+	movl	%d0, _ASM_LABEL(randseed)@GOT(%a0)
+#else
 	movl	%d0, _ASM_LABEL(randseed)
+#endif
 	rts

cvs diff -r1.1 -r1.2 src/sys/lib/libkern/arch/sparc/random.S (expand / switch to context diff)
--- src/sys/lib/libkern/arch/sparc/random.S 1998/02/22 09:33:27 1.1
+++ src/sys/lib/libkern/arch/sparc/random.S 2009/01/04 17:10:46 1.2
@@ -1,4 +1,4 @@
-/*	$NetBSD: random.S,v 1.1 1998/02/22 09:33:27 mycroft Exp $	*/
+/*	$NetBSD: random.S,v 1.2 2009/01/04 17:10:46 pooka Exp $	*/
 
 /*
  * Copyright (c) 1990,1993 The Regents of the University of California.
@@ -49,9 +49,15 @@
 ENTRY(random)
 	sethi	%hi(16807), %o1
 	wr	%o1, %lo(16807), %y
-	 sethi	%hi(randseed), %g1
-	 ld	[%g1 + %lo(randseed)], %o0
-	 andcc	%g0, 0, %o2
+#ifdef PIC
+	PIC_PROLOGUE(%g1, %g2)
+	set	randseed, %g2
+	ld	[%g1 + %g2], %o0
+#else
+	sethi	%hi(randseed), %g1
+	ld	[%g1 + %lo(randseed)], %o0
+#endif
+	andcc	%g0, 0, %o2
 	mulscc  %o2, %o0, %o2
 	mulscc  %o2, %o0, %o2
 	mulscc  %o2, %o0, %o2
@@ -77,12 +83,20 @@
 	or	%o3, %o0, %o0
 	addcc	%o0, %o1, %o0
 	bneg	1f
-	 sethi	%hi(0x7fffffff), %o1
+	sethi	%hi(0x7fffffff), %o1
 	retl
-	 st	%o0, [%g1 + %lo(randseed)]
+#ifdef PIC
+	st	%o0, [%g1 + %g2]
+#else
+	st	%o0, [%g1 + %lo(randseed)]
+#endif
 1:
 	or	%o1, %lo(0x7fffffff), %o1
 	add	%o0, 1, %o0
 	and	%o1, %o0, %o0
 	retl
-	 st	%o0, [%g1 + %lo(randseed)]
+#ifdef PIC
+	st	%o0, [%g1 + %g2]
+#else
+	st	%o0, [%g1 + %lo(randseed)]
+#endif

cvs diff -r1.1.1.1 -r1.2 src/sys/lib/libkern/arch/sparc64/random.S (expand / switch to context diff)
--- src/sys/lib/libkern/arch/sparc64/random.S 1998/06/20 05:18:14 1.1.1.1
+++ src/sys/lib/libkern/arch/sparc64/random.S 2009/01/04 17:10:47 1.2
@@ -1,4 +1,4 @@
-/*	$NetBSD: random.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $	*/
+/*	$NetBSD: random.S,v 1.2 2009/01/04 17:10:47 pooka Exp $	*/
 
 /*
  * Copyright (c) 1990,1993 The Regents of the University of California.
@@ -49,9 +49,15 @@
 ENTRY(random)
 	sethi	%hi(16807), %o1
 	wr	%o1, %lo(16807), %y
-	 sethi	%hi(randseed), %g1
-	 ld	[%g1 + %lo(randseed)], %o0
-	 andcc	%g0, 0, %o2
+#ifdef PIC
+	PIC_PROLOGUE(%g1, %g2)
+	set	randseed, %g2
+	ld	[%g1 + %g2], %o0
+#else
+	sethi	%hi(randseed), %g1
+	ld	[%g1 + %lo(randseed)], %o0
+#endif
+	andcc	%g0, 0, %o2
 	mulscc  %o2, %o0, %o2
 	mulscc  %o2, %o0, %o2
 	mulscc  %o2, %o0, %o2
@@ -77,12 +83,20 @@
 	or	%o3, %o0, %o0
 	addcc	%o0, %o1, %o0
 	bneg	1f
-	 sethi	%hi(0x7fffffff), %o1
+	sethi	%hi(0x7fffffff), %o1
 	retl
-	 st	%o0, [%g1 + %lo(randseed)]
+#ifdef PIC
+	st	%o0, [%g1 + %g2]
+#else
+	st	%o0, [%g1 + %lo(randseed)]
+#endif
 1:
 	or	%o1, %lo(0x7fffffff), %o1
 	add	%o0, 1, %o0
 	and	%o1, %o0, %o0
 	retl
-	 st	%o0, [%g1 + %lo(randseed)]
+#ifdef PIC
+	st	%o0, [%g1 + %g2]
+#else
+	st	%o0, [%g1 + %lo(randseed)]
+#endif