pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

wip/frida-libffi: import libffi-3.2.1nb4



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Mon Mar 12 20:20:52 2018 +0100
Changeset:	022f8ab368015304270edf1405bdc2771aecc342

Added Files:
	frida-libffi/DESCR
	frida-libffi/Makefile
	frida-libffi/PLIST
	frida-libffi/buildlink3.mk
	frida-libffi/distinfo
	frida-libffi/patches/patch-aa
	frida-libffi/patches/patch-ac
	frida-libffi/patches/patch-ad
	frida-libffi/patches/patch-ae
	frida-libffi/patches/patch-af
	frida-libffi/patches/patch-ag
	frida-libffi/patches/patch-aj
	frida-libffi/patches/patch-src_alpha_osf.S
	frida-libffi/patches/patch-src_arm_sysv.S
	frida-libffi/patches/patch-src_closures.c
	frida-libffi/patches/patch-src_m88k_elfbsd.S
	frida-libffi/patches/patch-src_x86_win32.S

Log Message:
wip/frida-libffi: import libffi-3.2.1nb4

The libffi library provides a portable, high level programming
interface to various calling conventions.  This allows a programmer to
call any function specified by a call interface description at
run-time.

Some programs may not know at the time of compilation what arguments
are to be passed to a function.  For instance, an interpreter may be
told at run-time about the number and types of arguments used to call
a given function.  Libffi can be used in such programs to provide a
bridge from the interpreter program to compiled code.

Ffi stands for Foreign Function Interface.  A foreign function
interface is the popular name for the interface that allows code
written in one language to call code written in another language.  The
libffi library really only provides the lowest, machine dependent
layer of a fully featured foreign function interface.  A layer must
exist above libffi that handles type conversions for values passed
between the two languages.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=022f8ab368015304270edf1405bdc2771aecc342

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 frida-libffi/DESCR                           |  18 +++
 frida-libffi/Makefile                        |  54 +++++++
 frida-libffi/PLIST                           |  10 ++
 frida-libffi/buildlink3.mk                   |  13 ++
 frida-libffi/distinfo                        |  18 +++
 frida-libffi/patches/patch-aa                | 134 ++++++++++++++++++
 frida-libffi/patches/patch-ac                |  15 ++
 frida-libffi/patches/patch-ad                |  15 ++
 frida-libffi/patches/patch-ae                |  27 ++++
 frida-libffi/patches/patch-af                |  39 ++++++
 frida-libffi/patches/patch-ag                |  15 ++
 frida-libffi/patches/patch-aj                |  31 ++++
 frida-libffi/patches/patch-src_alpha_osf.S   |  26 ++++
 frida-libffi/patches/patch-src_arm_sysv.S    |  89 ++++++++++++
 frida-libffi/patches/patch-src_closures.c    |  94 +++++++++++++
 frida-libffi/patches/patch-src_m88k_elfbsd.S | 202 +++++++++++++++++++++++++++
 frida-libffi/patches/patch-src_x86_win32.S   |  23 +++
 17 files changed, 823 insertions(+)

diffs:
diff --git a/frida-libffi/DESCR b/frida-libffi/DESCR
new file mode 100644
index 0000000000..96a2314ed6
--- /dev/null
+++ b/frida-libffi/DESCR
@@ -0,0 +1,18 @@
+The libffi library provides a portable, high level programming
+interface to various calling conventions.  This allows a programmer to
+call any function specified by a call interface description at
+run-time.
+
+Some programs may not know at the time of compilation what arguments
+are to be passed to a function.  For instance, an interpreter may be
+told at run-time about the number and types of arguments used to call
+a given function.  Libffi can be used in such programs to provide a
+bridge from the interpreter program to compiled code.
+
+Ffi stands for Foreign Function Interface.  A foreign function
+interface is the popular name for the interface that allows code
+written in one language to call code written in another language.  The
+libffi library really only provides the lowest, machine dependent
+layer of a fully featured foreign function interface.  A layer must
+exist above libffi that handles type conversions for values passed
+between the two languages.
diff --git a/frida-libffi/Makefile b/frida-libffi/Makefile
new file mode 100644
index 0000000000..d1e109e97e
--- /dev/null
+++ b/frida-libffi/Makefile
@@ -0,0 +1,54 @@
+# $NetBSD: Makefile,v 1.33 2017/09/05 15:08:42 joerg Exp $
+
+DISTNAME=	libffi-3.2.1
+PKGREVISION=	4
+CATEGORIES=	devel
+MASTER_SITES=	ftp://sourceware.org/pub/libffi/
+
+MAINTAINER=	asau%inbox.ru@localhost
+HOMEPAGE=	https://www.sourceware.org/libffi/
+COMMENT=	Foreign function interface
+LICENSE=	mit
+
+USE_LANGUAGES=		c c++
+USE_LIBTOOL=		yes
+USE_TOOLS+=		pkg-config
+GNU_CONFIGURE=		yes
+CONFIGURE_ARGS=		--includedir=${PREFIX}/include
+PKGCONFIG_OVERRIDE+=	libffi.pc.in
+INFO_FILES=		yes
+
+.include "../../mk/compiler.mk"
+# The Compaq C frontend groks .s, but not .S. Assemble osf.S directly w/ as(1).
+pre-build:
+.if !empty(PKGSRC_COMPILER:Mccc)
+	cd ${WRKSRC} && ./libtool --mode=compile --tag=CC as -I. -Iinclude -o src/alpha/osf.lo -c src/alpha/osf.S
+.endif
+
+# Since we don't have "TEST_DEPENDS", we implement it as a hack:
+.include "../../mk/bsd.prefs.mk"
+
+.if !empty(PKGSRC_RUN_TEST:M[Yy][Ee][Ss])
+TEST_TARGET=	check
+TEST_ENV=	# empty?
+BUILD_DEPENDS+=	dejagnu-[0-9]*:../../devel/dejagnu
+.endif
+
+# patch-aj uses m68k_sync_icache(2)
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-m68k)
+LIBS+=		-lm68k
+.endif
+
+# fix http://gnats.netbsd.org/42865
+.if !empty(MACHINE_PLATFORM:MSunOS-*-i386) && !empty(CC_VERSION:Mgcc-[23]*)
+CPPFLAGS+=	-D__PIC__
+.endif
+
+# irix fixes from PR 48587
+.if !empty(OPSYS:MIRIX)
+USE_TOOLS+=		bash gmake
+MAKE_FLAGS+=		SHELL=${TOOLS_DIR}/bin/bash
+.endif
+
+.include "../../mk/pthread.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/frida-libffi/PLIST b/frida-libffi/PLIST
new file mode 100644
index 0000000000..b3393dd0ca
--- /dev/null
+++ b/frida-libffi/PLIST
@@ -0,0 +1,10 @@
+@comment $NetBSD: PLIST,v 1.4 2012/09/14 23:45:27 asau Exp $
+include/ffi.h
+include/ffitarget.h
+info/libffi.info
+lib/libffi.la
+lib/pkgconfig/libffi.pc
+man/man3/ffi.3
+man/man3/ffi_call.3
+man/man3/ffi_prep_cif.3
+man/man3/ffi_prep_cif_var.3
diff --git a/frida-libffi/buildlink3.mk b/frida-libffi/buildlink3.mk
new file mode 100644
index 0000000000..aca08e99d8
--- /dev/null
+++ b/frida-libffi/buildlink3.mk
@@ -0,0 +1,13 @@
+# $NetBSD: buildlink3.mk,v 1.9 2012/09/15 00:22:43 asau Exp $
+
+BUILDLINK_TREE+=	libffi
+
+.if !defined(LIBFFI_BUILDLINK3_MK)
+LIBFFI_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.libffi+=	libffi>=1.20
+BUILDLINK_ABI_DEPENDS.libffi+=	libffi>=3.0.11
+BUILDLINK_PKGSRCDIR.libffi?=	../../devel/libffi
+.endif # LIBFFI_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-libffi
diff --git a/frida-libffi/distinfo b/frida-libffi/distinfo
new file mode 100644
index 0000000000..c01589c73c
--- /dev/null
+++ b/frida-libffi/distinfo
@@ -0,0 +1,18 @@
+$NetBSD: distinfo,v 1.45 2017/09/05 15:08:42 joerg Exp $
+
+SHA1 (libffi-3.2.1.tar.gz) = 280c265b789e041c02e5c97815793dfc283fb1e6
+RMD160 (libffi-3.2.1.tar.gz) = 9b546a3d002380bec3f00d86fc47d730abf51dfd
+SHA512 (libffi-3.2.1.tar.gz) = 980ca30a8d76f963fca722432b1fe5af77d7a4e4d2eac5144fbc5374d4c596609a293440573f4294207e1bdd9fda80ad1e1cafb2ffb543df5a275bc3bd546483
+Size (libffi-3.2.1.tar.gz) = 940837 bytes
+SHA1 (patch-aa) = 5218c8d895f97c812b7ca8d07c55b82ebcdc87d4
+SHA1 (patch-ac) = 63fba2e9486b73485a4f633927f5041110c43239
+SHA1 (patch-ad) = db57395ff721d7b56edec8a3a64b4b529258341c
+SHA1 (patch-ae) = fdb84a49c15041826396e4d3a6dda2de719801c0
+SHA1 (patch-af) = bf64b4082f24947cd47aba0758c347e5ddac3d7e
+SHA1 (patch-ag) = ae6a89f6b2be00c52139be6dcd14d0ebfe85d8f7
+SHA1 (patch-aj) = 5179cfd150bc7de15eb1c5ee0a327016c2c32b3e
+SHA1 (patch-src_alpha_osf.S) = 50d564a1d88284f04f6896719fa3613e9b0be70b
+SHA1 (patch-src_arm_sysv.S) = 2c97e0d069a4df2e1f5b6604e54b2d02c92691e2
+SHA1 (patch-src_closures.c) = 72760ccd973c5f9b157f5db8da180861d748beb2
+SHA1 (patch-src_m88k_elfbsd.S) = 6572c7fa39c00096cb4a80bb88993ff1b4aaa8cc
+SHA1 (patch-src_x86_win32.S) = 8a41cbc7237d6a171605a66e91d8d92a57181569
diff --git a/frida-libffi/patches/patch-aa b/frida-libffi/patches/patch-aa
new file mode 100644
index 0000000000..cc26834c67
--- /dev/null
+++ b/frida-libffi/patches/patch-aa
@@ -0,0 +1,134 @@
+$NetBSD: patch-aa,v 1.24 2016/01/25 17:56:39 jperkin Exp $
+
+Add more platforms to list which don't support writeable and executable heap.
+Other various platform changes.
+
+--- configure.orig	2014-11-12 11:59:57.000000000 +0000
++++ configure
+@@ -654,6 +654,8 @@ VAX_FALSE
+ VAX_TRUE
+ TILE_FALSE
+ TILE_TRUE
++VAX_FALSE
++VAX_TRUE
+ PA64_HPUX_FALSE
+ PA64_HPUX_TRUE
+ PA_HPUX_FALSE
+@@ -17120,7 +17122,7 @@ case "$host" in
+ 	TARGET=FRV; TARGETDIR=frv
+ 	;;
+ 
+-  hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*)
++  hppa*-*-linux* | hppa*-*-netbsd* | parisc*-*-linux* | hppa*-*-openbsd*)
+ 	TARGET=PA_LINUX; TARGETDIR=pa
+ 	;;
+   hppa*64-*-hpux*)
+@@ -17218,10 +17220,10 @@ case "$host" in
+ 	TARGET=METAG; TARGETDIR=metag
+ 	;;
+ 
+-  mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
++  mips*-sgi-irix5.* | mips*-sgi-irix6.* | mips*-*-rtems*)
+ 	TARGET=MIPS; TARGETDIR=mips
+ 	;;
+-  mips*-*linux* | mips*-*-openbsd*)
++  mips*-*linux* | mips*-*-netbsd* | mips*-*-openbsd*)
+ 	# Support 128-bit long double for NewABI.
+ 	HAVE_LONG_DOUBLE='defined(__mips64)'
+ 	TARGET=MIPS; TARGETDIR=mips
+@@ -17251,7 +17253,7 @@ case "$host" in
+   powerpc-*-aix* | rs6000-*-aix*)
+ 	TARGET=POWERPC_AIX; TARGETDIR=powerpc
+ 	;;
+-  powerpc-*-freebsd* | powerpc-*-openbsd*)
++  powerpc-*-freebsd* | powerpc-*-netbsd* | powerpc-*-openbsd*)
+ 	TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
+ 	HAVE_LONG_DOUBLE_VARIANT=1
+ 	;;
+@@ -17266,7 +17268,7 @@ case "$host" in
+ 	TARGET=S390; TARGETDIR=s390
+ 	;;
+ 
+-  sh-*-* | sh[34]*-*-*)
++  sh-*-* | shle-*-* | sh[34]*-*-*)
+ 	TARGET=SH; TARGETDIR=sh
+ 	;;
+   sh64-*-* | sh5*-*-*)
+@@ -17285,6 +17287,10 @@ case "$host" in
+ 	TARGET=VAX; TARGETDIR=vax
+ 	;;
+ 
++  vax-*-*)
++	TARGET=VAX; TARGETDIR=vax
++	;;
++
+   xtensa*-*)
+ 	TARGET=XTENSA; TARGETDIR=xtensa
+ 	;;
+@@ -17610,6 +17616,14 @@ else
+   VAX_FALSE=
+ fi
+ 
++ if test x$TARGET = xVAX; then
++  VAX_TRUE=
++  VAX_FALSE='#'
++else
++  VAX_TRUE='#'
++  VAX_FALSE=
++fi
++
+  if test x$TARGET = xXTENSA; then
+   XTENSA_TRUE=
+   XTENSA_FALSE='#'
+@@ -18530,7 +18544,7 @@ case "$target" in
+ $as_echo "#define FFI_EXEC_TRAMPOLINE_TABLE 1" >>confdefs.h
+ 
+      ;;
+-     *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
++     *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-netbsd* | *-*-openbsd* | *-*-solaris*)
+ 
+ $as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h
+ 
+@@ -18725,11 +18739,6 @@ if test "x$GCC" = "xyes"; then
+     toolexecdir="${libdir}"/gcc-lib/'$(target_alias)'
+     toolexeclibdir="${libdir}"
+   fi
+-  multi_os_directory=`$CC $CFLAGS -print-multi-os-directory`
+-  case $multi_os_directory in
+-    .) ;; # Avoid trailing /.
+-    ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
+-  esac
+ 
+ else
+   toolexeclibdir="${libdir}"
+@@ -19052,6 +19061,10 @@ if test -z "${VAX_TRUE}" && test -z "${V
+   as_fn_error $? "conditional \"VAX\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${VAX_TRUE}" && test -z "${VAX_FALSE}"; then
++  as_fn_error $? "conditional \"VAX\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+ if test -z "${XTENSA_TRUE}" && test -z "${XTENSA_FALSE}"; then
+   as_fn_error $? "conditional \"XTENSA\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+@@ -20749,13 +20762,13 @@ s/ [a-zA-Z0-9-]*-all [a-zA-Z0-9-]*-all-a
+ /-all-all/d
+ a\\
+ 	@ HOST="\$(HOST)\" \\\\\\
+-	; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\
+-	; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+-	; use=$x basename "\$\@" -all $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+-	; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" -eq "0" ; then : \\\\\\
+-	; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\
++	; test ".\$\$HOST" = "." && HOST="$x sh $ax_enable_builddir_auxdir/config.guess $x" \\\\\\
++	; BUILD="$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x" \\\\\\
++	; use="$x basename "\$\@" -all $x"; n="$x echo \$\$BUILD | wc -w $x" \\\\\\
++	; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test \$\$n = "0" ; then : \\\\\\
++	; BUILD="$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x" ; fi \\\\\\
+ 	; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+-	; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\
++	; test "\$\$use" = "\$\@" && BUILD="$x echo "\$\$BUILD" | tail -1 $x" \\\\\\
+ 	; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ 	; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done
+ /dist-all *:/a\\
diff --git a/frida-libffi/patches/patch-ac b/frida-libffi/patches/patch-ac
new file mode 100644
index 0000000000..69ea7b4b6e
--- /dev/null
+++ b/frida-libffi/patches/patch-ac
@@ -0,0 +1,15 @@
+$NetBSD: patch-ac,v 1.3 2016/01/25 17:56:39 jperkin Exp $
+
+Install header files in backwards compatible way.
+
+--- include/Makefile.in.orig	2014-11-12 11:59:58.000000000 +0000
++++ include/Makefile.in
+@@ -314,7 +314,7 @@ top_srcdir = @top_srcdir@
+ AUTOMAKE_OPTIONS = foreign
+ DISTCLEANFILES = ffitarget.h
+ EXTRA_DIST = ffi.h.in ffi_common.h
+-includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
++includesdir = $(includedir)
+ nodist_includes_HEADERS = ffi.h ffitarget.h
+ all: all-am
+ 
diff --git a/frida-libffi/patches/patch-ad b/frida-libffi/patches/patch-ad
new file mode 100644
index 0000000000..06a2d0e8cc
--- /dev/null
+++ b/frida-libffi/patches/patch-ad
@@ -0,0 +1,15 @@
+$NetBSD: patch-ad,v 1.3 2016/01/25 17:56:39 jperkin Exp $
+
+Install header files in backwards compatible way.
+
+--- libffi.pc.in.orig	2014-11-08 12:47:24.000000000 +0000
++++ libffi.pc.in
+@@ -2,7 +2,7 @@ prefix=@prefix@
+ exec_prefix=@exec_prefix@
+ libdir=@libdir@
+ toolexeclibdir=@toolexeclibdir@
+-includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
++includedir=@includedir@
+ 
+ Name: @PACKAGE_NAME@
+ Description: Library supporting Foreign Function Interfaces
diff --git a/frida-libffi/patches/patch-ae b/frida-libffi/patches/patch-ae
new file mode 100644
index 0000000000..475fbcda0b
--- /dev/null
+++ b/frida-libffi/patches/patch-ae
@@ -0,0 +1,27 @@
+$NetBSD: patch-ae,v 1.8 2016/11/03 11:40:28 maya Exp $
+
+Make a minimal adjustment to support the various NetBSD mips ports.
+
+--- src/mips/ffitarget.h.orig	2014-11-08 12:47:24.000000000 +0000
++++ src/mips/ffitarget.h
+@@ -32,7 +32,7 @@
+ #error "Please do not include ffitarget.h directly into your source.  Use ffi.h instead."
+ #endif
+ 
+-#ifdef linux
++#if defined(linux)
+ # include <asm/sgidefs.h>
+ #elif defined(__rtems__)
+ /*
+@@ -41,8 +41,10 @@
+ #define _MIPS_SIM_ABI32		1
+ #define _MIPS_SIM_NABI32	2
+ #define _MIPS_SIM_ABI64		3
+-#elif !defined(__OpenBSD__)
++#elif defined(__sgi)
+ # include <sgidefs.h>
++#else
++# include <sys/cdefs.h>
+ #endif
+ 
+ #  ifndef _ABIN32
diff --git a/frida-libffi/patches/patch-af b/frida-libffi/patches/patch-af
new file mode 100644
index 0000000000..c9f5dcbfaa
--- /dev/null
+++ b/frida-libffi/patches/patch-af
@@ -0,0 +1,39 @@
+$NetBSD: patch-af,v 1.5 2016/11/03 11:40:28 maya Exp $
+
+Fixes to support the various NetBSD mips ports.
+
+--- src/mips/ffi.c.orig	2014-11-08 12:47:24.000000000 +0000
++++ src/mips/ffi.c
+@@ -472,6 +477,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif 
+               ((cif->arg_types)[index]->type << (arg_reg * FFI_FLAG_BITS));
+ 	    arg_reg++;
+ 	    break;
++#ifdef __mips64
+           case FFI_TYPE_LONGDOUBLE:
+             /* Align it.  */
+             arg_reg = ALIGN(arg_reg, 2);
+@@ -490,7 +496,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif 
+ 		arg_reg++;
+ 	      }
+             break;
+-
++#endif
+ 	  case FFI_TYPE_STRUCT:
+             loc = arg_reg * FFI_SIZEOF_ARG;
+ 	    cif->flags += calc_n32_struct_flags(soft_float,
+@@ -552,6 +558,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif 
+ 	  cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
+ 	break;
+ 
++#ifdef __mips64
+       case FFI_TYPE_LONGDOUBLE:
+ 	/* Long double is returned as if it were a struct containing
+ 	   two doubles.  */
+@@ -568,6 +575,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif 
+ 					      << (4 + (FFI_FLAG_BITS * 8));
+ 	  }
+ 	break;
++#endif
+       default:
+ 	cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
+ 	break;
diff --git a/frida-libffi/patches/patch-ag b/frida-libffi/patches/patch-ag
new file mode 100644
index 0000000000..84acda3053
--- /dev/null
+++ b/frida-libffi/patches/patch-ag
@@ -0,0 +1,15 @@
+$NetBSD: patch-ag,v 1.2 2016/01/25 17:56:39 jperkin Exp $
+
+The %Lf printf format expects "long double", so cast args accordingly.
+
+--- testsuite/libffi.call/float2.c.orig	2014-11-08 12:47:24.000000000 +0000
++++ testsuite/libffi.call/float2.c
+@@ -45,7 +45,7 @@ int main (void)
+   /* This is ifdef'd out for now. long double support under SunOS/gcc
+      is pretty much non-existent.  You'll get the odd bus error in library
+      routines like printf().  */
+-  printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON);
++  printf ("%Lf, %Lf, %Lf, %Lf\n", (long double)ld, (long double)ldblit(f), (long double)(ld - ldblit(f)), (long double)LDBL_EPSILON);
+ #endif
+ 
+   /* These are not always the same!! Check for a reasonable delta */
diff --git a/frida-libffi/patches/patch-aj b/frida-libffi/patches/patch-aj
new file mode 100644
index 0000000000..0c4a5899e1
--- /dev/null
+++ b/frida-libffi/patches/patch-aj
@@ -0,0 +1,31 @@
+$NetBSD: patch-aj,v 1.5 2016/01/25 17:56:39 jperkin Exp $
+
+NetBSD/m68k support.
+
+--- src/m68k/ffi.c.orig	2014-11-08 12:47:24.000000000 +0000
++++ src/m68k/ffi.c
+@@ -9,8 +9,11 @@
+ 
+ #include <stdlib.h>
+ #include <unistd.h>
+-#ifdef __rtems__
++#if defined(__rtems__)
+ void rtems_cache_flush_multiple_data_lines( const void *, size_t );
++#elif defined(__NetBSD__)
++#include <sys/types.h>
++#include <m68k/sync_icache.h>
+ #else
+ #include <sys/syscall.h>
+ #ifdef __MINT__
+@@ -345,8 +348,10 @@ ffi_prep_closure_loc (ffi_closure* closu
+   else
+     *(void **)(closure->tramp + 8) = ffi_closure_SYSV;
+ 
+-#ifdef __rtems__
++#if defined(__rtems__)
+   rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE );
++#elif defined(__NetBSD__)
++  m68k_sync_icache(codeloc, FFI_TRAMPOLINE_SIZE);
+ #elif defined(__MINT__)
+   Ssystem(S_FLUSHCACHE, codeloc, FFI_TRAMPOLINE_SIZE);
+ #else
diff --git a/frida-libffi/patches/patch-src_alpha_osf.S b/frida-libffi/patches/patch-src_alpha_osf.S
new file mode 100644
index 0000000000..ec3901e3b2
--- /dev/null
+++ b/frida-libffi/patches/patch-src_alpha_osf.S
@@ -0,0 +1,26 @@
+$NetBSD: patch-src_alpha_osf.S,v 1.2 2016/01/25 17:56:39 jperkin Exp $
+
+Band-aid update of the alpha asm code to make it compile past the addition
+of type complex. Someone with clue on the alpha ELF ABI should provide
+real support for complex arguments.
+
+--- src/alpha/osf.S.orig	2014-11-08 12:47:24.000000000 +0000
++++ src/alpha/osf.S
+@@ -279,6 +279,7 @@ $load_table:
+ 	.gprel32 $load_64	# FFI_TYPE_SINT64
+ 	.gprel32 $load_none	# FFI_TYPE_STRUCT
+ 	.gprel32 $load_64	# FFI_TYPE_POINTER
++	.gprel32 $load_none	# FFI_TYPE_COMPLEX
+ 
+ /* Assert that the table above is in sync with ffi.h.  */
+ 
+@@ -294,7 +295,8 @@ $load_table:
+ 	|| FFI_TYPE_SINT64 != 12	\
+ 	|| FFI_TYPE_STRUCT != 13	\
+ 	|| FFI_TYPE_POINTER != 14	\
+-	|| FFI_TYPE_LAST != 14
++	|| FFI_TYPE_COMPLEX != 15	\
++	|| FFI_TYPE_LAST != 15
+ #error "osf.S out of sync with ffi.h"
+ #endif
+ 
diff --git a/frida-libffi/patches/patch-src_arm_sysv.S b/frida-libffi/patches/patch-src_arm_sysv.S
new file mode 100644
index 0000000000..ac8afad366
--- /dev/null
+++ b/frida-libffi/patches/patch-src_arm_sysv.S
@@ -0,0 +1,89 @@
+$NetBSD: patch-src_arm_sysv.S,v 1.7 2016/01/25 17:56:39 jperkin Exp $
+
+ARM fixes.
+
+--- src/arm/sysv.S.orig	2014-11-08 12:47:24.000000000 +0000
++++ src/arm/sysv.S
+@@ -25,6 +25,8 @@
+    DEALINGS IN THE SOFTWARE.
+    ----------------------------------------------------------------------- */
+ 
++.syntax unified
++
+ #define LIBFFI_ASM	
+ #include <fficonfig.h>
+ #include <ffi.h>
+@@ -103,7 +105,7 @@
+ #endif
+ 
+ /* Conditionally compile unwinder directives.  */
+-#ifdef __ARM_EABI__
++#if defined(__ARM_EABI__) && !defined(__ARM_DWARF_EH__)
+ #define UNWIND
+ #else
+ #define UNWIND @
+@@ -121,6 +123,7 @@
+ 	bx pc; \
+ 	nop; \
+ 	.arm; \
++	.cfi_startproc; \
+ 	UNWIND .fnstart; \
+ _L__##name:
+ #else
+@@ -129,6 +132,7 @@ _L__##name:
+ 	.align 2; \
+ 	.arm; \
+ 	ENTRY(name); \
++	.cfi_startproc; \
+ 	UNWIND .fnstart
+ #endif
+ 
+@@ -160,6 +164,7 @@ ARM_FUNC_START(ffi_call_SYSV)
+ 	@ Save registers
+         stmfd	sp!, {r0-r3, fp, lr}
+ 	UNWIND .save	{r0-r3, fp, lr}
++
+ 	mov	fp, sp
+ 
+ 	UNWIND .setfp	fp, sp
+@@ -238,6 +243,7 @@ LSYM(Lepilogue):
+ 
+ .ffi_call_SYSV_end:
+ 	UNWIND .fnend
++	.cfi_endproc
+ #ifdef __ELF__
+         .size    CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
+ #endif
+@@ -313,6 +319,7 @@ ARM_FUNC_START(ffi_closure_SYSV)
+ 
+ .ffi_closure_SYSV_end:
+ 	UNWIND .fnend
++	.cfi_endproc
+ #ifdef __ELF__
+         .size    CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
+ #endif
+@@ -396,7 +403,7 @@ LSYM(Lbase_args):
+ 	beq	LSYM(Lepilogue_vfp)
+ 
+ 	cmp	r3, #FFI_TYPE_SINT64
+-	stmeqia	r2, {r0, r1}
++	stmiaeq	r2, {r0, r1}
+ 	beq	LSYM(Lepilogue_vfp)
+ 
+ 	cmp	r3, #FFI_TYPE_FLOAT
+@@ -416,6 +423,7 @@ LSYM(Lepilogue_vfp):
+ 
+ .ffi_call_VFP_end:
+ 	UNWIND .fnend
++	.cfi_endproc
+         .size    CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP)
+ 
+ 
+@@ -478,6 +486,7 @@ ARM_FUNC_START(ffi_closure_VFP)
+ 
+ .ffi_closure_VFP_end:
+ 	UNWIND .fnend
++	.cfi_endproc
+         .size    CNAME(ffi_closure_VFP),.ffi_closure_VFP_end-CNAME(ffi_closure_VFP)
+ #endif
+ 
diff --git a/frida-libffi/patches/patch-src_closures.c b/frida-libffi/patches/patch-src_closures.c
new file mode 100644
index 0000000000..a135fecb8f
--- /dev/null
+++ b/frida-libffi/patches/patch-src_closures.c
@@ -0,0 +1,94 @@
+$NetBSD: patch-src_closures.c,v 1.2 2017/09/05 15:08:42 joerg Exp $
+
+--- src/closures.c.orig	2017-05-22 23:16:12.516083134 +0000
++++ src/closures.c
+@@ -33,6 +33,83 @@
+ #include <ffi.h>
+ #include <ffi_common.h>
+ 
++#ifdef __NetBSD__
++#include <sys/param.h>
++#endif
++
++#if __NetBSD_Version__ - 0 >= 799007200
++/* NetBSD with PROT_MPROTECT */
++#include <sys/mman.h>
++
++#include <stddef.h>
++#include <unistd.h>
++
++static const size_t overhead =
++  (sizeof(max_align_t) > sizeof(void *) + sizeof(size_t)) ?
++    sizeof(max_align_t)
++    : sizeof(void *) + sizeof(size_t);
++
++#define ADD_TO_POINTER(p, d) ((void *)((uintptr_t)(p) + (d)))
++
++void *
++ffi_closure_alloc (size_t size, void **code)
++{
++  static size_t page_size;
++  size_t rounded_size;
++  void *codeseg, *dataseg;
++  int prot;
++  
++
++  /* Expect that PAX mprotect is active and a separate code mapping is necessary. */
++  if (!code)
++    return NULL;
++
++  /* Obtain system page size. */
++  if (!page_size)
++    page_size = sysconf(_SC_PAGESIZE);
++
++  /* Round allocation size up to the next page, keeping in mind the size field and pointer to code map. */
++  rounded_size = (size + overhead + page_size - 1) & ~(page_size - 1);
++
++  /* Primary mapping is RW, but request permission to switch to PROT_EXEC later. */
++  prot = PROT_READ | PROT_WRITE | PROT_MPROTECT(PROT_EXEC);
++  dataseg = mmap(NULL, rounded_size, prot, MAP_ANON | MAP_PRIVATE, -1, 0);
++  if (dataseg == MAP_FAILED)
++    return NULL;
++
++  /* Create secondary mapping and switch it to RX. */
++  codeseg = mremap(dataseg, rounded_size, NULL, rounded_size, MAP_REMAPDUP);
++  if (codeseg == MAP_FAILED) {
++    munmap(dataseg, rounded_size);
++    return NULL;
++  }
++  if (mprotect(codeseg, rounded_size, PROT_READ | PROT_EXEC) == -1) {
++    munmap(codeseg, rounded_size);
++    munmap(dataseg, rounded_size);
++    return NULL;
++  }
++
++  /* Remember allocation size and location of the secondary mapping for ffi_closure_free. */
++  memcpy(dataseg, &rounded_size, sizeof(rounded_size));
++  memcpy(ADD_TO_POINTER(dataseg, sizeof(size_t)), &codeseg, sizeof(void *));
++  *code = ADD_TO_POINTER(codeseg, overhead);
++  return ADD_TO_POINTER(dataseg, overhead);
++}
++
++void
++ffi_closure_free (void *ptr)
++{
++  void *codeseg, *dataseg;
++  size_t rounded_size;
++
++  dataseg = ADD_TO_POINTER(ptr, -overhead);
++  memcpy(&rounded_size, dataseg, sizeof(rounded_size));
++  memcpy(&codeseg, ADD_TO_POINTER(dataseg, sizeof(size_t)), sizeof(void *));
++  munmap(dataseg, rounded_size);
++  munmap(codeseg, rounded_size);
++}
++#else /* !NetBSD with PROT_MPROTECT */
++
+ #if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE
+ # if __gnu_linux__ && !defined(__ANDROID__)
+ /* This macro indicates it may be forbidden to map anonymous memory
+@@ -686,3 +763,5 @@ ffi_closure_free (void *ptr)
+ 
+ # endif /* ! FFI_MMAP_EXEC_WRIT */
+ #endif /* FFI_CLOSURES */
++
++#endif /* NetBSD with PROT_MPROTECT */
diff --git a/frida-libffi/patches/patch-src_m88k_elfbsd.S b/frida-libffi/patches/patch-src_m88k_elfbsd.S
new file mode 100644
index 0000000000..943d22a337
--- /dev/null
+++ b/frida-libffi/patches/patch-src_m88k_elfbsd.S
@@ -0,0 +1,202 @@
+$NetBSD: patch-src_m88k_elfbsd.S,v 1.2 2016/01/25 17:56:39 jperkin Exp $
+
+m88k support.
+
+--- src/m88k/elfbsd.S.orig	2016-01-25 17:24:51.000000000 +0000
++++ src/m88k/elfbsd.S
+@@ -0,0 +1,195 @@
++/*
++ * Copyright (c) 2013 Miodrag Vallat.  <miod%openbsd.org@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining
++ * a copy of this software and associated documentation files (the
++ * ``Software''), to deal in the Software without restriction, including
++ * without limitation the rights to use, copy, modify, merge, publish,
++ * distribute, sublicense, and/or sell copies of the Software, and to
++ * permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ * 
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ * 
++ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
++ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
++ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++/*
++ * vax Foreign Function Interface
++ */
++
++#define LIBFFI_ASM	
++#include <fficonfig.h>
++#include <ffi.h>
++
++	.text
++
++/*
++ * void *					%r0
++ * ffi_call_elfbsd(extended_cif *ecif,		4(%ap)
++ *		   unsigned bytes,		8(%ap)
++ *		   unsigned flags,		12(%ap)
++ *		   void *rvalue,		16(%ap)
++ *		   void (*fn)());		20(%ap)
++ */
++	.globl	ffi_call_elfbsd
++	.type	ffi_call_elfbsd,@function
++	.align	2
++ffi_call_elfbsd:
++	.word	0x00c		# save R2 and R3
++
++	# Allocate stack space for the args
++	subl2	8(%ap), %sp
++
++	# Call ffi_prep_args
++	pushl	%sp
++	pushl	4(%ap)
++	calls	$2, ffi_prep_args
++
++	# Get function pointer
++	movl	20(%ap), %r1
++
++	# Build a CALLS frame
++	ashl	$-2, 8(%ap), %r0
++	pushl	%r0		# argument stack usage
++	movl	%sp, %r0	# future %ap
++	# saved registers
++	bbc	$11, 0(%r1), 1f
++	pushl	%r11
++1:	bbc	$10, 0(%r1), 1f
++	pushl	%r10
++1:	bbc	$9, 0(%r1), 1f
++	pushl	%r9
++1:	bbc	$8, 0(%r1), 1f
++	pushl	%r8
++1:	bbc	$7, 0(%r1), 1f
++	pushl	%r7
++1:	bbc	$6, 0(%r1), 1f
++	pushl	%r6
++1:	bbc	$5, 0(%r1), 1f
++	pushl	%r5
++1:	bbc	$4, 0(%r1), 1f
++	pushl	%r4
++1:	bbc	$3, 0(%r1), 1f
++	pushl	%r3
++1:	bbc	$2, 0(%r1), 1f
++	pushl	%r2
++1:	
++	pushal	9f
++	pushl	%fp
++	pushl	%ap
++	movl	16(%ap), %r3	# struct return address, if needed
++	movl	%r0, %ap
++	movzwl	4(%fp), %r0	# previous PSW, without the saved registers mask
++	bisl2	$0x20000000, %r0 # calls frame
++	movzwl	0(%r1), %r2
++	bicw2	$0xf003, %r2	# only keep R11-R2
++	ashl	$16, %r2, %r2
++	bisl2	%r2, %r0	# saved register mask of the called function
++	pushl	%r0	
++	pushl	$0
++	movl	%sp, %fp
++
++	# Invoke the function
++	pushal	2(%r1)		# skip procedure entry mask
++	movl	%r3, %r1
++	bicpsw	$0x000f
++	rsb
++
++9:
++	# Copy return value if necessary
++	tstl	16(%ap)
++	jeql	9f
++	movl	16(%ap), %r2
++
++	bbc	$0, 12(%ap), 1f	# CIF_FLAGS_CHAR
++	movb	%r0, 0(%r2)
++	brb	9f
++1:
++	bbc	$1, 12(%ap), 1f	# CIF_FLAGS_SHORT
++	movw	%r0, 0(%r2)
++	brb	9f
++1:
++	bbc	$2, 12(%ap), 1f	# CIF_FLAGS_INT
++	movl	%r0, 0(%r2)
++	brb	9f
++1:
++	bbc	$3, 12(%ap), 1f	# CIF_FLAGS_DINT
++	movq	%r0, 0(%r2)
++	brb	9f
++1:
++	movl	%r1, %r0	# might have been a struct
++	#brb	9f
++
++9:
++	ret
++
++/*
++ * ffi_closure_elfbsd(void);
++ * invoked with	%r0: ffi_closure *closure
++ */
++	.globl	ffi_closure_elfbsd
++	.type	ffi_closure_elfbsd, @function
++	.align	2
++ffi_closure_elfbsd:
++	.word	0
++
++	# Allocate room on stack for return value
++	subl2	$8, %sp
++
++	# Invoke the closure function
++	pushal	4(%ap)		# calling stack
++	pushal	4(%sp)		# return value
++	pushl	%r0		# closure
++	calls	$3, ffi_closure_elfbsd_inner
++
++	# Copy return value if necessary
++	bitb	$1, %r0		# CIF_FLAGS_CHAR
++	beql	1f
++	movb	0(%sp), %r0
++	brb	9f
++1:
++	bitb	$2, %r0		# CIF_FLAGS_SHORT
++	beql	1f
++	movw	0(%sp), %r0
++	brb	9f
++1:
++	bitb	$4, %r0		# CIF_FLAGS_INT
++	beql	1f
++	movl	0(%sp), %r0
++	brb	9f
++1:
++	bitb	$8, %r0		# CIF_FLAGS_DINT
++	beql	1f
++	movq	0(%sp), %r0
++	#brb	9f
++1:
++
++9:
++	ret
++
++/*
++ * ffi_closure_struct_elfbsd(void);
++ * invoked with	%r0: ffi_closure *closure
++ *		%r1: struct return address
++ */
++	.globl	ffi_closure_struct_elfbsd
++	.type	ffi_closure_struct_elfbsd, @function
++	.align	2
++ffi_closure_struct_elfbsd:
++	.word	0
++
++	# Invoke the closure function
++	pushal	4(%ap)		# calling stack
++	pushl	%r1		# return value
++	pushl	%r0		# closure
++	calls	$3, ffi_closure_elfbsd_inner
++
++	ret
diff --git a/frida-libffi/patches/patch-src_x86_win32.S b/frida-libffi/patches/patch-src_x86_win32.S
new file mode 100644
index 0000000000..eee7b8c06e
--- /dev/null
+++ b/frida-libffi/patches/patch-src_x86_win32.S
@@ -0,0 +1,23 @@
+$NetBSD: patch-src_x86_win32.S,v 1.1 2015/03/23 15:34:18 jperkin Exp $
+
+Disable incompatible assembly sections on 32-bit OSX.  Based on MacPorts fix
+in http://trac.macports.org/ticket/44170
+
+--- src/x86/win32.S.orig	2014-11-11 14:41:37.000000000 +0000
++++ src/x86/win32.S
+@@ -1182,6 +1182,7 @@ L_ffi_closure_WIN32_inner$stub:
+         hlt ; hlt ; hlt ; hlt ; hlt
+ #endif
+ 
++#if !defined(X86_DARWIN)
+ #if defined(X86_WIN32) && !defined(__OS2__)
+         .section	.eh_frame,"w"
+ #endif
+@@ -1343,6 +1344,7 @@ L_ffi_closure_WIN32_inner$stub:
+         /* End of DW_CFA_xxx CFI instructions.  */
+         .align 4
+ .LEFDE5:
++#endif /* X86_DARWIN */
+ 
+ #endif /* !_MSC_VER */
+ 


Home | Main Index | Thread Index | Old Index