Commit graph

29138 commits

Author SHA1 Message Date
Anton Kochkov
101155383b
core/analysis: API to calculate multiple instructions size (#4279) 2024-02-21 21:08:58 +08:00
Heersin
d37fc4c8f8
rx: add DWARF profile (register mapping) (#4277) 2024-02-21 00:09:10 +08:00
billow
3eb9527bcd
rl78: add DWARF register profile (#4276) 2024-02-20 22:34:40 +08:00
Anton Kochkov
551cf21ac7
type/format: fix output in pf commands (#4272) 2024-02-20 21:37:14 +08:00
Rot127
dfc0114a71 Replace sdb_fmt() with rz_strf(). 2024-02-20 05:57:03 +00:00
pelijah
cf62a870ab
Fix several memleaks in regex.c (#4274) 2024-02-20 11:29:59 +08:00
billow
f89e875d8f
v850: add local variables detection (#4271)
* v850: fix local variable detect
* v850: add local variable test
* v850: fix stack inc
2024-02-20 00:08:03 +08:00
Anton Kochkov
91702ed767
type/format: fix typedefs self-reference (#4270) 2024-02-19 23:07:16 +08:00
Anton Kochkov
3e995d86e0 pf command help fixes 2024-02-19 20:14:12 +08:00
Anton Kochkov
518659bef0 bin/dwarf: fix dSYM separate loading 2024-02-19 20:13:36 +08:00
wargio
bc6946bc4d Add long string test 2024-02-19 19:39:00 +08:00
wargio
ef5d22e13d Fix string search related tests 2024-02-19 19:39:00 +08:00
wargio
e978d7d442 Backtrace info should be fetched only in certain flag spaces 2024-02-19 19:39:00 +08:00
wargio
f9422ac0cd Bump project to v16 2024-02-19 19:39:00 +08:00
wargio
a80622bcc1 Remove old options and replace with new global ones for string search.
Removed options:
- `bin.maxstr`

Renamed options:
- `bin.minstr` is now `str.search.min_length`
- `bin.maxstrbuf` is now `str.search.buffer_size`
- `bin.str.enc` is now `str.search.encoding`

New options:
- `str.search.reload`
- `str.search.max_threads`
- `str.search.max_uni_blocks`
- `str.search.max_region_size`
- `str.search.raw_alignment`
- `str.search.check_ascii_freq`
- `str.search.mode`
2024-02-19 19:39:00 +08:00
Anton Kochkov
7abb3adc48
git: ignore pcre2 subproject (#4266) 2024-02-19 09:16:40 +08:00
Anton Kochkov
e60e17818a
doc: fix packagers.md formatting (#4265) 2024-02-19 09:16:21 +08:00
Giovanni
411e6fd09f
Fix jsdec build (#4264) 2024-02-19 09:10:30 +08:00
Rot127
31f6c53d4c Attempt to fix test regex. 2024-02-18 21:29:03 +08:00
Rot127
4e6f21b07f Add include guards for post CS v4 instructions. 2024-02-18 21:29:03 +08:00
Rot127
0363f71654 Fix JUMP flag is overwitten with MOV flag.
Fix test for mov to pc
2024-02-18 21:29:03 +08:00
Rot127
abb8c3db75 Bumb Capstone next version. 2024-02-18 21:29:03 +08:00
Rot127
a84c7897fc
pcre2: fix NetBSD build by using different allocator. (#4259) 2024-02-18 18:22:06 +08:00
Rot127
1311b75c75 Bump PCRE2 to 10.43 release. 2024-02-18 07:26:08 +00:00
Dhruv Maroo
de4a1297a1
Add RzIL for floating-point x86 instructions (#3865)
* Create `il_fp_ops.inc`, for floating-point instructions' IL ops

* Add IL implementation for `FABS`

 * Also add `x86_il_{get,set}_st_reg` helper functions

* Add IL implementation for `FNINIT` and `FLDCW`

* Add IL implementations for `FNSTCW` and `FNSTSW`

* Add IL implementation for `FNCLEX`

* Add ST push and pop functions

* Fix clang formatting

* Add fucntions for updating FPSW TOP pointer

* Add `FLD` instruction lifitng, FPSW flag support, FP operand support

* Remove `x86_bool_to_bv` and use the standard `BOOL_TO_BV`

* Add implementation for `FST{P}`, and rounding mode support

* Add `FLD` variants for constants

* Fix formatting and build

* Add IL lifting for `FXCH`

* Add width checks to avoid redundant rounding

* Implement IL lifting for `FILD`, `FIST{P}`

    * Add helper functions to inter-convert floating point values and
      integers using the rounding mode in the control word

* FPU stack regs are 80-bit, not 64-bit

* Add RzIL lifting for `FBLD`

* Add RzIL implementation for `FBSTP`

    * An invalid-arithmetic-operand (#IA) exception may occurr if the
      value being converted to the BCD integer cannot fit in an 18-bit
      BCD integer. For the IL's purpose, we just jump to the "int" label
      (stands for interrupt) using `GOTO`.

* Remove all the `EMPTY()` ops after `GOTO()` ops

    * On second thought, using `EMPTY()` ops after `GOTO()` ops is not
      the best idea to indicate end of analysis. Maybe the hooks can
      signal that analysis needs to be restarted.
    * Also, clean up the comments of a bunch of unimplemented ops

* Moved some code around

* Rename "rmode" local variable to "_rmode"

* Add some TODOs for deffered work

* Fix failing asm tests

    * Caused due to the removal of the [empty] opcode

* Implement IL lifting for `FADD` (and some other minor refactoring)

    * Implement the IL lifting for `FADD`: This is not entirely correct
      as of now, because we don't handle setting C1 based on rounding
      up/down, but I think it should be fine for now. Need to tackle
      setting the control word bits later
    * Start using `RzFloatFormat` to describe the float's width instead
      of using an unsigned integer. Provide and expose conversion
      functions between the two

* Use a global to denote when RMode needs to be init, implement FIADD

    * Other minor refactor which fixes the CI (hopefully)

* Implement `FMUL` and `FIMUL`

    * Extract the common code into a C macro

* Implement RzIL for `FSUB` and `FISUB`

    * Also add `x86_il_fsub_with_rmode` helper

* Implement RzIL for `FSUBR` and `FISUBR`

    * Reuse the implementation of `x86_il_fsub_with_rmode` and just pass
      the arguments in the opposite order

* Add RzIL implementation for `FDIV`, `FIDIV`, `FDIVR`, `FIDIVR`

* Add pop versions of floating point arithmetic instuctions

    * Add a new macro `X86_ARITHMETIC_POP_IL` macro for the same
    * Fix a typo
    * Add a note for using `X86_INS_PFADD` for FADDP instruction on
      Capstone version newer than 4

* Add RzIL implementations for `FCOM`, `FCOMP` and `FCOMPP`

* Add RzIL lifting for `FUCOM` and `FCOMI` families of instructions

* Implement RzIL lifting for `FCHS` and `FTST`

* Add RzIL implementation for `FRNDINT` and `FSQRT`

* Add RzIL implementation for `FNOP` and `FISTTP`

* Remove global variable `use_rmode` and use pass around a context instead

    * Define a new `X86ILContext` struct to pass around information
      whether we need to intitialize the rouding mode or not
    * Remove the global variable which was previously responsible for
      doing so

* Add RzIL for `FICOM` and `FICOMP`, add register bindings and fix bugs

* Make `rz-test` more robust against IL outputs with newlines in them

* Add RzIL tests in db/asm for x86 FPU instructions

* Fix the bug when using `FADDP` with Capstone version > 4

* Fix remaining db tests

* Remove tests for `FSTSW` or `FSTCW` instructions

    * We already test `WAIT` (in `db/asm/x86_32`) and `FSTSW` (or
      `FSTCW`) (in `db/asm/x86_64`)
    * Remove the newline replacement code in `rz-test` as well, since we
      wouldn't need that functionality anymore

* Add asm tests for math constant push instructions

* Add `RZ_IPI` annotation for all the functions exposed through the header

* Add `RZ_OWN`, `RZ_BORROW` and `RZ_NONNULL` annotations

* Add Doxygen doc for `ctx` argument

* Add description for the `EXEC_WITH_RMODE` macro

* Move the non-null check for `ctx` inside the valid branch

    * When we pop the FPU stack we pass in a `NULL` context since no
      resizing would be needed, which causes a failure if the non-null
      check for the `ctx` is outside the branch
    * Fixes failing tests in `db/asm`

* Minor bug fixes + make the annotations less strict than they need to be

* Minor bug fixes

    * Incorrect implementation for `RET` and `CALL`
    * Swapped arguments for shift right

* Fix asm tests for `JMP` and `RET` instructions

* Fix indexing error for `FXCH`

* Review changes

    * Move all unimplemented instructions to the end
    * Remove support for Capstone version less than 4
2024-02-18 08:48:34 +08:00
Heersin
5c79c42a56
Disassembler arch for RX microcontroller (MCU) family (#4198)
* Basic framework of rx implemented
* Add match and parse flow
* Add part of description for RxV1 instruction set
* Add datasheet for rxv1
* Implement stringify op for rx
* Add missing TST instruction in datasheet
* Test to div instruction and fix bugs
* Test known rxv1 instruction set
* Fix bugs in rx disasm plugin and add SPDX
* Add rz_analysis for renesas rx
* Fix rz_analysis bug for renesas rx
* Add rz_asm test and fix bug in datasheet
* Add analysis test and fix bugs for renesas rx
2024-02-17 22:29:16 +08:00
Anton Kochkov
f98ab29273
Convert p2 and p8 commands to rzshell (#4250) 2024-02-17 21:59:20 +08:00
Dhruv Maroo
01c0159f6e Fix the test for ARM and Windows 2024-02-17 15:46:11 +08:00
Dhruv Maroo
87f889efa7 Fix conversion of 80-bit floats
* Add a new unit test for the same
2024-02-17 15:46:11 +08:00
Dhruv Maroo
70fb3be17f 80-bit float initialization works now
* Added a test in `test_float.c` for it
    * It is kind of unfortunate to deal with the idiosyncrasy of 80-bit
      float this way. There are cleaner ways, but they would require
      more refactor, and are probably not worth it since we wouldn't be
      modifying the float code that often.
2024-02-17 15:46:11 +08:00
Rot127
008f4edaf3 Add pacibsp as valid function prologue. 2024-02-17 15:04:47 +08:00
Rot127
21bfc0881c Update rz_search_keyword_new() doxygen and variable names. 2024-02-17 15:04:47 +08:00
Anton Kochkov
b178dac5dd Add test for issue #329 2024-02-17 11:05:16 +08:00
billow
cd92cce3cb rz_analysis_function_set_var: Fix incorrectly adding the same variable 2024-02-17 11:05:16 +08:00
billow
8026d94b56
rzil: add analysis and evaluation integration test (#4241)
* Try to refactor rz_core_analysis_bytes_il
* Add the RzIterator
* Refactor rz_core_analysis_op_bytes with RzIterator
* Refactor rz_core_analysis_bytes with RzIterator
* Add test_analysis_il
* Fix AnalysisBytesContext_next
* Fix heap-buffer-overflow and UBSan
* Fix use-after-free
2024-02-16 21:10:44 +08:00
Anton Kochkov
753e43fbf1
core/flags: add complex unicode name test (#4245) 2024-02-16 16:58:03 +08:00
Rot127
49abb5d958 Fix doxygen for rz_regex_get_group_idx_by_name() 2024-02-16 16:57:31 +08:00
Rot127
2fde7808a0 Don't match numbers with a '.', '*' and '\w' prefix.
The exclusion pattern [^\w.*] excludes all numbers with a '.' and '*' prefix.
This is only done because the previous parsing did it like this.
And not doing it, breaks substitutions from before. E.g. when addresses,
were replaced with flag names which include numbers (case labels like: case.<switch-address>.<case-number>).
See: https://github.com/rizinorg/rizin/issues/4238 for more details of this problem.
2024-02-16 16:57:31 +08:00
Rot127
6fcc9f6c6a Fix tests with newly replaced symbol names.
With cd57f517fc30e49ea5ebb5c99db276c1f41c62f9 more numbers are detected
and symbol names can be replaced.
2024-02-16 16:57:31 +08:00
Rot127
d702d2bc0d Replace find_next_number with a regex version to be less obscure. 2024-02-16 16:57:31 +08:00
Rot127
18a4d71492 Add rz_regex_get_group_idx_by_name() 2024-02-16 16:57:31 +08:00
Rot127
643718d499 Fix hexagon analysis tests 2024-02-16 16:57:31 +08:00
Rot127
22827fd7ee Add rz_regex_find(). 2024-02-16 16:57:31 +08:00
Anton Kochkov
3b0f42acb9
analysis/types: add more WinAPI types (#4244) 2024-02-16 14:51:21 +08:00
Anton Kochkov
28de08e320
core/cmd_print: remove unused oldshell code (#4243) 2024-02-16 13:44:49 +08:00
Anton Kochkov
e9000ec45b core/bin: convert cmd call to API 2024-02-16 13:44:28 +08:00
Anton Kochkov
d0a24f5789 core/disasm: convert cmd call to API 2024-02-16 13:44:28 +08:00
Anton Kochkov
ceefb5e114
Convert pf commands to rzshell (#3467) 2024-02-16 10:30:59 +08:00
Ahmed_Hany
a5297b57c2
Add help and colors for rz-run -h (#4225) (#4237)
* `-l` flag for listing profile options
* `-d` for ouputing a base profile template.
* Updated relevant manpage.
2024-02-16 01:54:12 +08:00
Giovanni
ac63502f76
Fix aeA when rz_analysis_op fails. (#4240) 2024-02-15 20:55:52 +08:00