Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/rth/tags/pull-dis-20171026' int…
Browse files Browse the repository at this point in the history
…o staging

Capstone disassembler

# gpg: Signature made Thu 26 Oct 2017 10:57:27 BST
# gpg:                using RSA key 0x64DF38E8AF7E215F
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>"
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth/tags/pull-dis-20171026:
  disas: Add capstone as submodule
  disas: Remove monitor_disas_is_physical
  ppc: Support Capstone in disas_set_info
  arm: Support Capstone in disas_set_info
  i386: Support Capstone in disas_set_info
  disas: Support the Capstone disassembler library
  disas: Remove unused flags arguments
  target/arm: Don't set INSN_ARM_BE32 for CONFIG_USER_ONLY
  target/arm: Move BE32 disassembler fixup
  target/ppc: Convert to disas_set_info hook
  target/i386: Convert to disas_set_info hook

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

# Conflicts:
#	target/i386/cpu.c
#	target/ppc/translate_init.c
  • Loading branch information
pm215 committed Oct 27, 2017
2 parents 74d7fc7 + e219c49 commit 6e6430a
Show file tree
Hide file tree
Showing 33 changed files with 468 additions and 185 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -37,3 +37,6 @@
[submodule "ui/keycodemapdb"]
path = ui/keycodemapdb
url = git://git.qemu.org/keycodemapdb.git
[submodule "capstone"]
path = capstone
url = git://git.qemu.org/capstone.git
15 changes: 15 additions & 0 deletions Makefile
Expand Up @@ -383,6 +383,21 @@ subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests
dtc/%: .git-submodule-status
mkdir -p $@

# Overriding CFLAGS causes us to lose defines added in the sub-makefile.
# Not overriding CFLAGS leads to mis-matches between compilation modes.
# Therefore we replicate some of the logic in the sub-makefile.
# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
# no need to annoy QEMU developers with such things.
CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
CAP_CFLAGS += -DCAPSTONE_HAS_ARM
CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
CAP_CFLAGS += -DCAPSTONE_HAS_X86

subdir-capstone: .git-submodule-status
$(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=no BUILDDIR="$(BUILD_DIR)/capstone" CC="$(CC)" AR="$(AR)" LD="$(LD)" CFLAGS="$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_DIR)/capstone/$(LIBCAPSTONE))

$(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \
$(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY))

Expand Down
1 change: 1 addition & 0 deletions capstone
Submodule capstone added at 22ead3
72 changes: 72 additions & 0 deletions configure
Expand Up @@ -375,6 +375,7 @@ opengl_dmabuf="no"
cpuid_h="no"
avx2_opt="no"
zlib="yes"
capstone=""
lzo=""
snappy=""
bzip2=""
Expand Down Expand Up @@ -1294,6 +1295,14 @@ for opt do
error_exit "vhost-user isn't available on win32"
fi
;;
--disable-capstone) capstone="no"
;;
--enable-capstone) capstone="yes"
;;
--enable-capstone=git) capstone="git"
;;
--enable-capstone=system) capstone="system"
;;
*)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
Expand Down Expand Up @@ -1541,6 +1550,7 @@ disabled with --disable-FEATURE, default is enabled if available:
vxhs Veritas HyperScale vDisk backend support
crypto-afalg Linux AF_ALG crypto backend driver
vhost-user vhost-user support
capstone capstone disassembler support
NOTE: The object files are built at the place where configure is launched
EOF
Expand Down Expand Up @@ -4410,6 +4420,58 @@ EOF
fi
fi

##########################################
# capstone

case "$capstone" in
"" | yes)
if $pkg_config capstone; then
capstone=system
elif test -e "${source_path}/.git" ; then
capstone=git
elif test -e "${source_path}/capstone/Makefile" ; then
capstone=internal
elif test -z "$capstone" ; then
capstone=no
else
feature_not_found "capstone" "Install capstone devel or git submodule"
fi
;;

system)
if ! $pkg_config capstone; then
feature_not_found "capstone" "Install capstone devel"
fi
;;
esac

case "$capstone" in
git | internal)
if test "$capstone" = git; then
git_submodules="${git_submodules} capstone"
fi
mkdir -p capstone
QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
if test "$mingw32" = "yes"; then
LIBCAPSTONE=capstone.lib
else
LIBCAPSTONE=libcapstone.a
fi
LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
;;

system)
QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
LIBS="$($pkg_config --libs capstone) $LIBS"
;;

no)
;;
*)
error_exit "Unknown state for capstone: $capstone"
;;
esac

##########################################
# check if we have fdatasync

Expand Down Expand Up @@ -5468,6 +5530,7 @@ echo "jemalloc support $jemalloc"
echo "avx2 optimization $avx2_opt"
echo "replication support $replication"
echo "VxHS block device $vxhs"
echo "capstone $capstone"

if test "$sdl_too_old" = "yes"; then
echo "-> Your SDL version is too old - please upgrade to have SDL support"
Expand Down Expand Up @@ -6142,6 +6205,9 @@ fi
if test "$ivshmem" = "yes" ; then
echo "CONFIG_IVSHMEM=y" >> $config_host_mak
fi
if test "$capstone" != "no" ; then
echo "CONFIG_CAPSTONE=y" >> $config_host_mak
fi

# Hold two types of flag:
# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
Expand Down Expand Up @@ -6624,6 +6690,12 @@ done # for target in $targets
if [ "$dtc_internal" = "yes" ]; then
echo "config-host.h: subdir-dtc" >> $config_host_mak
fi
if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
echo "config-host.h: subdir-capstone" >> $config_host_mak
fi
if test -n "$LIBCAPSTONE"; then
echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
fi

if test "$numa" = "yes"; then
echo "CONFIG_NUMA=y" >> $config_host_mak
Expand Down

0 comments on commit 6e6430a

Please sign in to comment.