Really ugly hack to make ppc64 work.

diff --git a/MCONFIG b/MCONFIG
index c9e9b70..1eb49e3 100644
--- a/MCONFIG
+++ b/MCONFIG
@@ -19,6 +19,7 @@
 NM	= $(CROSS)nm
 PERL    = perl
 STRIP   = $(CROSS)strip --strip-all -R .comment -R .note
+OBJCOPY = $(CROSS)objcopy
 
 HOST_CC      = gcc
 HOST_CFLAGS  = -g -O
diff --git a/klibc/Makefile b/klibc/Makefile
index 990487d..956ab0c 100644
--- a/klibc/Makefile
+++ b/klibc/Makefile
@@ -57,6 +57,8 @@
 CRT0    = crt0.o
 LIB     = libc.a
 
+INTERP_O = interp.o
+
 all: tests $(CRT0) $(LIB) $(SOLIB) klibc.so
 
 # Add any architecture-specific rules
@@ -109,7 +111,7 @@
 	rm -f klibc-??????????????????????.so
 	ln -f $@ klibc-`cat $(SOLIB).hash`.so
 
-interp.o: interp.S $(SOLIB).hash
+$(INTERP_O): interp.S $(SOLIB).hash
 	$(CC) $(CFLAGS) -D__ASSEMBLY__ -DLIBDIR=\"$(SHLIBDIR)\" \
 		-DSOHASH=\"`cat $(SOLIB).hash`\" \
 		-c -o $@ $<
diff --git a/klibc/arch/ppc64/MCONFIG b/klibc/arch/ppc64/MCONFIG
index 6997693..86526f8 100644
--- a/klibc/arch/ppc64/MCONFIG
+++ b/klibc/arch/ppc64/MCONFIG
@@ -9,3 +9,10 @@
 
 OPTFLAGS = -Os -fomit-frame-pointer
 BITSIZE  = 64
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
+# to +/- 16 MB
+SHAREDFLAGS     = -Ttext 0x0f000200
diff --git a/klibc/arch/ppc64/Makefile.inc b/klibc/arch/ppc64/Makefile.inc
index c2d1d2f..928df1a 100644
--- a/klibc/arch/ppc64/Makefile.inc
+++ b/klibc/arch/ppc64/Makefile.inc
@@ -13,4 +13,13 @@
 
 ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
 
+INTERP_O = interp1.o
+
+interp.o: interp1.o klibc.got
+	$(LD) $(LDFLAGS) -r -o $@ interp1.o klibc.got
+
+klibc.got: $(SOHASH)
+	$(OBJCOPY) -j.got $< $@
+
 archclean:
+	rm -f klibc.got
diff --git a/klibc/arch/ppc64/setjmp.S b/klibc/arch/ppc64/setjmp.S
index dec75e9..30db419 100644
--- a/klibc/arch/ppc64/setjmp.S
+++ b/klibc/arch/ppc64/setjmp.S
@@ -16,14 +16,13 @@
 	.globl	setjmp
 	.globl	.setjmp
 .setjmp:
-	addi	%r3,%r3,-8
-        mflr    %r11                    /* save return address */
-        mfcr    %r12                    /* save condition register */
-	stdu	%r2,8(%r3)
-	stdu	%r1,8(%r3)
+	mflr	%r11			/* save return address */
+	mfcr	%r12			/* save condition register */
+	std	%r2,0(%r3)		/* save TOC pointer (not needed) */
+	stdu	%r1,8(%r3)		/* save stack pointer */
 	stdu	%r11,8(%r3)
 	stdu	%r12,8(%r3)
-	stdu	%r13,8(%r3)
+	stdu	%r13,8(%r3)		/* save caller saved regs */
 	stdu	%r14,8(%r3)
 	stdu	%r15,8(%r3)
 	stdu	%r16,8(%r3)
@@ -42,8 +41,8 @@
 	stdu	%r29,8(%r3)
 	stdu	%r30,8(%r3)
 	std	%r31,8(%r3)
-        li      %r3,0                   /* indicate success */
-        blr                             /* return */
+	li	%r3,0			/* indicate success */
+	blr				/* return */
 
 	.size .setjmp,.-.setjmp
 	.section ".opd","aw"
@@ -55,12 +54,11 @@
 	.globl	longjmp
 	.globl	.longjmp
 .longjmp:
-	addi	%r3,%r3,-8
-	ldu	%r2,8(%r3)
-	ldu	%r10,8(%r3)
+	ld	%r2,0(%r3)		/* restore TOC pointer (not needed) */
+	ldu	%r1,8(%r3)		/* restore stack */
 	ldu	%r11,8(%r3)
 	ldu	%r12,8(%r3)
-	ldu	%r13,8(%r3)
+	ldu	%r13,8(%r3)		/* restore caller saved regs */
 	ldu	%r14,8(%r3)
 	ldu	%r15,8(%r3)
 	ldu	%r16,8(%r3)
@@ -79,10 +77,9 @@
 	ldu	%r29,8(%r3)
 	ldu	%r30,8(%r3)
 	ld	%r31,8(%r3)
-        mtlr    %r11                    /* restore LR */
-        mtcr    %r12                    /* restore CR */
-        mr      %r1,%r10                /* restore stack */
-        mr      %r3,%r4                 /* get return value */
-        blr                             /* return */
+	mtlr	%r11			/* restore LR */
+	mtcr	%r12			/* restore CR */
+	mr	%r3,%r4			/* get return value */
+	blr				/* return */
 
 	.size .longjmp,.-.longjmp