diff mbox series

[3/6] openssl: add ppc64 support

Message ID 20210821231513.90996-4-stijn@linux-ipv6.be
State Changes Requested
Delegated to: Stijn Tintel
Headers show
Series qoriq: new target | expand

Commit Message

Stijn Tintel Aug. 21, 2021, 11:15 p.m. UTC
Backport an upstream patch that adds support for ELFv2 ABI on big endian
ppc64. As musl only supports ELFv2 ABI on ppc64 regardless of
endianness, this is required to be able to build OpenSSL for ppc64be.

Modify our targets patch to add linux-powerpc64-openwrt, which will use
the linux64v2 perlasm scheme. This will probably break the combination
ppc64 with glibc, but as we really only want to support musl, this
shouldn't be a problem.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
---
 ...m-ppc-xlate.pl-add-linux64v2-flavour.patch | 63 +++++++++++++++++++
 .../openssl/patches/110-openwrt_targets.patch |  6 +-
 2 files changed, 68 insertions(+), 1 deletion(-)
 create mode 100644 package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-add-linux64v2-flavour.patch

Comments

Adrian Schmutzler Aug. 22, 2021, 11:15 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org]
> On Behalf Of Stijn Tintel
> Sent: Sonntag, 22. August 2021 01:15
> To: openwrt-devel@lists.openwrt.org
> Subject: [PATCH 3/6] openssl: add ppc64 support
> 
> Backport an upstream patch that adds support for ELFv2 ABI on big endian
> ppc64. As musl only supports ELFv2 ABI on ppc64 regardless of endianness,
> this is required to be able to build OpenSSL for ppc64be.
> 
> Modify our targets patch to add linux-powerpc64-openwrt, which will use
> the linux64v2 perlasm scheme. This will probably break the combination
> ppc64 with glibc, but as we really only want to support musl, this shouldn't be
> a problem.

Looks like openssl still needs a PKG_RELEASE bump ...

Best

Adrian

> 
> Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
> ---
>  ...m-ppc-xlate.pl-add-linux64v2-flavour.patch | 63 +++++++++++++++++++
> .../openssl/patches/110-openwrt_targets.patch |  6 +-
>  2 files changed, 68 insertions(+), 1 deletion(-)  create mode 100644
> package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-add-
> linux64v2-flavour.patch
> 
> diff --git a/package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-
> add-linux64v2-flavour.patch b/package/libs/openssl/patches/001-crypto-
> perlasm-ppc-xlate.pl-add-linux64v2-flavour.patch
> new file mode 100644
> index 0000000000..bdc0509f8c
> --- /dev/null
> +++ b/package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-add-l
> +++ inux64v2-flavour.patch
> @@ -0,0 +1,63 @@
> +From 34ab13b7d8e3e723adb60be8142e38b7c9cd382a Mon Sep 17 00:00:00
> 2001
> +From: Andy Polyakov <appro@openssl.org>
> +Date: Sun, 5 May 2019 18:25:50 +0200
> +Subject: [PATCH] crypto/perlasm/ppc-xlate.pl: add linux64v2 flavour
> +MIME-Version: 1.0
> +Content-Type: text/plain; charset=UTF-8
> +Content-Transfer-Encoding: 8bit
> +
> +This is a big endian ELFv2 configuration. ELFv2 was already being used
> +for little endian, and big endian was traditionally ELFv1 but there are
> +practical configurations that use ELFv2 with big endian nowadays
> +(Adélie Linux, Void Linux, possibly Gentoo, etc.)
> +
> +Reviewed-by: Paul Dale <paul.dale@oracle.com>
> +Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from
> +https://github.com/openssl/openssl/pull/8883)
> +---
> + crypto/perlasm/ppc-xlate.pl | 8 ++++----
> + 1 file changed, 4 insertions(+), 4 deletions(-)
> +
> +diff --git a/crypto/perlasm/ppc-xlate.pl b/crypto/perlasm/ppc-xlate.pl
> +index e52f2f6ea6..5fcd0526df 100755
> +--- a/crypto/perlasm/ppc-xlate.pl
> ++++ b/crypto/perlasm/ppc-xlate.pl
> +@@ -49,7 +49,7 @@ my $globl = sub {
> + 	/osx/		&& do { $name = "_$name";
> + 				last;
> + 			      };
> +-	/linux.*(32|64le)/
> ++	/linux.*(32|64(le|v2))/
> + 			&& do {	$ret .= ".globl	$name";
> + 				if (!$$type) {
> + 				    $ret .= "\n.type	$name,\@function";
> +@@ -80,7 +80,7 @@ my $globl = sub {
> + };
> + my $text = sub {
> +     my $ret = ($flavour =~ /aix/) ? ".csect\t.text[PR],7" : ".text";
> +-    $ret = ".abiversion	2\n".$ret	if ($flavour =~ /linux.*64le/);
> ++    $ret = ".abiversion	2\n".$ret	if ($flavour =~
> /linux.*64(le|v2)/);
> +     $ret;
> + };
> + my $machine = sub {
> +@@ -186,7 +186,7 @@ my $vmr = sub {
> +
> + # Some ABIs specify vrsave, special-purpose register #256, as reserved
> +# for system use.
> +-my $no_vrsave = ($flavour =~ /aix|linux64le/);
> ++my $no_vrsave = ($flavour =~ /aix|linux64(le|v2)/);
> + my $mtspr = sub {
> +     my ($f,$idx,$ra) = @_;
> +     if ($idx == 256 && $no_vrsave) {
> +@@ -320,7 +320,7 @@ while($line=<>) {
> + 	if ($label) {
> + 	    my $xlated = ($GLOBALS{$label} or $label);
> + 	    print "$xlated:";
> +-	    if ($flavour =~ /linux.*64le/) {
> ++	    if ($flavour =~ /linux.*64(le|v2)/) {
> + 		if ($TYPES{$label} =~ /function/) {
> + 		    printf "\n.localentry	%s,0\n",$xlated;
> + 		}
> +--
> +2.31.1
> +
> diff --git a/package/libs/openssl/patches/110-openwrt_targets.patch
> b/package/libs/openssl/patches/110-openwrt_targets.patch
> index d0530b4661..828c14d21d 100644
> --- a/package/libs/openssl/patches/110-openwrt_targets.patch
> +++ b/package/libs/openssl/patches/110-openwrt_targets.patch
> @@ -12,7 +12,7 @@ new file mode 100644
>  index 0000000000..86a86d31e4
>  --- /dev/null
>  +++ b/Configurations/25-openwrt.conf
> -@@ -0,0 +1,48 @@
> +@@ -0,0 +1,52 @@
>  +## Openwrt "CONFIG_ARCH" matching targets.
>  +
>  +# The targets need to end in '-openwrt' for the AFALG patch to work @@ -
> 52,6 +52,10 @@ index 0000000000..86a86d31e4
>  +    "linux-powerpc-openwrt" => {
>  +        inherit_from    => [ "linux-ppc", "openwrt" ],
>  +    },
> ++    "linux-powerpc64-openwrt" => {
> ++        inherit_from    => [ "linux-ppc64", "openwrt" ],
> ++        perlasm_scheme  => "linux64v2",
> ++    },
>  +    "linux-x86_64-openwrt" => {
>  +        inherit_from    => [ "linux-x86_64", "openwrt" ],
>  +    },
> --
> 2.31.1
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
diff mbox series

Patch

diff --git a/package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-add-linux64v2-flavour.patch b/package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-add-linux64v2-flavour.patch
new file mode 100644
index 0000000000..bdc0509f8c
--- /dev/null
+++ b/package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-add-linux64v2-flavour.patch
@@ -0,0 +1,63 @@ 
+From 34ab13b7d8e3e723adb60be8142e38b7c9cd382a Mon Sep 17 00:00:00 2001
+From: Andy Polyakov <appro@openssl.org>
+Date: Sun, 5 May 2019 18:25:50 +0200
+Subject: [PATCH] crypto/perlasm/ppc-xlate.pl: add linux64v2 flavour
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This is a big endian ELFv2 configuration. ELFv2 was already being
+used for little endian, and big endian was traditionally ELFv1
+but there are practical configurations that use ELFv2 with big
+endian nowadays (Adélie Linux, Void Linux, possibly Gentoo, etc.)
+
+Reviewed-by: Paul Dale <paul.dale@oracle.com>
+Reviewed-by: Richard Levitte <levitte@openssl.org>
+(Merged from https://github.com/openssl/openssl/pull/8883)
+---
+ crypto/perlasm/ppc-xlate.pl | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/crypto/perlasm/ppc-xlate.pl b/crypto/perlasm/ppc-xlate.pl
+index e52f2f6ea6..5fcd0526df 100755
+--- a/crypto/perlasm/ppc-xlate.pl
++++ b/crypto/perlasm/ppc-xlate.pl
+@@ -49,7 +49,7 @@ my $globl = sub {
+ 	/osx/		&& do { $name = "_$name";
+ 				last;
+ 			      };
+-	/linux.*(32|64le)/
++	/linux.*(32|64(le|v2))/
+ 			&& do {	$ret .= ".globl	$name";
+ 				if (!$$type) {
+ 				    $ret .= "\n.type	$name,\@function";
+@@ -80,7 +80,7 @@ my $globl = sub {
+ };
+ my $text = sub {
+     my $ret = ($flavour =~ /aix/) ? ".csect\t.text[PR],7" : ".text";
+-    $ret = ".abiversion	2\n".$ret	if ($flavour =~ /linux.*64le/);
++    $ret = ".abiversion	2\n".$ret	if ($flavour =~ /linux.*64(le|v2)/);
+     $ret;
+ };
+ my $machine = sub {
+@@ -186,7 +186,7 @@ my $vmr = sub {
+ 
+ # Some ABIs specify vrsave, special-purpose register #256, as reserved
+ # for system use.
+-my $no_vrsave = ($flavour =~ /aix|linux64le/);
++my $no_vrsave = ($flavour =~ /aix|linux64(le|v2)/);
+ my $mtspr = sub {
+     my ($f,$idx,$ra) = @_;
+     if ($idx == 256 && $no_vrsave) {
+@@ -320,7 +320,7 @@ while($line=<>) {
+ 	if ($label) {
+ 	    my $xlated = ($GLOBALS{$label} or $label);
+ 	    print "$xlated:";
+-	    if ($flavour =~ /linux.*64le/) {
++	    if ($flavour =~ /linux.*64(le|v2)/) {
+ 		if ($TYPES{$label} =~ /function/) {
+ 		    printf "\n.localentry	%s,0\n",$xlated;
+ 		}
+-- 
+2.31.1
+
diff --git a/package/libs/openssl/patches/110-openwrt_targets.patch b/package/libs/openssl/patches/110-openwrt_targets.patch
index d0530b4661..828c14d21d 100644
--- a/package/libs/openssl/patches/110-openwrt_targets.patch
+++ b/package/libs/openssl/patches/110-openwrt_targets.patch
@@ -12,7 +12,7 @@  new file mode 100644
 index 0000000000..86a86d31e4
 --- /dev/null
 +++ b/Configurations/25-openwrt.conf
-@@ -0,0 +1,48 @@
+@@ -0,0 +1,52 @@
 +## Openwrt "CONFIG_ARCH" matching targets.
 +
 +# The targets need to end in '-openwrt' for the AFALG patch to work
@@ -52,6 +52,10 @@  index 0000000000..86a86d31e4
 +    "linux-powerpc-openwrt" => {
 +        inherit_from    => [ "linux-ppc", "openwrt" ],
 +    },
++    "linux-powerpc64-openwrt" => {
++        inherit_from    => [ "linux-ppc64", "openwrt" ],
++        perlasm_scheme  => "linux64v2",
++    },
 +    "linux-x86_64-openwrt" => {
 +        inherit_from    => [ "linux-x86_64", "openwrt" ],
 +    },