diff --git a/.github/workflows/CITest.yml b/.github/workflows/CITest.yml index de92c8df..5de2c8f8 100644 --- a/.github/workflows/CITest.yml +++ b/.github/workflows/CITest.yml @@ -30,28 +30,28 @@ jobs: matrix: config: - { - name: 'ubuntu-18.04 x64 python2.7 make', + name: 'ubuntu-18.04 x64 python2.7 cmake', os: ubuntu-18.04, arch: x64, python-arch: x64, python-version: '2.7', - build-system: 'make', + build-system: 'cmake', } - { - name: 'ubuntu-18.04 x64 python3.6 make', + name: 'ubuntu-18.04 x64 python3.6 cmake', os: ubuntu-18.04, arch: x64, python-arch: x64, python-version: '3.6', - build-system: 'make', + build-system: 'cmake', } - { - name: 'ubuntu-20.04 x64 python2.7 make', + name: 'ubuntu-20.04 x64 python2.7 cmake', os: ubuntu-20.04, arch: x64, python-arch: x64, python-version: '2.7', - build-system: 'make', + build-system: 'cmake', } - { name: 'ubuntu-20.04 x64 python3.9 make', @@ -91,25 +91,28 @@ jobs: if: startsWith(matrix.config.build-system, 'make') shell: 'script -q -e -c "bash {0}"' run: | - ./make.sh - make check - sudo make install + ./make.sh; + make check; + cp libcapstone.so.5 libcapstone.so.5.0 + # sudo make install - name: cmake if: startsWith(matrix.config.build-system, 'cmake') shell: 'script -q -e -c "bash {0}"' run: | - mkdir build - cd build - cmake -DCAPSTONE_INSTALL=1 .. - cmake --build . --config Release - sudo make install + mkdir build && cd build; + cmake -DCAPSTONE_INSTALL=1 -DBUILD_SHARED_LIBS=1 ..; + cmake --build . --config Release; + cp libcapstone.* ../; + # sudo make install; - name: build python binding shell: 'script -q -e -c "bash {0}"' run: | - cp libcapstone.so.* bindings/python/libcapstone.so - cd bindings/python && make check; cd ../..; + mkdir -p bindings/python/capstone/lib && cp libcapstone.so.5.* bindings/python/capstone/lib/libcapstone.so; + cd bindings/python; + make && make check ; + cd ../..; - name: cstest shell: 'script -q -e -c "bash {0}"' diff --git a/CMakeLists.txt b/CMakeLists.txt index 03b1d226..270a08f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ cmake_policy(SET CMP0042 NEW) cmake_policy(SET CMP0091 NEW) project(capstone - VERSION 5.0.0 + VERSION 5.0 ) # to configure the options specify them in in the command line or change them in the cmake UI. @@ -133,6 +133,7 @@ set(HEADERS_COMMON include/capstone/mos65xx.h include/capstone/bpf.h include/capstone/riscv.h + include/capstone/sh.h include/capstone/platform.h ) diff --git a/bindings/python/capstone/__init__.py b/bindings/python/capstone/__init__.py index f0238d58..9543eac2 100755 --- a/bindings/python/capstone/__init__.py +++ b/bindings/python/capstone/__init__.py @@ -672,7 +672,7 @@ class CsInsn(object): arch = self._cs.arch if arch == CS_ARCH_ARM: (self.usermode, self.vector_size, self.vector_data, self.cps_mode, self.cps_flag, self.cc, self.update_flags, \ - self.writeback, self.mem_barrier, self.operands) = arm.get_arch_info(self._raw.detail.contents.arch.arm) + self.writeback, self.post_index, self.mem_barrier, self.operands) = arm.get_arch_info(self._raw.detail.contents.arch.arm) elif arch == CS_ARCH_ARM64: (self.cc, self.update_flags, self.writeback, self.post_index, self.operands) = \ arm64.get_arch_info(self._raw.detail.contents.arch.arm64) diff --git a/bindings/python/setup_cython.py b/bindings/python/setup_cython.py index 23e5ac89..5751f309 100644 --- a/bindings/python/setup_cython.py +++ b/bindings/python/setup_cython.py @@ -9,7 +9,7 @@ from distutils.command.build import build from Cython.Distutils import build_ext SYSTEM = sys.platform -VERSION = '4.0.0' +VERSION = '5.0.0' # adapted from commit e504b81 of Nguyen Tan Cong # Reference: https://docs.python.org/2/library/platform.html#cross-platform diff --git a/bindings/python/test_basic.py b/bindings/python/test_basic.py index a580f05d..1f4c721a 100755 --- a/bindings/python/test_basic.py +++ b/bindings/python/test_basic.py @@ -82,7 +82,10 @@ def test_cs_disasm_quick(): def test_different_data_formats(): - data = bytes.fromhex('4831C948F7E1043B48BB0A2F62696E2F2F736852530A545F5257545E0F05') + if _python3: + data = bytes.fromhex('4831C948F7E1043B48BB0A2F62696E2F2F736852530A545F5257545E0F05') + else: + data = bytes(bytearray.fromhex('4831C948F7E1043B48BB0A2F62696E2F2F736852530A545F5257545E0F05')) mnemonics = ['xor', 'mul', 'add', 'movabs', 'push', 'pop', 'push', 'push', 'push', 'pop', 'syscall'] disassembler = Cs(CS_ARCH_X86, CS_MODE_64) for name, code in ( diff --git a/cs.c b/cs.c index 09db59e0..2588c340 100644 --- a/cs.c +++ b/cs.c @@ -369,7 +369,7 @@ bool CAPSTONE_API cs_support(int query) (1 << CS_ARCH_M68K) | (1 << CS_ARCH_TMS320C64X) | (1 << CS_ARCH_M680X) | (1 << CS_ARCH_EVM) | (1 << CS_ARCH_RISCV) | (1 << CS_ARCH_MOS65XX) | - (1 << CS_ARCH_WASM) | (1 << CS_ARCH_BPF) | + (1 << CS_ARCH_WASM) | (1 << CS_ARCH_BPF) | (1 << CS_ARCH_SH)); if ((unsigned int)query < CS_ARCH_MAX) diff --git a/suite/regress/test_arm64_ldr_registers.py b/suite/regress/test_arm64_ldr_registers.py index d366c403..fded0ae8 100644 --- a/suite/regress/test_arm64_ldr_registers.py +++ b/suite/regress/test_arm64_ldr_registers.py @@ -2,6 +2,9 @@ import unittest from capstone import * from capstone.arm64 import * +_python3 = sys.version_info.major == 3 + + class SubRegTest(unittest.TestCase): PATTERNS = [ @@ -18,7 +21,10 @@ class SubRegTest(unittest.TestCase): self.cs.detail = True for pattern, asm in self.PATTERNS: - l = list(self.cs.disasm(bytes.fromhex(pattern), 0)) + if _python3: + l = list(self.cs.disasm(bytes.fromhex(pattern), 0)) + else: + l = list(self.cs.disasm(bytearray.fromhex(pattern), 0)) self.assertTrue(len(l) == 1) _, expected_reg_written, expected_reg_read = asm.split()