rizin/librz
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
..
analysis Add RzIL for floating-point x86 instructions (#3865) 2024-02-18 08:48:34 +08:00
asm Disassembler arch for RX microcontroller (MCU) family (#4198) 2024-02-17 22:29:16 +08:00
bin Disassembler arch for RX microcontroller (MCU) family (#4198) 2024-02-17 22:29:16 +08:00
bp librz: add some initial documentation (#3782) 2023-10-13 13:46:19 +08:00
config Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
cons Trim grep expression before processing it. (#4227) 2024-02-14 21:43:42 +08:00
core Convert p2 and p8 commands to rzshell (#4250) 2024-02-17 21:59:20 +08:00
crypto Introducing SM4 encryption and decryption (#3863) 2023-12-03 13:36:38 +08:00
debug Rewrite how rz_cons_pipe_open/close behave to remove globals (#4223) 2024-02-14 09:05:17 +08:00
demangler librz: add some initial documentation (#3782) 2023-10-13 13:46:19 +08:00
diff Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
egg librz: add some initial documentation (#3782) 2023-10-13 13:46:19 +08:00
flag Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
hash Fix openssl 3.0 support due changes on legacy algorithms. (#4215) 2024-02-12 17:44:04 +08:00
il Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
include Disassembler arch for RX microcontroller (MCU) family (#4198) 2024-02-17 22:29:16 +08:00
io Remove some more of sdb_fmt() calls (#4140) 2024-01-30 22:36:39 +08:00
lang Convert from rz_str_new to rz_str_dup (#4178) 2024-02-07 00:07:53 +08:00
magic Replace current regex engine with PCRE2 (#4185) 2024-02-05 12:51:16 +08:00
main Add help and colors for rz-run -h (#4225) (#4237) 2024-02-16 01:54:12 +08:00
parse Don't match numbers with a '.', '*' and '\w' prefix. 2024-02-16 16:57:31 +08:00
reg Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
search Update rz_search_keyword_new() doxygen and variable names. 2024-02-17 15:04:47 +08:00
sign Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
socket Add help and colors for rz-run -h (#4225) (#4237) 2024-02-16 01:54:12 +08:00
syscall Remove some more of sdb_fmt() calls (#4140) 2024-01-30 22:36:39 +08:00
type Convert pf commands to rzshell (#3467) 2024-02-16 10:30:59 +08:00
util Fix conversion of 80-bit floats 2024-02-17 15:46:11 +08:00
config.h.in
meson.build
README.md librz: add some initial documentation (#3782) 2023-10-13 13:46:19 +08:00
RizinConfig.cmake.in
RzModulesConfig.cmake.in

Rizin Libs (librz)

The Rizin framework is composed of several pieces that work together to provide a reverse-engineering framework useful for a variety of use-cases and tasks. All tools present in binrz are based on the libraries present in this directory, so getting a general idea of what these libraries are and do is key to navigate the codebase.