Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed Nov 1, 2022
2 parents 3c53a64 + db9ddab commit 241a391
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "unicorn-engine"
version = "2.0.0"
version = "2.0.1"
authors = ["Ziqiao Kong", "Lukas Seidel"]
documentation = "https://github.com/unicorn-engine/unicorn/wiki"
edition = "2021"
Expand Down
6 changes: 2 additions & 4 deletions bindings/dotnet/UnicornManaged/Const/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ module Common =
let UC_API_MAJOR = 2

let UC_API_MINOR = 0

let UC_API_PATCH = 0
let UC_API_PATCH = 1
let UC_API_EXTRA = 255
let UC_VERSION_MAJOR = 2

let UC_VERSION_MINOR = 0

let UC_VERSION_PATCH = 0
let UC_VERSION_PATCH = 1
let UC_VERSION_EXTRA = 255
let UC_SECOND_SCALE = 1000000
let UC_MILISECOND_SCALE = 1000
Expand Down
6 changes: 2 additions & 4 deletions bindings/go/unicorn/unicorn_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ const (
API_MAJOR = 2

API_MINOR = 0

API_PATCH = 0
API_PATCH = 1
API_EXTRA = 255
VERSION_MAJOR = 2

VERSION_MINOR = 0

VERSION_PATCH = 0
VERSION_PATCH = 1
VERSION_EXTRA = 255
SECOND_SCALE = 1000000
MILISECOND_SCALE = 1000
Expand Down
6 changes: 2 additions & 4 deletions bindings/java/unicorn/UnicornConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ public interface UnicornConst {
public static final int UC_API_MAJOR = 2;

public static final int UC_API_MINOR = 0;

public static final int UC_API_PATCH = 0;
public static final int UC_API_PATCH = 1;
public static final int UC_API_EXTRA = 255;
public static final int UC_VERSION_MAJOR = 2;

public static final int UC_VERSION_MINOR = 0;

public static final int UC_VERSION_PATCH = 0;
public static final int UC_VERSION_PATCH = 1;
public static final int UC_VERSION_EXTRA = 255;
public static final int UC_SECOND_SCALE = 1000000;
public static final int UC_MILISECOND_SCALE = 1000;
Expand Down
6 changes: 2 additions & 4 deletions bindings/pascal/unicorn/UnicornConst.pas
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ interface
const UC_API_MAJOR = 2;

UC_API_MINOR = 0;

UC_API_PATCH = 0;
UC_API_PATCH = 1;
UC_API_EXTRA = 255;
UC_VERSION_MAJOR = 2;

UC_VERSION_MINOR = 0;

UC_VERSION_PATCH = 0;
UC_VERSION_PATCH = 1;
UC_VERSION_EXTRA = 255;
UC_SECOND_SCALE = 1000000;
UC_MILISECOND_SCALE = 1000;
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
UC_DIR = SRC_DIR if os.path.exists(SRC_DIR) else os.path.join(ROOT_DIR, '../..')
BUILD_DIR = os.path.join(UC_DIR, 'build_python')

VERSION = "2.0.0"
VERSION = "2.0.1"

if SYSTEM == 'darwin':
LIBRARY_FILE = "libunicorn.2.dylib"
Expand Down
6 changes: 2 additions & 4 deletions bindings/python/unicorn/unicorn_const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
UC_API_MAJOR = 2

UC_API_MINOR = 0

UC_API_PATCH = 0
UC_API_PATCH = 1
UC_API_EXTRA = 255
UC_VERSION_MAJOR = 2

UC_VERSION_MINOR = 0

UC_VERSION_PATCH = 0
UC_VERSION_PATCH = 1
UC_VERSION_EXTRA = 255
UC_SECOND_SCALE = 1000000
UC_MILISECOND_SCALE = 1000
Expand Down
6 changes: 2 additions & 4 deletions bindings/ruby/unicorn_gem/lib/unicorn_engine/unicorn_const.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ module UnicornEngine
UC_API_MAJOR = 2

UC_API_MINOR = 0

UC_API_PATCH = 0
UC_API_PATCH = 1
UC_API_EXTRA = 255
UC_VERSION_MAJOR = 2

UC_VERSION_MINOR = 0

UC_VERSION_PATCH = 0
UC_VERSION_PATCH = 1
UC_VERSION_EXTRA = 255
UC_SECOND_SCALE = 1000000
UC_MILISECOND_SCALE = 1000
Expand Down
15 changes: 8 additions & 7 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Optimize your program with less instrumentation, e.g. by using `UC_HOOK_BLOCK` i

## Why do I get a wrong PC after emulation stops?

Updating PC is a very large overhead (10x slower in the worst case, see FAQ above) for emulation so the PC sync guarantee is explained below:
Updating PC is a very large overhead (10x slower in the worst case, see FAQ above) for emulation so the PC sync guarantee is explained below in several cases:

- A `UC_HOOK_CODE` is installed. In this case, the PC is sync-ed _everywhere_ within the effective range of the hook. However, on some architectures, the PC might by sync-ed all the time if the hook is installed.
- A `UC_HOOK_MEM_READ` or `UC_HOOK_MEM_WRITE` is installed. In this case, the PC is sync-ed exactly before any read/write events within the effective range of the hook.
- A `UC_HOOK_CODE` hook is installed. In this case, the PC is sync-ed _everywhere_ within the effective range of the hook. However, on some architectures, the PC might by sync-ed all the time if the hook is installed in any range. Note using `count` in `uc_emu_start` implies installing a `UC_HOOK_CODE` hook.
- A `UC_HOOK_MEM_READ` or `UC_HOOK_MEM_WRITE` hook is installed. In this case, the PC is sync-ed exactly before any read/write events within the effective range of the hook.
- Emulation (`uc_emu_start`) terminates without any exception. In this case, the PC will point to the next instruction.
- No hook mentioned above is installed and emulation terminates with exceptions. In this case, the PC is sync-ed at the basic block boundary, in other words, the first instruction of the basic block where the exception happens.

Expand Down Expand Up @@ -44,12 +44,13 @@ Currently, only a small subset of the instructions can be instrumented.

On x86, all available instructions are: `in` `out` `syscall` `sysenter` `cpuid`.

## Emulating some instructions gives an error, what should I do?
## Emulating some instructions gives an error like "Invalid Instruction", what should I do?

1. Some instructions are not enabled by default on some architectures. For example, you have to setup CSR on RISC-V or VFP on ARM before emulating floating-point instructions. Refer to the corresponding manual to check if you leave out possible switches in special registers.
2. If you are on ARM, please check whether you are emulating a THUMB instruction. If so, please use `UC_MODE_THUMB` and make sure the starting address is odd.
3. If either is not the case, it might be some newer instruction sets that qemu5 doesn’t support.
4. Note some instruction sets are not implemented by QEMU.
2. Different CPU models support different sets of instructions. This is especially observed on ARM CPUs. For example, for `THUMB2` big-endian instructions, consider setting CPU model to `cortex-r5` or `arm_max`. See [#1725](https://github.com/unicorn-engine/unicorn/issues/1725) and [#1724](https://github.com/unicorn-engine/unicorn/issues/1724).
3. If you are on ARM, please check whether you are emulating a THUMB instruction. If so, please use `UC_MODE_THUMB` and make sure the starting address is odd.
4. If it's not the cases above, it might be some newer instruction sets that qemu5 doesn’t support.
5. Note some instruction sets are not implemented by the latest QEMU.

If you are still using Unicorn1, please upgrade to Unicorn2 for better support.

Expand Down
2 changes: 1 addition & 1 deletion include/unicorn/unicorn.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ typedef size_t uc_hook;
// Unicorn API version
#define UC_API_MAJOR 2
#define UC_API_MINOR 0
#define UC_API_PATCH 0
#define UC_API_PATCH 1
// Release candidate version, 255 means the official release.
#define UC_API_EXTRA 255

Expand Down

0 comments on commit 241a391

Please sign in to comment.