From f4b50af4c9bbda43d5396e87f083427f09895965 Mon Sep 17 00:00:00 2001 From: Nathan Owens Date: Thu, 31 Dec 2020 20:27:21 -0600 Subject: [PATCH] scanmem: fix cross-build Add build option procmem, other than allowing user to choose if they want to use procmem. Set to disabled by defaut in case system does not support procmem. --- srcpkgs/scanmem/patches/0001-fix-cross.patch | 65 +++++++++++++++++++ .../patches/0002-fix-test-for-musl.patch | 41 ++++++++++++ srcpkgs/scanmem/template | 7 +- 3 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 srcpkgs/scanmem/patches/0001-fix-cross.patch create mode 100644 srcpkgs/scanmem/patches/0002-fix-test-for-musl.patch diff --git a/srcpkgs/scanmem/patches/0001-fix-cross.patch b/srcpkgs/scanmem/patches/0001-fix-cross.patch new file mode 100644 index 00000000000..f9709415ff1 --- /dev/null +++ b/srcpkgs/scanmem/patches/0001-fix-cross.patch @@ -0,0 +1,65 @@ +From 967f6ed071e41a289a49b26ba0f16ee098f13324 Mon Sep 17 00:00:00 2001 +From: Nathan Owens +Date: Fri, 1 Jan 2021 18:08:42 -0600 +Subject: [PATCH] fix cross + +--- + configure.ac | 42 ++++++++++++++---------------------------- + 1 file changed, 14 insertions(+), 28 deletions(-) + +diff --git configure.ac configure.ac +index 5b8bac3..a82bd00 100644 +--- configure.ac ++++ configure.ac +@@ -57,34 +57,20 @@ case "$host_os" in + AC_MSG_NOTICE([Your platform is not currently supported]) + ;; + esac +- +-AS_IF([test "x$android" = "xno"], [ +- # also need to check if the file is zero'ed (some hardened systems) +- AC_CHECK_FILE([/proc/self/maps], [], [ +- echo "This system does not seem to have /proc/pid/maps files." +- exit 1 +- ]) +- +- # also need to check this file works +- AC_CHECK_FILE([/proc/self/mem], [ +- # LARGEFILE support required for this to work +- AC_SYS_LARGEFILE +- AC_DEFINE(HAVE_PROCMEM, [1], [Enable /proc/pid/mem support]) +- ],[ +- # This will hurt performance. +- echo "This system does not seem to have /proc/pid/mem files." +- echo "Falling back to ptrace() only support." +- AC_DEFINE(HAVE_PROCMEM, [0], [Enable /proc/pid/mem support]) +- ]) +- # malloc optimizations without Android +- AC_FUNC_MALLOC +- AC_FUNC_REALLOC +-], [ +- # supported on Android +- AC_SYS_LARGEFILE +- # /proc/pid/mem is there but reading interesting data fails +- AC_DEFINE(HAVE_PROCMEM, [0], [Enable /proc/pid/mem support]) +-]) ++AC_ARG_ENABLE(procmem, ++ [AS_HELP_STRING([--enable-procmem], [forcefully enable proc/pid/mem support])]) ++ ++AS_IF([test "x$android" = "xno"],[ ++ AS_IF([test "x$enable_procmem" = "xyes"],[ ++ AC_SYS_LARGEFILE ++ AC_DEFINE(HAVE_PROCMEM, [1], [Enable /proc/pid/mem support])], ++ [AC_DEFINE(HAVE_PROCMEM, [0], [Disable /proc/pid/mem support]) ++ ]) ++ # malloc optimizations without Android ++ AC_FUNC_MALLOC ++ AC_FUNC_REALLOC], ++ [AC_SYS_LARGEFILE ++ AC_DEFINE([HAVE_PROCMEM, [0], [Disable /proc/pid/mem support]])]) + + # Check for termcap and readline or bypass checking for the libraries. + AC_ARG_WITH([readline], [AS_HELP_STRING([--without-readline], +-- +2.30.0 + diff --git a/srcpkgs/scanmem/patches/0002-fix-test-for-musl.patch b/srcpkgs/scanmem/patches/0002-fix-test-for-musl.patch new file mode 100644 index 00000000000..43f6a338a4c --- /dev/null +++ b/srcpkgs/scanmem/patches/0002-fix-test-for-musl.patch @@ -0,0 +1,41 @@ +From e5781feb4403e7f2de19f7c027cda5e5ef092a5c Mon Sep 17 00:00:00 2001 +From: Nathan Owens +Date: Fri, 1 Jan 2021 15:46:05 -0600 +Subject: [PATCH] fix test for musl + +--- + test/memfake.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git test/memfake.c test/memfake.c +index 1c4fa94..bc2da8e 100644 +--- test/memfake.c ++++ test/memfake.c +@@ -22,19 +22,21 @@ + #include + #include + #include ++#include + + int main(int argc, char **argv) + { +- uint MB_to_allocate = 1; ++ size_t MB_to_allocate = 1; + bool add_randomness = false; + +- if (argc >= 2) MB_to_allocate = atoi(argv[1]); +- if (argc >= 3) add_randomness = atoi(argv[2]); ++ if (argc >= 2) MB_to_allocate = strtoul(argv[1], 0, 10); ++ if (argc >= 3) add_randomness = strtoul(argv[2], 0, 10); + if (argc >= 4) return 1; + + size_t array_size = MB_to_allocate * 1024 * 1024 / sizeof(int); + + int* array = calloc(array_size, sizeof(int)); ++ assert(array != NULL); + + // Fill half with random values and leave an half of zeroes, if asked to + if (add_randomness) { +-- +2.30.0 + diff --git a/srcpkgs/scanmem/template b/srcpkgs/scanmem/template index d694f33d372..8ea73b20c31 100644 --- a/srcpkgs/scanmem/template +++ b/srcpkgs/scanmem/template @@ -1,9 +1,9 @@ # Template file for 'scanmem' pkgname=scanmem version=0.17 -revision=6 +revision=7 build_style=gnu-configure -configure_args="--disable-static --enable-gui" +configure_args="--disable-static --enable-gui $(vopt_enable procmem)" hostmakedepends="automake gettext-devel intltool libtool m4 python" makedepends="readline-devel" short_desc="Memory scanner designed to isolate the address of an arbitrary var" @@ -14,7 +14,8 @@ distfiles="https://github.com/${pkgname}/${pkgname}/archive/v${version}.tar.gz" checksum=f02054b91322cf41517506158fcb74554e9fc6644e696f8aa25e5acf162d374b CFLAGS="-D__NEED_pid_t" -nocross="checking for /proc/self/maps... configure: error" +build_options="procmem" +desc_option_procmem="Enable /proc/pid/mem support" pre_configure() { NOCONFIGURE=1 ./autogen.sh