336 Commits

Author SHA1 Message Date
Nam Cao
43ddc91283 correct register accesses for ARM's sxtb/uxtb and similar instructions 2023-03-07 18:59:06 +01:00
ζeh Matt
1249f05c49 Add post_index to arm 2022-11-22 22:25:08 +02:00
pancake
f477dd4f70 One semicolon is enough in C (#1892)
Co-authored-by: pancake <pancake@nopcode.org>
2022-07-08 07:06:38 +08:00
DarkaMaul
0e90045ddc fix: Remove wrong write in ARM_t2STMDB_UPD instruction (#1588) 2020-02-21 09:56:35 +08:00
Richard Henderson
936dca0e2d Constify backends (#1549)
* Constify registerinfo.py output

Remove two conditionals separating identical bits of code.
Add "const" markup to MCRegisterDesc and MCRegisterClass.

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify instrinfo-arch.py output

In this case, do not actively strip const.

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the AArch64 backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the EVM backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify M680X backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify M68K backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the Mips backend

The Mips backend has not been regenerated from LLVM recently,
and there are more fixups required than I'd like.  Just apply
the fixes to the tables by hand for now.

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the Sparc backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the TMS320C64x backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the X86 backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the XCore backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify systemregister.py output

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the ARM backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the PowerPC backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the MOS65XX backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the SystemZ backend

The mapping of system register to indexes is easy to
generate read-only.  Since we know the indexes are
between 0 and 31, use uint8_t instead of unsigned.

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the WASM backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify cs.c

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the BPF backend

Signed-off-by: Richard Henderson <rth@twiddle.net>
2019-12-23 20:30:57 +08:00
Nguyen Anh Quynh
29c7012025 fix some compilation issues when DIET mode is on 2019-06-24 12:52:38 +08:00
Nguyen Anh Quynh
ea1b4537b8 arm: printAliasInstr() properly handle memory operands (similar to the last commit for ARM64 2019-05-16 21:34:39 +08:00
Nguyen Anh Quynh
788f3e5dc5 arm: fix printPKHASRShiftImm() - issue #1456 2019-04-17 00:48:12 +08:00
Nguyen Anh Quynh
79e30283ef arm: fix printAliasInstr() for wfe.w - issue #1456 2019-04-17 00:34:45 +08:00
Nguyen Anh Quynh
55b149f60a arm: alias LDR [sp], 4 to POP 2019-04-16 00:01:54 +08:00
Nguyen Anh Quynh
88d5c390eb arm: fix the missing third operand of LSR - issue #1456 2019-04-15 07:47:04 +08:00
Nguyen Anh Quynh
af867a3fe1 arm: fix wrong order of operand with shift - issue #1456 2019-04-15 00:04:40 +08:00
Nguyen Anh Quynh
3d50d2cffd arm: fix opcode of ASR/LSL/LSR/ROR/RRX - issue #1456 2019-04-12 00:08:04 +08:00
Nguyen Anh Quynh
e024477065 arm: fix some wrong insn mapping - issue #1456 2019-04-11 23:56:50 +08:00
Nguyen Anh Quynh
d5050f76ac arm: fix cstest 2019-04-11 00:46:12 +08:00
Nguyen Anh Quynh
a5b2d2a70a arm: fix mapping of ARM_SUBri (issue #1456) 2019-04-11 00:18:25 +08:00
Nguyen Anh Quynh
4754471262 merge next-arm64 to next 2019-04-10 17:46:07 +08:00
Nguyen Anh Quynh
f0a5df2504 arm64 & arm: fix some warnings 2019-04-10 17:33:41 +08:00
Nguyen Anh Quynh
f407e94249 arm64: sync with LLVM 7.0.1 2019-04-10 14:17:08 +08:00
Nguyen Anh Quynh
d17d8754ba arm: brkdiv0 is invalid code. TODO: this is just a quick fix, later fix thisn in tablegen 2019-03-19 00:17:35 +08:00
Philippe Antoine
0b23157074 Adds info for ARM brkdiv0 2019-03-18 09:19:49 +01:00
Nguyen Anh Quynh
0113195d49 arm: delete unused ARMRegisterName.inc 2019-03-16 18:05:30 +08:00
Nguyen Anh Quynh
ad3264e9c2 arm: use ARMMappingInsnName.inc for instruction names 2019-03-16 18:03:11 +08:00
Nguyen Anh Quynh
58750a1b71 arm: fix more MSVC warnings 2019-03-16 15:40:38 +08:00
Nguyen Anh Quynh
41f24e31af arm: fix more MSVC warnings 2019-03-16 15:32:14 +08:00
Nguyen Anh Quynh
b540ece988 arm: fix warnings reported by MSVC 2019-03-16 15:29:25 +08:00
Nguyen Anh Quynh
eb4dcfb214 arm: sync with llvm 7.0.1 2019-03-16 15:22:15 +08:00
Nguyen Anh Quynh
0f4300cf11 arm: cleanup ARMGenInstrInfo.inc 2019-03-07 18:13:39 +08:00
Nguyen Anh Quynh
260bc7e44f trimming MCInstrDesc (ARM) 2019-02-21 23:30:38 +08:00
Nguyen Anh Quynh
de420ec49a trimming MCRegisterClass 2019-02-21 22:33:15 +08:00
Nguyen Anh Quynh
e0b9ca7329 Revert "trimming MCRegisterClass usage"
This reverts commit 86743f83cdb40338d840a646b288fad31511ff75.
2019-02-21 21:06:01 +08:00
Nguyen Anh Quynh
9426405822 trimming MCRegisterClass usage 2019-02-21 20:55:25 +08:00
Nguyen Anh Quynh
432e507ce2 arm: lowercase for APSR_nzcv 2019-02-13 00:43:42 +08:00
Nguyen Anh Quynh
be24095038 arm: update writeback for STR_POST_REG (issue #1296) 2019-01-28 16:35:18 +08:00
Nguyen Anh Quynh
dbab8d6494 arm: fix issue #746 for arm mode. reported by @HarDToBelieve 2019-01-27 22:37:43 +08:00
Disconnect3d
6e29dfa2c0 Fix arm thb instruction shift value (#1330)
* Fixes #1317 - arm thb operand.shift.value

For a more detailed description, see issue #1317.

Release 4.0.0 introduced a new field for ARM operands:
`operand.mem.lshift`. This field was supposed to be a bug fix for #246.
The #246 issue has been fixed in the meantime and the proper shift value
was stored in `operand.shift.value`.

The 4.0.0 changes created a regression in which `operand.shift.value`
was not set for a `tbh [r0, r1, lsl #1]` instruction on ARM and the
value was set in a `operand.mem.lshift` field instead.

As the regression broke some of users codebase (e.g. in
[manticore](https://github.com/trailofbits/manticore/pull/1312) project), we fix it by setting
`operand.shift.value` back again.

As a result, the shift value is set in two fields: `operand.shift.value`
and `operand.mem.lshift`. As the `operand.shift` also stores a `.type`
field, we might want to deprecate `operand.mem.lshift` in the future.

* Add changelog stub
2019-01-02 09:51:22 +08:00
Nguyen Anh Quynh
454160598a arm: remove group ARM_REG_PC for thumb BX (#1323, 1126) 2018-12-27 09:40:19 +08: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
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
a33567db49 Fix ARM operand subtracted field (#1163) 2018-06-06 06:17:25 +08:00
Catena cyber
9217582b9f Fixes shift for ARM memory operand (#1162)
Shift is for same operand as index register
2018-06-06 06:09:53 +08:00
Catena cyber
62f1d9fe14 Fix ARM operand subtracted field (#1163) 2018-06-05 22:20:02 +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
Nguyen Anh Quynh
538b7bfbd1 arm: BX & BLX write to PC. see #1126 2018-05-28 20:30:15 +08:00