112 Commits

Author SHA1 Message Date
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
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
Nguyen Anh Quynh
14283f1556 ppc: print 0 offset for memory operand. see issue #856 2017-02-19 21:27:17 +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
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
Nguyen Anh Quynh
3a46e85ad2 ppc: return failure when Base>=32 in decodeMemRIOperands() 2015-06-16 14:03:22 +08:00
Nguyen Anh Quynh
7ae9c9d9d3 ppc: handle invalid CR bits with more than 8 zeros in decodeCRBitMOperand(). bug reported by @felixgr 2015-06-16 13:59:10 +08:00
Nguyen Anh Quynh
fb18a93f73 ppc: avoid potential memleak issue when alias mnemonic is empty in PPC_printInst() 2015-06-06 19:11:25 +08:00
Nguyen Anh Quynh
5cb356061e ppc: make sure alias mnememonic is not empty in PPC_printInst() 2015-06-06 16:10:07 +08:00
Cr4sh
9d60607645 inttypes.h fix 2015-03-29 18:29:06 +08:00
Nguyen Anh Quynh
674db4c96f ppc: fix some compilation bugs when DIET mode is enable 2014-12-16 22:12:23 +08:00
Peter Mackay
4e732c7db4 Populate PowerPC slwi/srwi instruction details with SH operand. 2014-11-23 00:15:19 +00:00
Nguyen Anh Quynh
c00bc2efb6 fix the left-over C89 issues introduced by Pedro 2014-11-21 19:29:47 +08:00
reverser
68197d9a5e Make it C89 compatible. 2014-11-20 13:45:43 +00:00
reverser
202da41980 Fix compiler warnings about different sizes and sign. 2014-11-20 12:13:19 +00:00
Nguyen Anh Quynh
e07bc91349 ppc: fix a stupid mistake on printing operands of MR instruction 2014-11-11 13:12:22 +08:00
Nguyen Anh Quynh
d82b28a75f ppc: do not print a dot in front of absolute address. issue reported by @pancake 2014-11-11 11:05:20 +08:00
Nguyen Anh Quynh
c2ea812ea7 fix cs_group_name() after the change on generic group ids 2014-10-31 15:36:19 +08:00
kratolp
5c0d9a4ade Add '4*cri+cond' to operand list 2014-10-17 14:52:03 +02:00
kratolp
f2b699a716 Don't add cr0 to the operand list as it's not displayed by the disassembly 2014-10-02 20:53:55 +02:00
Nguyen Anh Quynh
e96935ed68 ppc: remove duplicate op_addReg() in printAliasInstrEx() 2014-10-02 17:09:22 +08:00
Nguyen Anh Quynh
48eb13c33c ppc: add detail for alias instructions introduced in the latest change by @kratolp 2014-10-01 21:18:55 +08:00
Nguyen Anh Quynh
6b731a097f fix conflicts when merging 2014-10-01 21:05:51 +08:00
Nguyen Anh Quynh
630bcd6d4e ppc: c99 2014-10-01 21:02:30 +08:00
Nguyen Anh Quynh
70fa90fbfe ppc: coding style 2014-10-01 18:21:02 +08:00
kratolp
73835104a4 Merge branch 'next' of https://github.com/aquynh/capstone into next
Conflicts:
	arch/PowerPC/PPCInstPrinter.c
2014-10-01 11:54:14 +02:00
kratolp
a3f0aef79a PPC: Fix absolute/relative offset for branch instruction
PPC: Fix non handling of bc instruction that uses the CTR
2014-10-01 11:39:15 +02:00
Nguyen Anh Quynh
e135056f17 fix a negative array index read in PPC_alias_insn(). issue reported by Coverity 2014-10-01 14:23:35 +08:00
Nguyen Anh Quynh
7e644f0fea ppc: initialize needComma to false. issue reported by Coverity 2014-10-01 14:13:48 +08:00
Nguyen Anh Quynh
6756eddee5 ppc: alias instructions handled by printAliasInstrEx() miss CR* registers in detail mode. fixed 2014-09-29 23:32:14 +08:00
Nguyen Anh Quynh
ca44c4897d ppc: coding style for PPCInstPrinter.c 2014-09-29 17:58:20 +08:00
Nguyen Anh Quynh
27767e8c08 merge PR of @kratolp 2014-09-29 17:54:05 +08:00
Nguyen Anh Quynh
d7e42b7d36 rename all the constants marking ending from _MAX to _ENDING. this also updates Java/Python/Ocaml bindings accordingly 2014-09-29 17:15:25 +08:00
kratolp
f0221a2aeb * Fix pcc branch offset in a better way
* Update PPC branch alias function to print cri register
* Fix immediate branch offset sign extension for bd type branch instruction
2014-09-29 10:59:12 +02:00
Yegor Derevenets
ced9d24e35 Workaround missing <inttypes.h> on MSVC 2010 2014-09-21 17:27:11 +02:00
Nguyen Anh Quynh
7e57e79800 ppc: handle branch condition for alias instructions. this also updates Python & Java bindings 2014-09-21 13:04:50 +08:00
Nguyen Anh Quynh
9d6383973f ppc: move our own alias instructions to PPCInstPrinter.c to isolate them from auto-gen code of LLVM 2014-09-20 12:02:19 +08:00
Nguyen Anh Quynh
d37b0df762 merge PR of @kratolp 2014-09-20 11:27:07 +08:00
kratolp
05d4b83391 Extend sign of the branch destination operand 2014-09-16 17:15:50 +02:00
kratolp
87736c1e5e Update alias of PPC branch instructions 2014-09-16 17:13:39 +02:00
Nguyen Anh Quynh
eaecfa4925 ppc: add PPC_INS_BNE for alias instruction BNE 2014-09-16 23:13:14 +08:00
Nguyen Anh Quynh
f46ef2e0fe ppc: alias instruction for 'gBC 4, 2, target' to 'bne target'. issue reported by @kratolp 2014-09-15 12:12:10 +08:00
Nguyen Anh Quynh
721d07f6b2 ppc: support alias instructions. update Python & Java bindings accordingly 2014-09-04 12:03:31 +08:00
Nguyen Anh Quynh
0c07cc9b06 zero-out instruction details, mnemonic & op_str so cs_insn doesnt have garbage in Diet mode 2014-08-27 22:31:54 +08:00
Nguyen Anh Quynh
4c95022c74 fix warnings on unused variables when compiling in Diet mode 2014-08-27 18:33:38 +08:00
Nguyen Anh Quynh
f41dc3222a Merge branch 'v3' of https://github.com/aquynh/capstone into v3 2014-08-26 16:42:55 +08:00