[klibc] [klibc:master] ppc64: Add ppc64le support

klibc-bot for Anton Blanchard anton at samba.org
Tue Dec 3 10:57:05 PST 2013


Commit-ID:  87ad992e1ae0036436646610a23feb4c2895593f
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=87ad992e1ae0036436646610a23feb4c2895593f
Author:     Anton Blanchard <anton at samba.org>
AuthorDate: Tue, 3 Dec 2013 18:18:03 +1100
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Tue, 3 Dec 2013 10:53:19 -0800

[klibc] ppc64: Add ppc64le support

Add PowerPC 64bit little endian support.

Signed-off-by: Anton Blanchard <anton at samba.org>
Signed-off-by: H. Peter Anvin <hpa at zytor.com>

---
 Makefile                        |  7 +++++--
 usr/klibc/arch/ppc64/MCONFIG    |  4 ++--
 usr/klibc/arch/ppc64/crt0.S     | 34 ++++++++++++++++++++-----------
 usr/klibc/arch/ppc64/setjmp.S   | 40 ++++++++++++++++++++++++++----------
 usr/klibc/arch/ppc64/sysstub.ph | 45 ++++++++++++++++++++++++++---------------
 5 files changed, 87 insertions(+), 43 deletions(-)

diff --git a/Makefile b/Makefile
index a7da622..dc10fc5 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 cb66614..0294c44 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 c976d5c..ed14534 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, at function
+_start:
+#else
 	.section ".opd","aw"
+	.balign 8
 _start:
 	.quad	._start, .TOC. at tocbase, 0
 	.previous
-	.size	_start, 24
 	.type	._start, at 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 at ha
+	addi	2,2,.TOC.-0b at 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 30db419..ecf9717 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, at function
+setjmp:
+#else
 	.section ".opd","aw"
+	.balign 8
 setjmp:
-	.quad	.setjmp,.TOC. at tocbase,0
+	.quad	.setjmp, .TOC. at tocbase, 0
 	.previous
-	.size	setjmp,24
 	.type	.setjmp, at 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, at function
+longjmp:
+#else
 	.section ".opd","aw"
+	.balign 8
 longjmp:
-	.quad	.longjmp,.TOC. at tocbase,0
+	.quad	.longjmp, .TOC. at tocbase, 0
 	.previous
-	.size	longjmp,24
 	.type	.longjmp, at 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 9ee9370..b3f6e38 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);
 }
 


More information about the klibc mailing list