aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2004-09-15 02:51:16 +0000
committerH. Peter Anvin <hpa@zytor.com>2004-09-15 02:51:16 +0000
commit2f0930f0c0a64ce31aeb11283fd62132e801a0ce (patch)
treea762c5aa2d6ae937dcbe1ec5556f5e9259236f4a
parent04fcd4bf246753758da62871c584b20e010873ed (diff)
downloadklibc-2f0930f0c0a64ce31aeb11283fd62132e801a0ce.tar.gz
Really ugly hack to make ppc64 work.klibc-0.175
-rw-r--r--MCONFIG1
-rw-r--r--klibc/Makefile4
-rw-r--r--klibc/arch/ppc64/MCONFIG7
-rw-r--r--klibc/arch/ppc64/Makefile.inc9
-rw-r--r--klibc/arch/ppc64/setjmp.S31
5 files changed, 34 insertions, 18 deletions
diff --git a/MCONFIG b/MCONFIG
index c9e9b70d28a08..1eb49e3a8a77c 100644
--- a/MCONFIG
+++ b/MCONFIG
@@ -19,6 +19,7 @@ RANLIB = $(CROSS)ranlib
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 990487de88616..956ab0c2c659b 100644
--- a/klibc/Makefile
+++ b/klibc/Makefile
@@ -57,6 +57,8 @@ SOHASH = klibc.so
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 @@ $(SOHASH): $(SOLIB) $(SOLIB).hash
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 6997693e99bb5..86526f895cfc9 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 c2d1d2fbfcc01..928df1aeb70ad 100644
--- a/klibc/arch/ppc64/Makefile.inc
+++ b/klibc/arch/ppc64/Makefile.inc
@@ -13,4 +13,13 @@ ARCHOBJS = \
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 dec75e9660134..30db419140ed5 100644
--- a/klibc/arch/ppc64/setjmp.S
+++ b/klibc/arch/ppc64/setjmp.S
@@ -16,14 +16,13 @@ setjmp:
.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 @@ setjmp:
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 @@ longjmp:
.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 @@ longjmp:
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