summaryrefslogtreecommitdiff
path: root/harmony/libffi
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-02-27 14:34:02 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-02-27 14:34:02 -0600
commit7553795ec2d735c01dbdde129a65b7f45d5aa999 (patch)
treeb3970009a8246b0c17a105fe6b10c8077fc2b763 /harmony/libffi
parente2b01859c88d221992403d1293d42da33002be4d (diff)
downloadpackages-7553795ec2d735c01dbdde129a65b7f45d5aa999.tar.gz
packages-7553795ec2d735c01dbdde129a65b7f45d5aa999.tar.bz2
packages-7553795ec2d735c01dbdde129a65b7f45d5aa999.tar.xz
packages-7553795ec2d735c01dbdde129a65b7f45d5aa999.zip
Add harmony/ repo for packages still being discussed
See https://wiki.adelielinux.org/wiki/Project:Harmony
Diffstat (limited to 'harmony/libffi')
-rw-r--r--harmony/libffi/APKBUILD57
-rw-r--r--harmony/libffi/disable-ppc-ldvariant.patch11
-rw-r--r--harmony/libffi/fix-testsuite-longdouble.patch44
-rw-r--r--harmony/libffi/gnu-linux-define.patch15
-rw-r--r--harmony/libffi/pax-dlmmap.patch120
5 files changed, 247 insertions, 0 deletions
diff --git a/harmony/libffi/APKBUILD b/harmony/libffi/APKBUILD
new file mode 100644
index 000000000..4f4923b38
--- /dev/null
+++ b/harmony/libffi/APKBUILD
@@ -0,0 +1,57 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libffi
+pkgver=3.2.1
+pkgrel=4
+pkgdesc="A portable, high level programming interface to various calling conventions."
+url="http://sourceware.org/libffi"
+arch="all"
+license="MIT"
+depends=
+makedepends="texinfo"
+checkdepends="dejagnu"
+install=
+subpackages="$pkgname-dev $pkgname-doc"
+source="ftp://sourceware.org/pub/$pkgname/$pkgname-$pkgver.tar.gz
+ disable-ppc-ldvariant.patch
+ fix-testsuite-longdouble.patch
+ gnu-linux-define.patch
+ pax-dlmmap.patch
+ "
+
+builddir="$srcdir"/$pkgname-$pkgver
+
+build () {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --enable-pax_emutramp
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR=""$pkgdir"" install
+ install -m755 -d ""$pkgdir"/usr/share/licenses/$pkgname"
+ install -m644 LICENSE ""$pkgdir"/usr/share/licenses/$pkgname/"
+ # fix location for headers
+ # see also: https://github.com/libffi/libffi/issues/24
+ mkdir -p "$pkgdir"/usr/include/
+ mv "$pkgdir"/usr/lib/libffi-$pkgver/include/*.h \
+ "$pkgdir"/usr/include/
+ rmdir "$pkgdir"/usr/lib/libffi-$pkgver/include || true
+ sed -i -e '/^includedir=/{s,=.*,=/usr/include,g}' \
+ "$pkgdir"/usr/lib/pkgconfig/libffi.pc
+}
+
+sha512sums="980ca30a8d76f963fca722432b1fe5af77d7a4e4d2eac5144fbc5374d4c596609a293440573f4294207e1bdd9fda80ad1e1cafb2ffb543df5a275bc3bd546483 libffi-3.2.1.tar.gz
+cfd3b11a0e168fd74da0a6219c95610df3466b0769966351b2a5076c93a75996daf9aed41644bebb80e28793bbe18d62272385afd7813c472104cc6c93dcba41 disable-ppc-ldvariant.patch
+de92cb20ded7bfefc3e469ba2ac2d9d869d67dc172ec7e2d1222f8530944eb6d5016ae913baf01ac2e26bee1624c682ae9dd08d0e45d5532d59298dbe7e417eb fix-testsuite-longdouble.patch
+264af568ae5388d50f647f891a406945c73cc358692266f65ad341787c0bf5f6bf31203b86c39fa1b338101c1a6d2f4fec60f95a90d379951ff5153f8f9e178f gnu-linux-define.patch
+72486b389db16055ae4d7d33ba0cb05840537e28fe7a86aa89e2cb922592125d99c18c26c5df7ffde6282742e79f2b9126353e58b58f091f0486589e14dd6474 pax-dlmmap.patch"
diff --git a/harmony/libffi/disable-ppc-ldvariant.patch b/harmony/libffi/disable-ppc-ldvariant.patch
new file mode 100644
index 000000000..8b3f9cea0
--- /dev/null
+++ b/harmony/libffi/disable-ppc-ldvariant.patch
@@ -0,0 +1,11 @@
+--- libffi-3.2.1/configure.old 2014-11-12 06:59:57.000000000 -0500
++++ libffi-3.2.1/configure 2017-10-10 05:44:12.732989967 -0400
+@@ -17237,7 +17237,7 @@
+
+ powerpc*-*-linux* | powerpc-*-sysv*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+- HAVE_LONG_DOUBLE_VARIANT=1
++ #HAVE_LONG_DOUBLE_VARIANT=1
+ ;;
+ powerpc-*-amigaos*)
+ TARGET=POWERPC; TARGETDIR=powerpc
diff --git a/harmony/libffi/fix-testsuite-longdouble.patch b/harmony/libffi/fix-testsuite-longdouble.patch
new file mode 100644
index 000000000..20fe4b8c6
--- /dev/null
+++ b/harmony/libffi/fix-testsuite-longdouble.patch
@@ -0,0 +1,44 @@
+--- libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split.c.old 2014-11-08 07:47:24.000000000 -0500
++++ libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split.c 2017-10-10 06:04:26.293045176 -0400
+@@ -6,7 +6,7 @@
+
+ /* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+-/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
++/* { dg-options -mlong-double-64 { target powerpc64*-*-linux* } } */
+ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+ #include "ffitest.h"
+--- libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split2.c.old 2014-11-08 07:47:24.000000000 -0500
++++ libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split2.c 2017-10-10 06:04:54.283046103 -0400
+@@ -7,7 +7,7 @@
+
+ /* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+ /* { dg-do run { xfail strongarm*-*-* } } */
+-/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
++/* { dg-options -mlong-double-64 { target powerpc64*-*-linux* } } */
+ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+ #include "ffitest.h"
+--- libffi-3.2.1/testsuite/libffi.call/cls_longdouble.c.old 2014-11-08 07:47:24.000000000 -0500
++++ libffi-3.2.1/testsuite/libffi.call/cls_longdouble.c 2017-10-10 06:05:19.683046965 -0400
+@@ -8,7 +8,7 @@
+ /* This test is known to PASS on armv7l-unknown-linux-gnueabihf, so I have
+ remove the xfail for arm*-*-* below, until we know more. */
+ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+-/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
++/* { dg-options -mlong-double-64 { target powerpc64*-*-linux* } } */
+ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+ #include "ffitest.h"
+--- libffi-3.2.1/testsuite/libffi.call/huge_struct.c.old 2014-11-08 07:47:24.000000000 -0500
++++ libffi-3.2.1/testsuite/libffi.call/huge_struct.c 2017-10-10 06:05:39.383047674 -0400
+@@ -7,7 +7,7 @@
+
+ /* { dg-excess-errors "" { target x86_64-*-mingw* x86_64-*-cygwin* } } */
+ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+-/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
++/* { dg-options -mlong-double-64 { target powerpc64*-*-linux* } } */
+ /* { dg-options -Wformat=0 { target moxie*-*-elf } } */
+ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
diff --git a/harmony/libffi/gnu-linux-define.patch b/harmony/libffi/gnu-linux-define.patch
new file mode 100644
index 000000000..8dcae738b
--- /dev/null
+++ b/harmony/libffi/gnu-linux-define.patch
@@ -0,0 +1,15 @@
+http://bugs.alpinelinux.org/issues/4275
+
+diff --git a/closures.c.orig b/closures.c
+index 721ff00..22a699c 100644
+--- a/src/closures.c.orig
++++ b/src/closures.c
+@@ -34,7 +34,7 @@
+ #include <ffi_common.h>
+
+ #if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE
+-# if __gnu_linux__ && !defined(__ANDROID__)
++# if __linux__ && !defined(__ANDROID__)
+ /* This macro indicates it may be forbidden to map anonymous memory
+ with both write and execute permission. Code compiled when this
+ option is defined will attempt to map such pages once, but if it
diff --git a/harmony/libffi/pax-dlmmap.patch b/harmony/libffi/pax-dlmmap.patch
new file mode 100644
index 000000000..ec4150410
--- /dev/null
+++ b/harmony/libffi/pax-dlmmap.patch
@@ -0,0 +1,120 @@
+From 48d2e46528fb6e621d95a7fa194069fd136b712d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20B=C3=BChler?= <buehler@cert.uni-stuttgart.de>
+Date: Wed, 7 Sep 2016 15:49:48 +0200
+Subject: [PATCH 1/2] dlmmap_locked always needs locking as it always modifies
+ execsize
+
+---
+ src/closures.c | 13 ++++---------
+ 1 file changed, 4 insertions(+), 9 deletions(-)
+
+diff --git a/src/closures.c b/src/closures.c
+index 2e0ffb45..04d6e27f 100644
+--- a/src/closures.c
++++ b/src/closures.c
+@@ -769,16 +769,11 @@ dlmmap (void *start, size_t length, int prot,
+ MREMAP_DUP and prot at this point. */
+ }
+
+- if (execsize == 0 || execfd == -1)
+- {
+- pthread_mutex_lock (&open_temp_exec_file_mutex);
+- ptr = dlmmap_locked (start, length, prot, flags, offset);
+- pthread_mutex_unlock (&open_temp_exec_file_mutex);
++ pthread_mutex_lock (&open_temp_exec_file_mutex);
++ ptr = dlmmap_locked (start, length, prot, flags, offset);
++ pthread_mutex_unlock (&open_temp_exec_file_mutex);
+
+- return ptr;
+- }
+-
+- return dlmmap_locked (start, length, prot, flags, offset);
++ return ptr;
+ }
+
+ /* Release memory at the given address, as well as the corresponding
+
+From 7aad5f895e2dfdb79d2ef67e1b231d21063e6511 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20B=C3=BChler?= <buehler@cert.uni-stuttgart.de>
+Date: Wed, 7 Sep 2016 15:50:54 +0200
+Subject: [PATCH 2/2] ignore PaX EMUTRAMP flag; instead check for MPROTECT
+
+- code using ffi_closure_alloc doesn't necessarily generate gcc compatible trampolines; only those are allowed by PaX
+- if MPROTECT is enabled use the same workaround as is used for SELinux (double mmap())
+---
+ src/closures.c | 29 +++++++++++++----------------
+ 1 file changed, 13 insertions(+), 16 deletions(-)
+
+diff --git a/src/closures.c b/src/closures.c
+index 04d6e27f..babecc1a 100644
+--- a/src/closures.c
++++ b/src/closures.c
+@@ -401,14 +401,15 @@ selinux_enabled_check (void)
+
+ #endif /* !FFI_MMAP_EXEC_SELINUX */
+
+-/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */
++/* On PaX enable kernels that have MPROTECT enabled we can't use PROT_EXEC. */
+ #ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX
+ #include <stdlib.h>
+
+-static int emutramp_enabled = -1;
++/* -1: not read yet; 0: no PaX or MPROTECT disabled; 1: MPROTECT enabled. */
++static int mprotect_enabled = -1;
+
+ static int
+-emutramp_enabled_check (void)
++mprotect_enabled_check (void)
+ {
+ char *buf = NULL;
+ size_t len = 0;
+@@ -422,9 +423,7 @@ emutramp_enabled_check (void)
+ while (getline (&buf, &len, f) != -1)
+ if (!strncmp (buf, "PaX:", 4))
+ {
+- char emutramp;
+- if (sscanf (buf, "%*s %*c%c", &emutramp) == 1)
+- ret = (emutramp == 'E');
++ ret = (NULL != strchr (buf + 4, 'M'));
+ break;
+ }
+ free (buf);
+@@ -432,8 +431,9 @@ emutramp_enabled_check (void)
+ return ret;
+ }
+
+-#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
+- : (emutramp_enabled = emutramp_enabled_check ()))
++#define is_mprotect_enabled() (mprotect_enabled >= 0 ? mprotect_enabled \
++ : (mprotect_enabled = mprotect_enabled_check ()))
++
+ #endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
+
+ #elif defined (__CYGWIN__) || defined(__INTERIX)
+@@ -446,7 +446,7 @@ emutramp_enabled_check (void)
+ #endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
+
+ #ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX
+-#define is_emutramp_enabled() 0
++#define is_mprotect_enabled() 0
+ #endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
+
+ /* Declare all functions defined in dlmalloc.c as static. */
+@@ -750,13 +750,10 @@ dlmmap (void *start, size_t length, int prot,
+ && flags == (MAP_PRIVATE | MAP_ANONYMOUS)
+ && fd == -1 && offset == 0);
+
+- if (execfd == -1 && is_emutramp_enabled ())
+- {
+- ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset);
+- return ptr;
+- }
+-
+- if (execfd == -1 && !is_selinux_enabled ())
++ /* -1 != execfd hints that we already decided to use dlmmap_locked
++ last time. If PaX MPROTECT or SELinux is active fallback to
++ dlmmap_locked. */
++ if (execfd == -1 && !is_mprotect_enabled () && !is_selinux_enabled ())
+ {
+ ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
+