Commit Graph

122 Commits

Author SHA1 Message Date
Nguyen Anh Quynh
c7c665f8f3 CMake: retain VERSION_xxx macros 2022-01-13 00:17:31 +08:00
Rwitaban Goswami
487cde56f2
Update CMakeLists.txt to bump CMake version to 2.8.12 (#1817)
* Update CMakeLists.txt

* Fix depcrecated warning on CMP0048

* Fix CMP0048 policy
2022-01-13 00:13:57 +08:00
Keegan Saunders
aff05e613a
Option to generate install target (#1700)
Co-authored-by: meme <meme@users.noreply.github.com>
2020-10-28 23:34:48 +08:00
Matthias C. M. Troffaes
852c075723
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
Schrijvers Luc
7a2357ec3b Use GNUInstallDirs for the headers too (#1570) 2019-12-16 00:37:22 +08:00
Travis Finkenauer
0574f899e5 [RISCV] Use CS_ASSERT (#1493)
* makefile: set CAPSTONE_DEBUG for debug build

Also fix long longs

* riscv: replace assert with CS_ASSERT

* cmake: add CAPSTONE_DEBUG option
2019-05-23 08:25:36 +07:00
Nguyen Anh Quynh
0c31f14db1 ppc: print condition register bits. issue #1469 2019-05-08 13:56:40 +08:00
Nguyen Anh Quynh
dbefe3a6d5 ppc: add some new .inc files 2019-04-30 13:52:23 +08:00
Nguyen Anh Quynh
11206deb78 ppc: sync with llvm 7.0.1 2019-04-30 13:50:42 +08:00
JornVernee
f4fd2d925c Add cmake option to tell whether architectures should be included by default (#1463) (#1466) 2019-04-29 19:20:01 +07:00
Nguyen Anh Quynh
ec672f9388 fuzz: update CMakeLists.txt after the last refactor 2019-04-13 15:27:54 +08:00
Nguyen Anh Quynh
25b6704978 merge next-arm64 to next 2019-04-10 17:46:07 +08:00
Nguyen Anh Quynh
9d292268a9 arm64: sync with LLVM 7.0.1 2019-04-10 14:17:08 +08:00
z
f1e49f6ce6 add riscv cmake support & using static array contain temp string for riscv (#1435)
* add TableGen patch whcih fix riscv asmwrter.inc memory leak

* add riscv for cmake suporrt and change asmwriter using static array container

* add missing .inc files for riscv cmake support
2019-03-20 23:19:26 +08:00
Nguyen Anh Quynh
831ea98bdd arm: remove ARMRegisterName.inc from CMakeLists.txt 2019-03-16 18:12:54 +08:00
Nguyen Anh Quynh
124f91b303 arm: sync with llvm 7.0.1 2019-03-16 15:22:15 +08:00
z
a012f75754 RISCV support ISRV32/ISRV64 (#1401)
* Added RISCV dir to contain the RISCV architecture engine code. Adding the TableGen files generated from llvm-tblgen. Add Disassembler.h

* Started working on RISCVDisassembler.c - RISCV_init(), RISCVDisassembler_getInstruction, and RISCV_getInstruction

* Added all functions to RISCVDisassembler.c and needed modifications to RISCVGenDisassemblerTables.inc. Add and modified RISCVGenSubtargetInfo.inc. Start creation of RISCVInstPrinter.h

* Finished RISCVGenAsmWriter.inc. Finished RISCVGenRegisterInfo.inc. Minor fixes to RISCVDisassembler.c. Working on RISCVInstPrinter

* Finished RISCVInstPrinter, RISCVMapping, RISCVBaseInfo, RISCVGenInstrInfo.inc, RISCVModule.c. Working on riscv.h

* Backport it from: 0db412ce3b

* All RISCV files added. Compiled correctly and initial test for ADD, ADDI, AND works properly.

* Add refactored cs.c for RISCV

* Testing all I instructions in test_riscv.c

* Modify the orignal backport for RISCVGenRegisterInfo.inc, capstone.h and test_iter to work w/ the current code strcuture

* Fix issue with RISCVGenRegisterInfo.inc - RISCVRegDesc[] (Excess elements in struct initializer). Added RISCV tests to test_iter.c

* fixed bug related to incorrect initialization of memory after malloc

* fix compile bug

* Fix compile errors.

* move riscv.h to include/capstone

* fix indentation issues

* fix coding style issues

* Fix indentation issues

* fix coding style

* Move variable declaration to the top of the block

* Fix coding indentation

* Move some stuff into RISCVMappingInsn.inc

* Fix code sytle

* remove cs_mode support for RISCV

* update asmwriter-inc to LLVM upstream

* update the .inc files to riscv upstream

* update riscv disassembler function for suport 16bit instructions

* update printer & tablegen inc files which have fixed arguments mismatch

* update headers and mapping source

* add riscv architecture specific test code

* fix all RISCV tons of compiler errors

* pass final tests

* add riscv tablegen patchs

* merge with upstream/next

* fix cstool missing riscv file

* fix root Makefile

* add new TableGen patchs for riscv

* fix cmakefile.txt of missing one riscv file

* fix declaration conflict

* fix incompatible declaration type

* change riscvc from arch to mode

* fix test_riscv warnning

* fix code style and add riscv part of test_basic

* add RISCV64 mode

* add suite for riscv

* crack fuzz test

* fix getfeaturebits test add riscvc

* fix test missing const qualifier warnning

* fix testcase type mismatch

* fix return value missing

* change getfeaturebits test

* add test cs files

* using a winder type contain the decode string

* fix a copy typo

* remove useless mode for riscv

* change cs file blank type

* add repo for update_riscv & fix cstool missing riscv mode

* fix typo

* add riscv for cstool useage

* add TableGen patch for riscv asmwriter

* clean ctags file

* remove black comment line

* fix fuzz related something

* fix missing RISCV string of fuzz

* update readme, etc..

* add riscv *.s.cs file

* add riscv *.s.cs file & clear ctags

* clear useless array declarations at capstone_test

* update to 5e4069f

* update readme change name more formal

* change position of riscv after bpf and modify copyright more uniform

* clear useless ctags file

* change blank with tab in riscv.h

* add riscv python bindings

* add riscv in __init__.py

* fix riscv define value for python binding

* fix test_riscv.py typo

* add missing riscvc in __init__.py of python bindings

* fix alias-insn printer bug, remove useless newline

* change inst print delimter from tab to bankspace for travis

* add riscv tablegen patch

* fix inst output more consistency

* add TableGen patch which fix inst output formal

* crack the effective address output for detail and change register print function

* fix not detail crash bug

* change item declaration position at cs_riscv

* update riscv.py

* change function name more meaningfull

* update python binding makefile

* fix register enum sequence according to riscvgenreginfo.inc

* test function name

* add enum s0/fp in riscv.h & update riscv_const.py

* add register name enum
2019-03-09 08:41:12 +08:00
Nguyen Anh Quynh
55a65a7331 x86: new files X86GenRegisterName.inc & X86GenRegisterName1.inc 2019-03-04 00:56:07 +08:00
Nguyen Anh Quynh
ee8d2f9696 cmake: update HEADERS_X86 2019-03-01 12:54:08 +08:00
Nguyen Anh Quynh
5a99624074 sync with LLVM 7.0.1. X86 is first 2019-02-26 15:19:51 +08:00
Anton Bolshakov
0cce9bdaf0 respect libsuffix in pkgconfig (#1393)
* respect libsuffix in pkgconfig

discovered in https://bugs.gentoo.org/677946

* Update CMakeLists.txt

* Update CMakeLists.txt

* Update CMakeLists.txt
2019-02-20 10:12:42 +08:00
david942j
cac94ccee5 New architecture: BPF (#1388)
* Basic changes of new arch - BPF

* Define some constants

* defined some API methods

* Able to print MISC instruction

* Follow Linux coding style

* Ability to show ALU insn names

* decode return

* Add suite/MC/BPF

* decode jump

* decode store

* decode load

* print instruction done

* try to implement BPF_reg_access

* Implements explicit accessed registers and fix some tiny bugs

* Fix unhandled ja case

* Added BPF_REG_OFF do fix wrong display in jump class

* Great I'm able to decode cBPF with eyes

* Fix: misunderstood the 16-byte instruction's imm

* Add ldxdw

* Add extended-all.cs

* Implements cstest/bpf_getdetail.c

* Fix memory leak

* Add BPF to fuzz

* Implemented regs_read and regs_write

* Fix missing write-access on ALU's dst

* Updated cstool/, test_basic.c, test_detail.c, and test_iter.c

* Updated docs

* Fix type of cs_bpf#operands

* Implements python bindings

* Fix some bugs found by self code review

* Remove dummy tests

* remove typeof

* Address comments

* Fix MSVC's warnings and add test_bpf.py to bindings/python/Makefile

* Fix: call is not offset
2019-02-18 17:39:51 +08:00
Spike
4ae8645b43 Add webassembly arch (#1359)
* add wasm arch

* fix bug

* delete todo & add wasm into readme
2019-02-01 23:03:47 +08:00
Nguyen Anh Quynh
f1fc51bd09 next version = 5.0 2019-01-09 13:53:17 +08:00
mephi42
d9b8079aba Update SystemZ to LLVM commit 5ad902a6 (#1306) 2018-12-16 21:48:51 +08:00
Nguyen Anh Quynh
5c634289b4 bump version to 4.1 2018-12-16 20:18:20 +08:00
Sebastian Macke
87221fa742 Add support for the MOS65XX family such as the MOS 6502.
Signed-off-by: Sebastian Macke <sebastian@macke.de>
2018-12-06 22:53:33 +01:00
Derrick McKee
c3bc43e354 Generate capstone.pc to the location it is installed from (#1265)
* forcing capstone.pc to be generated in the same place it is installed from

* x86: fix operand access of SETE & SETNE (#1262)

* forcing capstone.pc to be generated in the same place it is installed from
2018-10-23 19:42:36 -03:00
Bruce Mitchener
e8b234d237 Fix typos. (#1248) 2018-09-17 20:54:00 +08:00
Nguyen Anh Quynh
afffa5d741 merge next to master 2018-07-20 12:36:50 +08:00
Catena cyber
5315c5b785 Integrate capstone with oss-fuzz (#1150)
Compile the fuzz target with the rest of the tests
2018-06-01 20:47:19 +08:00
Catena cyber
170904d5f1 Integrate capstone with oss-fuzz (#1150)
Compile the fuzz target with the rest of the tests
2018-06-01 20:46:20 +08:00
Connor Davis
b4998b3264 CMakeLists.txt: Add cstool build option (#1118) 2018-04-26 10:16:52 +08:00
Connor Davis
5c17897497 CMakeLists.txt: Add cstool build option (#1118) 2018-04-26 10:15:59 +08:00
Nguyen Anh Quynh
ed1246d79b add Ethereum VM architecture 2018-03-31 17:29:22 +08:00
Alberto Garcia Illera
a6b4e42788 force Capstone to be build using MT (#1109) 2018-03-29 22:18:04 +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
Andrew D'Addesio
540a1b2bdb Fix pkg-config output when using cmake (#1098) 2018-03-18 08:55:51 +08:00
Andrew D'Addesio
7185555a6e Fix pkg-config output when using cmake (#1098) 2018-03-18 08:54:56 +08:00
Wolfgang Schwotzer
22b4d0eb41 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
Nguyen Anh Quynh
f5b0e3cf43 cmake: do not set libsuffix=64 on MacOS. fix issue #963 2017-07-19 22:53:09 +08:00
Nguyen Anh Quynh
cbf274c94c cmake: do not set libsuffix=64 on MacOS. fix issue #963 2017-07-19 22:46:38 +08:00
Fernie
4be19c3cbb detect 64bit library location. compatibility for 64bit systems. (#963)
credit goes to Theo. (Theodore Papadopoulo Theodore.Papadopoulo at inria.fr https://cmake.org/pipermail/cmake/2013-July/055374.html)
2017-07-18 08:27:29 +08:00
Fernie
408de035d2 detect 64bit library location. compatibility for 64bit systems. (#963)
credit goes to Theo. (Theodore Papadopoulo Theodore.Papadopoulo at inria.fr https://cmake.org/pipermail/cmake/2013-July/055374.html)
2017-07-18 08:26:39 +08:00
Nick Briggs
ce3f0d0935 Rename test.c to test_basic.c with corresponding executable name change. (#923)
* Rename test.c to test_basic.c with corresponding executable name change.

* Fix Makefile, tests/Makefile to comprehend renamed test program. See issue #922

* Fix XCode project to comprehend renamed test program.  See issue #922

* Rename python test.py to test_basic.py to parallel C test name.  See issue #922

* Rename ocaml test.ml to test_basic.ml to parallel C test name.  See issue #922

* Fix MSVC project definitions to comprehend renamed test program.  See issue #922
2017-05-11 22:58:12 +07:00
Nguyen Anh Quynh
7917523c96 cmake: build static MSVCRT by default 2017-05-09 00:35:05 -07:00
Gabor Buella
3cc69be43d cmake - fix SOVERSION property used for libcapstone.so (#914)
It was set as a global property before, but cmake appears to ignore that,
even after the following fix:
-set_property(GLOBAL PROPERTY SOVERSION SOVERSION ${VERSION_MAJOR})
+set_property(GLOBAL PROPERTY SOVERSION ${VERSION_MAJOR})

So this patch removes the global property, and SOVERSION is now specified as
a target specific property. The result of the cmake install target seems better:

Before:

$ ls -la lib
4375834 May  1 16:05 libcapstone.a
3510040 May  1 16:05 libcapstone.so

After:

$ ls -la lib
4375834 May  1 16:05 libcapstone.a
     16 May  1 16:08 libcapstone.so -> libcapstone.so.4
     20 May  1 16:08 libcapstone.so.4 -> libcapstone.so.4.0.0
3510040 May  1 16:08 libcapstone.so.4.0.0

The SOVERSION property triggers symlink creation in cmake, see:
https://cmake.org/cmake/help/v3.0/prop_tgt/SOVERSION.html
2017-05-02 09:25:32 +08:00
Gabor Buella
5dccc620b1 cmake - fix SOVERSION property used for libcapstone.so (#914)
It was set as a global property before, but cmake appears to ignore that,
even after the following fix:
-set_property(GLOBAL PROPERTY SOVERSION SOVERSION ${VERSION_MAJOR})
+set_property(GLOBAL PROPERTY SOVERSION ${VERSION_MAJOR})

So this patch removes the global property, and SOVERSION is now specified as
a target specific property. The result of the cmake install target seems better:

Before:

$ ls -la lib
4375834 May  1 16:05 libcapstone.a
3510040 May  1 16:05 libcapstone.so

After:

$ ls -la lib
4375834 May  1 16:05 libcapstone.a
     16 May  1 16:08 libcapstone.so -> libcapstone.so.4
     20 May  1 16:08 libcapstone.so.4 -> libcapstone.so.4.0.0
3510040 May  1 16:08 libcapstone.so.4.0.0

The SOVERSION property triggers symlink creation in cmake, see:
https://cmake.org/cmake/help/v3.0/prop_tgt/SOVERSION.html
2017-05-02 09:24:45 +08:00
Gabor Buella
b9a2c1a73c cmake: install pkg config file 2017-04-30 23:19:54 +08:00
Gabor Buella
150ac00ab0 cmake: install pkg config file 2017-04-30 11:50:03 +02:00