Commit Graph

186 Commits

Author SHA1 Message Date
Nguyen Anh Quynh
623eaaba27 trimming MCRegisterClass 2019-02-21 22:33:15 +08:00
Marius Melzer
850ebc2a32 Fix missing-prototypes warnings (#1348) 2019-01-22 08:43:02 +08:00
Riccardo Schirone
6cfbd06b61 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
Nguyen Anh Quynh
afffa5d741 merge next to master 2018-07-20 12:36:50 +08:00
Nguyen Anh Quynh
bbe9ce9b7c mips: compilable for MSVC 2013 2018-07-18 23:47:07 +08:00
Nguyen Anh Quynh
7123dbc486 mips: compilable for MSVC 2013 2018-07-18 23:46:36 +08:00
clslgrnc
9b9844d276 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
65da43d0b1 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
0b874b2fca cleanup 2018-06-22 01:03:26 +08:00
Travis Finkenauer
853a2870ce 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
2b054af693 Use printint functions from SStream (#1165)
in perticular, not to overflow -INT_MIN
2018-06-06 06:31:53 +08:00
Catena cyber
86d124a2d3 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
fb798d3f9b 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
Catena cyber
08b1cfa235 Do not shift signed values in Mips disassembling (#1148)
* Do not shift signed values in Mips disassembling

* Do not shift signed values in Mips disassembling

Multiply instead
2018-06-01 20:51:46 +08:00
Alberto Garcia Illera
5c3021250d 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
5f173b0562 prefix cs_ to global variables to avoid link problems (#1102) 2018-03-19 22:23:09 +08:00
Jean-David Gadina
171731a583 Added an explicit cast to silence a compiler warning casting a parameter to an enum type (). (#1052) 2017-11-21 10:19:29 +03:00
Richard Henderson
22ead3e0bf 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
8998a3a1d5 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
Nguyen Anh Quynh
f5ee69e42b Mips64: fix the last cherry-pick on selecting getInstruction() 2017-10-09 09:26:41 +08:00
Travis Finkenauer
c1dbc8a42e Mips: Fix selection of disasm handler (#1022) 2017-10-09 08:52:53 +08:00
Travis Finkenauer
94bce437e8 Fix selection of mips disasm handler (#1022)
* Fix selection of mips disasm handler

handle->disasm was incorrectly set to Mips64_getInstruction if CS_MODE_MIPS32R6
was set but CS_MODE_32 was not set. Now, CS_MODE_32 is set automatically if
CS_MODE_MIPS32R6 is set.

* Align with current style
2017-10-09 08:44:01 +08:00
Alfredo Beaumont
9f6b28cc0b Add name to relative branch group in supported architectures. (#982) 2017-08-01 16:49:43 +08:00
Alfredo Beaumont
a09a81813c 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
Francesco Tamagni
1fb2b53620 Add CS_MODE_MIPS2 to opt-in for COP3 instructions (#939)
* Add CS_MODE_MIPS2 to opt-in for COP3 instructions

* Fix indentation

* Get rid of `+`
2017-06-27 20:56:54 +08:00
Nguyen Anh Quynh
bd2077c2d6 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
0f456b3379 switch endian mode with cs_option() for Arm/Arm64/Mips/Sparc. fix issue #849 2017-02-01 11:17:13 +08:00
Nguyen Anh Quynh
84c14d177b fix merging conflict 2016-05-22 08:58:33 +08:00
Zach Riggle
91d4273021 Add missing MIPS groups 2016-05-12 10:11:00 -07:00
tandasat
45e5eab646 port Windows driver support 2016-05-11 21:48:32 -07:00
Zach Riggle
4c6d791ac8 Annotate MIPS insructions JALR and SYSCALL
Add the appropriate MIPS_GRP_XXX groups to those instructions.
2016-05-03 07:37:09 -07:00
Zach Riggle
5cb3fe320e Add MIPS_GRP_XXX aliases for generic types. 2016-05-03 07:30:31 -07:00
Nguyen Anh Quynh
b158b93a7d remove myinttypes.h 2016-04-26 09:47:30 +08:00
Nguyen Anh Quynh
901f407c0c mips: remove alias_insns[] 2015-06-22 15:48:45 +08:00
Nguyen Anh Quynh
517a0fe68e mips: remove alias_insns map 2015-06-22 15:30:25 +08:00
Nguyen Anh Quynh
ffb878ab53 mips: delete the alias map SUBU to NEGU. bug reported by @joelpx 2015-06-22 11:21:49 +08:00
Nguyen Anh Quynh
2ad9eb2a43 mips: delete the alias map SUBU to NEGU. bug reported by @joelpx 2015-06-22 11:21:14 +08:00
Nguyen Anh Quynh
3dcbc07e04 mips: remove dead code reported by Coverity 2015-06-17 14:05:46 +08:00
Nguyen Anh Quynh
2ec0f814f9 mips: return Fail on assert failure in MipsDisassembler.c 2015-06-16 14:09:25 +08:00
Nguyen Anh Quynh
4a273b7e92 mips: return Fail on assert() that we ignored before 2015-06-16 14:06:34 +08:00
Nguyen Anh Quynh
c009dc6dbf mips: fix OOB issue in DecodeRegListOperand() reported by @felixgr 2015-06-16 12:29:33 +08:00
Nguyen Anh Quynh
1182d25759 simplify ARCH_group_name() by using lookup table as suggested by @learn_more. also added the missing group name for GRP_PRIVILEGE 2015-04-27 12:13:34 +08:00
learn_more
9668b2641f Fix compiling with nmake 2015-04-14 15:36:10 +02:00
Cr4sh
19ee2d10b3 inttypes.h fix 2015-03-29 21:16:38 +08:00
Cr4sh
9d60607645 inttypes.h fix 2015-03-29 18:29:06 +08:00
Nguyen Anh Quynh
efffe787d1 Add new API and start to provide access information for instruction operands
- New API cs_regs_access() that provide registers being read & modified by instruction

- New field cs_x86_op.access provides access info (READ, WRITE) for each operand

- New field cs_x86.eflags provides EFLAGS affected by instruction

- Extend cs_detail.{regs_read, regs_write} from uint8_t to uint16_t type
2015-03-25 15:02:13 +08:00
pancake
21b0bdd0e1 Fix indent issue 2015-03-11 00:40:14 +01:00
Nguyen Anh Quynh
037e01f942 core: remove unused Subregister indices for Sparc, PPC, SystemZ & Mips 2015-03-09 21:36:02 +08:00
Nguyen Anh Quynh
bb5dccedfa core: put insns[] into separate .inc files to make it easier to manage 2015-03-08 10:54:32 +08:00
Nguyen Anh Quynh
3c626fbb98 mips: add register operands when detail = ON in the newly added function printRegisterList() 2015-03-07 13:56:41 +08:00