commit
305167eb51
@ -0,0 +1,14 @@
|
||||
version: 4.0-{build}
|
||||
|
||||
os:
|
||||
- Visual Studio 2015
|
||||
|
||||
before_build:
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
|
||||
|
||||
build_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -DCMAKE_BUILD_TYPE=RELEASE -G "NMake Makefiles" ..
|
||||
- nmake
|
||||
|
@ -0,0 +1 @@
|
||||
/arch/**/*.inc linguist-language=C
|
@ -0,0 +1,41 @@
|
||||
name: coverity-scan
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 18 * * 1,4' # Bi-weekly at 18:00 UTC on Monday and Thursday
|
||||
|
||||
jobs:
|
||||
latest:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Download Coverity Build Tool
|
||||
run: |
|
||||
wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=capstone-next" -O cov-analysis-linux64.tar.gz
|
||||
mkdir cov-analysis-linux64
|
||||
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
|
||||
env:
|
||||
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
||||
|
||||
- name: Fixed world writable dirs
|
||||
run: |
|
||||
chmod go-w $HOME
|
||||
sudo chmod -R go-w /usr/share
|
||||
|
||||
- name: Build with cov-build
|
||||
run: |
|
||||
export PATH=`pwd`/cov-analysis-linux64/bin:$PATH
|
||||
cov-build --dir cov-int make
|
||||
|
||||
- name: Submit the result to Coverity Scan
|
||||
run: |
|
||||
tar czvf capstone.tgz cov-int
|
||||
curl \
|
||||
--form project=capstone-next \
|
||||
--form token=$TOKEN \
|
||||
--form email=noreply@capstone-engine.org \
|
||||
--form file=@capstone.tgz \
|
||||
--form version=trunk \
|
||||
--form description="capstone" \
|
||||
https://scan.coverity.com/builds?project=capstone-next
|
||||
env:
|
||||
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
@ -0,0 +1,23 @@
|
||||
name: CIFuzz
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
Fuzzing:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Build Fuzzers
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'capstone'
|
||||
dry-run: false
|
||||
- name: Run Fuzzers
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'capstone'
|
||||
fuzz-seconds: 600
|
||||
dry-run: false
|
||||
- name: Upload Crash
|
||||
uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
name: artifacts
|
||||
path: ./out/artifacts
|
@ -0,0 +1,80 @@
|
||||
name: PyPI ๐ฆ Distribution
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
platform: [x32, x64]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Set up MSVC x86
|
||||
if: matrix.os == 'windows-latest' && matrix.platform == 'x32'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: x86
|
||||
|
||||
- name: Set up MSVC x64
|
||||
if: matrix.os == 'windows-latest' && matrix.platform == 'x64'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install setuptools wheel
|
||||
|
||||
- name: Build distribution ๐ฆ
|
||||
shell: bash
|
||||
run: |
|
||||
if [ ${{ matrix.platform }} == 'x32' ] && [ ${{ matrix.os }} == 'windows-latest' ]; then
|
||||
cd bindings/python && python setup.py build -p win32 bdist_wheel -p win32
|
||||
elif [ ${{ matrix.platform }} == 'x32' ] && [ ${{ matrix.os }} == 'ubuntu-latest' ]; then
|
||||
docker run --rm -v `pwd`/:/work dockcross/manylinux1-x86 > ./dockcross
|
||||
chmod +x ./dockcross
|
||||
./dockcross bindings/python/build_wheel.sh
|
||||
elif [ ${{ matrix.platform }} == 'x64' ] && [ ${{ matrix.os }} == 'ubuntu-latest' ]; then
|
||||
docker run --rm -v `pwd`/:/work dockcross/manylinux1-x64 > ./dockcross
|
||||
chmod +x ./dockcross
|
||||
./dockcross bindings/python/build_wheel.sh
|
||||
elif [ ${{ matrix.platform }} == 'x32' ] && [ ${{ matrix.os }} == 'macos-latest' ]; then
|
||||
cd bindings/python && python setup.py sdist
|
||||
else
|
||||
cd bindings/python && python setup.py bdist_wheel
|
||||
fi
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
path: ${{ github.workspace }}/bindings/python/dist/*
|
||||
|
||||
publish:
|
||||
needs: [build]
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
steps:
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: artifact
|
||||
path: dist
|
||||
|
||||
- name: Publish distribution ๐ฆ to test PyPI
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.testpypi_pass }}
|
||||
repository_url: https://test.pypi.org/legacy/
|
||||
|
||||
- name: Publish distribution ๐ฆ to PyPI
|
||||
if: ${{ success() }}
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.pypi_pass }}
|
@ -0,0 +1,124 @@
|
||||
.DS_Store
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
|
||||
# Gcc dependency-tracking files
|
||||
*.d
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# python
|
||||
bindings/python/build/
|
||||
bindings/python/capstone.egg-info/
|
||||
*.pyc
|
||||
|
||||
# java
|
||||
bindings/java/capstone.jar
|
||||
|
||||
# ocaml
|
||||
bindings/ocaml/*.cmi
|
||||
bindings/ocaml/*.cmx
|
||||
bindings/ocaml/*.cmxa
|
||||
bindings/ocaml/*.mli
|
||||
bindings/ocaml/test
|
||||
bindings/ocaml/test_arm
|
||||
bindings/ocaml/test_arm64
|
||||
bindings/ocaml/test_basic
|
||||
bindings/ocaml/test_mips
|
||||
bindings/ocaml/test_x86
|
||||
bindings/ocaml/test_detail
|
||||
bindings/ocaml/test_ppc
|
||||
bindings/ocaml/test_sparc
|
||||
bindings/ocaml/test_systemz
|
||||
bindings/ocaml/test_xcore
|
||||
bindings/ocaml/test_m680x
|
||||
|
||||
|
||||
# test binaries
|
||||
tests/test_basic
|
||||
tests/test_detail
|
||||
tests/test_iter
|
||||
tests/test_arm
|
||||
tests/test_arm64
|
||||
tests/test_mips
|
||||
tests/test_x86
|
||||
tests/test_ppc
|
||||
tests/test_skipdata
|
||||
tests/test_sparc
|
||||
tests/test_systemz
|
||||
tests/test_xcore
|
||||
tests/*.static
|
||||
tests/test_customized_mnem
|
||||
tests/test_m68k
|
||||
tests/test_tms320c64x
|
||||
tests/test_m680x
|
||||
tests/test_evm
|
||||
tests/test_mos65xx
|
||||
|
||||
# regress binaries
|
||||
suite/regress/invalid_read_in_print_operand
|
||||
|
||||
# vim tmp file
|
||||
*.swp
|
||||
*~
|
||||
|
||||
capstone.pc
|
||||
|
||||
# local files
|
||||
_*
|
||||
|
||||
# freebsd ports: generated file with "make makesum" command
|
||||
packages/freebsd/ports/devel/capstone/distinfo
|
||||
|
||||
# VisualStudio
|
||||
ProjectUpgradeLog.log
|
||||
Debug/
|
||||
Release/
|
||||
ipch/
|
||||
build*/
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.suo
|
||||
*.user
|
||||
*.backup
|
||||
*.VC.db
|
||||
*.VC.opendb
|
||||
|
||||
# CMake build directories
|
||||
build*/
|
||||
|
||||
# Xcode
|
||||
xcode/Capstone.xcodeproj/xcuserdata
|
||||
xcode/Capstone.xcodeproj/project.xcworkspace/xcuserdata
|
||||
|
||||
# suite/
|
||||
test_arm_regression
|
||||
test_arm_regression.o
|
||||
fuzz_harness
|
||||
test_iter_benchmark
|
||||
fuzz_bindisasm
|
||||
fuzz_disasm
|
||||
capstone_get_setup
|
||||
|
||||
|
||||
*.s
|
||||
|
||||
cstool/cstool
|
||||
|
||||
# android
|
||||
android-ndk-*
|
@ -0,0 +1,75 @@
|
||||
language: cpp
|
||||
sudo: false
|
||||
before_install:
|
||||
- export LD_LIBRARY_PATH=`pwd`/tests/:$LD_LIBRARY_PATH
|
||||
before_script:
|
||||
- wget https://github.com/groundx/capstonefuzz/raw/master/corpus/corpus-libFuzzer-capstone_fuzz_disasmnext-latest.zip
|
||||
- unzip -q corpus-libFuzzer-capstone_fuzz_disasmnext-latest.zip -d suite/fuzz
|
||||
# TODO remove built in cmocka compile and use system cmocka (including brewfile) once xenial is default
|
||||
- git clone https://git.cryptomilk.org/projects/cmocka.git suite/cstest/cmocka
|
||||
- chmod +x suite/cstest/build_cstest.sh
|
||||
script:
|
||||
- ./make.sh
|
||||
- make check
|
||||
- sudo make install
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp libcapstone.so.* bindings/python/libcapstone.so; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cp libcapstone.*.dylib bindings/python/libcapstone.dylib; fi
|
||||
- if [[ "$NOPYTEST" != "true" ]]; then cd bindings/python && make check; cd ../..; fi
|
||||
- if [[ "$NOPYTEST" != "true" ]]; then cd suite/cstest && ./build_cstest.sh; fi
|
||||
- if [[ "$NOPYTEST" != "true" ]]; then python cstest_report.py -D -t build/cstest -d ../MC; fi
|
||||
- if [[ "$NOPYTEST" != "true" ]]; then python cstest_report.py -D -t build/cstest -f issues.cs; fi
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
matrix:
|
||||
include:
|
||||
- name: xenial gcc
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libcmocka-dev
|
||||
- name: bionic gcc (ARM64)
|
||||
arch: arm64
|
||||
os: linux
|
||||
dist: bionic
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libcmocka-dev
|
||||
- unzip
|
||||
- name: bionic gcc (System Z)
|
||||
arch: s390x
|
||||
os: linux
|
||||
dist: bionic
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libcmocka-dev
|
||||
- name: xenial clang
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libcmocka-dev
|
||||
- name: fuzza
|
||||
env: ASAN_OPTIONS=detect_leaks=0 CXXFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address" CFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address" LDFLAGS="-fsanitize=address" NOPYTEST=true
|
||||
compiler: clang
|
||||
os: linux
|
||||
- name: fuzzm
|
||||
env: CXXFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory" CFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory" LDFLAGS="-fsanitize=memory" NOPYTEST=true
|
||||
compiler: clang
|
||||
os: linux
|
||||
- name: fuzzu
|
||||
env: CXXFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined" CFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined -fno-sanitize-recover=undefined,integer" LDFLAGS="-fsanitize=undefined" NOPYTEST=true
|
||||
compiler: clang
|
||||
os: linux
|
@ -0,0 +1,629 @@
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
project(capstone)
|
||||
|
||||
set(VERSION_MAJOR 5)
|
||||
set(VERSION_MINOR 0)
|
||||
set(VERSION_PATCH 0)
|
||||
|
||||
if(POLICY CMP0042)
|
||||
# http://www.cmake.org/cmake/help/v3.0/policy/CMP0042.html
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif(POLICY CMP0042)
|
||||
|
||||
if (POLICY CMP0048)
|
||||
# use old policy to honor version set using VERSION_* variables to preserve backwards
|
||||
# compatibility. change OLD to NEW when minimum cmake version is updated to 3.* and
|
||||
# set VERSION using project(capstone VERSION 4.0.0).
|
||||
# http://www.cmake.org/cmake/help/v3.0/policy/CMP0048.html
|
||||
cmake_policy (SET CMP0048 OLD)
|
||||
endif()
|
||||
|
||||
# to configure the options specify them in in the command line or change them in the cmake UI.
|
||||
# Don't edit the makefile!
|
||||
option(CAPSTONE_BUILD_STATIC_RUNTIME "Embed static runtime" ON)
|
||||
option(CAPSTONE_BUILD_STATIC "Build static library" ON)
|
||||
option(CAPSTONE_BUILD_SHARED "Build shared library" ON)
|
||||
option(CAPSTONE_BUILD_DIET "Build diet library" OFF)
|
||||
option(CAPSTONE_BUILD_TESTS "Build tests" ON)
|
||||
option(CAPSTONE_BUILD_CSTOOL "Build cstool" ON)
|
||||
option(CAPSTONE_USE_DEFAULT_ALLOC "Use default memory allocation functions" ON)
|
||||
option(CAPSTONE_ARCHITECTURE_DEFAULT "Whether architectures are enabled by default" ON)
|
||||
option(CAPSTONE_INSTALL "Generate install target" ON)
|
||||
|
||||
set(SUPPORTED_ARCHITECTURES ARM ARM64 M68K MIPS PPC SPARC SYSZ XCORE X86 TMS320C64X M680X EVM MOS65XX)
|
||||
set(SUPPORTED_ARCHITECTURE_LABELS ARM ARM64 M68K MIPS PowerPC Sparc SystemZ XCore x86 TMS320C64x M680x EVM MOS65XX)
|
||||
|
||||
list(LENGTH SUPPORTED_ARCHITECTURES count)
|
||||
math(EXPR count "${count}-1")
|
||||
# create options controlling whether support for a particular architecture is needed
|
||||
foreach(i RANGE ${count})
|
||||
list(GET SUPPORTED_ARCHITECTURES ${i} supported_architecture)
|
||||
list(GET SUPPORTED_ARCHITECTURE_LABELS ${i} supported_architecture_label)
|
||||
option("CAPSTONE_${supported_architecture}_SUPPORT" "${supported_architecture_label} support" ${CAPSTONE_ARCHITECTURE_DEFAULT})
|
||||
endforeach(i)
|
||||
|
||||
# propagate architecture support variables to preprocessor
|
||||
foreach(supported_architecture ${SUPPORTED_ARCHITECTURES})
|
||||
set(option_name "CAPSTONE_${supported_architecture}_SUPPORT")
|
||||
if(${option_name})
|
||||
message("Enabling ${option_name}")
|
||||
add_definitions("-D${option_name}")
|
||||
endif()
|
||||
endforeach(supported_architecture)
|
||||
|
||||
option(CAPSTONE_X86_REDUCE "x86 with reduce instruction sets to minimize library" OFF)
|
||||
option(CAPSTONE_X86_ATT_DISABLE "Disable x86 AT&T syntax" OFF)
|
||||
option(CAPSTONE_OSXKERNEL_SUPPORT "Support to embed Capstone into OS X Kernel extensions" OFF)
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
endif ()
|
||||
|
||||
enable_testing()
|
||||
|
||||
if (CAPSTONE_BUILD_DIET)
|
||||
add_definitions(-DCAPSTONE_DIET)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_USE_DEFAULT_ALLOC)
|
||||
add_definitions(-DCAPSTONE_USE_SYS_DYN_MEM)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_X86_REDUCE)
|
||||
add_definitions(-DCAPSTONE_X86_REDUCE)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_X86_ATT_DISABLE)
|
||||
add_definitions(-DCAPSTONE_X86_ATT_DISABLE)
|
||||
endif ()
|
||||
|
||||
## sources
|
||||
set(SOURCES_ENGINE
|
||||
cs.c
|
||||
MCInst.c
|
||||
MCInstrDesc.c
|
||||
MCRegisterInfo.c
|
||||
SStream.c
|
||||
utils.c
|
||||
)
|
||||
set(HEADERS_ENGINE
|
||||
cs_priv.h
|
||||
LEB128.h
|
||||
MathExtras.h
|
||||
MCDisassembler.h
|
||||
MCFixedLenDisassembler.h
|
||||
MCInst.h
|
||||
MCInstrDesc.h
|
||||
MCRegisterInfo.h
|
||||
SStream.h
|
||||
utils.h
|
||||
)
|
||||
|
||||
set(HEADERS_COMMON
|
||||
include/capstone/arm64.h
|
||||
include/capstone/arm.h
|
||||
include/capstone/capstone.h
|
||||
include/capstone/evm.h
|
||||
include/capstone/mips.h
|
||||
include/capstone/ppc.h
|
||||
include/capstone/x86.h
|
||||
include/capstone/sparc.h
|
||||
include/capstone/systemz.h
|
||||
include/capstone/xcore.h
|
||||
include/capstone/m68k.h
|
||||
include/capstone/tms320c64x.h
|
||||
include/capstone/m680x.h
|
||||
include/capstone/mos65xx.h
|
||||
include/capstone/platform.h
|
||||
)
|
||||
|
||||
set(TEST_SOURCES test_basic.c test_detail.c test_skipdata.c test_iter.c)
|
||||
|
||||
## architecture support
|
||||
if (CAPSTONE_ARM_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_ARM)
|
||||
set(SOURCES_ARM
|
||||
arch/ARM/ARMDisassembler.c
|
||||
arch/ARM/ARMInstPrinter.c
|
||||
arch/ARM/ARMMapping.c
|
||||
arch/ARM/ARMModule.c
|
||||
)
|
||||
set(HEADERS_ARM
|
||||
arch/ARM/ARMAddressingModes.h
|
||||
arch/ARM/ARMBaseInfo.h
|
||||
arch/ARM/ARMDisassembler.h
|
||||
arch/ARM/ARMGenAsmWriter.inc
|
||||
arch/ARM/ARMGenDisassemblerTables.inc
|
||||
arch/ARM/ARMGenInstrInfo.inc
|
||||
arch/ARM/ARMGenRegisterInfo.inc
|
||||
arch/ARM/ARMGenSubtargetInfo.inc
|
||||
arch/ARM/ARMInstPrinter.h
|
||||
arch/ARM/ARMMapping.h
|
||||
arch/ARM/ARMMappingInsn.inc
|
||||
arch/ARM/ARMMappingInsnOp.inc
|
||||
)
|
||||
set(HEADERS_ARM
|
||||
arch/ARM/ARMAddressingModes.h
|
||||
arch/ARM/ARMBaseInfo.h
|
||||
arch/ARM/ARMDisassembler.h
|
||||
arch/ARM/ARMGenAsmWriter.inc
|
||||
arch/ARM/ARMGenDisassemblerTables.inc
|
||||
arch/ARM/ARMGenInstrInfo.inc
|
||||
arch/ARM/ARMGenRegisterInfo.inc
|
||||
arch/ARM/ARMGenSubtargetInfo.inc
|
||||
arch/ARM/ARMInstPrinter.h
|
||||
arch/ARM/ARMMapping.h
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_arm.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_ARM64_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_ARM64)
|
||||
set(SOURCES_ARM64
|
||||
arch/AArch64/AArch64BaseInfo.c
|
||||
arch/AArch64/AArch64Disassembler.c
|
||||
arch/AArch64/AArch64InstPrinter.c
|
||||
arch/AArch64/AArch64Mapping.c
|
||||
arch/AArch64/AArch64Module.c
|
||||
)
|
||||
set(HEADERS_ARM64
|
||||
arch/AArch64/AArch64AddressingModes.h
|
||||
arch/AArch64/AArch64BaseInfo.h
|
||||
arch/AArch64/AArch64Disassembler.h
|
||||
arch/AArch64/AArch64GenAsmWriter.inc
|
||||
arch/AArch64/AArch64GenDisassemblerTables.inc
|
||||
arch/AArch64/AArch64GenInstrInfo.inc
|
||||
arch/AArch64/AArch64GenRegisterInfo.inc
|
||||
arch/AArch64/AArch64GenSubtargetInfo.inc
|
||||
arch/AArch64/AArch64InstPrinter.h
|
||||
arch/AArch64/AArch64Mapping.h
|
||||
arch/AArch64/AArch64MappingInsn.inc
|
||||
)
|
||||
set(HEADERS_ARM64
|
||||
arch/AArch64/AArch64AddressingModes.h
|
||||
arch/AArch64/AArch64BaseInfo.h
|
||||
arch/AArch64/AArch64Disassembler.h
|
||||
arch/AArch64/AArch64GenAsmWriter.inc
|
||||
arch/AArch64/AArch64GenDisassemblerTables.inc
|
||||
arch/AArch64/AArch64GenInstrInfo.inc
|
||||
arch/AArch64/AArch64GenRegisterInfo.inc
|
||||
arch/AArch64/AArch64GenSubtargetInfo.inc
|
||||
arch/AArch64/AArch64InstPrinter.h
|
||||
arch/AArch64/AArch64Mapping.h
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_arm64.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_MIPS_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_MIPS)
|
||||
set(SOURCES_MIPS
|
||||
arch/Mips/MipsDisassembler.c
|
||||
arch/Mips/MipsInstPrinter.c
|
||||
arch/Mips/MipsMapping.c
|
||||
arch/Mips/MipsModule.c
|
||||
)
|
||||
set(HEADERS_MIPS
|
||||
arch/Mips/MipsDisassembler.h
|
||||
arch/Mips/MipsGenAsmWriter.inc
|
||||
arch/Mips/MipsGenDisassemblerTables.inc
|
||||
arch/Mips/MipsGenInstrInfo.inc
|
||||
arch/Mips/MipsGenRegisterInfo.inc
|
||||
arch/Mips/MipsGenSubtargetInfo.inc
|
||||
arch/Mips/MipsInstPrinter.h
|
||||
arch/Mips/MipsMapping.h
|
||||
arch/Mips/MipsMappingInsn.inc
|
||||
)
|
||||
set(HEADERS_MIPS
|
||||
arch/Mips/MipsDisassembler.h
|
||||
arch/Mips/MipsGenAsmWriter.inc
|
||||
arch/Mips/MipsGenDisassemblerTables.inc
|
||||
arch/Mips/MipsGenInstrInfo.inc
|
||||
arch/Mips/MipsGenRegisterInfo.inc
|
||||
arch/Mips/MipsGenSubtargetInfo.inc
|
||||
arch/Mips/MipsInstPrinter.h
|
||||
arch/Mips/MipsMapping.h
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_mips.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_PPC_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_POWERPC)
|
||||
set(SOURCES_PPC
|
||||
arch/PowerPC/PPCDisassembler.c
|
||||
arch/PowerPC/PPCInstPrinter.c
|
||||
arch/PowerPC/PPCMapping.c
|
||||
arch/PowerPC/PPCModule.c
|
||||
)
|
||||
set(HEADERS_PPC
|
||||
arch/PowerPC/PPCDisassembler.h
|
||||
arch/PowerPC/PPCGenAsmWriter.inc
|
||||
arch/PowerPC/PPCGenDisassemblerTables.inc
|
||||
arch/PowerPC/PPCGenInstrInfo.inc
|
||||
arch/PowerPC/PPCGenRegisterInfo.inc
|
||||
arch/PowerPC/PPCGenSubtargetInfo.inc
|
||||
arch/PowerPC/PPCInstPrinter.h
|
||||
arch/PowerPC/PPCMapping.h
|
||||
arch/PowerPC/PPCMappingInsn.inc
|
||||
arch/PowerPC/PPCPredicates.h
|
||||
)
|
||||
set(HEADERS_PPC
|
||||
arch/PowerPC/PPCDisassembler.h
|
||||
arch/PowerPC/PPCGenAsmWriter.inc
|
||||
arch/PowerPC/PPCGenDisassemblerTables.inc
|
||||
arch/PowerPC/PPCGenInstrInfo.inc
|
||||
arch/PowerPC/PPCGenRegisterInfo.inc
|
||||
arch/PowerPC/PPCGenSubtargetInfo.inc
|
||||
arch/PowerPC/PPCInstPrinter.h
|
||||
arch/PowerPC/PPCMapping.h
|
||||
arch/PowerPC/PPCPredicates.h
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_ppc.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_X86_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_X86)
|
||||
set(SOURCES_X86
|
||||
arch/X86/X86Disassembler.c
|
||||
arch/X86/X86DisassemblerDecoder.c
|
||||
arch/X86/X86IntelInstPrinter.c
|
||||
arch/X86/X86Mapping.c
|
||||
arch/X86/X86Module.c
|
||||
)
|
||||
set(HEADERS_X86
|
||||
arch/X86/X86BaseInfo.h
|
||||
arch/X86/X86Disassembler.h
|
||||
arch/X86/X86DisassemblerDecoder.h
|
||||
arch/X86/X86DisassemblerDecoderCommon.h
|
||||
arch/X86/X86GenAsmWriter.inc
|
||||
arch/X86/X86GenAsmWriter1.inc
|
||||
arch/X86/X86GenAsmWriter1_reduce.inc
|
||||
arch/X86/X86GenAsmWriter_reduce.inc
|
||||
arch/X86/X86GenDisassemblerTables.inc
|
||||
arch/X86/X86GenDisassemblerTables_reduce.inc
|
||||
arch/X86/X86GenInstrInfo.inc
|
||||
arch/X86/X86GenInstrInfo_reduce.inc
|
||||
arch/X86/X86GenRegisterInfo.inc
|
||||
arch/X86/X86InstPrinter.h
|
||||
arch/X86/X86Mapping.h
|
||||
arch/X86/X86MappingInsn.inc
|
||||
arch/X86/X86MappingInsnOp.inc
|
||||
arch/X86/X86MappingInsnOp_reduce.inc
|
||||
arch/X86/X86MappingInsn_reduce.inc
|
||||
)
|
||||
set(HEADERS_X86
|
||||
arch/X86/X86BaseInfo.h
|
||||
arch/X86/X86Disassembler.h
|
||||
arch/X86/X86DisassemblerDecoder.h
|
||||
arch/X86/X86DisassemblerDecoderCommon.h
|
||||
arch/X86/X86GenAsmWriter.inc
|
||||
arch/X86/X86GenAsmWriter1.inc
|
||||
arch/X86/X86GenAsmWriter1_reduce.inc
|
||||
arch/X86/X86GenAsmWriter_reduce.inc
|
||||
arch/X86/X86GenDisassemblerTables.inc
|
||||
arch/X86/X86GenDisassemblerTables_reduce.inc
|
||||
arch/X86/X86GenInstrInfo.inc
|
||||
arch/X86/X86GenInstrInfo_reduce.inc
|
||||
arch/X86/X86GenRegisterInfo.inc
|
||||
arch/X86/X86InstPrinter.h
|
||||
arch/X86/X86Mapping.h
|
||||
)
|
||||
if (NOT CAPSTONE_BUILD_DIET)
|
||||
set(SOURCES_X86 ${SOURCES_X86} arch/X86/X86ATTInstPrinter.c)
|
||||
endif ()
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_x86.c test_customized_mnem.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_SPARC_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_SPARC)
|
||||
set(SOURCES_SPARC
|
||||
arch/Sparc/SparcDisassembler.c
|
||||
arch/Sparc/SparcInstPrinter.c
|
||||
arch/Sparc/SparcMapping.c
|
||||
arch/Sparc/SparcModule.c
|
||||
)
|
||||
set(HEADERS_SPARC
|
||||
arch/Sparc/Sparc.h
|
||||
arch/Sparc/SparcDisassembler.h
|
||||
arch/Sparc/SparcGenAsmWriter.inc
|
||||
arch/Sparc/SparcGenDisassemblerTables.inc
|
||||
arch/Sparc/SparcGenInstrInfo.inc
|
||||
arch/Sparc/SparcGenRegisterInfo.inc
|
||||
arch/Sparc/SparcGenSubtargetInfo.inc
|
||||
arch/Sparc/SparcInstPrinter.h
|
||||
arch/Sparc/SparcMapping.h
|
||||
arch/Sparc/SparcMappingInsn.inc
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_sparc.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_SYSZ_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_SYSZ)
|
||||
set(SOURCES_SYSZ
|
||||
arch/SystemZ/SystemZDisassembler.c
|
||||
arch/SystemZ/SystemZInstPrinter.c
|
||||
arch/SystemZ/SystemZMapping.c
|
||||
arch/SystemZ/SystemZModule.c
|
||||
arch/SystemZ/SystemZMCTargetDesc.c
|
||||
)
|
||||
set(HEADERS_SYSZ
|
||||
arch/SystemZ/SystemZDisassembler.h
|
||||
arch/SystemZ/SystemZGenAsmWriter.inc
|
||||
arch/SystemZ/SystemZGenDisassemblerTables.inc
|
||||
arch/SystemZ/SystemZGenInsnNameMaps.inc
|
||||
arch/SystemZ/SystemZGenInstrInfo.inc
|
||||
arch/SystemZ/SystemZGenRegisterInfo.inc
|
||||
arch/SystemZ/SystemZGenSubtargetInfo.inc
|
||||
arch/SystemZ/SystemZInstPrinter.h
|
||||
arch/SystemZ/SystemZMapping.h
|
||||
arch/SystemZ/SystemZMappingInsn.inc
|
||||
arch/SystemZ/SystemZMCTargetDesc.h
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_systemz.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_XCORE_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_XCORE)
|
||||
set(SOURCES_XCORE
|
||||
arch/XCore/XCoreDisassembler.c
|
||||
arch/XCore/XCoreInstPrinter.c
|
||||
arch/XCore/XCoreMapping.c
|
||||
arch/XCore/XCoreModule.c
|
||||
)
|
||||
set(HEADERS_XCORE
|
||||
arch/XCore/XCoreDisassembler.h
|
||||
arch/XCore/XCoreGenAsmWriter.inc
|
||||
arch/XCore/XCoreGenDisassemblerTables.inc
|
||||
arch/XCore/XCoreGenInstrInfo.inc
|
||||
arch/XCore/XCoreGenRegisterInfo.inc
|
||||
arch/XCore/XCoreInstPrinter.h
|
||||
arch/XCore/XCoreMapping.h
|
||||
arch/XCore/XCoreMappingInsn.inc
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_xcore.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_M68K_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_M68K)
|
||||
set(SOURCES_M68K
|
||||
arch/M68K/M68KDisassembler.c
|
||||
arch/M68K/M68KInstPrinter.c
|
||||
arch/M68K/M68KModule.c
|
||||
)
|
||||
set(HEADERS_M68K
|
||||
arch/M68K/M68KDisassembler.h
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_m68k.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_TMS320C64X_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_TMS320C64X)
|
||||
set(SOURCES_TMS320C64X
|
||||
arch/TMS320C64x/TMS320C64xDisassembler.c
|
||||
arch/TMS320C64x/TMS320C64xInstPrinter.c
|
||||
arch/TMS320C64x/TMS320C64xMapping.c
|
||||
arch/TMS320C64x/TMS320C64xModule.c
|
||||
)
|
||||
set(HEADERS_TMS320C64X
|
||||
arch/TMS320C64x/TMS320C64xDisassembler.h
|
||||
arch/TMS320C64x/TMS320C64xGenAsmWriter.inc
|
||||
arch/TMS320C64x/TMS320C64xGenDisassemblerTables.inc
|
||||
arch/TMS320C64x/TMS320C64xGenInstrInfo.inc
|
||||
arch/TMS320C64x/TMS320C64xGenRegisterInfo.inc
|
||||
arch/TMS320C64x/TMS320C64xInstPrinter.h
|
||||
arch/TMS320C64x/TMS320C64xMapping.h
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_tms320c64x.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_M680X_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_M680X)
|
||||
set(SOURCES_M680X
|
||||
arch/M680X/M680XDisassembler.c
|
||||
arch/M680X/M680XInstPrinter.c
|
||||
arch/M680X/M680XModule.c
|
||||
)
|
||||
set(HEADERS_M680X
|
||||
arch/M680X/M680XInstPrinter.h
|
||||
arch/M680X/M680XDisassembler.h
|
||||
arch/M680X/M680XDisassemblerInternals.h
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_m680x.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_EVM_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_EVM)
|
||||
set(SOURCES_EVM
|
||||
arch/EVM/EVMDisassembler.c
|
||||
arch/EVM/EVMInstPrinter.c
|
||||
arch/EVM/EVMMapping.c
|
||||
arch/EVM/EVMModule.c
|
||||
)
|
||||
set(HEADERS_EVM
|
||||
arch/EVM/EVMDisassembler.h
|
||||
arch/EVM/EVMInstPrinter.h
|
||||
arch/EVM/EVMMapping.h
|
||||
arch/EVM/EVMMappingInsn.inc
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_evm.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_MOS65XX_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_MOS65XX)
|
||||
set(SOURCES_MOS65XX
|
||||
arch/MOS65XX/MOS65XXModule.c
|
||||
arch/MOS65XX/MOS65XXDisassembler.c)
|
||||
set(HEADERS_SOURCES_MOS65XX
|
||||
arch/MOS65XX/MOS65XXDisassembler.h
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_mos65xx.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_OSXKERNEL_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_OSXKERNEL)
|
||||
endif ()
|
||||
|
||||
set(ALL_SOURCES
|
||||
${SOURCES_ENGINE}
|
||||
${SOURCES_ARM}
|
||||
${SOURCES_ARM64}
|
||||
${SOURCES_MIPS}
|
||||
${SOURCES_PPC}
|
||||
${SOURCES_X86}
|
||||
${SOURCES_SPARC}
|
||||
${SOURCES_SYSZ}
|
||||
${SOURCES_XCORE}
|
||||
${SOURCES_M68K}
|
||||
${SOURCES_TMS320C64X}
|
||||
${SOURCES_M680X}
|
||||
${SOURCES_EVM}
|
||||
${SOURCES_MOS65XX}
|
||||
)
|
||||
|
||||
set(ALL_HEADERS
|
||||
${HEADERS_COMMON}
|
||||
${HEADERS_ENGINE}
|
||||
${HEADERS_ARM}
|
||||
${HEADERS_ARM64}
|
||||
${HEADERS_MIPS}
|
||||
${HEADERS_PPC}
|
||||
${HEADERS_X86}
|
||||
${HEADERS_SPARC}
|
||||
${HEADERS_SYSZ}
|
||||
${HEADERS_XCORE}
|
||||
${HEADERS_M68K}
|
||||
${HEADERS_TMS320C64X}
|
||||
${HEADERS_M680X}
|
||||
${HEADERS_EVM}
|
||||
${HEADERS_MOS65XX}
|
||||
)
|
||||
|
||||
include_directories("${PROJECT_SOURCE_DIR}/include")
|
||||
|
||||
## properties
|
||||
# version info
|
||||
set_property(GLOBAL PROPERTY VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
||||
|
||||
## targets
|
||||
if (CAPSTONE_BUILD_STATIC)
|
||||
add_library(capstone-static STATIC ${ALL_SOURCES} ${ALL_HEADERS})
|
||||
set_property(TARGET capstone-static PROPERTY OUTPUT_NAME capstone)
|
||||
set(default-target capstone-static)
|
||||
endif ()
|
||||
|
||||
# Force static runtime libraries
|
||||
if (CAPSTONE_BUILD_STATIC_RUNTIME)
|
||||
FOREACH(flag
|
||||
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT
|
||||
CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT)
|
||||
if (MSVC)
|
||||
STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}")
|
||||
SET("${flag}" "${${flag}} /EHsc")
|
||||
endif (MSVC)
|
||||
ENDFOREACH()
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_BUILD_SHARED)
|
||||
add_library(capstone-shared SHARED ${ALL_SOURCES} ${ALL_HEADERS})
|
||||
set_property(TARGET capstone-shared PROPERTY OUTPUT_NAME capstone)
|
||||
set_property(TARGET capstone-shared PROPERTY COMPILE_FLAGS -DCAPSTONE_SHARED)
|
||||
|
||||
if (MSVC)
|
||||
set_target_properties(capstone-shared PROPERTIES IMPORT_SUFFIX _dll.lib)
|
||||
else()
|
||||
set_target_properties(capstone-shared PROPERTIES
|
||||
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
SOVERSION ${VERSION_MAJOR})
|
||||
endif ()
|
||||
|
||||
if(NOT DEFINED default-target) # honor `capstone-static` for tests first.
|
||||
set(default-target capstone-shared)
|
||||
add_definitions(-DCAPSTONE_SHARED)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_BUILD_TESTS)
|
||||
foreach (TSRC ${TEST_SOURCES})
|
||||
STRING(REGEX REPLACE ".c$" "" TBIN ${TSRC})
|
||||
add_executable(${TBIN} "tests/${TSRC}")
|
||||
target_link_libraries(${TBIN} ${default-target})
|
||||
add_test(NAME "capstone_${TBIN}" COMMAND ${TBIN})
|
||||
endforeach ()
|
||||
if (CAPSTONE_ARM_SUPPORT)
|
||||
set(ARM_REGRESS_TEST test_arm_regression.c)
|
||||
STRING(REGEX REPLACE ".c$" "" ARM_REGRESS_BIN ${ARM_REGRESS_TEST})
|
||||
add_executable(${ARM_REGRESS_BIN} "suite/arm/${ARM_REGRESS_TEST}")
|
||||
target_link_libraries(${ARM_REGRESS_BIN} ${default-target})
|
||||
add_test(NAME "capstone_${ARM_REGRESS_BIN}" COMMAND ${ARM_REGRESS_BIN})
|
||||
endif()
|
||||
# fuzz target built with the tests
|
||||
add_executable(fuzz_disasm suite/fuzz/onefile.c suite/fuzz/fuzz_disasm.c)
|
||||
target_link_libraries(fuzz_disasm ${default-target})
|
||||
endif ()
|
||||
|
||||
source_group("Source\\Engine" FILES ${SOURCES_ENGINE})
|
||||
source_group("Source\\ARM" FILES ${SOURCES_ARM})
|
||||
source_group("Source\\ARM64" FILES ${SOURCES_ARM64})
|
||||
source_group("Source\\Mips" FILES ${SOURCES_MIPS})
|
||||
source_group("Source\\PowerPC" FILES ${SOURCES_PPC})
|
||||
source_group("Source\\Sparc" FILES ${SOURCES_SPARC})
|
||||
source_group("Source\\SystemZ" FILES ${SOURCES_SYSZ})
|
||||
source_group("Source\\X86" FILES ${SOURCES_X86})
|
||||
source_group("Source\\XCore" FILES ${SOURCES_XCORE})
|
||||
source_group("Source\\M68K" FILES ${SOURCES_M68K})
|
||||
source_group("Source\\TMS320C64x" FILES ${SOURCES_TMS320C64X})
|
||||
source_group("Source\\M680X" FILES ${SOURCES_M680X})
|
||||
source_group("Source\\EVM" FILES ${SOURCES_EVM})
|
||||
source_group("Source\\MOS65XX" FILES ${SOURCES_MOS65XX})
|
||||
|
||||
source_group("Include\\Common" FILES ${HEADERS_COMMON})
|
||||
source_group("Include\\Engine" FILES ${HEADERS_ENGINE})
|
||||
source_group("Include\\ARM" FILES ${HEADERS_ARM})
|
||||
source_group("Include\\ARM64" FILES ${HEADERS_ARM64})
|
||||
source_group("Include\\Mips" FILES ${HEADERS_MIPS})
|
||||
source_group("Include\\PowerPC" FILES ${HEADERS_PPC})
|
||||
source_group("Include\\Sparc" FILES ${HEADERS_SPARC})
|
||||
source_group("Include\\SystemZ" FILES ${HEADERS_SYSZ})
|
||||
source_group("Include\\X86" FILES ${HEADERS_X86})
|
||||
source_group("Include\\XCore" FILES ${HEADERS_XCORE})
|
||||
source_group("Include\\M68K" FILES ${HEADERS_M68K})
|
||||
source_group("Include\\TMS320C64x" FILES ${HEADERS_TMS320C64X})
|
||||
source_group("Include\\M680X" FILES ${HEADERS_MC680X})
|
||||
source_group("Include\\EVM" FILES ${HEADERS_EVM})
|
||||
source_group("Include\\MOS65XX" FILES ${HEADERS_MOS65XX})
|
||||
|
||||
### test library 64bit routine:
|
||||
include("GNUInstallDirs")
|
||||
|
||||
## installation
|
||||
if (CAPSTONE_INSTALL)
|
||||
install(FILES ${HEADERS_COMMON} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/capstone)
|
||||
endif ()
|
||||
configure_file(capstone.pc.in ${CMAKE_BINARY_DIR}/capstone.pc @ONLY)
|
||||
|
||||
if (CAPSTONE_BUILD_STATIC AND CAPSTONE_INSTALL)
|
||||
install(TARGETS capstone-static
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_BUILD_SHARED AND CAPSTONE_INSTALL)
|
||||
install(TARGETS capstone-shared
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_BUILD_SHARED AND CAPSTONE_BUILD_CSTOOL)
|
||||
FILE(GLOB CSTOOL_SRC cstool/*.c)
|
||||
add_executable(cstool ${CSTOOL_SRC})
|
||||
target_link_libraries(cstool ${default-target})
|
||||
|
||||
if (CAPSTONE_INSTALL)
|
||||
install(TARGETS cstool DESTINATION bin)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/capstone.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
endif ()
|
||||
endif ()
|
@ -0,0 +1,200 @@
|
||||
This documentation explains how to compile, install & run Capstone on MacOSX,
|
||||
Linux, *BSD & Solaris. We also show steps to cross-compile for Microsoft Windows.
|
||||
|
||||
To natively compile for Windows using Microsoft Visual Studio, see COMPILE_MSVC.TXT.
|
||||
|
||||
To compile using CMake, see COMPILE_CMAKE.TXT.
|
||||
|
||||
To compile using XCode on MacOSX, see xcode/README.md.
|
||||
|
||||
To compile for Windows CE (a.k.a, Windows Embedded Compact), see windowsce/COMPILE.md.
|
||||
|
||||
*-*-*-*-*-*
|
||||
|
||||
Capstone requires no prerequisite packages, so it is easy to compile & install.
|
||||
|
||||
|
||||
|
||||
(0) Tailor Capstone to your need.
|
||||
|
||||
Out of all archtitectures supported by Capstone, if you just need several
|
||||
selected archs, choose the ones you want to compile in by editing "config.mk"
|
||||
before going to next steps.
|
||||
|
||||
By default, all architectures are compiled.
|
||||
|
||||
The other way of customize Capstone without having to edit config.mk is to
|
||||
pass the desired options on the commandline to ./make.sh. Currently,
|
||||
Capstone supports 7 options, as followings.
|
||||
|
||||
- CAPSTONE_ARCHS: specify list of architectures to compiled in.
|
||||
- CAPSTONE_USE_SYS_DYN_MEM: change this if you have your own dynamic memory management.
|
||||
- CAPSTONE_DIET: use this to make the output binaries more compact.
|
||||
- CAPSTONE_X86_REDUCE: another option to make X86 binary smaller.
|
||||
- CAPSTONE_X86_ATT_DISABLE: disables AT&T syntax on x86.
|
||||
- CAPSTONE_STATIC: build static library.
|
||||
- CAPSTONE_SHARED: build dynamic (shared) library.
|
||||
|
||||
By default, Capstone uses system dynamic memory management, both DIET and X86_REDUCE
|
||||
modes are disable, and builds all the static & shared libraries.
|
||||
|
||||
To avoid editing config.mk for these customization, we can pass their values to
|
||||
make.sh, as followings.
|
||||
|
||||
$ CAPSTONE_ARCHS="arm aarch64 x86" CAPSTONE_USE_SYS_DYN_MEM=no CAPSTONE_DIET=yes CAPSTONE_X86_REDUCE=yes ./make.sh
|
||||
|
||||
NOTE: on commandline, put these values in front of ./make.sh, not after it.
|
||||
|
||||
For each option, refer to docs/README for more details.
|
||||
|
||||
|
||||
|
||||
(1) Compile from source
|
||||
|
||||
On *nix (such as MacOSX, Linux, *BSD, Solaris):
|
||||
|
||||
- To compile for current platform, run:
|
||||
|
||||
$ ./make.sh
|
||||
|
||||
- On 64-bit OS, run the command below to cross-compile Capstone for 32-bit binary:
|
||||
|
||||
$ ./make.sh nix32
|
||||
|
||||
|
||||
|
||||
(2) Install Capstone on *nix
|
||||
|
||||
To install Capstone, run:
|
||||
|
||||
$ sudo ./make.sh install
|
||||
|
||||
For FreeBSD/OpenBSD, where sudo is unavailable, run:
|
||||
|
||||
$ su; ./make.sh install
|
||||
|
||||
Users are then required to enter root password to copy Capstone into machine
|
||||
system directories.
|
||||
|
||||
Afterwards, run ./tests/test* to see the tests disassembling sample code.
|
||||
|
||||
|
||||
NOTE: The core framework installed by "./make.sh install" consist of
|
||||
following files:
|
||||
|
||||
/usr/include/capstone/arm.h
|
||||
/usr/include/capstone/arm64.h
|
||||
/usr/include/capstone/capstone.h
|
||||
/usr/include/capstone/evm.h
|
||||
/usr/include/capstone/m680x.h
|
||||
/usr/include/capstone/m68k.h
|
||||
/usr/include/capstone/mips.h
|
||||
/usr/include/capstone/mos65xx.h
|
||||
/usr/include/capstone/platform.h
|
||||
/usr/include/capstone/ppc.h
|
||||
/usr/include/capstone/sparc.h
|
||||
/usr/include/capstone/systemz.h
|
||||
/usr/include/capstone/tms320c64x.h
|
||||
/usr/include/capstone/x86.h
|
||||
/usr/include/capstone/xcore.h
|
||||
/usr/lib/libcapstone.a
|
||||
/usr/lib/libcapstone.so (for Linux/*nix), or /usr/lib/libcapstone.dylib (OSX)
|
||||
|
||||
|
||||
|
||||
(3) Cross-compile for Windows from *nix
|
||||
|
||||
To cross-compile for Windows, Linux & gcc-mingw-w64-i686 (and also gcc-mingw-w64-x86-64
|
||||
for 64-bit binaries) are required.
|
||||
|
||||
- To cross-compile Windows 32-bit binary, simply run:
|
||||
|
||||
$ ./make.sh cross-win32
|
||||
|
||||
- To cross-compile Windows 64-bit binary, run:
|
||||
|
||||
$ ./make.sh cross-win64
|
||||
|
||||
Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then
|
||||
be used on Windows machine.
|
||||
|
||||
|
||||
|
||||
(4) Cross-compile for iOS from Mac OSX.
|
||||
|
||||
To cross-compile for iOS (iPhone/iPad/iPod), Mac OSX with XCode installed is required.
|
||||
|
||||
- To cross-compile for ArmV7 (iPod 4, iPad 1/2/3, iPhone4, iPhone4S), run:
|
||||
$ ./make.sh ios_armv7
|
||||
|
||||
- To cross-compile for ArmV7s (iPad 4, iPhone 5C, iPad mini), run:
|
||||
$ ./make.sh ios_armv7s
|
||||
|
||||
- To cross-compile for Arm64 (iPhone 5S, iPad mini Retina, iPad Air), run:
|
||||
$ ./make.sh ios_arm64
|
||||
|
||||
- To cross-compile for all iDevices (armv7 + armv7s + arm64), run:
|
||||
$ ./make.sh ios
|
||||
|
||||
Resulted files libcapstone.dylib, libcapstone.a & tests/test* can then
|
||||
be used on iOS devices.
|
||||
|
||||
|
||||
|
||||
(5) Cross-compile for Android
|
||||
|
||||
To cross-compile for Android (smartphone/tablet), Android NDK is required.
|
||||
NOTE: Only ARM and ARM64 are currently supported.
|
||||
|
||||
$ NDK=/android/android-ndk-r10e ./make.sh cross-android arm
|
||||
or
|
||||
$ NDK=/android/android-ndk-r10e ./make.sh cross-android arm64
|
||||
|
||||
Resulted files libcapstone.so, libcapstone.a & tests/test* can then
|
||||
be used on Android devices.
|
||||
|
||||
|
||||
|
||||
(6) Compile on Windows with Cygwin
|
||||
|
||||
To compile under Cygwin gcc-mingw-w64-i686 or x86_64-w64-mingw32 run:
|
||||
|
||||
- To compile Windows 32-bit binary under Cygwin, run:
|
||||
|
||||
$ ./make.sh cygwin-mingw32
|
||||
|
||||
- To compile Windows 64-bit binary under Cygwin, run:
|
||||
|
||||
$ ./make.sh cygwin-mingw64
|
||||
|
||||
Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then
|
||||
be used on Windows machine.
|
||||
|
||||
|
||||
|
||||
(7) By default, "cc" (default C compiler on the system) is used as compiler.
|
||||
|
||||
- To use "clang" compiler instead, run the command below:
|
||||
|
||||
$ ./make.sh clang
|
||||
|
||||
- To use "gcc" compiler instead, run:
|
||||
|
||||
$ ./make.sh gcc
|
||||
|
||||
|
||||
|
||||
(8) To uninstall Capstone, run the command below:
|
||||
|
||||
$ sudo ./make.sh uninstall
|
||||
|
||||
|
||||
|
||||
(9) Language bindings
|
||||
|
||||
So far, Python, Ocaml & Java are supported by bindings in the main code.
|
||||
Look for the bindings under directory bindings/, and refer to README file
|
||||
of corresponding languages.
|
||||
|
||||
Community also provide bindings for C#, Go, Ruby, NodeJS, C++ & Vala. Links to
|
||||
these can be found at address http://capstone-engine.org/download.html
|
@ -0,0 +1,114 @@
|
||||
This documentation explains how to compile Capstone with CMake, focus on
|
||||
using Microsoft Visual C as the compiler.
|
||||
|
||||
To compile Capstone on *nix, see COMPILE.TXT.
|
||||
|
||||
To compile Capstone on Windows using Visual Studio, see COMPILE_MSVC.TXT.
|
||||
|
||||
*-*-*-*-*-*
|
||||
|
||||
This documentation requires CMake & Windows SDK or MS Visual Studio installed on
|
||||
your machine.
|
||||
|
||||
Get CMake for free from http://www.cmake.org.
|
||||
|
||||
|
||||
|
||||
(0) Tailor Capstone to your need.
|
||||
|
||||
Out of archtitectures supported by Capstone, if you just need several selected archs,
|
||||
run "cmake" with the unwanted archs disabled (set to 0) as followings.
|
||||
|
||||
- CAPSTONE_ARM_SUPPORT: support ARM. Run cmake with -DCAPSTONE_ARM_SUPPORT=0 to remove ARM.
|
||||
- CAPSTONE_ARM64_SUPPORT: support ARM64. Run cmake with -DCAPSTONE_ARM64_SUPPORT=0 to remove ARM64.
|
||||
- CAPSTONE_M680X_SUPPORT: support M680X. Run cmake with -DCAPSTONE_M680X_SUPPORT=0 to remove M680X.
|
||||
- CAPSTONE_M68K_SUPPORT: support M68K. Run cmake with -DCAPSTONE_M68K_SUPPORT=0 to remove M68K.
|
||||
- CAPSTONE_MIPS_SUPPORT: support Mips. Run cmake with -DCAPSTONE_MIPS_SUPPORT=0 to remove Mips.
|
||||
- CAPSTONE_MOS65XX_SUPPORT: support MOS65XX. Run cmake with -DCAPSTONE_MOS65XX_SUPPORT=0 to remove MOS65XX.
|
||||
- CAPSTONE_PPC_SUPPORT: support PPC. Run cmake with -DCAPSTONE_PPC_SUPPORT=0 to remove PPC.
|
||||
- CAPSTONE_SPARC_SUPPORT: support Sparc. Run cmake with -DCAPSTONE_SPARC_SUPPORT=0 to remove Sparc.
|
||||
- CAPSTONE_SYSZ_SUPPORT: support SystemZ. Run cmake with -DCAPSTONE_SYSZ_SUPPORT=0 to remove SystemZ.
|
||||
- CAPSTONE_XCORE_SUPPORT: support XCore. Run cmake with -DCAPSTONE_XCORE_SUPPORT=0 to remove XCore.
|
||||
- CAPSTONE_X86_SUPPORT: support X86. Run cmake with -DCAPSTONE_X86_SUPPORT=0 to remove X86.
|
||||
- CAPSTONE_TMS320C64X_SUPPORT: support TMS320C64X. Run cmake with -DCAPSTONE_TMS320C64X_SUPPORT=0 to remove TMS320C64X.
|
||||
- CAPSTONE_EVM_SUPPORT: support EVM. Run cmake with -DCAPSTONE_EVM_SUPPORT=0 to remove EVM.
|
||||
- CAPSTONE_ARCHITECUTRE_DEFAULT: Whether architectures are enabled by default.
|
||||
Set this of OFF with -DCAPSTONE_ARCHITECUTRE_DEFAULT=OFF to dissable all architectures by default.
|
||||
You can then enable them again with one of the CAPSTONE_<ARCH>_SUPPORT options.
|
||||
|
||||
By default, all architectures are compiled in.
|
||||
|
||||
|
||||
Besides, Capstone also allows some more customization via following macros.
|
||||
|
||||
- CAPSTONE_USE_SYS_DYN_MEM: change this to OFF to use your own dynamic memory management.
|
||||
- CAPSTONE_BUILD_DIET: change this to ON to make the binaries more compact.
|
||||
- CAPSTONE_X86_REDUCE: change this to ON to make X86 binary smaller.
|
||||
- CAPSTONE_X86_ATT_DISABLE: change this to ON to disable AT&T syntax on x86.
|
||||
|
||||
By default, Capstone use system dynamic memory management, and both DIET and X86_REDUCE
|
||||
modes are disabled. To use your own memory allocations, turn ON both DIET &
|
||||
X86_REDUCE, run "cmake" with: -DCAPSTONE_USE_SYS_DYN_MEM=0 -DCAPSTONE_BUILD_DIET=1 -DCAPSTONE_X86_REDUCE=1
|
||||
|
||||
|
||||
For each option, refer to docs/README for more details.
|
||||
|
||||
|
||||
|
||||
(1) CMake allows you to generate different generators to build Capstone. Below is
|
||||
some examples on how to build Capstone on Windows with CMake.
|
||||
|
||||
(*) You can let CMake select a generator for you. Do:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
|
||||
This last command is also where you can pass additional CMake configuration flags
|
||||
using `-D<key>=<value>`. Then to build use:
|
||||
|
||||
cmake --build . --config Release
|
||||
|
||||
|
||||
(*) To build Capstone using Nmake of Windows SDK, do:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
..\nmake.bat
|
||||
|
||||
After this, find the samples test*.exe, capstone.lib & capstone.dll
|
||||
in the same directory.
|
||||
|
||||
|
||||
|
||||
(*) To build Capstone using Visual Studio, choose the generator accordingly to the
|
||||
version of Visual Studio on your machine. For example, with Visual Studio 2013, do:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G "Visual Studio 12" ..
|
||||
|
||||
After this, find capstone.sln in the same directory. Open it with Visual Studio
|
||||
and build the solution including libraries & all test as usual.
|
||||
|
||||
|
||||
|
||||
(2) You can make sure the prior steps successfully worked by launching one of the
|
||||
testing binary (test*.exe).
|
||||
|
||||
(3) You can also enable just one specific architecture by passing the architecture name
|
||||
to either the cmake.sh or nmake.bat scripts. e.g.:
|
||||
|
||||
../cmake.sh x86
|
||||
|
||||
Will just target the x86 architecture. The list of available architectures is: ARM,
|
||||
ARM64, M68K, MIPS, PowerPC, Sparc, SystemZ, XCore, x86, TMS320C64x, M680x, EVM, MOS65XX.
|
||||
|
||||
(4) You can also create an installation image with cmake, by using the 'install' target.
|
||||
Use:
|
||||
|
||||
cmake --build . --config Release --target install
|
||||
|
||||
This will normally install an image in a default location (`C:\Program Files` on Windows),
|
||||
so it's good to explicitly set this location when configuring CMake. Use: `-DCMAKE_INSTALL_PREFIX=image`
|
||||
for instance, to put the installation in the 'image' subdirectory of the build directory.
|
@ -0,0 +1,122 @@
|
||||
This documentation explains how to compile Capstone on Windows using
|
||||
Microsoft Visual Studio version 2010 or newer.
|
||||
|
||||
To compile Capstone on *nix, see COMPILE.TXT
|
||||
|