aboutsummaryrefslogtreecommitdiff
path: root/qemu_mode
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-05-15 08:36:51 +0200
committerGitHub <noreply@github.com>2020-05-15 08:36:51 +0200
commit87a693d1a956fd0fcb0ebbdecff24053b69e8560 (patch)
tree34578ae146ad79b7748363f23fe022a8e6c1a76d /qemu_mode
parent1317433a51a7f7336c82c80a592835ddda9ef60f (diff)
parent49bd24144a881f4f55ef1a3db9a7f129a6670488 (diff)
downloadafl++-87a693d1a956fd0fcb0ebbdecff24053b69e8560.tar.gz
Merge pull request #360 from AFLplusplus/dev2.65c
new code formatting + applied
Diffstat (limited to 'qemu_mode')
-rwxr-xr-xqemu_mode/build_qemu_support.sh18
-rw-r--r--qemu_mode/libcompcov/libcompcov.so.c4
-rw-r--r--qemu_mode/patches/afl-qemu-common.h24
-rw-r--r--qemu_mode/patches/afl-qemu-cpu-inl.h2
-rw-r--r--qemu_mode/patches/afl-qemu-cpu-translate-inl.h4
5 files changed, 31 insertions, 21 deletions
diff --git a/qemu_mode/build_qemu_support.sh b/qemu_mode/build_qemu_support.sh
index bd18927f..1828528e 100755
--- a/qemu_mode/build_qemu_support.sh
+++ b/qemu_mode/build_qemu_support.sh
@@ -63,7 +63,7 @@ if [ ! -f "../afl-showmap" ]; then
fi
PREREQ_NOTFOUND=
-for i in libtool wget python automake autoconf sha384sum bison flex iconv patch pkg-config; do
+for i in libtool wget automake autoconf sha384sum bison flex iconv patch pkg-config; do
T=`command -v "$i" 2>/dev/null`
@@ -76,6 +76,14 @@ for i in libtool wget python automake autoconf sha384sum bison flex iconv patch
done
+PYTHONBIN=`command -v python3 || command -v python || command -v python2`
+
+if [ "$PYTHONBIN" = "" ]; then
+ echo "[-] Error: 'python' not found, please install using 'sudo apt install python3'."
+ PREREQ_NOTFOUND=1
+fi
+
+
if [ ! -d "/usr/include/glib-2.0/" -a ! -d "/usr/local/include/glib-2.0/" ]; then
echo "[-] Error: devel version of 'glib2' not found, please install first."
@@ -202,16 +210,17 @@ if [ "$STATIC" = "1" ]; then
--disable-libusb --disable-usb-redir --disable-vde --disable-vhost-net --disable-virglrenderer \
--disable-virtfs --disable-vnc --disable-vte --disable-xen --disable-xen-pci-passthrough --disable-xfsctl \
--enable-linux-user --disable-system --disable-blobs --disable-tools --enable-capstone=internal \
- --target-list="${CPU_TARGET}-linux-user" --static --disable-pie --cross-prefix=$CROSS_PREFIX || exit 1
+ --target-list="${CPU_TARGET}-linux-user" --static --disable-pie --cross-prefix=$CROSS_PREFIX --python="$PYTHONBIN" \
+ || exit 1
else
# --enable-pie seems to give a couple of exec's a second performance
# improvement, much to my surprise. Not sure how universal this is..
-
+
./configure --disable-system \
--enable-linux-user --disable-gtk --disable-sdl --disable-vnc --enable-capstone=internal \
- --target-list="${CPU_TARGET}-linux-user" --enable-pie $CROSS_PREFIX || exit 1
+ --target-list="${CPU_TARGET}-linux-user" --enable-pie $CROSS_PREFIX --python="$PYTHONBIN" || exit 1
fi
@@ -279,6 +288,7 @@ echo "[+] Building libcompcov ..."
make -C libcompcov && echo "[+] libcompcov ready"
echo "[+] Building unsigaction ..."
make -C unsigaction && echo "[+] unsigaction ready"
+
echo "[+] All done for qemu_mode, enjoy!"
exit 0
diff --git a/qemu_mode/libcompcov/libcompcov.so.c b/qemu_mode/libcompcov/libcompcov.so.c
index bffdd5d8..23f465a4 100644
--- a/qemu_mode/libcompcov/libcompcov.so.c
+++ b/qemu_mode/libcompcov/libcompcov.so.c
@@ -20,7 +20,7 @@
*/
#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
+ #define _GNU_SOURCE
#endif
#include <dlfcn.h>
#include <stdio.h>
@@ -36,7 +36,7 @@
#include "pmparser.h"
#ifndef __linux__
-#error "Sorry, this library is Linux-specific for now!"
+ #error "Sorry, this library is Linux-specific for now!"
#endif /* !__linux__ */
/* Change this value to tune the compare coverage */
diff --git a/qemu_mode/patches/afl-qemu-common.h b/qemu_mode/patches/afl-qemu-common.h
index 94f853cc..dbdb41bc 100644
--- a/qemu_mode/patches/afl-qemu-common.h
+++ b/qemu_mode/patches/afl-qemu-common.h
@@ -40,27 +40,27 @@
#define PERSISTENT_DEFAULT_MAX_CNT 1000
#ifdef CPU_NB_REGS
-#define AFL_REGS_NUM CPU_NB_REGS
+ #define AFL_REGS_NUM CPU_NB_REGS
#elif TARGET_ARM
-#define AFL_REGS_NUM 32
+ #define AFL_REGS_NUM 32
#elif TARGET_AARCH64
-#define AFL_REGS_NUM 32
+ #define AFL_REGS_NUM 32
#else
-#define AFL_REGS_NUM 100
+ #define AFL_REGS_NUM 100
#endif
/* NeverZero */
#if (defined(__x86_64__) || defined(__i386__)) && defined(AFL_QEMU_NOT_ZERO)
-#define INC_AFL_AREA(loc) \
- asm volatile( \
- "incb (%0, %1, 1)\n" \
- "adcb $0, (%0, %1, 1)\n" \
- : /* no out */ \
- : "r"(afl_area_ptr), "r"(loc) \
- : "memory", "eax")
+ #define INC_AFL_AREA(loc) \
+ asm volatile( \
+ "incb (%0, %1, 1)\n" \
+ "adcb $0, (%0, %1, 1)\n" \
+ : /* no out */ \
+ : "r"(afl_area_ptr), "r"(loc) \
+ : "memory", "eax")
#else
-#define INC_AFL_AREA(loc) afl_area_ptr[loc]++
+ #define INC_AFL_AREA(loc) afl_area_ptr[loc]++
#endif
typedef void (*afl_persistent_hook_fn)(uint64_t *regs, uint64_t guest_base);
diff --git a/qemu_mode/patches/afl-qemu-cpu-inl.h b/qemu_mode/patches/afl-qemu-cpu-inl.h
index 78a8f800..e4ebaf88 100644
--- a/qemu_mode/patches/afl-qemu-cpu-inl.h
+++ b/qemu_mode/patches/afl-qemu-cpu-inl.h
@@ -35,7 +35,7 @@
#include "afl-qemu-common.h"
#ifndef AFL_QEMU_STATIC_BUILD
-#include <dlfcn.h>
+ #include <dlfcn.h>
#endif
/***************************
diff --git a/qemu_mode/patches/afl-qemu-cpu-translate-inl.h b/qemu_mode/patches/afl-qemu-cpu-translate-inl.h
index 2e740ad9..083c27e5 100644
--- a/qemu_mode/patches/afl-qemu-cpu-translate-inl.h
+++ b/qemu_mode/patches/afl-qemu-cpu-translate-inl.h
@@ -36,9 +36,9 @@
#include "tcg-op.h"
#if TCG_TARGET_REG_BITS == 64
-#define _DEFAULT_MO MO_64
+ #define _DEFAULT_MO MO_64
#else
-#define _DEFAULT_MO MO_32
+ #define _DEFAULT_MO MO_32
#endif
static void afl_gen_compcov(target_ulong cur_loc, TCGv arg1, TCGv arg2,