Commit Graph

216 Commits

Author SHA1 Message Date
Nguyen Anh Quynh
de420ec49a trimming MCRegisterClass 2019-02-21 22:33:15 +08:00
Nguyen Anh Quynh
f38aec3d72 arm64: fix CS_OPT_UNSIGNED option on memory operand offset 2019-02-13 22:12:00 +08:00
Nguyen Anh Quynh
4ee7d45078 arm64: support CS_OPT_UNSIGNED 2019-02-12 23:27:29 +08:00
Marius Melzer
c6612a3059 Fix missing-prototypes warnings (#1348) 2019-01-22 07:39:44 +07:00
Riccardo Schirone
c316ef189d arch/M68k: do not return reg_name if beyond limits (#1219)
* arch/M68k: do not return reg_name if beyond limits

(patch coming from radare2)

* arch: checks index when returning reg names
2018-07-24 16:25:47 +08:00
Francesco Tamagni
f6e0fa42f2 Fix testAndBranch sign extend to 64 bit (#1213) 2018-07-20 14:50:41 +08:00
Nguyen Anh Quynh
76c1c3c4e9 merge next to master 2018-07-20 12:36:50 +08:00
clslgrnc
91601ac1fd Init cs_detail (#1205)
* Update init of cs_detail for AArch64

as @aquynh requested in #1125

* Update init of cs_detail for ARM

as @aquynh requested in #1125

* Update init of cs_detail for EVM

as @aquynh requested in #1125

* Update init of cs_detail for M680X

as @aquynh requested in #1125

* Update init of cs_detail for M68K

as @aquynh requested in #1125

* Update init of cs_detail for Mips

as @aquynh requested in #1125

* Update init of cs_detail for PowerPC

as @aquynh requested in #1125

* Update init of cs_detail for Sparc

as @aquynh requested in #1125

* Update init of cs_detail for SystemZ

as @aquynh requested in #1125

* Update init of cs_detail for TMS320C64x

as @aquynh requested in #1125

* Update init of cs_detail for XCore

as @aquynh requested in #1125

* Comment on init of cs_detail

* wrap long lines
2018-07-12 11:01:34 +07:00
Travis Finkenauer
292116bd0d Declare global arch arrays with contents (next branch) (#1186)
* Declare global arch arrays with contents (#1171)

This eliminates the need for archs_enable() and eliminates the racey
initialization.

This makes the architecture-specific init and option functions
non-static so that they may be called from a different file.

Cherry-picked 853a2870

* Add cs_arch_disallowed_mode_mask global

Cherry-pick 94bce437:
mips: CS_MODE_MIPS32R6 implies CS_MODE_32

Cherry-pick 8998a3a1:
ppc: fix endian check (#1029)
Fixes bug where endianness could not be set for ppc.

Remove `big_endian` field of `cs_struct`.
Added a helper macro `MODE_IS_BIG_ENDIAN()` to check if
`CS_MODE_BIG_ENDIAN` is set.

Refactored `cs_open()` check for valid mode out of arch-specific code
into arch-independent code. Also added a valid mode check to
`cs_option()`.  The checks use a new global array
`cs_arch_disallowed_mode_mask[]`.

* Make global arrays static

Make all_arch uint32_t to guarantee a certain number of bits (with
adequate room for growth).
2018-06-24 21:05:04 +08:00
Nguyen Anh Quynh
7566f79879 cleanup 2018-06-22 01:03:26 +08:00
Travis Finkenauer
ce597d5296 Declare global arch arrays with contents (#1171)
This eliminates the need for archs_enable() and eliminates the racey
initialization.

This makes the architecture-specific init, option, and destroy functions
non-static so that they may be called from a different file.
2018-06-21 14:52:35 +08:00
Catena cyber
aad3aca3e7 Use printint functions from SStream (#1165)
in perticular, not to overflow -INT_MIN
2018-06-06 06:31:53 +08:00
Catena cyber
8f7c495e05 Fix undefined shifts (#1158) 2018-06-03 22:29:58 +08:00
Catena cyber
17076b66d2 Fix undefined negative value shift (#1161)
Use multiply instead
2018-06-03 22:19:07 +08:00
Catena cyber
fbb90bcb35 Fix undefined shifts (#1158)
Use multiply instead
Found by oss-fuzz
2018-06-02 16:52:52 +08:00
Catena cyber
65c0be823c Fix undefined shifts (#1156)
* Fix undefined shifts

Found by oss-fuzz
uint8_t gets promoted to integer
and integers shift cannot overflow on sign bit

* Fix undefined shifts

shifting 31 bits the sign bit
2018-06-02 16:51:40 +08:00
Catena cyber
bf97c62001 Undefined shifts (#1154)
* Fix undefined shifts

uint8 gets promoted to signed integer

in ARM, MIPS, Sparc
in AArch64, PPC and Xcore

* fix undefined shift in powerpc

* Fix undefined shift in Mips

use mulitply instead
2018-06-02 16:49:36 +08:00
Alberto Garcia Illera
3c8e828b14 prefix cs_ to global variables to avoid link problems (#1108)
* prefix cs_ to global variables to avoid link problems

* force Capstone to be build using MT

* fix identation
2018-03-29 22:17:37 +08:00
Alberto Garcia Illera
d0525ca346 prefix cs_ to global variables to avoid link problems (#1102) 2018-03-19 22:23:09 +08:00
Richard Henderson
5423b215bf Constify backend data (#1040)
* Constify string literals

Use -Wwrite-strings to force string literals to be of
type "const char[]", then fix up all warning fallout.

* Constify common infrastructure

Step one in allowing backend data to be readonly.
Minimal changes to backends for now; just set all pointers
in common structs that aren't modified to const.

* Constify AArch64 backend

Section size changes within libcapstone.so are

-.rodata               602587
-.data.rel.ro          228416
-.data                1003746
+.rodata               769051
+.data.rel.ro          241120
+.data                 824578

* Constify ARM backend

Section size changes within libcapstone.so are

-.rodata               769051
-.data.rel.ro          241120
-.data                 824578
+.rodata               959835
+.data.rel.ro          245120
+.data                 629506

* Constify Mips backend

Section size changes within libcapstone.so are

-.rodata               959835
-.data.rel.ro          245120
-.data                 629506
+.rodata              1069851
+.data.rel.ro          256416
+.data                 508194

* Constify PowerPC backend

Section size changes within libcapstone.so are

-.rodata              1069851
-.data.rel.ro          256416
-.data                 508194
+.rodata              1142715
+.data.rel.ro          272224
+.data                 419490

* Constify Sparc backend

Section size changes within libcapstone.so are

-.rodata              1142715
-.data.rel.ro          272224
-.data                 419490
+.rodata              1175227
+.data.rel.ro          277536
+.data                 381666

* Constify SystemZ backend

Section size changes within libcapstone.so are

-.rodata              1175227
-.data.rel.ro          277536
-.data                 381666
+.rodata              1221883
+.data.rel.ro          278016
+.data                 334498

* Constify X86 backend

Section size changes within libcapstone.so are

-.rodata              1221883
-.data.rel.ro          278016
-.data                 334498
+.rodata              1533531
+.data.rel.ro          281184
+.data                  19714

* Constify XCore backend

Section size changes within libcapstone.so are

-.rodata              1533531
-.data.rel.ro          281184
-.data                  19714
+.rodata              1553026
+.data.rel.ro          281280
+.data                     40
2017-10-22 08:45:40 +08:00
Travis Finkenauer
de99147c73 ppc: fix endian check (#1029)
* Remove `big_endian` field of `cs_struct`

Added a helper macro `MODE_IS_BIG_ENDIAN()` to check if
`CS_MODE_BIG_ENDIAN` is set.

Refactored `cs_open()` check for valid mode out of arch-specific code
into arch-independent code. Also added a valid mode check to
`cs_option()`.  The checks use a new global array
`arch_disallowed_mode_mask[]`, which is initialized in the arch-specific
`*_enable()` functions.

Fixes bug where endianness could not be set for ppc.

* Fix Mac OS brew for Travis CI
2017-10-20 23:33:24 +08:00
Matt Suiche
0441af5ce7 Resolve some casting issues with Visual Studio. 2017-09-05 22:20:57 +07:00
Matt Suiche
4e7f49228b - Resolve some casting issues with Visual Studio. (#1007) 2017-09-05 22:15:13 +07:00
Andrew Calvano
166feea41c Bug fix for incorrect operand type in certain load/store instructions on AArch64. (#952) 2017-08-03 23:01:47 +07:00
Andrew Calvano
0c5ee0e4aa Bug fix for incorrect operand type in certain load/store instructions on AArch64. (#952) 2017-08-03 23:00:53 +08:00
Alfredo Beaumont
5fc444c073 Add name to relative branch group in supported architectures. (#982) 2017-08-01 16:49:43 +08:00
Alfredo Beaumont
f82395b959 Relative branch group (#964)
* Add a new group for relative branching instructions

* x86: Add relative branch group to appropiate instructions

* Rename RELATIVE_BRANCH to BRANCH_RELATIVE

* aarch64: Add relative branch group to appropiate instructions

* arm: Add relative branch group to appropiate instructions

* m68k: Add relative branch group to appropiate instructions

* mips: Add relative branch group to appropiate instructions
2017-07-30 19:05:03 +08:00
semihalf-oleksy-michalina
de6666c531 arm64: handling of system registers added in ARMv8.1/2 (#960)
* arm64: handling of system registers added in ARMv8.2

This commit adds handling of system registers added in ARMv8.2.
Those registers are accessed by mrs and msr instructions.
Changes based on https://static.docs.arm.com/ddi0487/b/DDI0487B_a_armv8_arm.pdf, chapters D7.2-5.

List of added registers:
id_mmfr4_el1
id_aa64mmfr2_el1
sctlr_el12
cpacr_el12
ttbr0_el12
ttbr1_el12
ttbr1_el2
tcr_el12
spsr_el12
elr_el12
afsr0_el12
afsr1_el12
esr_el12
far_el12
mair_el12
amair_el12
vbar_el12
cntkctl_el12
cnthv_ctl_el2
cnthv_cval_el2
cnthv_tval_el2
cntp_tval_el02
cntp_cval_el02
cntv_ctl_el02
ntv_cval_el02
cntv_tval_el02
lorid_el1
lorc_el1
lorea_el1
lorn_el1
lorsa_el1
contextidr_el12

sign-of: Michalina Oleksy (https://github.com/layika)

* arm64: handling of system registers added in ARMv8.1/2

v8.1:
PAN (https://static.docs.arm.com/ddi0487/b/DDI0487B_a_armv8_arm.pdf, page 358)
PAN (as pstate field)
contextdir_el2

v8.2:
UAO (https://static.docs.arm.com/ddi0487/b/DDI0487B_a_armv8_arm.pdf, page 403)
UAO (as pstate field)

* arm64: handling of system registers for statistical profiling

Added handling of system registers for statistical profiling extension based on https://static.docs.arm.com/ddi0586/a/DDI0586A_Statistical_Profiling_Extension.pdf

* Update AArch64BaseInfo.h

* arm64: An attempt to fix indentation
2017-07-29 18:27:32 +08:00
szt
20643d4d34 replace if-s in AArch64_AM_decodeAdvSIMDModImmType10 with lookup table (#552)
* replace if-s in AArch64_AM_decodeAdvSIMDModImmType10 with lookup table

Lookup table is much faster than bunch of if-s. If you don't like lookup tables, I have another proposal. See http://goo.gl/RjW1lr and compare generated machine code

* Smaller lookup table and shifting and bit mask used

* Update AArch64AddressingModes.h
2017-04-15 10:36:43 +08:00
szt
468b4b0b54 replace if-s in AArch64_AM_decodeAdvSIMDModImmType10 with lookup table (#552)
* replace if-s in AArch64_AM_decodeAdvSIMDModImmType10 with lookup table

Lookup table is much faster than bunch of if-s. If you don't like lookup tables, I have another proposal. See http://goo.gl/RjW1lr and compare generated machine code

* Smaller lookup table and shifting and bit mask used

* Update AArch64AddressingModes.h
2017-04-15 09:50:06 +08:00
Nguyen Anh Quynh
f91b2c2470 arm64: fix immediate number in detail mode. see #860 2017-02-26 18:17:39 +08:00
Nguyen Anh Quynh
76b94cba23 switch endian mode with cs_option() for Arm/Arm64/Mips/Sparc. fix issue #849 2017-02-01 11:19:00 +08:00
Nguyen Anh Quynh
c4b0030b3b switch endian mode with cs_option() for Arm/Arm64/Mips/Sparc. fix issue #849 2017-02-01 11:17:13 +08:00
Vincent Bénony
ad1d38b582 Fixes truncated immediate value in operand details
The instruction encoded « 00 00 19 B2 » was correctly disassembled « orr x0, x0, #0x8000000080 », but the reported immediate value, in the detail structure, was truncated to 0x80 due to the cast.
2017-01-26 17:10:16 +01:00
Satoshi Tanda
c7b00b3756 suppress MSVC code analysis (PREfast) warnings
Signed-off-by: Satoshi Tanda <tanda.sat@gmail.com>
2016-09-28 07:33:39 -07:00
Satoshi Tanda
d7e38cd903 suppress MSVC code analysis (PREfast) warnings
Signed-off-by: Satoshi Tanda <tanda.sat@gmail.com>
2016-09-27 08:08:58 -07:00
Simorfo
a7fce04074 AArch64 set good extender 2016-09-09 21:03:38 +08:00
Simorfo
90adc35a8e AArch64 set good extender 2016-09-09 13:15:32 +02:00
Nguyen Anh Quynh
e93290962c arm64: add NEGS & NGCS alias instructions. this fixes issue #752 2016-08-23 14:01:17 +08:00
Yuping Li
8637c3b5b6 Fix BL, BLR group information 2016-07-19 22:59:14 -07:00
tandasat
7b2f93068d port #684 to the next branch 2016-05-16 20:32:36 -07:00
tandasat
0368aa7c42 fix #681 2016-05-16 08:32:58 -07:00
tandasat
e36384e224 Merge remote-tracking branch 'upstream/next' into next 2016-05-11 22:52:34 -07:00
tandasat
d4ef430b33 port Windows driver support 2016-05-11 21:48:32 -07:00
tandasat
8d377f3b7b address warnings with capstone_static_winkernel 2016-05-04 05:54:28 -07:00
Nguyen Anh Quynh
3f461adae3 remove myinttypes.h 2016-04-26 09:47:30 +08:00
tandasat
152c1baf9f skip stdint.h for windows driver configuration 2016-04-23 15:58:31 -07:00
Koutheir Attouchi
9f2070748c Added support for building binaries for Windows CE 7 on ARMv7 (a.k.a., Windows Embedded Compact 7) and for Windows CE 8 on ARMv7 (a.k.a., Windows Embedded Compact 2013).
Added support for building binaries for Windows CE 7 on ARMv7 (a.k.a., Windows Embedded Compact 7) and for Windows CE 8 on ARMv7 (a.k.a., Windows Embedded Compact 2013).

Added support for building binaries for Windows CE 7 on ARMv7 (a.k.a., Windows Embedded Compact 7) and for Windows CE 8 on ARMv7 (a.k.a., Windows Embedded Compact 2013).

Replaced header inclusions of "stdint.h" and "intrin.h" by selective inclusions to support platforms that do not provide those headers. The header "platform.h" handles the platform test.
Updated the build script for Windows CE 7 on ARMv7.
2016-04-07 17:05:00 +02:00
tandasat
cb2b4e6263 Replaced snprintf with cs_snprintf 2016-03-31 18:07:53 -07:00
Nguyen Anh Quynh
1a4253b88f arm64: another attempt to fix MSVC warning 2016-03-08 01:07:36 +08:00