2017-01-24 18:20:19 +03:00
|
|
|
To build Unicorn on Windows natively using Visual Studio, see docs under "msvc"
|
|
|
|
directory in root directory.
|
|
|
|
|
|
|
|
The rest of this manual shows how to cross-compile Unicorn for Windows using
|
|
|
|
either MingW or Msys2.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:05:35 +03:00
|
|
|
To compile for Linux, Mac OS X and Unix-based OS, see [COMPILE-NIX.md](COMPILE-NIX.md)
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
---
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
|
|
|
|
[0] Dependencies
|
|
|
|
|
2016-12-19 17:01:50 +03:00
|
|
|
For Windows, cross-compile requires Mingw. At the moment, it is confirmed that
|
|
|
|
Unicorn can be compiled either on Ubuntu or Windows.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
- On Ubuntu 14.04 64-bit, do:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:08:40 +03:00
|
|
|
- Download DEB packages for Mingw64 from:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
https://launchpad.net/~greg-hellings/+archive/ubuntu/mingw-libs/+build/2924251
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
- On Windows, install MinGW via package MSYS2 at https://msys2.github.io/
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
Follow the install instructions and don't forget to update the system packages with:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
$ pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
Then close MSYS2, run it again from Start menu and update the rest with:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
$ pacman -Su
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
Finally, install required toolchain to build C projects.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
- To compile for Windows 32-bit, run:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-05-17 16:09:13 +03:00
|
|
|
$ pacman -S python2
|
|
|
|
$ pacman -S make
|
|
|
|
$ pacman -S mingw-w64-i686-toolchain
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
- To compile for Windows 64-bit, run:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-05-17 16:09:13 +03:00
|
|
|
$ pacman -S python2
|
|
|
|
$ pacman -S make
|
|
|
|
$ pacman -S mingw-w64-x86_64-toolchain
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-12-20 06:30:26 +03:00
|
|
|
- For Cygwin, "make", "gcc-core", "libpcre-devel", "zlib-devel"
|
2016-12-19 17:01:50 +03:00
|
|
|
are needed.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
If apt-cyg is available, you can install these with:
|
|
|
|
|
2016-12-20 06:30:26 +03:00
|
|
|
$ apt-cyg install make gcc-core libpcre-devel zlib-devel
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[1] Tailor Unicorn to your need.
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
Out of 6 archtitectures supported by Unicorn (Arm, Arm64, M68K, Mips, Sparc,
|
|
|
|
& X86), if you just need several selected archs, choose which ones you want
|
|
|
|
to compile in by editing "config.mk" before going to next steps.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
By default, all 6 architectures are compiled.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
The other way of customize Unicorn without having to edit config.mk is to
|
|
|
|
pass the desired options on the commandline to ./make.sh. Currently,
|
|
|
|
Unicorn supports 4 options, as follows.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
- UNICORN_ARCHS: specify list of architectures to compiled in.
|
|
|
|
- UNICORN_STATIC: build static library.
|
|
|
|
- UNICORN_SHARED: build dynamic (shared) library.
|
|
|
|
- UNICORN_QEMU_FLAGS: specify extra flags for qemu's configure script
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
To avoid editing config.mk for these customization, we can pass their values to
|
|
|
|
make.sh, as follows.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
$ UNICORN_ARCHS="arm aarch64 x86" ./make.sh
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
NOTE: on commandline, put these values in front of ./make.sh, not after it.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
For each option, refer to docs/README for more details.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[2] Compile from source on Windows - with MinGW (MSYS2)
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
To compile with MinGW, install MSYS2 as instructed in the first section.
|
|
|
|
Then, build Unicorn with the next steps:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
- To compile Windows 32-bit binary with MinGW, run:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
$ ./make.sh cross-win32
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
- To compile Windows 64-bit binary with MinGW, run:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
$ ./make.sh cross-win64
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
Resulted files unicorn.dll, unicorn.lib & samples/sample*.exe can then
|
|
|
|
be used on Windows machine.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
To run sample_x86.exe on Windows 32-bit, you need the following files:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
unicorn.dll
|
2016-12-04 16:50:13 +03:00
|
|
|
%MSYS2%\mingw32\bin\libgcc_s_dw2-1.dll
|
2016-04-30 04:49:00 +03:00
|
|
|
%MSYS2%\mingw32\bin\libiconv-2.dll
|
|
|
|
%MSYS2%\mingw32\bin\libintl-8.dll
|
2016-12-04 16:50:13 +03:00
|
|
|
%MSYS2%\mingw32\bin\libpcre-1.dll
|
2016-04-30 04:49:00 +03:00
|
|
|
%MSYS2%\mingw32\bin\libwinpthread-1.dll
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
To run sample_x86.exe on Windows 64-bit, you need the following files:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
unicorn.dll
|
2016-12-04 16:50:13 +03:00
|
|
|
%MSYS2%\mingw64\bin\libgcc_s_seh-1.dll
|
2016-04-30 04:49:00 +03:00
|
|
|
%MSYS2%\mingw64\bin\libiconv-2.dll
|
|
|
|
%MSYS2%\mingw64\bin\libintl-8.dll
|
2016-12-04 16:50:13 +03:00
|
|
|
%MSYS2%\mingw64\bin\libpcre-1.dll
|
2016-04-30 04:49:00 +03:00
|
|
|
%MSYS2%\mingw64\bin\libwinpthread-1.dll
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[3] Compile and install from source on Cygwin
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
To build Unicorn on Cygwin, run:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
$ ./make.sh
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
After compiling, install Unicorn with:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
$ ./make.sh install
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
Resulted files cygunicorn.dll, libunicorn.dll.a and libunicorn.a can be
|
|
|
|
used on Cygwin but not native Windows.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
NOTE: The core framework installed by "./make.sh install" consist of
|
|
|
|
following files:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
/usr/include/unicorn/*.h
|
|
|
|
/usr/bin/cygunicorn.dll
|
|
|
|
/usr/lib/libunicorn.dll.a
|
|
|
|
/usr/lib/libunicorn.a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[4] Cross-compile for Windows from *nix
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
To cross-compile for Windows, Linux & gcc-mingw-w64-i686 (and also gcc-mingw-w64-x86-64
|
|
|
|
for 64-bit binaries) are required.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
- To cross-compile Windows 32-bit binary, simply run:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
$ ./make.sh cross-win32
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
- To cross-compile Windows 64-bit binary, run:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
$ ./make.sh cross-win64
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
Resulted files unicorn.dll, unicorn.lib & samples/sample*.exe can then
|
|
|
|
be used on Windows machine.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
To run sample_x86.exe on Windows 32-bit, you need the following files:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
unicorn.dll
|
|
|
|
/usr/lib/gcc/i686-w64-mingw32/4.8/libgcc_s_sjlj-1.dll
|
|
|
|
/usr/i686-w64-mingw32/lib/libwinpthread-1.dll
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
To run sample_x86.exe on Windows 64-bit, you need the following files:
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
unicorn.dll
|
|
|
|
/usr/lib/gcc/x86_64-w64-mingw32/4.8/libgcc_s_sjlj-1.dll
|
|
|
|
/usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
Then run either "sample_x86.exe -32" or "sample_x86.exe -64" to test emulators for X86 32-bit or X86 64-bit.
|
|
|
|
For other architectures, run "sample_xxx.exe" found in the same directory.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[5] Language bindings
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
Look for the bindings under directory bindings/, and refer to README file
|
|
|
|
of corresponding languages.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[6] Unit tests
|
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
Automated unit tests use the cmocka unit testing framework (https://cmocka.org/).
|
|
|
|
It can be installed in most Linux distros using the package manager, e.g.
|
|
|
|
`sudo yum install libcmocka libcmocka-devel`, or you can easily build and install it from source.
|
2016-04-30 04:49:00 +03:00
|
|
|
|
2016-04-30 08:03:39 +03:00
|
|
|
You can run the tests by running `make test` in the project directory.
|