Commit graph

512 commits

Author SHA1 Message Date
tdube
e1aaa50a5b python: fix merge confliction of #1073 2018-01-15 13:34:13 +08:00
Kalmalyzer
9944bfde76 M68K: Branch targets are a separate addressing mode; PC relative displacements printed as target addresses (#1068)
* Branch targets are a separate addressing mode

Branch targets are relative displacements that identify code locations. These are neither .w nor .l nor immediates. This change removes the immediate #s before branch target addresses in disassembly, and represents the actual branch instructions more accurately in the cs_m68k_op datastructure.

M68K Python bindings have also been updated.

* m68k_inst.pc handles better; print target for PC relative offsets

Previous changes to branch operations relied on m68k_inst.pc pointing to (start of instruction + 2). This was not the case - it pointed to the end of the current instruction. This change makes it so that m68k_inst.pc points to (start of instruction), which is simple to work with.

It also changes printing of PC relative offsets to print the absolute target address, which is consistent with how most 68000 assemblers & disassemblers behave.
2018-01-06 20:13:41 +08:00
Kalmalyzer
775a1d9825 Reorder M68KOp elements to match order on C side (#1067) 2018-01-02 13:35:25 +08:00
Nguyen Anh Quynh
2cf2c1a0fc sparc: change imm type from int32_t to int64_t 2017-12-27 14:46:47 +08:00
Nguyen Anh Quynh
130545f040 bindings: update after #1064 2017-12-21 09:15:24 +08:00
Nguyen Anh Quynh
a105b2d234 cython: add m68x to ext_module_names[] 2017-11-21 15:21:49 +08:00
Anton Bolshakov
96411be363 fix python (cython) bindings 2017-11-21 15:17:24 +08:00
Wolfgang Schwotzer
e8d1f1d4d2 M680X: Target ready for pull request (#1034)
* Added new M680X target. Supports M6800/1/2/3/9, HD6301

* M680X: Reformat for coding guide lines. Set alphabetical order in HACK.TXT

* M680X: Prepare for python binding. Move cs_m680x, m680x_insn to m680x_info. Chec
> k cpu type, no default.

* M680X: Add python bindings. Added python tests.

* M680X: Added cpu types to usage message.

* cstool: Avoid segfault for invalid <arch+mode>.

* Make test_m680x.c/test_m680x.py output comparable (diff params: -bu). Keep xprint.py untouched.

* M680X: Update CMake/make for m680x support. Update .gitignore.

* M680X: Reduce compiler warnings.

* M680X: Reduce compiler warnings.

* M680X: Reduce compiler warnings.

* M680X: Make test_m680x.c/test_m680x.py output comparable (diff params: -bu).

* M680X: Add ocaml bindings and tests.

* M680X: Add java bindings and tests.

* M680X: Added tests for all indexed addressing modes. C/Python/Ocaml

* M680X: Naming, use page1 for PAGE1 instructions (without prefix).

* M680X: Naming, use page1 for PAGE1 instructions (without prefix).

* M680X: Used M680X_FIRST_OP_IN_MNEM in tests C/python/java/ocaml.

* M680X: Added access property to cs_m680x_op.

* M680X: Added operand size.

* M680X: Remove compiler warnings.

* M680X: Added READ/WRITE access property per operator.

* M680X: Make reg_inherent_hdlr independent of CPU type.

* M680X: Add HD6309 support + bug fixes

* M680X: Remove errors and warning.

* M680X: Add Bcc/LBcc to group BRAREL (relative branch).

* M680X: Add group JUMP to BVS/BVC/LBVS/LBVC. Remove BRAREL from BRN/LBRN.

* M680X: Remove LBRN from group BRAREL.

* M680X: Refactored cpu_type initialization for better readability.

* M680X: Add two operands for insn having two reg. in mnemonic. e.g. ABX.

* M680X: Remove typo in cstool.c

* M680X: Some format improvements in changed_regs.

* M680X: Remove insn id string list from tests (C/python/java/ocaml).

* M680X: SEXW, set access of reg. D to WRITE.

* M680X: Sort changed_regs in increasing m680x_insn order.

* M680X: Add M68HC11 support + Reduced from two to one INDEXED operand.

* M680X: cstool, also write '(in mnemonic)' for second reg. operand.

* M680X: Add BRN/LBRN to group JUMP and BRAREL.

* M680X: For Bcc/LBcc/BRSET/BRCLR set reg. CC to read access.

* M680X: Correctly print negative immediate values with option CS_OPT_UNSIGNED.

* M680X: Rename some instruction handlers.

* M680X: Add M68HC05 support.

* M680X: Dont print prefix '<' for direct addr. mode.

* M680X: Add M68HC08 support + resorted tables + bug fixes.

* M680X: Add Freescale HCS08 support.

* M680X: Changed group names, avoid spaces.

* M680X: Refactoring, rename addessing mode handlers.

* M680X: indexed addr. mode, changed pre/post inc-/decrement representation.

* M680X: Rename some M6809/HD6309 specific functions.

* M680X: Add CPU12 (68HC12/HCS12) support.

* M680X: Correctly display illegal instruction as FCB .

* M680X: bugfix: BRA/BRN/BSR/LBRA/LBRN/LBSR does not read CC reg.

* M680X: bugfix: Correctly check for sufficient code size for M6809 indexed addressing.

* M680X: Better support for changing insn id within handler for addessing mode.

* M680X: Remove warnings.

* M680X: In set_changed_regs_read_write_counts use own access_mode.

* M680X: Split cpu specific tables into separate *.inc files.

* M680X: Remove warnings.

* M680X: Removed address_mode. Addressing mode is available in operand.type

* M680X: Bugfix: BSET/BCLR/BRSET/BRCLR correct read/modify CC reg.

* M680X: Remove register TMP1. It is first visible in CPU12X.

* M680X: Performance improvement + bug fixes.

* M680X: Performance improvement, make cpu_tables const static.

* M680X: Simplify operand decoding by using two handlers.

* M680X: Replace M680X_OP_INDEX by M680X_OP_CONSTANT + bugfix in java/python/ocaml bindings.

* M680X: Format with astyle.

* M680X: Update documentation.

* M680X: Corrected author for m680x specific files.

* M680X: Make max. number of architectures single source.
2017-10-21 21:44:36 +08:00
Daniel Collin
3b43ddb92c [M68K] Fixed invalid base reg (#1028)
This is one of those “how did this ever work?” changes. Problem was that as m68k_op was aliased with the imm value so when changing that to something big it would trash the values in the mem struct which would make things go really bad.

Now m68k_op_mem has been moved out of the union so this will not happen again. Also fixed instruction printing bug related to this (just happend to “work” due to the old union layout)
2017-10-13 09:06:01 +08:00
smart-rabbit
f1201f4093 retrieve and print "status register updates" info (#995)
is equal to the code in https://github.com/aquynh/capstone/blob/next/tests/test_x86.c
2017-09-06 20:37:21 +07:00
Nguyen Anh Quynh
ff2f6831db binding: update following addition of GRP_BRANCH_RELATIVE 2017-07-30 19:06:29 +08:00
Francesco Tamagni
b8342f9b90 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
bd66403357 x86: fix FPU flags so const_generator.py can generate proper Python symbols 2017-05-31 21:42:02 +08:00
Nguyen Anh Quynh
f9fabed4d2 bindings: update FPU flags & FPU group for x86 after the last merge 2017-05-31 21:19:50 +08:00
Nguyen Anh Quynh
fcaf7d9a6f x86: add UD0 instruction 2017-05-07 11:17:23 +08:00
Fotis Loukos
5fbe75eb50 Fixed python bindings. 2017-04-14 18:57:40 +03:00
Fotis Loukos
308af00815 TMS320C64x support at tests and const generator. 2017-04-14 17:03:28 +03:00
Fotis Loukos
ae6f2d1411 Added support for the TMS320C64x architecture. 2017-04-14 17:00:40 +03:00
Andrew Dutcher
6e95167865 Add ability to copy prebuilt libraries from prebuilt directory during python build 2017-03-05 06:08:36 +08:00
Nguyen Anh Quynh
617c64fbb5 Python: Automatically conform to PEP440 for version numbers. ported from Unicorn Python binding 2017-02-01 13:23:15 +08:00
BartmanAbyss
6830660783 (M68k) make displacements signed (#836)
* (M68k) make displacements signed

* (M68k) revert group changes

* (m68k) signed displacement in python bindings
2017-01-01 01:11:48 +08:00
Nguyen Anh Quynh
f1aa0a3d04 python: version 4.0.0 2016-11-04 23:55:20 +08:00
Nguyen Anh Quynh
1b5846ee90 Merge branch 'feat/better_python_setup_next' of https://github.com/angr/capstone into angr-feat/better_python_setup_next 2016-11-04 23:25:27 +08:00
Andrew Dutcher
2f1c3ce8a6 On this branch, dylib and so files are versioned 2016-10-31 10:54:58 -07:00
Nguyen Anh Quynh
91808ab6cd python: cleanup 2016-10-30 16:19:10 +08:00
Andrew Dutcher
b2504b963e Python setup: Clean up some merge failures, adapt for changes on next branch 2016-10-26 23:15:42 -07:00
Andrew Dutcher
5acdd97ca2 Python: Actually attempt to load .so.3 extension on linux 2016-10-25 21:49:59 -07:00
Andrew Dutcher
97fac00499 Python: Spelling/capitalization/contact fixes in readme 2016-10-25 21:49:58 -07:00
Andrew Dutcher
73f92384ee Minor english fixes 2016-10-25 21:49:58 -07:00
Andrew Dutcher
06b26efbf4 Python: remove special case for cygwin build 2016-10-25 21:49:58 -07:00
Andrew Dutcher
816f131d27 Python: Make cython work with extreme prejudice 2016-10-25 21:49:58 -07:00
Andrew Dutcher
1008716ee5 Python: Clean up the capstone-windows stuff with extreme prejudice 2016-10-25 21:48:41 -07:00
Andrew Dutcher
3b5b5ff58c Python: make setup work as expected 2016-10-25 21:48:18 -07:00
Nguyen Anh Quynh
c72ab6014f bindings: regenerate consts 2016-10-25 14:30:13 +08:00
Nguyen Anh Quynh
1e5a48535c add CS_VERSION_{MAJOR, MINOR, EXTRA} 2016-10-25 14:29:21 +08:00
Fish
8a5f7af308 Change pointer-deref-then-assignment to memmove to make PyPy happy. 2016-10-13 19:56:41 -07:00
Richo Healey
57cbb8beeb Workaround unicorn handing back bytearrays 2016-10-06 14:40:37 +08:00
Benno Fünfstück
b446327f3b python-bindings: fix setup.py for wheel installation
When the python bindings are installed using the new wheels
infrastructure, data_files are relative to the site-packages directory
even if using absolute paths.

The following example demonstrates the bug fixed by this commit: (ran on archlinux)

```bash
$ pip install wheel       # if this package is installed, wheel installation is made the default
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |################################| 71kB 124kB/s
Installing collected packages: wheel
Successfully installed wheel-0.29.0

$ pip install capstone    # this will use the wheel installation method now
Collecting capstone
  Using cached capstone-3.0.4.tar.gz
Building wheels for collected packages: capstone
  Running setup.py bdist_wheel for capstone ... done
  Stored in directory: /root/.cache/pip/wheels/7c/d1/d0/db6e2c5ef1063aabb9de2dd8b92b4c27ee6f9fd213240099b8
Successfully built capstone
Installing collected packages: capstone
Successfully installed capstone-3.0.4

$ find /usr/lib/ -name "libcapstone.so"
/usr/lib/python3.5/site-packages/usr/lib/python3.5/site-packages/capstone/libcapstone.so
```

So the path `SITE_PACKAGES` in the `data_files` specification of the
setup.py file was interpreted relative to the python site-packages
directory. The fix for this is simple: use `/capstone` instead of an
absolute path for `SITE_PACKAGES`.
2016-10-03 10:50:08 +08:00
Nguyen Anh Quynh
71a42c13c6 python: cast skipdata function inside binding to simplify the API 2016-10-02 01:35:28 +08:00
Nguyen Anh Quynh
0cac0ec5e8 python: fix CS_SKIPDATA_CALLBACK prototype 2016-10-01 01:31:24 +08:00
Nguyen Anh Quynh
399dd9da81 Merge pull request #764 from akihikodaki/next
arm: treat ARM address as unsigned
2016-09-07 09:51:04 +08:00
Akihiko Odaki
e7e4e1dfda arm: treat ARM address as unsigned
It should be unsigned because:
* It does arithmetic operations
* Format strings have "%u" instead of "%d"

# Conflicts:
#	arch/ARM/ARMInstPrinter.c
#	bindings/python/test_arm.py
#	tests/test_arm.c
2016-09-04 00:13:50 +09:00
mrexodia
fb2c843f66 changed fcompi to fcomip and fucompi to fucomip 2016-08-30 23:10:04 +02:00
Nguyen Anh Quynh
e93290962c arm64: add NEGS & NGCS alias instructions. this fixes issue #752 2016-08-23 14:01:17 +08:00
Nguyen Anh Quynh
a4634b45dc Merge pull request #696 from emoon/m68k-reg-read-write
[M68K] Implemented regs read/write lists
2016-08-11 11:22:48 +08:00
Daniel Collin
147083be67 [M68K] Implemented regs read/write lists 2016-08-09 17:29:36 +02:00
Nguyen Anh Quynh
fae35cedac x86: properly handle SSE/AVX instructions 2016-07-15 20:37:19 +08:00
lucasg
8b1899d859 Replace copy.deepcopy by copy_ctypes_list for get_arch_info
This replacement was done for commit
16477206564745782854e0ec5c68defa02429dd8, allowing the python binding to
be used in PyPy. It seems the m68k arch has been forgotten.
2016-07-09 14:38:01 +02:00
Pranith Kumar
ddaeb354ee Fix error return code 2016-06-29 11:08:13 -04:00
Andrew Dutcher
fcd06dedd7 Re-apply changes from 16477206564745782854e0ec5c68defa02429dd8 on next branch, that's the commit that lets the python bindings run in pypy 2016-06-16 15:47:43 -07:00