Skip to contentSkip to conversation

Disassembler patches

GIT PULL Applied Richard Henderson 3 participants 4 messages Oct 26, 2017 – Dec 1, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

[Qemu-devel] [PULL v2 11/11] disas: Add capstone as submodule

Do not require the submodule, but use it if present. Allow the command-line to override system or git submodule either way.

---
 Makefile    | 15 ++++++++++++++
 .gitmodules |  3 +++
 capstone    |  1 +
 configure   | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++----------
 4 files changed, 76 insertions(+), 11 deletions(-)
 create mode 160000 capstone
Makefile +15 -0
index 9372742f86..ec73acfa9a 100644
@@ -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))
 
.gitmodules +3 -0
index 7c981a42b6..1500579638 100644
@@ -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
capstone new file +1 -0
new file mode 160000
index 0000000000..22ead3e0bf
@@ -0,0 +1 @@
+Subproject commit 22ead3e0bfdb87516656453336160e0a37b066bf
configure +57 -11

94 lines not on this page · raw message

Signature · 1 line
2.13.6
#2 lore raw

Re: [Qemu-devel] [PULL v2 11/11] disas: Add capstone as submodule

Quoted 6 lines · Richard Henderson

Do not require the submodule, but use it if present. Allow the command-line to override system or git submodule either way.

Quoted 7 lines
---
 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.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#3 lore raw
In reply to Richard Henderson
Quoted 15 lines · Richard Henderson

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:

Quoted 9 lines

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