2014-05-17 16:39:49 +00:00
|
|
|
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.
|
|
|
|
|
2014-05-28 14:39:23 +00:00
|
|
|
To compile using CMake, see COMPILE_CMAKE.TXT.
|
|
|
|
|
2014-10-06 14:19:10 +00:00
|
|
|
To compile using XCode on MacOSX, see xcode/README.md.
|
|
|
|
|
2016-04-12 07:26:47 +00:00
|
|
|
To compile for Windows CE (a.k.a, Windows Embedded Compact), see windowsce/COMPILE.md.
|
|
|
|
|
2013-11-27 04:11:31 +00:00
|
|
|
*-*-*-*-*-*
|
|
|
|
|
|
|
|
Capstone requires no prerequisite packages, so it is easy to compile & install.
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-24 09:03:45 +00:00
|
|
|
(0) Tailor Capstone to your need.
|
|
|
|
|
2019-01-22 07:49:34 +00:00
|
|
|
Out of all archtitectures supported by Capstone, if you just need several
|
2018-03-31 09:29:22 +00:00
|
|
|
selected archs, choose the ones you want to compile in by editing "config.mk"
|
|
|
|
before going to next steps.
|
2013-12-24 09:03:45 +00:00
|
|
|
|
2019-01-22 07:49:34 +00:00
|
|
|
By default, all architectures are compiled.
|
2013-12-24 09:03:45 +00:00
|
|
|
|
2014-04-29 06:00:16 +00:00
|
|
|
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,
|
2019-05-20 03:22:27 +00:00
|
|
|
Capstone supports 8 options, as followings.
|
2014-04-29 06:00:16 +00:00
|
|
|
|
|
|
|
- CAPSTONE_ARCHS: specify list of architectures to compiled in.
|
2014-04-29 06:25:15 +00:00
|
|
|
- CAPSTONE_USE_SYS_DYN_MEM: change this if you have your own dynamic memory management.
|
2014-04-29 06:00:16 +00:00
|
|
|
- CAPSTONE_DIET: use this to make the output binaries more compact.
|
|
|
|
- CAPSTONE_X86_REDUCE: another option to make X86 binary smaller.
|
2014-08-20 06:02:14 +00:00
|
|
|
- CAPSTONE_X86_ATT_DISABLE: disables AT&T syntax on x86.
|
2014-11-13 06:58:45 +00:00
|
|
|
- CAPSTONE_STATIC: build static library.
|
|
|
|
- CAPSTONE_SHARED: build dynamic (shared) library.
|
2019-05-20 03:22:27 +00:00
|
|
|
- CAPSTONE_DEBUG: enable debug build supporting assert().
|
2014-04-29 06:00:16 +00:00
|
|
|
|
2014-11-13 06:58:45 +00:00
|
|
|
By default, Capstone uses system dynamic memory management, both DIET and X86_REDUCE
|
|
|
|
modes are disable, and builds all the static & shared libraries.
|
2014-05-15 03:06:43 +00:00
|
|
|
|
2014-11-13 06:58:45 +00:00
|
|
|
To avoid editing config.mk for these customization, we can pass their values to
|
2014-04-29 06:00:16 +00:00
|
|
|
make.sh, as followings.
|
|
|
|
|
2014-04-29 06:25:15 +00:00
|
|
|
$ CAPSTONE_ARCHS="arm aarch64 x86" CAPSTONE_USE_SYS_DYN_MEM=no CAPSTONE_DIET=yes CAPSTONE_X86_REDUCE=yes ./make.sh
|
2014-04-29 06:00:16 +00:00
|
|
|
|
|
|
|
NOTE: on commandline, put these values in front of ./make.sh, not after it.
|
|
|
|
|
|
|
|
For each option, refer to docs/README for more details.
|
2013-12-24 09:03:45 +00:00
|
|
|
|
|
|
|
|
2014-04-07 14:13:56 +00:00
|
|
|
|
2013-12-24 09:03:45 +00:00
|
|
|
(1) Compile from source
|
|
|
|
|
2014-01-17 06:20:54 +00:00
|
|
|
On *nix (such as MacOSX, Linux, *BSD, Solaris):
|
2013-12-24 09:03:45 +00:00
|
|
|
|
2014-01-17 06:56:03 +00:00
|
|
|
- To compile for current platform, run:
|
2013-12-24 09:03:45 +00:00
|
|
|
|
2014-01-17 06:20:54 +00:00
|
|
|
$ ./make.sh
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2014-04-14 06:40:25 +00:00
|
|
|
- On 64-bit OS, run the command below to cross-compile Capstone for 32-bit binary:
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2014-04-14 06:40:25 +00:00
|
|
|
$ ./make.sh nix32
|
2013-11-27 04:11:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-24 09:03:45 +00:00
|
|
|
(2) Install Capstone on *nix
|
|
|
|
|
|
|
|
To install Capstone, run:
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2014-01-17 06:20:54 +00:00
|
|
|
$ sudo ./make.sh install
|
2014-04-14 06:40:25 +00:00
|
|
|
|
2014-01-17 06:20:54 +00:00
|
|
|
For FreeBSD/OpenBSD, where sudo is unavailable, run:
|
2013-12-09 05:53:11 +00:00
|
|
|
|
2014-04-14 06:40:25 +00:00
|
|
|
$ su; ./make.sh install
|
2013-12-09 05:53:11 +00:00
|
|
|
|
2013-12-24 09:03:45 +00:00
|
|
|
Users are then required to enter root password to copy Capstone into machine
|
|
|
|
system directories.
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2014-01-22 02:17:17 +00:00
|
|
|
Afterwards, run ./tests/test* to see the tests disassembling sample code.
|
2014-01-17 06:20:54 +00:00
|
|
|
|
|
|
|
|
2014-01-17 06:56:03 +00:00
|
|
|
NOTE: The core framework installed by "./make.sh install" consist of
|
|
|
|
following files:
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2013-11-27 12:25:34 +00:00
|
|
|
/usr/include/capstone/capstone.h
|
|
|
|
/usr/include/capstone/x86.h
|
|
|
|
/usr/include/capstone/arm.h
|
|
|
|
/usr/include/capstone/arm64.h
|
2018-03-31 09:29:22 +00:00
|
|
|
/usr/include/capstone/evm.h
|
2019-02-01 15:03:47 +00:00
|
|
|
/usr/include/capstone/wasm.h
|
2015-10-05 08:14:19 +00:00
|
|
|
/usr/include/capstone/m68k.h
|
2018-03-31 09:29:22 +00:00
|
|
|
/usr/include/capstone/m680x.h
|
2013-11-27 12:25:34 +00:00
|
|
|
/usr/include/capstone/mips.h
|
2014-01-17 06:20:54 +00:00
|
|
|
/usr/include/capstone/ppc.h
|
2014-03-10 03:58:57 +00:00
|
|
|
/usr/include/capstone/sparc.h
|
2014-03-23 00:35:45 +00:00
|
|
|
/usr/include/capstone/systemz.h
|
2018-03-31 09:29:22 +00:00
|
|
|
/usr/include/capstone/tms320c64x.h
|
2015-02-11 02:30:03 +00:00
|
|
|
/usr/include/capstone/xcore.h
|
2019-02-18 09:39:51 +00:00
|
|
|
/usr/include/capstone/bpf.h
|
2015-02-11 02:30:03 +00:00
|
|
|
/usr/include/capstone/platform.h
|
2013-11-27 04:11:31 +00:00
|
|
|
/usr/lib/libcapstone.so (for Linux/*nix), or /usr/lib/libcapstone.dylib (OSX)
|
2013-12-09 03:12:47 +00:00
|
|
|
/usr/lib/libcapstone.a
|
2013-11-27 04:11:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-07 14:13:56 +00:00
|
|
|
(3) Cross-compile for Windows from *nix
|
2013-12-24 09:03:45 +00:00
|
|
|
|
|
|
|
To cross-compile for Windows, Linux & gcc-mingw-w64-i686 (and also gcc-mingw-w64-x86-64
|
|
|
|
for 64-bit binaries) are required.
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2014-01-17 06:56:03 +00:00
|
|
|
- To cross-compile Windows 32-bit binary, simply run:
|
2014-04-14 06:40:25 +00:00
|
|
|
|
2014-01-17 06:20:54 +00:00
|
|
|
$ ./make.sh cross-win32
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2014-01-17 06:56:03 +00:00
|
|
|
- To cross-compile Windows 64-bit binary, run:
|
2014-04-14 06:40:25 +00:00
|
|
|
|
2014-01-17 06:20:54 +00:00
|
|
|
$ ./make.sh cross-win64
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2014-01-22 02:17:17 +00:00
|
|
|
Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then
|
|
|
|
be used on Windows machine.
|
2013-12-24 09:03:45 +00:00
|
|
|
|
2013-11-27 04:11:31 +00:00
|
|
|
|
|
|
|
|
2014-04-07 14:13:56 +00:00
|
|
|
(4) Cross-compile for iOS from Mac OSX.
|
2014-04-01 02:22:54 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-07 14:13:56 +00:00
|
|
|
(5) Cross-compile for Android
|
|
|
|
|
|
|
|
To cross-compile for Android (smartphone/tablet), Android NDK is required.
|
2015-06-22 07:52:45 +00:00
|
|
|
NOTE: Only ARM and ARM64 are currently supported.
|
2014-04-07 14:13:56 +00:00
|
|
|
|
2015-06-22 07:52:45 +00:00
|
|
|
$ NDK=/android/android-ndk-r10e ./make.sh cross-android arm
|
|
|
|
or
|
|
|
|
$ NDK=/android/android-ndk-r10e ./make.sh cross-android arm64
|
2014-04-07 14:13:56 +00:00
|
|
|
|
|
|
|
Resulted files libcapstone.so, libcapstone.a & tests/test* can then
|
|
|
|
be used on Android devices.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(6) Compile on Windows with Cygwin
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2013-12-24 09:03:45 +00:00
|
|
|
To compile under Cygwin gcc-mingw-w64-i686 or x86_64-w64-mingw32 run:
|
2013-11-28 18:23:39 +00:00
|
|
|
|
2014-04-14 06:40:25 +00:00
|
|
|
- To compile Windows 32-bit binary under Cygwin, run:
|
|
|
|
|
2014-01-17 06:20:54 +00:00
|
|
|
$ ./make.sh cygwin-mingw32
|
2013-11-28 18:23:39 +00:00
|
|
|
|
2014-04-14 06:40:25 +00:00
|
|
|
- To compile Windows 64-bit binary under Cygwin, run:
|
|
|
|
|
2014-01-17 06:20:54 +00:00
|
|
|
$ ./make.sh cygwin-mingw64
|
2013-11-28 18:23:39 +00:00
|
|
|
|
2014-01-22 02:17:17 +00:00
|
|
|
Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then
|
|
|
|
be used on Windows machine.
|
2013-11-28 18:23:39 +00:00
|
|
|
|
2014-01-17 06:56:03 +00:00
|
|
|
|
2014-04-07 14:13:56 +00:00
|
|
|
|
|
|
|
(7) By default, "cc" (default C compiler on the system) is used as compiler.
|
2014-01-16 11:16:21 +00:00
|
|
|
|
2014-04-14 06:40:25 +00:00
|
|
|
- To use "clang" compiler instead, run the command below:
|
2014-01-16 11:16:21 +00:00
|
|
|
|
2014-01-17 06:20:54 +00:00
|
|
|
$ ./make.sh clang
|
2013-12-24 09:03:45 +00:00
|
|
|
|
2014-01-17 06:56:03 +00:00
|
|
|
- To use "gcc" compiler instead, run:
|
2013-12-24 09:03:45 +00:00
|
|
|
|
2014-01-17 06:20:54 +00:00
|
|
|
$ ./make.sh gcc
|
2013-11-27 04:11:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-14 06:40:25 +00:00
|
|
|
(8) To uninstall Capstone, run the command below:
|
2014-04-14 06:00:12 +00:00
|
|
|
|
|
|
|
$ sudo ./make.sh uninstall
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(9) Language bindings
|
2013-12-24 09:03:45 +00:00
|
|
|
|
2014-01-22 02:17:17 +00:00
|
|
|
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.
|
|
|
|
|
2014-11-14 07:22:05 +00:00
|
|
|
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
|