Commit Graph

4412 Commits

Author SHA1 Message Date
Wu ChenXu
79d897ee87 Merge pull request #1655 from cyanpencil/aarch64_cmp_reg_access_fix2
Fix cmp register access on aarch64
2021-11-13 20:41:30 +08:00
Wu ChenXu
01c819e434 Merge pull request #1773 from huettenhain/next
support disassembling bytes from memoryview
2021-11-13 20:16:12 +08:00
jesko
8bd5dc1a37 adds test and bugfix for memoryview support 2021-11-13 11:32:18 +01:00
jesko
28dbf409cf invoke from_buffer only for writeable interfaces 2021-11-13 00:16:19 +01:00
Wu ChenXu
9963db3952 Merge pull request #1657 from NicolasDerumigny/next
Correcting X86 Imm Size
2021-11-11 08:16:22 +08:00
Wu ChenXu
ca3f8b4380 Merge pull request #1791 from Smartsmurf/next
fixed library extension to build properly under CYGWIN
2021-11-11 00:26:14 +08:00
Wu ChenXu
609f5ce842 Merge pull request #1754 from jranieri-grammatech/jranieri/moffset_disp
Fix the displacement offset for moffset-encoded operands
2021-11-11 00:09:13 +08:00
SmartSmurf
261c2a62ec switched to next branch 2021-11-10 17:05:26 +01:00
Catena cyber
7e5baa2972 Adds oss-fuzz badge (#1541) 2021-11-10 00:23:13 +08:00
jesko
3f75a02950 support disassembling bytes from memoryview 2021-07-05 22:40:07 +02:00
Joe Ranieri
4e151e66d4 Fix the displacement offset for moffset-encoded operands
This was initially introduced in dce7da9 but lost in the LLVM 7 sync
in 5a99624.
2021-05-19 17:08:46 -04:00
pancake
af57fb3a01 Use braces instead of indentation. C is not Python (#1745)
Co-authored-by: pancake <pancake@nopcode.org>
2021-05-11 23:31:28 +08:00
StalkR
7826376884 ppc: fix registers overflow (#1688)
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22236

Same as https://github.com/aquynh/capstone/pull/1687 for next branch
2021-03-20 07:34:34 +08:00
Jesús A. Álvarez
26ad2edd1a use ".byte" when skipdata is set up with NULL mnemonic (#1703) 2021-03-20 07:34:03 +08:00
Mark Jansen
2b72d7c2bc Always return the same type from regs_read (#1736) 2021-03-20 07:32:23 +08:00
Jesús A. Álvarez
06662e0d52 mos65xx: use address on mem operands for relative addressing (#1702)
* mos65xx: use imm field for immediate operand value

using the wrong field works on little-endian hosts, but on big-endian the wrong value would be read

* mos65xx: set operand mem field to address also in relative modes

previously the last operand would have an offset, which doesn't match the printed operand

* mos65xx: add bpl instruction to test

this demonstrates an address operand with relative addressing
2021-03-10 08:21:31 +08:00
Antonio Flores Montoya
2e06b6db75 x86 Fix AVX-512 k registers (#1689)
* fix bug in displacement offset

* fix k0-k7 registers in X86 table.
2021-03-07 21:57:14 +08:00
keenk
548dabc989 Fix registry access for several versions of pop such as POPDS, POPSS, etc. (#1725)
* Fix a few registry access mode mappings

* Fix rollback of operand access changes

Re-fix operand access of three mov instructions

* Remove binding breaking #if 0

The python script for generating constants in the bindings does not know how to handle the #if 0 statements included in these files.

* Add files via upload

Update registry access mode for several versions of pop such as POPDS, POPSS, etc
2021-03-07 21:51:22 +08:00
keenk
29ad509528 Fix registry access on cmov instructions (#1727)
* Fix a few registry access mode mappings

* Fix rollback of operand access changes

Re-fix operand access of three mov instructions

* Remove binding breaking #if 0

The python script for generating constants in the bindings does not know how to handle the #if 0 statements included in these files.

* Updated registry access on cmov instructions

Registry access for the destination operand of the conditional move (cmov) opcodes were incorrectly listed as READ | WRITE. Although you would expect the two operands to be compared in this opcode, it instead relies on the associated flag in EFLAGS regardless of the value in the destination operand.
2021-03-07 21:50:39 +08:00
Richard Henderson
9a29b6afa7 RISC-V CSR output (#1690)
* riscv: Fix printAliasInstr

We do not want to append the entire string, only the
single non-argument character.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

* riscv: Implement printCSRSystemRegister

While upstream LLVM probably has a tablegen thing for these
somewhere, the current import doesn't include them.  Take the
list from riscv-privileged-v1.10.pdf.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-03-07 21:28:43 +08:00
Nguyen Anh Quynh
b059ba4ed0 code style fix 2020-12-03 16:13:00 +08:00
Michal Schulz
8751115a2e Honour direction bit in fmove instruction (#1709)
Co-authored-by: Michal Schulz <michal@Michals-iMac-Pro.local>
2020-12-03 16:12:56 +08:00
Nguyen Anh Quynh
eebb69152d fix cstest compile issue 2020-11-27 17:30:12 +08:00
Nguyen Anh Quynh
9ae491097c add Swift binding to README 2020-11-25 16:19:40 +08:00
Nguyen Anh Quynh
ba932de97a bindings: update Arm64 register enum 2020-11-25 16:18:50 +08:00
Jesús A. Álvarez
4dd716c37e Swift binding (#1707)
* update const generator for swift

* groups constants by enum
* use pascal case for enum names
* use camel case for enum values
* values are always literals
* add extra options for some enums
* use different types for some enums
* generate option sets instead of enums for some types
* renaming constants according to regex pattern

* don't output documentation comments for non-exported defines

* add Swift binding to readme
2020-11-25 14:41:10 +08:00
Anton Kochkov
6a8406aff6 M680X - remove unused s_cpu_type (#1695) 2020-10-29 12:29:49 +08:00
Keegan Saunders
dcd4869033 Option to generate install target (#1700)
Co-authored-by: meme <meme@users.noreply.github.com>
2020-10-28 23:34:48 +08:00
Tobias Faller
20e3ebd372 Added export for Python CS_MODE_RISCVC binding (#1691) 2020-09-18 22:34:35 +08:00
StalkR
c88a7b37ef MCInst: fix uninitialized value in operand value (#1685)
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14912

Same as https://github.com/aquynh/capstone/pull/1684 for next branch
2020-09-16 17:06:27 +08:00
Richard Henderson
e34cd5475b Two RISC-V fixes (#1682)
* RISCV: Check CS_MODE_RISCVC in getFeatureBits

Enable compressed instruction extension with RISCVC.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

* RISCV: Fix skipdata_size for CS_MODE_RISCVC

RISC-V compressed instructions are 2 bytes, not 1.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2020-09-16 17:04:18 +08:00
Carlo Marcelo Arenas Belón
74282e18a2 systemz: pad instruction width up to 6 bytes (#1679)
instructions could be 2, 4 or 6 bytes so pad accordingly as it
was done on the other CISC architecture.
2020-09-16 17:03:34 +08:00
Carlo Marcelo Arenas Belón
a39b6175e3 include: avoid UB with signed overflow/shift (#1675)
if integer is 32-bit, and numeric literals default to int type,
the following applies (from The C Standard, 6.5.7, paragraph 4
[ISO/IEC 9899:2011]):

If E1 has a signed type and nonnegative value, and E1 × 2^E2 is
representable in the result type, then that is the resulting value;
otherwise, the behavior is undefined.

which means that the only way to safely shift is unsigned, so
use 1U to indicate the shifted bit is unsigned.
2020-09-16 17:03:28 +08:00
junchao-loongson
da7ba93a13 fix CS_ mips_ OP structure comment error (#1674) 2020-08-06 09:37:19 +08:00
Sergei Trofimovich
6e89663fd6 capstone.pc.in: use CMAKE_INSTALL_LIBDIR for libdir (#1659)
On x86_64-linux gentoo system capstone was installing
it's files to 'lib64' libdir, but was referring 'lib' libdir:

```
$ cat /usr/lib64/pkgconfig/capstone.pc
...
libdir=${prefix}/lib
...
```

On radare2 built it means injecting -L/usr/lib into a 64-build
and pulling in 32-bit libraries. 'ld.lld' is not able to resolve
the ambiguity.

It happens because @LIBSUFFIX@ is not present in cmake-3.17.3.

Let's fix the paths by using @CMAKE_INSTALL_LIBDIR@.
This variable is already used in capstone's build system,
thus should be safe to rely on.

Reported-by: Agostino Sarubbo
Bug: https://bugs.gentoo.org/730722
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2020-07-19 17:08:47 +08:00
Maxim Poliakovski
46e4a405da M68K: fix MOVEC operand transfer direction. (#1663) 2020-07-19 17:06:08 +08:00
Nicolas Derumigny
e46d8c49c7 Correcting X86 Imm Size 2020-07-02 16:39:15 +02:00
cyanpencil
b99a991a9b Fix cmp register access on aarch64 2020-07-01 16:04:06 +02:00
Mahesh Madhav
0473959db9 Change include path to fix error with embedded cmake builds (#1649)
Co-authored-by: Mahesh Madhav <mahesh@amperecomputing.com>
2020-06-25 09:22:47 +08:00
Daniel Collin
83d817339e Fixed incorrect read of 32-bit imm for bsr (#1644) 2020-06-12 23:00:47 +08:00
Matthias C. M. Troffaes
3814ea95ee Add cmake config and export targets. (#1637)
These additions simplify using capstone in cmake projects:

find_package(capstone CONFIG REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE capstone::capstone-static)
2020-06-02 20:58:33 +08:00
Nikita
db20180560 Allow to override PYTHON[23] in Makefiles (#1639)
$(PYTHON2) and/or $(PYTHON3) might differ from python and/or python3,
accordingly. Allow to override these variables by user choice.
2020-05-30 10:51:54 +08:00
Antonio Flores Montoya
78a897ee12 fix bug in displacement offset (#1600) 2020-05-11 02:20:13 +08:00
Eric Kilmer
c0d5f4e280 Add more cases for LD1 instruction immediate fixups (#1632) 2020-05-10 10:03:52 +08:00
el poto rico
b818c6bdd0 ARM64: Populate implicitly used/modified registers and map ARM64_GRP_CALL to BL* (#1610)
This commit adds some registers to the list of implicit used registers and
implicit modified registers for several AArch64 instructions.

This commit also maps the `ARM64_GRP_CALL` group to the BL* instruction family.
It should fix issue #1606.
2020-05-10 01:46:55 +08:00
Nguyen Anh Quynh
73bbf84432 arm64: some POST instructions miss IMM operand. this fixes issue #1627 2020-05-10 01:39:57 +08:00
Nguyen Anh Quynh
b471e50c74 x86: fix testcase of MOVSD 2020-05-07 21:51:54 +08:00
Disconnect3d
95f25c5325 Add __repr__ for capstone.CsInsn (#1625)
* Add __repr__ for capstone.CsInsn

Currently, a `print(instruction)` displays a not very useful string like `<capstone.CsInsn object at 0x7f3759d88128>`.

This PR enhances adds a `__repr__` magic method to the `capstone.CsInsn` class so it displays as follows:
```
<cs.CsInsn: address=0x5555555545fa, size=1, mnemonic=push, op_str=rbp>
```

* Update __init__.py
2020-05-05 01:54:28 +08:00
Summus
7ba43baec0 Fix Makefile CAPSTONE_BUILD_CORE_ONLY (#1617)
Co-authored-by: Romain Lesteven <romain.lesteven@armaturetech.com>
2020-05-05 01:12:21 +08:00
elp0t0r1c0
0e759ed68e Add ARM64_GRP_PAC group for Pointer Authentication (#1607)
* Add ARM64_GRP_PAC group for Pointer Authentication

* Lowercase the group's name
2020-03-30 08:37:11 +08:00