Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Keystone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Third Party Mirrors
Keystone
Commits
3cdfd7a2
Commit
3cdfd7a2
authored
8 years ago
by
Nguyen Anh Quynh
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://github.com/keystone-engine/beta
parents
25ff3f3c
f22e16cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/python/sample.py
+23
-23
23 additions, 23 deletions
bindings/python/sample.py
docs/COMPILE-NIX.md
+15
-9
15 additions, 9 deletions
docs/COMPILE-NIX.md
with
38 additions
and
32 deletions
bindings/python/sample.py
+
23
−
23
View file @
3cdfd7a2
...
...
@@ -14,46 +14,46 @@ def test_ks(arch, mode, code, syntax=0):
encoding
,
count
=
ks
.
asm
(
code
)
print
(
"
%s = [
"
%
code
,
end
=
''
)
print
(
"
%s = [
"
%
code
,
end
=
''
)
for
i
in
encoding
:
print
(
"
%02x
"
%
i
,
end
=
''
)
print
(
"
%02x
"
%
i
,
end
=
''
)
print
(
"
]
"
)
if
__name__
==
'
__main__
'
:
# X86
test_ks
(
KS_ARCH_X86
,
KS_MODE_16
,
"
add eax, ecx
"
)
test_ks
(
KS_ARCH_X86
,
KS_MODE_32
,
"
add eax, ecx
"
)
test_ks
(
KS_ARCH_X86
,
KS_MODE_64
,
"
add rax, rcx
"
)
test_ks
(
KS_ARCH_X86
,
KS_MODE_32
,
"
add %ecx, %eax
"
,
KS_OPT_SYNTAX_ATT
)
test_ks
(
KS_ARCH_X86
,
KS_MODE_64
,
"
add %rcx, %rax
"
,
KS_OPT_SYNTAX_ATT
)
test_ks
(
KS_ARCH_X86
,
KS_MODE_16
,
b
"
add eax, ecx
"
)
test_ks
(
KS_ARCH_X86
,
KS_MODE_32
,
b
"
add eax, ecx
"
)
test_ks
(
KS_ARCH_X86
,
KS_MODE_64
,
b
"
add rax, rcx
"
)
test_ks
(
KS_ARCH_X86
,
KS_MODE_32
,
b
"
add %ecx, %eax
"
,
KS_OPT_SYNTAX_ATT
)
test_ks
(
KS_ARCH_X86
,
KS_MODE_64
,
b
"
add %rcx, %rax
"
,
KS_OPT_SYNTAX_ATT
)
# ARM
test_ks
(
KS_ARCH_ARM
,
KS_MODE_ARM
,
"
sub r1, r2, r5
"
)
test_ks
(
KS_ARCH_ARM
,
KS_MODE_ARM
+
KS_MODE_BIG_ENDIAN
,
"
sub r1, r2, r5
"
)
test_ks
(
KS_ARCH_ARM
,
KS_MODE_THUMB
,
"
movs r4, #0xf0
"
)
test_ks
(
KS_ARCH_ARM
,
KS_MODE_THUMB
+
KS_MODE_BIG_ENDIAN
,
"
movs r4, #0xf0
"
)
test_ks
(
KS_ARCH_ARM
,
KS_MODE_ARM
,
b
"
sub r1, r2, r5
"
)
test_ks
(
KS_ARCH_ARM
,
KS_MODE_ARM
+
KS_MODE_BIG_ENDIAN
,
b
"
sub r1, r2, r5
"
)
test_ks
(
KS_ARCH_ARM
,
KS_MODE_THUMB
,
b
"
movs r4, #0xf0
"
)
test_ks
(
KS_ARCH_ARM
,
KS_MODE_THUMB
+
KS_MODE_BIG_ENDIAN
,
b
"
movs r4, #0xf0
"
)
# ARM64
test_ks
(
KS_ARCH_ARM64
,
KS_MODE_BIG_ENDIAN
,
"
ldr w1, [sp, #0x8]
"
)
test_ks
(
KS_ARCH_ARM64
,
KS_MODE_BIG_ENDIAN
,
b
"
ldr w1, [sp, #0x8]
"
)
# Hexagon
test_ks
(
KS_ARCH_HEXAGON
,
KS_MODE_BIG_ENDIAN
,
"
v23.w=vavg(v11.w,v2.w):rnd
"
)
test_ks
(
KS_ARCH_HEXAGON
,
KS_MODE_BIG_ENDIAN
,
b
"
v23.w=vavg(v11.w,v2.w):rnd
"
)
# Mips
test_ks
(
KS_ARCH_MIPS
,
KS_MODE_MIPS32
,
"
and $9, $6, $7
"
)
test_ks
(
KS_ARCH_MIPS
,
KS_MODE_MIPS32
+
KS_MODE_BIG_ENDIAN
,
"
and $9, $6, $7
"
)
test_ks
(
KS_ARCH_MIPS
,
KS_MODE_MIPS64
,
"
and $9, $6, $7
"
)
test_ks
(
KS_ARCH_MIPS
,
KS_MODE_MIPS64
+
KS_MODE_BIG_ENDIAN
,
"
and $9, $6, $7
"
)
test_ks
(
KS_ARCH_MIPS
,
KS_MODE_MIPS32
,
b
"
and $9, $6, $7
"
)
test_ks
(
KS_ARCH_MIPS
,
KS_MODE_MIPS32
+
KS_MODE_BIG_ENDIAN
,
b
"
and $9, $6, $7
"
)
test_ks
(
KS_ARCH_MIPS
,
KS_MODE_MIPS64
,
b
"
and $9, $6, $7
"
)
test_ks
(
KS_ARCH_MIPS
,
KS_MODE_MIPS64
+
KS_MODE_BIG_ENDIAN
,
b
"
and $9, $6, $7
"
)
# PowerPC
test_ks
(
KS_ARCH_PPC
,
KS_MODE_PPC32
+
KS_MODE_BIG_ENDIAN
,
"
add 1, 2, 3
"
)
test_ks
(
KS_ARCH_PPC
,
KS_MODE_PPC64
,
"
add 1, 2, 3
"
)
test_ks
(
KS_ARCH_PPC
,
KS_MODE_PPC64
+
KS_MODE_BIG_ENDIAN
,
"
add 1, 2, 3
"
)
test_ks
(
KS_ARCH_PPC
,
KS_MODE_PPC32
+
KS_MODE_BIG_ENDIAN
,
b
"
add 1, 2, 3
"
)
test_ks
(
KS_ARCH_PPC
,
KS_MODE_PPC64
,
b
"
add 1, 2, 3
"
)
test_ks
(
KS_ARCH_PPC
,
KS_MODE_PPC64
+
KS_MODE_BIG_ENDIAN
,
b
"
add 1, 2, 3
"
)
# Sparc
test_ks
(
KS_ARCH_SPARC
,
KS_MODE_SPARC32
+
KS_MODE_LITTLE_ENDIAN
,
"
add %g1, %g2, %g3
"
)
test_ks
(
KS_ARCH_SPARC
,
KS_MODE_SPARC32
+
KS_MODE_BIG_ENDIAN
,
"
add %g1, %g2, %g3
"
)
test_ks
(
KS_ARCH_SPARC
,
KS_MODE_SPARC32
+
KS_MODE_LITTLE_ENDIAN
,
b
"
add %g1, %g2, %g3
"
)
test_ks
(
KS_ARCH_SPARC
,
KS_MODE_SPARC32
+
KS_MODE_BIG_ENDIAN
,
b
"
add %g1, %g2, %g3
"
)
# SystemZ
test_ks
(
KS_ARCH_SYSTEMZ
,
KS_MODE_BIG_ENDIAN
,
"
a %r0, 4095(%r15,%r1)
"
)
test_ks
(
KS_ARCH_SYSTEMZ
,
KS_MODE_BIG_ENDIAN
,
b
"
a %r0, 4095(%r15,%r1)
"
)
This diff is collapsed.
Click to expand it.
docs/COMPILE-NIX.md
+
15
−
9
View file @
3cdfd7a2
...
...
@@ -4,38 +4,44 @@ For Windows, see [COMPILE-WINDOWS.md](COMPILE-WINDOWS.md)
0.
Dependency
CMake is required
as dependency
.
CMake is required
to build keystone
.
-
On Mac OS X, you can install "cmake" with "brew".
$ brew install cmake
-
On U
t
un
b
u Linux, install "cmake" with
.
-
On U
b
un
t
u Linux, install "cmake" with
:
$ sudo apt-get install cmake
1.
From the root directory of Keystone source, compile dynamic library
with
below
commands.
1.
From the root directory of Keystone source, compile
as a
dynamic library
with
the following
commands.
$ mkdir build
$ cd build
$ ../make-share.sh
You can also compile static libray with
.
You can also compile static
a
libra
r
y with
:
$ mkdir build
$ cd build
$ ../make-lib.sh
2.
Right after building
step
, install Keystone.
2.
Right after building, install Keystone.
$ sudo make install
Besides the libraries & C header files under directory "include/keystone",
this step also installs a tool named "kstool" into the system.
(Find source of "kstool" in directory "kstool/kstool")
Keystone is installed in '/usr/local', depending on your distribution (eg. Ubuntu) you might
need to add '/usr/local/lib' to '/etc/ld.so.conf'. Then update the dynamic linker
with:
$ sudo ldconfig
Besides the libraries & C header files under thedirectory "include/keystone",
this step also installs a tool named "kstool" on the system.
(The source of "kstool" is in the directory "kstool/kstool")
3.
Test Keystone with "kstool" like below.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment