From 237029b037437a9f689458c81cd67d9b6e4dae73 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 9 Aug 2024 01:57:02 +0200 Subject: [PATCH] Switch to Capstone 5.x --- .appveyor.yml | 20 +++++------ .github/workflows/vcpkg.yml | 30 ++++++---------- CMakeLists.txt | 3 -- README.md | 6 ++-- doc/CMakeLists.txt | 36 +++++-------------- src/libtriton/CMakeLists.txt | 30 ++++++++-------- src/libtriton/arch/architecture.cpp | 6 ---- src/libtriton/arch/irBuilder.cpp | 10 ------ .../python/namespaces/initArchNamespace.cpp | 2 -- .../namespaces/initOpcodesNamespace.cpp | 4 --- .../python/namespaces/initRegNamespace.cpp | 2 -- src/libtriton/context/context.cpp | 4 --- src/libtriton/includes/triton/archEnums.hpp | 6 ---- .../includes/triton/externalLibs.hpp | 2 -- src/libtriton/includes/triton/irBuilder.hpp | 2 -- .../includes/triton/shortcutRegister.hpp | 6 ---- src/testers/CMakeLists.txt | 16 +++------ src/testers/unittests/test_examples.py | 2 -- 18 files changed, 50 insertions(+), 137 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index e2a153722..023e322e7 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -11,16 +11,16 @@ configuration: clone_folder: c:\projects\triton environment: - CAPSTONE_INCLUDE_DIRS: c:\projects\triton\build\capstone-4.0.2\include + CAPSTONE_INCLUDE_DIRS: c:\projects\triton\build\capstone-5.0.1\include PLATFORM_TOOLSET: v142 - CMAKE_TEMPLATE: Visual Studio 16 2019 + CMAKE_GENERATOR: Visual Studio 16 2019 matrix: # 64-bit, python3.8, boost off - platform: x64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 PYTHON: C:\Python38-x64 - CAPSTONE_LIBRARIES: c:\projects\triton\build\capstone-4.0.2\msvc\x64\%configuration%\capstone.lib + CAPSTONE_LIBRARIES: c:\projects\triton\build\capstone-5.0.1\msvc\x64\%configuration%\capstone.lib LIEF_VERSION: 0.12.1 LIEF_ZIP: lief-0.12.1-cp38-cp38-win_amd64.whl Z3_INCLUDE_DIRS: c:\projects\triton\build\z3-4.8.9-x64-win\include @@ -33,7 +33,7 @@ environment: - platform: x64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 PYTHON: C:\Python39-x64 - CAPSTONE_LIBRARIES: c:\projects\triton\build\capstone-4.0.2\msvc\x64\%configuration%\capstone.lib + CAPSTONE_LIBRARIES: c:\projects\triton\build\capstone-5.0.1\msvc\x64\%configuration%\capstone.lib LIEF_VERSION: 0.12.1 LIEF_ZIP: lief-0.12.1-cp39-cp39-win_amd64.whl Z3_INCLUDE_DIRS: c:\projects\triton\build\z3-4.8.9-x64-win\include @@ -46,7 +46,7 @@ environment: - platform: x64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 PYTHON: C:\Python310-x64 - CAPSTONE_LIBRARIES: c:\projects\triton\build\capstone-4.0.2\msvc\x64\%configuration%\capstone.lib + CAPSTONE_LIBRARIES: c:\projects\triton\build\capstone-5.0.1\msvc\x64\%configuration%\capstone.lib LIEF_VERSION: 0.12.1 LIEF_ZIP: lief-0.12.1-cp310-cp310-win_amd64.whl Z3_INCLUDE_DIRS: c:\projects\triton\build\z3-4.8.9-x64-win\include @@ -59,7 +59,7 @@ environment: - platform: x64 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 PYTHON: C:\Python310-x64 - CAPSTONE_LIBRARIES: c:\projects\triton\build\capstone-4.0.2\msvc\x64\%configuration%\capstone.lib + CAPSTONE_LIBRARIES: c:\projects\triton\build\capstone-5.0.1\msvc\x64\%configuration%\capstone.lib LIEF_VERSION: 0.12.1 LIEF_ZIP: lief-0.12.1-cp310-cp310-win_amd64.whl Z3_INCLUDE_DIRS: c:\projects\triton\build\z3-4.8.9-x64-win\include @@ -84,10 +84,10 @@ install: - set PYTHONPATH=C:\projects\triton\build\%Z3_PKG_NAME%\bin\python;%PYTHONPATH% # Install capstone - cmd: echo Downloading capstone... - - cmd: appveyor DownloadFile https://github.com/aquynh/capstone/archive/4.0.2.zip - - cmd: 7z x 4.0.2.zip + - cmd: appveyor DownloadFile https://github.com/capstone-engine/capstone/archive/refs/tags/5.0.1.zip + - cmd: 7z x 5.0.1.zip - cmd: echo Building capstone... - - cmd: msbuild capstone-4.0.2\msvc\capstone.sln /p:Configuration=%configuration% /p:Platform=%platform% /p:PlatformToolset=%PLATFORM_TOOLSET% /t:capstone_static /m + - cmd: msbuild capstone-5.0.1\msvc\capstone.sln /p:Configuration=%configuration% /p:Platform=%platform% /p:PlatformToolset=%PLATFORM_TOOLSET% /t:capstone_static /m # Install LIEF - cmd: echo Downloading LIEF... - cmd: appveyor DownloadFile https://github.com/lief-project/LIEF/releases/download/%LIEF_VERSION%/%LIEF_ZIP% @@ -95,7 +95,7 @@ install: - cmd: python -m pip install %LIEF_ZIP% # Running cmake for Triton - cmd: echo Running cmake for Triton... - - cmd: cmake -DPython3_ROOT_DIR=%PYTHON% -DBOOST_INTERFACE=%BOOST_INTERFACE% -DPYTHON_VERSION=%PYTHON_VERSION% .. -A %platform% -G "%CMAKE_TEMPLATE%" + - cmd: cmake -DPython3_ROOT_DIR=%PYTHON% -DBOOST_INTERFACE=%BOOST_INTERFACE% -DPYTHON_VERSION=%PYTHON_VERSION% .. -A %platform% -G "%CMAKE_GENERATOR%" build_script: - cmd: msbuild c:\projects\triton\build\triton.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /t:python-triton /m:3 diff --git a/.github/workflows/vcpkg.yml b/.github/workflows/vcpkg.yml index 5111c9806..c3bc886bd 100644 --- a/.github/workflows/vcpkg.yml +++ b/.github/workflows/vcpkg.yml @@ -12,26 +12,22 @@ jobs: os: - macOS-latest - ubuntu-20.04 - # FIXME - #- windows-2022 + - windows-2022 include: - #- os: windows-2022 - # platform: windows - # vcpkg-triplet: x64-windows-static-release-md - # cmake-preset: windows-x64 - # capstone-library: capstone.lib - # python-executable: python + - os: windows-2022 + platform: windows + vcpkg-triplet: x64-windows-static-release-md + cmake-preset: windows-x64 + python-executable: python - os: ubuntu-20.04 platform: linux vcpkg-triplet: x64-linux-release cmake-preset: linux-x64 - capstone-library: libcapstone.a python-executable: python3 - os: macOS-latest platform: macos vcpkg-triplet: x64-osx-release cmake-preset: macos-x64 - capstone-library: libcapstone.a python-executable: python3 steps: @@ -64,11 +60,8 @@ jobs: - name: Configure (Windows) if: ${{ matrix.platform == 'windows' }} run: | - cmake --preset=${{ matrix.cmake-preset }} -DBUILD_SHARED_LIBS:BOOL=ON -DCS_VERSION_MAJOR:STRING=5 -DVCPKG_OVERLAY_TRIPLETS:PATH=${{ github.workspace }}\vcpkg\triplets -DVCPKG_TARGET_TRIPLET:STRING=${{ matrix.vcpkg-triplet }} + cmake --preset=${{ matrix.cmake-preset }} -DBUILD_SHARED_LIBS:BOOL=ON -DVCPKG_OVERLAY_TRIPLETS:PATH=${{ github.workspace }}\vcpkg\triplets -DVCPKG_TARGET_TRIPLET:STRING=${{ matrix.vcpkg-triplet }} env: - # capstone 4.0.2 does not produce a CMake Config, hence the need to point directly to include directories and libraries - CAPSTONE_INCLUDE_DIRS: ${{ github.workspace }}/build/${{ matrix.cmake-preset }}/vcpkg_installed/${{ matrix.vcpkg-triplet }}/include - CAPSTONE_LIBRARIES: ${{ github.workspace }}/build/${{ matrix.cmake-preset }}/vcpkg_installed/${{ matrix.vcpkg-triplet }}/lib/${{ matrix.capstone-library }} VCPKG_ROOT: ${{ github.workspace }}/_vcpkg VCPKG_FEATURE_FLAGS: manifests,versions,binarycaching,registries @@ -76,17 +69,14 @@ jobs: if: ${{ matrix.platform != 'windows' }} run: | python -m pip install importlib-resources - cmake --preset=${{ matrix.cmake-preset }} -DBUILD_SHARED_LIBS:BOOL=ON -DCS_VERSION_MAJOR:STRING=5 -DVCPKG_OVERLAY_TRIPLETS:PATH=${{ github.workspace }}/vcpkg/triplets -DVCPKG_TARGET_TRIPLET:STRING=${{ matrix.vcpkg-triplet }} + cmake --preset=${{ matrix.cmake-preset }} -DBUILD_SHARED_LIBS:BOOL=ON -DVCPKG_OVERLAY_TRIPLETS:PATH=${{ github.workspace }}/vcpkg/triplets -DVCPKG_TARGET_TRIPLET:STRING=${{ matrix.vcpkg-triplet }} env: - # capstone 4.0.2 does not produce a CMake Config, hence the need to point directly to include directories and libraries - CAPSTONE_INCLUDE_DIRS: ${{ github.workspace }}/build/${{ matrix.cmake-preset }}/vcpkg_installed/${{ matrix.vcpkg-triplet }}/include - CAPSTONE_LIBRARIES: ${{ github.workspace }}/build/${{ matrix.cmake-preset }}/vcpkg_installed/${{ matrix.vcpkg-triplet }}/lib/${{ matrix.capstone-library }} VCPKG_ROOT: ${{ github.workspace }}/_vcpkg VCPKG_FEATURE_FLAGS: manifests,versions,binarycaching,registries - name: Build run: | - cmake --build --preset build-${{ matrix.cmake-preset }} --config Release -DCS_VERSION_MAJOR:STRING=5 + cmake --build --preset build-${{ matrix.cmake-preset }} --config Release - name: Test # Test disabled on Windows `pip install lief` fails as there is no ready to use .whl and compilation fails @@ -98,7 +88,7 @@ jobs: - name: Install run: | - cmake --build --preset build-${{ matrix.cmake-preset }} --config Release --target install -DCS_VERSION_MAJOR:STRING=5 + cmake --build --preset build-${{ matrix.cmake-preset }} --config Release --target install - name: Upload uses: actions/upload-artifact@v3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 78e9c10f6..d8c375d74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,9 +201,6 @@ endif() message(STATUS "Compiling with Capstone") find_package(CAPSTONE 5 REQUIRED) message(STATUS "CAPSTONE version: ${CAPSTONE_VERSION}") -if(${CS_VERSION_MAJOR} GREATER_EQUAL 5) - add_definitions(-DCOMPILE_RISCV) -endif() if(TARGET capstone::capstone) link_libraries(capstone::capstone) elseif(DEFINED CAPSTONE_INCLUDE_DIRS) diff --git a/README.md b/README.md index ed2a49edb..1c1df03eb 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ from triton import * Triton relies on the following dependencies: ``` -* libcapstone >= 4.0.x https://github.com/capstone-engine/capstone +* libcapstone >= 5.0.x https://github.com/capstone-engine/capstone * libboost (optional) >= 1.68 * libpython (optional) >= 3.6 * libz3 (optional) >= 4.6.0 https://github.com/Z3Prover/z3 @@ -164,8 +164,8 @@ You can use cmake to generate the .sln file of libTriton. -DPYTHON_LIBRARIES="C:/Python36/libs/python36.lib" \ -DZ3_INCLUDE_DIRS="C:/Users/jonathan/Works/Tools/z3-4.6.0-x64-win/include" \ -DZ3_LIBRARIES="C:/Users/jonathan/Works/Tools/z3-4.6.0-x64-win/bin/libz3.lib" \ - -DCAPSTONE_INCLUDE_DIRS="C:/Users/jonathan/Works/Tools/capstone-4.0.2-win64/include" \ - -DCAPSTONE_LIBRARIES="C:/Users/jonathan/Works/Tools/capstone-4.0.2-win64/capstone.lib" .. + -DCAPSTONE_INCLUDE_DIRS="C:/Users/jonathan/Works/Tools/capstone-5.0.1-win64/include" \ + -DCAPSTONE_LIBRARIES="C:/Users/jonathan/Works/Tools/capstone-5.0.1-win64/capstone.lib" .. ``` However, if you prefer to directly download the precompiled library, check out our AppVeyor's [artefacts](https://ci.appveyor.com/project/JonathanSalwan/triton/history). diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 9adeaf0d7..83d90c754 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -36,27 +36,17 @@ add_custom_target(gen_rv32_doc_from_spec DEPENDS ${TRITON_ROOT}/src/libtriton/includes/triton/riscv32.spec ) -if(${CS_VERSION_MAJOR} GREATER_EQUAL 5) - add_custom_target(doc - COMMAND doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - DEPENDS gen_x86_doc_from_spec - DEPENDS gen_aarch64_doc_from_spec - DEPENDS gen_arm32_doc_from_spec - DEPENDS gen_rv64_doc_from_spec - DEPENDS gen_rv32_doc_from_spec - ) -else() - add_custom_target(doc - COMMAND doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - DEPENDS gen_x86_doc_from_spec - DEPENDS gen_aarch64_doc_from_spec - DEPENDS gen_arm32_doc_from_spec - ) -endif() +add_custom_target(doc + COMMAND doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + DEPENDS gen_x86_doc_from_spec + DEPENDS gen_aarch64_doc_from_spec + DEPENDS gen_arm32_doc_from_spec + DEPENDS gen_rv64_doc_from_spec + DEPENDS gen_rv32_doc_from_spec +) if(PYTHON_BINDINGS_AUTOCOMPLETE) - if(${CS_VERSION_MAJOR} GREATER_EQUAL 5) - add_custom_target(python_autocomplete + add_custom_target(python_autocomplete COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/autocomplete/generate_autocomplete.py "--basedir" "${CMAKE_CURRENT_BINARY_DIR}" "$<$:--bitwuzla>" "$<$:--z3>" DEPENDS gen_x86_doc_from_spec DEPENDS gen_aarch64_doc_from_spec @@ -64,14 +54,6 @@ if(PYTHON_BINDINGS_AUTOCOMPLETE) DEPENDS gen_rv64_doc_from_spec DEPENDS gen_rv32_doc_from_spec ) - else() - add_custom_target(python_autocomplete - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/autocomplete/generate_autocomplete.py "--basedir" "${CMAKE_CURRENT_BINARY_DIR}" "$<$:--bitwuzla>" "$<$:--z3>" - DEPENDS gen_x86_doc_from_spec - DEPENDS gen_aarch64_doc_from_spec - DEPENDS gen_arm32_doc_from_spec - ) - endif() if (NOT DEFINED PYTHON_SITE_PACKAGES) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from sysconfig import get_path; print(get_path('platlib'))" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE) endif() diff --git a/src/libtriton/CMakeLists.txt b/src/libtriton/CMakeLists.txt index 07502c816..d7b9b9378 100644 --- a/src/libtriton/CMakeLists.txt +++ b/src/libtriton/CMakeLists.txt @@ -148,22 +148,20 @@ set(LIBTRITON_HEADER_FILES ) # Add riscv source and header files -if(${CS_VERSION_MAJOR} GREATER_EQUAL 5) - list(APPEND LIBTRITON_SOURCE_FILES - arch/riscv/riscv32Cpu.cpp - arch/riscv/riscv64Cpu.cpp - arch/riscv/riscvSemantics.cpp - arch/riscv/riscvSpecifications.cpp - ) - list(APPEND LIBTRITON_HEADER_FILES - includes/triton/riscv32.spec - includes/triton/riscv64.spec - includes/triton/riscv32Cpu.hpp - includes/triton/riscv64Cpu.hpp - includes/triton/riscvSemantics.hpp - includes/triton/riscvSpecifications.hpp - ) -endif() +list(APPEND LIBTRITON_SOURCE_FILES + arch/riscv/riscv32Cpu.cpp + arch/riscv/riscv64Cpu.cpp + arch/riscv/riscvSemantics.cpp + arch/riscv/riscvSpecifications.cpp +) +list(APPEND LIBTRITON_HEADER_FILES + includes/triton/riscv32.spec + includes/triton/riscv64.spec + includes/triton/riscv32Cpu.hpp + includes/triton/riscv64Cpu.hpp + includes/triton/riscvSemantics.hpp + includes/triton/riscvSpecifications.hpp +) # Define all resource files set(LIBTRITON_RESOURCE_FILES diff --git a/src/libtriton/arch/architecture.cpp b/src/libtriton/arch/architecture.cpp index 58cf93bb4..ca1a9508e 100644 --- a/src/libtriton/arch/architecture.cpp +++ b/src/libtriton/arch/architecture.cpp @@ -13,11 +13,9 @@ #include #include #include -#ifdef COMPILE_RISCV #include #include #include -#endif #include #include #include @@ -59,10 +57,8 @@ namespace triton { case triton::arch::ARCH_X86: this->cpu.reset(new(std::nothrow) triton::arch::x86::x86Cpu(this->callbacks)); break; case triton::arch::ARCH_AARCH64: this->cpu.reset(new(std::nothrow) triton::arch::arm::aarch64::AArch64Cpu(this->callbacks)); break; case triton::arch::ARCH_ARM32: this->cpu.reset(new(std::nothrow) triton::arch::arm::arm32::Arm32Cpu(this->callbacks)); break; - #ifdef COMPILE_RISCV case triton::arch::ARCH_RV64: this->cpu.reset(new(std::nothrow) triton::arch::riscv::riscv64Cpu(this->callbacks)); break; case triton::arch::ARCH_RV32: this->cpu.reset(new(std::nothrow) triton::arch::riscv::riscv32Cpu(this->callbacks)); break; - #endif default: throw triton::exceptions::Architecture("Architecture::setArchitecture(): Architecture not supported."); } @@ -409,11 +405,9 @@ namespace triton { case triton::arch::ARCH_X86_64: return triton::arch::x86::nop; - #ifdef COMPILE_RISCV case triton::arch::ARCH_RV64: case triton::arch::ARCH_RV32: return triton::arch::riscv::nop; - #endif default: throw triton::exceptions::Architecture("Architecture::getNopInstruction(): Invalid architecture."); diff --git a/src/libtriton/arch/irBuilder.cpp b/src/libtriton/arch/irBuilder.cpp index 7ed560d39..760017e58 100644 --- a/src/libtriton/arch/irBuilder.cpp +++ b/src/libtriton/arch/irBuilder.cpp @@ -16,9 +16,7 @@ #include #include #include -#ifdef COMPILE_RISCV #include -#endif namespace triton { @@ -46,14 +44,10 @@ namespace triton { this->aarch64Isa = new(std::nothrow) triton::arch::arm::aarch64::AArch64Semantics(architecture, symbolicEngine, taintEngine, astCtxt); this->arm32Isa = new(std::nothrow) triton::arch::arm::arm32::Arm32Semantics(architecture, symbolicEngine, taintEngine, astCtxt); this->x86Isa = new(std::nothrow) triton::arch::x86::x86Semantics(architecture, symbolicEngine, taintEngine, modes, astCtxt); - #ifdef COMPILE_RISCV this->riscvIsa = new(std::nothrow) triton::arch::riscv::riscvSemantics(architecture, symbolicEngine, taintEngine, modes, astCtxt); - #endif if (this->x86Isa == nullptr || this->aarch64Isa == nullptr || this->arm32Isa == nullptr - #ifdef COMPILE_RISCV || this->riscvIsa == nullptr - #endif ) throw triton::exceptions::IrBuilder("IrBuilder::IrBuilder(): Not enough memory."); } @@ -63,9 +57,7 @@ namespace triton { delete this->aarch64Isa; delete this->arm32Isa; delete this->x86Isa; - #ifdef COMPILE_RISCV delete this->riscvIsa; - #endif } @@ -101,12 +93,10 @@ namespace triton { ret = this->x86Isa->buildSemantics(inst); break; - #ifdef COMPILE_RISCV case triton::arch::ARCH_RV64: case triton::arch::ARCH_RV32: ret = this->riscvIsa->buildSemantics(inst); break; - #endif default: throw triton::exceptions::IrBuilder("IrBuilder::buildSemantics(): Architecture not supported."); diff --git a/src/libtriton/bindings/python/namespaces/initArchNamespace.cpp b/src/libtriton/bindings/python/namespaces/initArchNamespace.cpp index 63ce23e08..d622a3644 100644 --- a/src/libtriton/bindings/python/namespaces/initArchNamespace.cpp +++ b/src/libtriton/bindings/python/namespaces/initArchNamespace.cpp @@ -43,10 +43,8 @@ namespace triton { void initArchNamespace(PyObject* archDict) { xPyDict_SetItemString(archDict, "AARCH64", PyLong_FromUint32(triton::arch::ARCH_AARCH64)); xPyDict_SetItemString(archDict, "ARM32", PyLong_FromUint32(triton::arch::ARCH_ARM32)); - #ifdef COMPILE_RISCV xPyDict_SetItemString(archDict, "RV32", PyLong_FromUint32(triton::arch::ARCH_RV32)); xPyDict_SetItemString(archDict, "RV64", PyLong_FromUint32(triton::arch::ARCH_RV64)); - #endif xPyDict_SetItemString(archDict, "X86", PyLong_FromUint32(triton::arch::ARCH_X86)); xPyDict_SetItemString(archDict, "X86_64", PyLong_FromUint32(triton::arch::ARCH_X86_64)); } diff --git a/src/libtriton/bindings/python/namespaces/initOpcodesNamespace.cpp b/src/libtriton/bindings/python/namespaces/initOpcodesNamespace.cpp index 6ac617789..0d02e7f39 100644 --- a/src/libtriton/bindings/python/namespaces/initOpcodesNamespace.cpp +++ b/src/libtriton/bindings/python/namespaces/initOpcodesNamespace.cpp @@ -10,9 +10,7 @@ #include #include #include -#ifdef COMPILE_RISCV #include -#endif #include @@ -4529,7 +4527,6 @@ namespace triton { xPyDict_SetItemString(opcodesDict, "ARM32", arm32OpcodesDictClass); - #ifdef COMPILE_RISCV PyObject* riscv64OpcodesDict = xPyDict_New(); xPyDict_SetItemString(riscv64OpcodesDict, "ADD", PyLong_FromUint32(triton::arch::riscv::ID_INS_ADD)); @@ -4712,7 +4709,6 @@ namespace triton { PyObject* riscv32OpcodesDictClass = xPyClass_New(nullptr, riscv32OpcodesDict, xPyString_FromString("RV32")); xPyDict_SetItemString(opcodesDict, "RV32", riscv32OpcodesDictClass); - #endif } }; /* python namespace */ diff --git a/src/libtriton/bindings/python/namespaces/initRegNamespace.cpp b/src/libtriton/bindings/python/namespaces/initRegNamespace.cpp index 579d7772a..1f24f26d6 100644 --- a/src/libtriton/bindings/python/namespaces/initRegNamespace.cpp +++ b/src/libtriton/bindings/python/namespaces/initRegNamespace.cpp @@ -140,7 +140,6 @@ namespace triton { PyObject* arm32RegistersDictClass = xPyClass_New(nullptr, arm32RegistersDict, xPyString_FromString("ARM32")); xPyDict_SetItemString(registersDict, "ARM32", arm32RegistersDictClass); - #ifdef COMPILE_RISCV // Create RISCV64 REG namespace PyObject* riscv64RegistersDict = xPyDict_New(); @@ -168,7 +167,6 @@ namespace triton { PyObject* riscv32RegistersDictClass = xPyClass_New(nullptr, riscv32RegistersDict, xPyString_FromString("RV32")); xPyDict_SetItemString(registersDict, "RV32", riscv32RegistersDictClass); - #endif } }; /* python namespace */ diff --git a/src/libtriton/context/context.cpp b/src/libtriton/context/context.cpp index 392692ded..34a559145 100644 --- a/src/libtriton/context/context.cpp +++ b/src/libtriton/context/context.cpp @@ -10,10 +10,8 @@ #include #include #include -#ifdef COMPILE_RISCV #include #include -#endif #include #include @@ -466,14 +464,12 @@ namespace triton { case triton::arch::ARCH_AARCH64: *static_cast(this->getCpuInstance()) = *static_cast(other.getCpuInstance()); break; - #ifdef COMPILE_RISCV case triton::arch::ARCH_RV64: *static_cast(this->getCpuInstance()) = *static_cast(other.getCpuInstance()); break; case triton::arch::ARCH_RV32: *static_cast(this->getCpuInstance()) = *static_cast(other.getCpuInstance()); break; - #endif default: throw triton::exceptions::Engines("Context::setConcreteState(): Invalid architecture."); } diff --git a/src/libtriton/includes/triton/archEnums.hpp b/src/libtriton/includes/triton/archEnums.hpp index 5bdf24c3e..c6629c929 100644 --- a/src/libtriton/includes/triton/archEnums.hpp +++ b/src/libtriton/includes/triton/archEnums.hpp @@ -33,10 +33,8 @@ namespace triton { ARCH_INVALID = 0, /*!< Invalid architecture. */ ARCH_AARCH64, /*!< AArch64 architecture. */ ARCH_ARM32, /*!< ARM32 architecture. */ - #ifdef COMPILE_RISCV ARCH_RV32, /*!< RISCV32 architecture. */ ARCH_RV64, /*!< RISCV64 architecture. */ - #endif ARCH_X86, /*!< X86 architecture. */ ARCH_X86_64, /*!< X86_64 architecture. */ }; @@ -84,7 +82,6 @@ namespace triton { #define REG_SPEC_NO_CAPSTONE REG_SPEC #include "triton/arm32.spec" - #ifdef COMPILE_RISCV #define REG_SPEC(_1, UPPER_NAME, _2, _3, _4, _5, _6) \ ID_REG_RV64_##UPPER_NAME, #define REG_SPEC_NO_CAPSTONE REG_SPEC @@ -94,7 +91,6 @@ namespace triton { ID_REG_RV32_##UPPER_NAME, #define REG_SPEC_NO_CAPSTONE REG_SPEC #include "triton/riscv32.spec" - #endif /* Must be the last item */ ID_REG_LAST_ITEM //!< must be the last item @@ -210,7 +206,6 @@ namespace triton { /*! @} End of arm namespace */ }; - #ifdef COMPILE_RISCV //! The riscv namespace namespace riscv { /*! @@ -260,7 +255,6 @@ namespace triton { /*! @} End of riscv namespace */ }; - #endif /*! @} End of arch namespace */ }; /*! @} End of triton namespace */ diff --git a/src/libtriton/includes/triton/externalLibs.hpp b/src/libtriton/includes/triton/externalLibs.hpp index e4d640d33..49d699468 100644 --- a/src/libtriton/includes/triton/externalLibs.hpp +++ b/src/libtriton/includes/triton/externalLibs.hpp @@ -32,9 +32,7 @@ namespace triton { #include #include #include - #ifdef COMPILE_RISCV #include - #endif #include /*! @} End of capstone namespace */ }; diff --git a/src/libtriton/includes/triton/irBuilder.hpp b/src/libtriton/includes/triton/irBuilder.hpp index 2838256b5..45d21f6f6 100644 --- a/src/libtriton/includes/triton/irBuilder.hpp +++ b/src/libtriton/includes/triton/irBuilder.hpp @@ -79,10 +79,8 @@ namespace triton { //! x86 ISA builder. triton::arch::SemanticsInterface* x86Isa; - #ifdef COMPILE_RISCV //! RISCV ISA builder. triton::arch::SemanticsInterface* riscvIsa; - #endif public: //! Constructor. diff --git a/src/libtriton/includes/triton/shortcutRegister.hpp b/src/libtriton/includes/triton/shortcutRegister.hpp index d17088233..b701b7a79 100644 --- a/src/libtriton/includes/triton/shortcutRegister.hpp +++ b/src/libtriton/includes/triton/shortcutRegister.hpp @@ -49,13 +49,11 @@ namespace triton { #define REG_SPEC_NO_CAPSTONE REG_SPEC #include "triton/arm32.spec" - #ifdef COMPILE_RISCV // ShortcutRegister set for RV32 is the same, #define REG_SPEC(_0, _1, LOWER_NAME, _2, _3, _4, _5) \ triton::arch::Register riscv_##LOWER_NAME; #define REG_SPEC_NO_CAPSTONE REG_SPEC #include "triton/riscv64.spec" - #endif /*! Constructor */ ShortcutRegister() {}; @@ -78,13 +76,11 @@ namespace triton { #define REG_SPEC_NO_CAPSTONE REG_SPEC #include "triton/arm32.spec" - #ifdef COMPILE_RISCV // ShortcutRegister set for RV32 is the same, #define REG_SPEC(_0, _1, LOWER_NAME, _2, _3, _4, _5) \ this->riscv_##LOWER_NAME = triton::arch::Register(); #define REG_SPEC_NO_CAPSTONE REG_SPEC #include "triton/riscv64.spec" - #endif }; /*! Inits the shortcut */ @@ -146,7 +142,6 @@ namespace triton { } break; - #ifdef COMPILE_RISCV case triton::arch::ARCH_RV64: { #define REG_SPEC(CS_UPPER_NAME, UPPER_NAME, LOWER_NAME, ABI_NAME, RISCV_UPPER, RISCV_LOWER, MUTABLE) \ this->riscv_##LOWER_NAME = triton::arch::Register(triton::arch::ID_REG_RV64_##UPPER_NAME, \ @@ -172,7 +167,6 @@ namespace triton { #include "triton/riscv32.spec" } break; - #endif default: throw triton::exceptions::Architecture("ShortcutRegister::init(): Invalid architecture."); diff --git a/src/testers/CMakeLists.txt b/src/testers/CMakeLists.txt index 74b65ee05..dfe67ba95 100644 --- a/src/testers/CMakeLists.txt +++ b/src/testers/CMakeLists.txt @@ -5,10 +5,8 @@ if((${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin add_test(NAME UnicornAArch64Semantics COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/aarch64/unicorn_test_aarch64.py) add_test(NAME UnicornX86Semantics COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/x86/unicorn_test_x86.py) - if(${CS_VERSION_MAJOR} GREATER_EQUAL 5) - add_test(NAME UnicornRiscv64Semantics COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/riscv/unicorn_test_riscv64.py) - add_test(NAME UnicornRiscv32Semantics COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/riscv/unicorn_test_riscv32.py) - endif() + add_test(NAME UnicornRiscv64Semantics COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/riscv/unicorn_test_riscv64.py) + add_test(NAME UnicornRiscv32Semantics COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/riscv/unicorn_test_riscv32.py) add_test(NAME UnicornARM32Semantics1 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/arm32/unicorn_test_arm32_branch_arm_1.py) add_test(NAME UnicornARM32Semantics2 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/arm32/unicorn_test_arm32_branch_arm_2.py) add_test(NAME UnicornARM32Semantics3 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/arm32/unicorn_test_arm32_branch_pc_arm_1.py) @@ -83,14 +81,8 @@ if((${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin UnicornARM32Semantics33 UnicornARM32Semantics34 UnicornARM32Semantics35 + UnicornRiscv64Semantics + UnicornRiscv32Semantics PROPERTY ENVIRONMENT "PYTHONPATH=$" ) - if(${CS_VERSION_MAJOR} GREATER_EQUAL 5) - set_property(TEST - UnicornRiscv64Semantics - UnicornRiscv32Semantics - APPEND - PROPERTY ENVIRONMENT "PYTHONPATH=$" - ) - endif() endif() diff --git a/src/testers/unittests/test_examples.py b/src/testers/unittests/test_examples.py index 46e1c49bd..c37c9b9a1 100644 --- a/src/testers/unittests/test_examples.py +++ b/src/testers/unittests/test_examples.py @@ -34,8 +34,6 @@ def _test_example(self, example_name=example): if ('TRAVIS' in os.environ or 'APPVEYOR' in os.environ) and example_name.find('hackcon-2016-angry-reverser') >= 0: # FIXME: Doesn't work on Travis and Appveyor... return - if ('APPVEYOR' in os.environ or not 'COMPILE_RISCV' in os.environ) and example_name.find('riscv') >= 0: - return p = subprocess.Popen([sys.executable, example_name] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate()