* [Qemu-devel] [PULL v2 00/11] Disassembler patches
@ 2017-10-26 10:00 Richard Henderson
2017-10-26 10:00 ` [Qemu-devel] [PULL v2 11/11] disas: Add capstone as submodule Richard Henderson
2017-10-27 8:28 ` [Qemu-devel] [PULL v2 00/11] Disassembler patches Peter Maydell
0 siblings, 2 replies; 4+ messages in thread
From: Richard Henderson @ 2017-10-26 10:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell
Support for Capstone, plus an arm32 fix.
Changes since v1:
* Fixed mingw32 build in patch 11/11.
(Not re-sending patches 01-10.)
r~
The following changes since commit 3d7196d43bfe12efe98568cb60057e273652b99b:
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20171023-pull-request' into staging (2017-10-24 16:05:57 +0100)
are available in the git repository at:
git://github.com/rth7680/qemu.git tags/pull-dis-20171026
for you to fetch changes up to e219c499e9f5d4fa0e25dc07682f75531ee84d86:
disas: Add capstone as submodule (2017-10-26 11:56:20 +0200)
----------------------------------------------------------------
Capstone disassembler
----------------------------------------------------------------
Richard Henderson (11):
target/i386: Convert to disas_set_info hook
target/ppc: Convert to disas_set_info hook
target/arm: Move BE32 disassembler fixup
target/arm: Don't set INSN_ARM_BE32 for CONFIG_USER_ONLY
disas: Remove unused flags arguments
disas: Support the Capstone disassembler library
i386: Support Capstone in disas_set_info
arm: Support Capstone in disas_set_info
ppc: Support Capstone in disas_set_info
disas: Remove monitor_disas_is_physical
disas: Add capstone as submodule
Makefile | 15 ++
include/disas/bfd.h | 11 +-
include/disas/capstone.h | 38 ++++++
include/disas/disas.h | 4 +-
include/exec/log.h | 4 +-
disas.c | 308 ++++++++++++++++++++++++++++++------------
disas/arm.c | 21 ++-
monitor.c | 29 +---
target/alpha/translate.c | 2 +-
target/arm/cpu.c | 49 +++----
target/arm/translate-a64.c | 3 +-
target/arm/translate.c | 3 +-
target/cris/translate.c | 3 +-
target/hppa/translate.c | 2 +-
target/i386/cpu.c | 19 +++
target/i386/translate.c | 8 +-
target/lm32/translate.c | 2 +-
target/m68k/translate.c | 2 +-
target/microblaze/translate.c | 2 +-
target/mips/translate.c | 2 +-
target/nios2/translate.c | 2 +-
target/openrisc/translate.c | 2 +-
target/ppc/translate.c | 5 +-
target/ppc/translate_init.c | 27 ++++
target/s390x/translate.c | 2 +-
target/sh4/translate.c | 2 +-
target/sparc/translate.c | 2 +-
target/tricore/translate.c | 2 +-
target/unicore32/translate.c | 2 +-
target/xtensa/translate.c | 2 +-
.gitmodules | 3 +
capstone | 1 +
configure | 72 ++++++++++
33 files changed, 467 insertions(+), 184 deletions(-)
create mode 100644 include/disas/capstone.h
create mode 160000 capstone
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PULL v2 11/11] disas: Add capstone as submodule
2017-10-26 10:00 [Qemu-devel] [PULL v2 00/11] Disassembler patches Richard Henderson
@ 2017-10-26 10:00 ` Richard Henderson
2017-12-01 22:46 ` Eric Blake
2017-10-27 8:28 ` [Qemu-devel] [PULL v2 00/11] Disassembler patches Peter Maydell
1 sibling, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2017-10-26 10:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell
Do not require the submodule, but use it if present. Allow the
command-line to override system or git submodule either way.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
Makefile | 15 ++++++++++++++
.gitmodules | 3 +++
capstone | 1 +
configure | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++----------
4 files changed, 76 insertions(+), 11 deletions(-)
create mode 160000 capstone
diff --git a/Makefile b/Makefile
index 9372742f86..ec73acfa9a 100644
--- a/Makefile
+++ b/Makefile
@@ -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))
diff --git a/.gitmodules b/.gitmodules
index 7c981a42b6..1500579638 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -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
diff --git a/capstone b/capstone
new file mode 160000
index 0000000000..22ead3e0bf
--- /dev/null
+++ b/capstone
@@ -0,0 +1 @@
+Subproject commit 22ead3e0bfdb87516656453336160e0a37b066bf
diff --git a/configure b/configure
index d06ad64058..23eddc2f50 100755
--- a/configure
+++ b/configure
@@ -1299,6 +1299,10 @@ for opt do
;;
--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"
@@ -4419,18 +4423,54 @@ fi
##########################################
# capstone
-if test "$capstone" != no; then
- if $pkg_config capstone; then
- capstone=yes
+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"
- else
- if test "$capstone" = yes; then
- feature_not_found capstone
- fi
- capstone=no
- fi
-fi
+ ;;
+
+ no)
+ ;;
+ *)
+ error_exit "Unknown state for capstone: $capstone"
+ ;;
+esac
##########################################
# check if we have fdatasync
@@ -6165,7 +6205,7 @@ fi
if test "$ivshmem" = "yes" ; then
echo "CONFIG_IVSHMEM=y" >> $config_host_mak
fi
-if test "$capstone" = "yes" ; then
+if test "$capstone" != "no" ; then
echo "CONFIG_CAPSTONE=y" >> $config_host_mak
fi
@@ -6650,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
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PULL v2 00/11] Disassembler patches
2017-10-26 10:00 [Qemu-devel] [PULL v2 00/11] Disassembler patches Richard Henderson
2017-10-26 10:00 ` [Qemu-devel] [PULL v2 11/11] disas: Add capstone as submodule Richard Henderson
@ 2017-10-27 8:28 ` Peter Maydell
1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2017-10-27 8:28 UTC (permalink / raw)
To: Richard Henderson; +Cc: QEMU Developers
On 26 October 2017 at 11:00, Richard Henderson
<richard.henderson@linaro.org> wrote:
> Support for Capstone, plus an arm32 fix.
>
> Changes since v1:
> * Fixed mingw32 build in patch 11/11.
> (Not re-sending patches 01-10.)
>
> r~
>
>
> The following changes since commit 3d7196d43bfe12efe98568cb60057e273652b99b:
>
> Merge remote-tracking branch 'remotes/kraxel/tags/usb-20171023-pull-request' into staging (2017-10-24 16:05:57 +0100)
>
> are available in the git repository at:
>
> git://github.com/rth7680/qemu.git tags/pull-dis-20171026
>
> for you to fetch changes up to e219c499e9f5d4fa0e25dc07682f75531ee84d86:
>
> disas: Add capstone as submodule (2017-10-26 11:56:20 +0200)
>
> ----------------------------------------------------------------
> Capstone disassembler
>
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PULL v2 11/11] disas: Add capstone as submodule
2017-10-26 10:00 ` [Qemu-devel] [PULL v2 11/11] disas: Add capstone as submodule Richard Henderson
@ 2017-12-01 22:46 ` Eric Blake
0 siblings, 0 replies; 4+ messages in thread
From: Eric Blake @ 2017-12-01 22:46 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: peter.maydell
[-- Attachment #1: Type: text/plain, Size: 2009 bytes --]
On 10/26/2017 05:00 AM, Richard Henderson wrote:
> Do not require the submodule, but use it if present. Allow the
> command-line to override system or git submodule either way.
>
> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> Makefile | 15 ++++++++++++++
> .gitmodules | 3 +++
> capstone | 1 +
> configure | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++----------
> 4 files changed, 76 insertions(+), 11 deletions(-)
> create mode 160000 capstone
I'm seeing a couple of anomalies which I think are due to this series.
One is that make is now always noisy, even when there is nothing to do:
$ make
make[1]: '/home/eblake/qemu/capstone/libcapstone.a' is up to date.
$
It would be really nice to silence that line when things are up-to-date,
the way it used to be.
The other is that, at least on my setup (Fedora 27 with 'capstone' not
installed), I get a spurious 'make check-unit' failure (part of 'make
check'):
GTESTER tests/check-qdict
tests/check-qdict: error while loading shared libraries:
libcapstone.so.3: cannot open shared object file: No such file or directory
make: *** [/home/eblake/qemu/tests/Makefile.include:864:
check-tests/check-qdict] Error 1
make: *** Waiting for unfinished jobs....
but if I then 'dnf install capstone-devel', running 'make check'
succeeds. I'm not sure why the in-tree library when using the submodule
is not letting the testsuite run, but suspect that our CI engine and
most developers aren't seeing the failure because they have installed
the distro library and are therefore not relying on the submodule.
It's probably too late to change anything for 2.11, but it's worth
seeing if it can be improved during 2.12.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-01 22:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-26 10:00 [Qemu-devel] [PULL v2 00/11] Disassembler patches Richard Henderson
2017-10-26 10:00 ` [Qemu-devel] [PULL v2 11/11] disas: Add capstone as submodule Richard Henderson
2017-12-01 22:46 ` Eric Blake
2017-10-27 8:28 ` [Qemu-devel] [PULL v2 00/11] Disassembler patches Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).