Commit graph

223 commits

Author SHA1 Message Date
Khairul Azhar Kasmiran
a80555e9c5
Update librz/asm/arch/cris/gnu/ to the latest binutils (#3127) 2022-10-27 19:06:53 +08:00
Khairul Azhar Kasmiran
2957d60730
Remove cosmetic changes from cris-dis.c (#3120) 2022-10-24 18:51:27 +08:00
Khairul Azhar Kasmiran
3ca1413c1c Revert cris.h back to mainstream formatting 2022-10-18 18:54:57 +08:00
Khairul Azhar Kasmiran
9ce5ef89c7
Revert some changes in 52e614035e of cris-dis.c (#3100) 2022-10-16 12:02:18 +02:00
Khairul Azhar Kasmiran
a92d5f52ed
Fix gcc11-asan arcompact-dis -Wstringop-truncation warning (#3097) 2022-10-15 16:54:20 +08:00
Khairul Azhar Kasmiran
b81d9225fc
Fix gcc12-asan arcompact-dis -Wformat-overflow= warnings (#3092) 2022-10-13 08:09:57 +08:00
Rot127
0268d5dba3
Add missing type annotations and fix #3020. (#3022) 2022-09-12 22:09:00 +02:00
Dean
59b38e6efa
Add /*<type>*/ comments everywhere (#2986)
Adds /*<type>*/ comments and a linter check from rz-bindgen to enforce
their existence and consistency

Also includes the following fixes made when adding the annotations:
* removed unused intern_table arguments in pyc_dis.c, pyc_dis.h, asm_pyc.c
* removed unused classes argument from place_nodes in agraph.c
* removed unused recurse and recurse_bb functions in canalysis.c
* removed unused vars field from RzPrint struct
* removed unused RzAnalysisType* structs from rz_analysis.h
* removed unused list field from RzEgg struct
* fixed bug in bp_plugin.c where duplication-checking logic iterates over the wrong list
* removed unused q_regs field from RzDebug struct
* removed unused backtrace field from RzDebugPlugin struct
* removed unused classes_list field from RzBinNXOObj struct
* removed unused methods_list and classes_list fields from RzBinZimgObj struct
2022-09-11 13:04:53 +08:00
Giovanni
008363fcc4
Fix #2851 - wrong AVR analysis jump value for rjmp/rcall (#3012) 2022-09-07 23:00:23 +02:00
billow
9f4548991d
Expose pda and fix memory leaks (#2943) 2022-08-23 06:56:49 +08:00
Florian Märkl
4e5857cacf
Meson refactor: collect modules in dict and centralize config (#2945)
Duplicated code for pkg-config and cmake configuration is avoided by
letting every rizin module register itself in a global dictionary
called "modules" which is then iterated in one place to perform any
shared logic, inspired by how qemu handles multiple targets in its meson
build system.

This is an almost pure refactor, so the resulting .pc/.cmake files
should be identical with the following exceptions:
- rz_reg.pc does not have plugindir anymore as rz_reg has no plugins.
- Some other modules have their dependencies in .pc files altered to be
  consistent with cmake.
2022-08-20 19:59:27 +02:00
Florian Märkl
7cc70d80b0
Fix oob read and endian dependency in asm_ebc (#2929)
Fixes all tests in test/db/asm/ebc on big endian. Tested on
OpenBSD/sparc64.
Also fixes oob reads in cases like `rz-asm -a ebc -d cc`.
2022-08-17 21:58:06 +08:00
Florian Märkl
35438aab29 Replace sprintf by snprintf in tms320_dasm 2022-08-16 07:48:33 +08:00
Florian Märkl
1619d94329 Fix tms320 disassembler for big endian hosts
The union of stream/opcode64 is unreasonably hard to use right, so we
just read as little endian manually into an extra field. This also
eliminates the need for any endian-specific code, such as in be16/be24.

Tested on OpenBSD/sparc64.
Fixes all tests in test/db/asm/tms320_c55x_32 there.
2022-08-16 07:48:33 +08:00
Florian Märkl
6e04ddeb3d
Fix asm_riscv on big endian hosts (#2918)
This fixes all tests in test/db/asm/riscv_32 on be, tested on
OpenBSD/sparc64.
2022-08-14 20:00:58 +02:00
Florian Märkl
7cbeaf2653
Fix arm64 assembler tests on big endian hosts (#2913) 2022-08-13 14:43:33 +02:00
Rot127
9f64b41766
Disassemble invalid duplex instructions to invalid ; invalid. (#2889) 2022-08-08 21:05:50 +08:00
Rot127
720598f1f0
[Hexagon] Resolve duplex instructions dynamically (#2882)
* Chane HexInsn -> HexInsnContainer in asm plugin.

* Make HexInsn -> HexInsnContainer in hexagon_disas.c

* Add function to set concatinate textual disassembly parts.

* Switch expressions, fix segfault.

* Print number of unhandle ops, if they can not be added to RzAnalysisOp.

* Add lookup function to determine sub-instructions for duplex iclass.

* Fix asm tests.

* Add memcpy for instruction containers

* Fix off by one.

* Fix segfault if the packet held only the instruction which is currently resolved. `hic->bin.insn` would be NULL in this case.

* Remove duplicate index name.

* Set instruction address.

* Clean up hic->parse_bits use

* Fix: .new registers were not resolved dur to too early return.

* Fix rebase mistakes.
* Add missing code

* Fix build error: Use sizeof(`text_infix`) since it is way smaller than `text`

* Initialize `HexInsn` inside `setup_new_hic`. Fixes NULL access.

* Mark RzAsm/RzAnalysis members as deprecated and fix typo.
2022-08-08 08:12:53 +08:00
Dhruv Maroo
2205f3623f
Use clang-format 14 instead of 13 (#2846) 2022-08-05 23:30:07 +05:30
Dhruv Maroo
cfd9453c45
Fix Coverity defects for SuperH lifting, assembler and disassembler (#2866)
* Check for `NULL` result for `strchr` in `sh_op_movl_param_bits`

* Remove unnecessary `rz_str_newf` and also remove the corresponding leak

* Add `NULL` checks for resulsts of `strchr` in the assembler
2022-08-04 08:39:06 +08:00
wingdeans
a6a7a5f530 Fix annotation inconsistencies 2022-08-03 00:29:56 -04:00
Dhruv Maroo
d44b5748eb
[RzIL] IL lifting of SuperH ISA (#2518)
* Add an assembler for the SuperH ISA
	* Rewrite GPL GNU disassembler code
2022-08-02 02:37:03 +05:30
Rot127
b9fa2be193
Asm tokens fixes (#2855)
* Replace on s390x failing tms320 c55x test with c55x+ test.

* Fix resource leaks of parse paramters.

* Revive unreachable code.

* Raplace test with one which has not a different asm string in Capstone v3.

* Rename `new` to `newt` since `new` is a keyword and should not be used as var name.
2022-07-30 21:24:49 +08:00
Rot127
c009f8d7a3
Tokenize and colorize asm strings (#2417)
This introduces the ability to split asm strings into tokens and assign a type to them.

This means:
* Each asm strings is assigned a list of tokens. Each token points to a sub-string.
* A token has a type attached which describes it (e.g. register token, operator token, mnemonic token etc.)
* A generic parsing method is introduced which splits an asm string into tokens. The pattern it parses is `<mnem> <op> <op> ...`.
* Instead of the generic method, plugins can create the token strings on their own.
* An API method was introduced to help plugins implement their own parsing methods via regex patterns.
* Custom token strings are stored in `RzAsmOp.asm_toks`

Additionally the coloring of asm strings is now exclusively done via the token strings.
* For this a function was added to colorize tokenized asm strings according to their token types.
2022-07-27 08:52:01 -04:00
Florian Märkl
9a316f308a Fix pic18c disassembler on big endian
Test case:
rz-asm -a pic -c pic18 -d 37ef12f0
as part of test/db/io/ihex
2022-07-26 15:50:09 +02:00
Riccardo Schirone
a689f0a86e librz: refactor a bit how plugins are built
Rely on RZ_ARRAY_SIZE to add librz plugins instead of NULL terminators.
2022-07-20 22:04:02 +02:00
GustavoLCR
57831ae5ae Remove globals from pyc code 2022-07-20 00:09:05 +08:00
Riccardo Schirone
8939fdbd7d
Use add_global_arguments instead of passing cflags/ldflags all around (#2812)
See also 66a0e22293/docs/TESTING_WITH_SANITIZERS.md (clang)
2022-07-17 21:33:51 +08:00
Giovanni
b1f5b5b454
Remove usage of rz_bin_is_big_endian (#2761)
* Remove usage of rz_bin_is_big_endian which changes the endianness set by the user
2022-07-02 18:36:16 +00:00
Khairul Azhar Kasmiran
5f826df878
Remove 1 from some header guards (#2765) 2022-07-01 22:15:12 +08:00
Dean
bf2871c7eb
Add dotnet PE support (#2528)
* Add CIL support

* refactor dotnet parsing to pe/dotnet.c
* parse PE CLR metatables (based on yara implementation)
* use CLR methoddefs to add binsymbols (including method namespace/class)
* parse CLR method headers
* CIL disassembler using .NET opcodes.def
* CIL analysis plugin
2022-06-21 09:20:47 +08:00
Dhruv Maroo
b2d84a9796
Replace IL opbuilder macro NOP with NOP() to make it more intuitive (#2705)
* Also, undef `EMPTY` in `rz_il_opbuilder_end.h`
2022-06-19 10:12:26 +08:00
Ben Demick
49680257af
Fix default ELF arch for x86 binaries 2022-06-13 21:16:47 +08:00
Riccardo Schirone
ce6ac3e467 meson: use major/minor only in the lib soversion 2022-05-10 21:04:43 +02:00
Mario Haustein
46626a692c Fix capstone include directory 2022-05-10 11:10:04 +02:00
Anton Kochkov
564d88c319
Add missing Python magic values (#2522) 2022-05-02 13:22:12 +02:00
Florian Märkl
3cbde10260
Update Hexagon for compact struct conversion (#2548)
This is updating with rz-hexagon 1ca78d073861b6ce66b682d200c7a3fc2734a6a3
2022-04-22 17:50:39 +02:00
Rot127
2bd8ef5517
Fix: Propeller and Hexagon out of bounds reads 2022-04-12 12:38:02 +08:00
Rot127
0a89fd23fc
Set constant -1 value and type in hi->ops[]. (#2526)
Dual to rz-hexagon #58
2022-04-09 13:48:57 +00:00
Martin M
74c071b071
Fix disassembly of LDD instruction on AVR (#2519) 2022-04-08 21:23:15 +02:00
Rot127
e858ca6d93
Sort imported instruction/register files before processing. (#2493) 2022-04-04 13:09:04 +08:00
Rot127
10bedc2b00
Add Hexagon register profile (#2490)
Although the reg profile was not really used yet it will be relevant for the RZIL uplifting.
Introduces:
* Double/quadruple registers now properly overlap with their counterparts.
* Registers have correct types assigned (vec, ctr, sys etc. Before, all regs were of type gbr)
* Consistent register names (asm name style: c3:2, r31 etc, alias style: lc1:sa1, lr etc.)
* Adds _tmp registers in the profile. Later used by uplifted instructions (think of .new registers).
2022-04-03 18:26:17 +02:00
Rot127
628d04f713
Add RzConfig for asm plugins (#2488)
* Add function to add config node to config by `RzConfigNode*`
* Move `SET<NODE>` macros to `rz_config.h`
* Add un/set functions for plugin specific configs.
* Add RzConfig and node setter to hexagon plugin.
* Use plugins RzConfig to determine sdk syntax setting.
* Use plugins RzConfig to determine if numbers should be signed.
* Use plugins RzConfig to determine if immediate hash should be printed.
* Remove unused parameter `rz_asm`.
* Remove unused variable.
* Remove unused callback.
* Remove unused flags from `RzAsm`
* Fix asm tests: Add NULL check; Set correct sign in asm test.
2022-04-03 20:44:50 +08:00
Riccardo Schirone
230652aa98
Add -Wimplicit-fallthrough to meson file (#2438) 2022-03-24 08:27:18 +08:00
Giovanni
bfec86a12e
Add option to install sigdb systemwise and custom user location for additional signatures (#2328) 2022-02-28 14:32:38 +01:00
Florian Märkl
8545686ae7
Add remaining b conds to arm64 assembler (#2369)
This adds support for all possible kinds of b.<cond> instructions, like
b.eq, b.ne, ...
2022-02-27 18:31:44 +01:00
Giovanni
63622fa9e6
[RzIL] AVR lifter (#1890)
Added all the ops excluding des and spm due their complexity
Added tests to verify output of each execution cycle.
2022-02-22 18:54:55 +01:00
Florian Märkl
4698f43d7a
Unify reglist parsing in arm assembler and fix leaks (#2347)
This is about parsing braced register lists like in
  push {r0, r1, r2}
The malloced temp string in collect_list was never freed. But since
thumb and non-thumb used completely different logic for parsing these
things anyway, it was better to just rewrite it in a single way.
2022-02-21 21:26:22 +01:00
Florian Märkl
5a4a4d9863
Fix leaks in RzAsm (#2346)
RzAsmOp needs to be finid, otherwise the internal RzStrBufs may leak
heap buffers.
2022-02-21 18:11:08 +01:00
Florian Märkl
b84fe55b3a
Add bfc and bfi to arm32 assembler (#2337) 2022-02-20 09:27:34 +01:00