Source: klibc
Version: 2.0.2-1

Severity: important
Tags: patch

Maintainer,

May you please include these 2 patches from klibc,
in order to support the ppc64el architecture?

        [klibc] ppc64: Add ppc64le support
        [klibc] ppc64: build with -mcmodel=small

A new upstream release with klibc 2.0.3 would resolve this as well.

thank you

--
Mauricio Faria de Oliveira
IBM Linux Technology Center
From: Anton Blanchard <an...@samba.org>
Date: Tue, 3 Dec 2013 18:18:03 +1100
Subject: [klibc] ppc64: Add ppc64le support

Add PowerPC 64bit little endian support.

Signed-off-by: Anton Blanchard <an...@samba.org>
Signed-off-by: H. Peter Anvin <h...@zytor.com>

Trivial backport to 2.0.2 (Makefile conflict, no arm64 in source package): 
	Mauricio Faria de Oliveira <mauri...@linux.vnet.ibm.com>
---
 Makefile                        |  6 +++++-
 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(+), 42 deletions(-)

diff --git a/Makefile b/Makefile
index 0a3ee69..0d06774 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +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/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/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,@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 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,@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 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);
 }
 
-- 
1.8.5.3

From: Anton Blanchard <an...@samba.org>
Date: Tue, 3 Dec 2013 18:19:06 +1100
Subject: [klibc] ppc64: build with -mcmodel=small

If available, use -mcmodel=small. klibc is small enough that we
should never hit the limits of the small memory model.

This produces better code, for example:

000000000f003890 <.strcasecmp>:
f003890:       3c a2 ff fe     addis   r5,r2,-2
...
f003898:       38 c5 23 58     addi    r6,r5,9048
...
f0038ac:       7d 46 50 ae     lbzx    r10,r6,r10

vs:

000000000f0037c4 <.strcasecmp>:
f0037c4:       e8 c2 81 48     ld      r6,-32440(r2)
f0037dc:       7d 46 50 ae     lbzx    r10,r6,r10

Signed-off-by: Anton Blanchard <an...@samba.org>
Signed-off-by: H. Peter Anvin <h...@zytor.com>
---
 usr/klibc/arch/ppc64/MCONFIG | 1 +
 1 file changed, 1 insertion(+)

diff --git a/usr/klibc/arch/ppc64/MCONFIG b/usr/klibc/arch/ppc64/MCONFIG
index 0294c44..1331e05 100644
--- a/usr/klibc/arch/ppc64/MCONFIG
+++ b/usr/klibc/arch/ppc64/MCONFIG
@@ -9,6 +9,7 @@
 
 KLIBCARCHREQFLAGS = -m64
 KLIBCARCHREQFLAGS += $(call cc-option, -mcall-aixdesc, )
+KLIBCARCHREQFLAGS += $(call cc-option, -mcmodel=small, )
 KLIBCOPTFLAGS     += -Os
 KLIBCBITSIZE      = 64
 
-- 
1.8.5.3

Reply via email to