aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Blanchard <anton@samba.org>2013-12-03 18:18:03 +1100
committerH. Peter Anvin <hpa@zytor.com>2013-12-03 10:53:19 -0800
commit87ad992e1ae0036436646610a23feb4c2895593f (patch)
treeb06a552922d9173b50046d7699b5ffbc441eb0ee
parent3892f676f83d4da24f6417846645272d367a97a7 (diff)
downloadklibc-87ad992e1ae0036436646610a23feb4c2895593f.tar.gz
[klibc] ppc64: Add ppc64le support
Add PowerPC 64bit little endian support. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--Makefile7
-rw-r--r--usr/klibc/arch/ppc64/MCONFIG4
-rw-r--r--usr/klibc/arch/ppc64/crt0.S34
-rw-r--r--usr/klibc/arch/ppc64/setjmp.S40
-rw-r--r--usr/klibc/arch/ppc64/sysstub.ph45
5 files changed, 87 insertions, 43 deletions
diff --git a/Makefile b/Makefile
index a7da622c83a37..dc10fc5da9af1 100644
--- a/Makefile
+++ b/Makefile
@@ -30,8 +30,11 @@ export OBJDUMP := $(KLIBCROSS)objdump
NOSTDINC_FLAGS := -nostdlib -nostdinc -isystem $(shell $(CC) -print-file-name=include)
-ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ \
- -e s/aarch64.*/arm64/ -e s/sh.*/sh/)
+ARCH := $(shell uname -m | sed -e s/i.86/i386/ \
+ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ \
+ -e s/arm.*/arm/ -e s/sa110/arm/ \
+ -e s/aarch64.*/arm64/ -e s/sh.*/sh/ \
+ -e s/ppc64le/ppc64/)
export KLIBCARCH ?= $(ARCH)
export KLIBCARCHDIR := $(shell echo $(KLIBCARCH) | sed -e s/s390x/s390/)
diff --git a/usr/klibc/arch/ppc64/MCONFIG b/usr/klibc/arch/ppc64/MCONFIG
index cb666147f948b..0294c440a0dd2 100644
--- a/usr/klibc/arch/ppc64/MCONFIG
+++ b/usr/klibc/arch/ppc64/MCONFIG
@@ -7,10 +7,10 @@
# accordingly.
#
-KLIBCARCHREQFLAGS = -m64 -mcall-aixdesc
+KLIBCARCHREQFLAGS = -m64
+KLIBCARCHREQFLAGS += $(call cc-option, -mcall-aixdesc, )
KLIBCOPTFLAGS += -Os
KLIBCBITSIZE = 64
-KLIBCLDFLAGS = -m elf64ppc
# Extra linkflags when building the shared version of the library
# This address needs to be reachable using normal inter-module
diff --git a/usr/klibc/arch/ppc64/crt0.S b/usr/klibc/arch/ppc64/crt0.S
index c976d5c1450b0..ed14534d3a047 100644
--- a/usr/klibc/arch/ppc64/crt0.S
+++ b/usr/klibc/arch/ppc64/crt0.S
@@ -9,25 +9,35 @@
# }
#
- .section ".toc","aw"
-.LC0: .tc environ[TC],environ
-
.text
- .align 4
-
+ .balign 4
+ .globl _start
+#if _CALL_ELF == 2
+ .type _start,@function
+_start:
+#else
.section ".opd","aw"
+ .balign 8
_start:
.quad ._start, .TOC.@tocbase, 0
.previous
- .size _start, 24
.type ._start,@function
- .globl _start
- .globl ._start
._start:
- stdu %r1,-32(%r1)
- addi %r3,%r1,32
+#endif
+
+#if _CALL_ELF == 2
+0: addis 2,12,.TOC.-0b@ha
+ addi 2,2,.TOC.-0b@l
+#endif
+
+ stdu %r1,-32(%r1)
+ addi %r3,%r1,32
li %r4,0 /* fini (unused) */
- b .__libc_init
+ b __libc_init
nop
- .size ._start,.-._start
+#if _CALL_ELF == 2
+ .size _start,.-_start
+#else
+ .size _start,.-._start
+#endif
diff --git a/usr/klibc/arch/ppc64/setjmp.S b/usr/klibc/arch/ppc64/setjmp.S
index 30db419140ed5..ecf9717b57dc2 100644
--- a/usr/klibc/arch/ppc64/setjmp.S
+++ b/usr/klibc/arch/ppc64/setjmp.S
@@ -5,17 +5,21 @@
#
.text
- .align 4
-
+ .balign 4
+ .globl setjmp
+#if _CALL_ELF == 2
+ .type setjmp,@function
+setjmp:
+#else
.section ".opd","aw"
+ .balign 8
setjmp:
- .quad .setjmp,.TOC.@tocbase,0
+ .quad .setjmp, .TOC.@tocbase, 0
.previous
- .size setjmp,24
.type .setjmp,@function
- .globl setjmp
.globl .setjmp
.setjmp:
+#endif
mflr %r11 /* save return address */
mfcr %r12 /* save condition register */
std %r2,0(%r3) /* save TOC pointer (not needed) */
@@ -43,17 +47,28 @@ setjmp:
std %r31,8(%r3)
li %r3,0 /* indicate success */
blr /* return */
+#if _CALL_ELF == 2
+ .size setjmp,.-setjmp
+#else
+ .size setjmp,.-.setjmp
+#endif
- .size .setjmp,.-.setjmp
+ .text
+ .balign 4
+ .globl longjmp
+#if _CALL_ELF == 2
+ .type longjmp,@function
+longjmp:
+#else
.section ".opd","aw"
+ .balign 8
longjmp:
- .quad .longjmp,.TOC.@tocbase,0
+ .quad .longjmp, .TOC.@tocbase, 0
.previous
- .size longjmp,24
.type .longjmp,@function
- .globl longjmp
.globl .longjmp
.longjmp:
+#endif
ld %r2,0(%r3) /* restore TOC pointer (not needed) */
ldu %r1,8(%r3) /* restore stack */
ldu %r11,8(%r3)
@@ -81,5 +96,8 @@ longjmp:
mtcr %r12 /* restore CR */
mr %r3,%r4 /* get return value */
blr /* return */
-
- .size .longjmp,.-.longjmp
+#if _CALL_ELF == 2
+ .size longjmp,.-longjmp
+#else
+ .size longjmp,.-.longjmp
+#endif
diff --git a/usr/klibc/arch/ppc64/sysstub.ph b/usr/klibc/arch/ppc64/sysstub.ph
index 9ee93701f6fae..b3f6e38582450 100644
--- a/usr/klibc/arch/ppc64/sysstub.ph
+++ b/usr/klibc/arch/ppc64/sysstub.ph
@@ -9,22 +9,35 @@ sub make_sysstub($$$$$@) {
my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
open(OUT, '>', "${outputdir}/${fname}.S");
- print OUT "#include <asm/unistd.h>\n";
- print OUT "\n";
- print OUT "\t.globl ${fname}\n";
- print OUT "\t.section \".opd\",\"aw\"\n";
- print OUT "\t.align 3\n";
- print OUT "${fname}:\n";
- print OUT "\t.quad .${fname},.TOC.\@tocbase,0\n";
- print OUT "\t.text\n";
- print OUT "\t.type .${fname},\@function\n";
- print OUT "\t.globl .${fname}\n";
- print OUT ".${fname}:\n";
- print OUT "\tli 0,__NR_${sname}\n";
- print OUT "\tsc\n";
- print OUT "\tbnslr\n";
- print OUT "\tb .__syscall_error\n";
- print OUT "\t.size .${fname},.-.${fname}\n";
+ print OUT <<EOF;
+#include <asm/unistd.h>
+
+ .text
+ .balign 4
+ .globl ${fname}
+#if _CALL_ELF == 2
+ .type ${fname},\@function
+${fname}:
+#else
+ .section ".opd","aw"
+ .balign 8
+${fname}:
+ .quad .${fname}, .TOC.\@tocbase, 0
+ .previous
+ .type .${fname},\@function
+ .globl .${fname}
+.${fname}:
+#endif
+ li 0, __NR_${sname}
+ sc
+ bnslr
+ b __syscall_error
+#if _CALL_ELF == 2
+ .size ${fname},.-${fname}
+#else
+ .size ${fname},.-.${fname}
+#endif
+EOF
close(OUT);
}