rizin/test/unit
Rot127 fb6efca4b5
[Hexagon] RzIL uplifiting (#3837)
Uplift Hexagon architecture to RzIL

The general structure is, that every (sub-)instruction has a getter for it's RzIL code.
Calling the getter will return the RzIL operation.
If RzIL for an instruction is requested, the plugin makes a decision. Because Hexagon only executes whole instruction packets. If the instruction is not the last instruction in a packet, it will simply return `EMPTY()`. If the RzIL for the last instruction in a packet is requested, it will get the RzIL operations for all instructions in the packet, shuffles them into the correct execution order (according to some rules) and returns the complete operation for the packet.

The RzIL code was entirely generated with the [rzil-compiler](https://github.com/Rot127/rzil-compiler/), using the semantic definition of the [QEMU Hexagon module](https://github.com/qemu/qemu/tree/master/target/hexagon).

Currently successful compile instructions (and tested):
```
[*] 1581/1733 standard instructions compiled.
[*] 431/643 HVX instructions compiled.
[*] In total: 2012/2376 instructions compiled.
```

It was tested with:
- (Semantic tests) `rz-tracetest` against the execution trace of the QEMU Hexagon test binaries.
- (Bug free and semi-semtantic test) Adding tests which simply execute the test binaries to ensure leak and segfault free execution. Also it is executed until a certain instruction is reached (end of `main` or `loc.pass` symbol), partially testing it executes correctly.

For the uplifting several changes and modernization had to be made:

- Enhance consistency of decoding
  - Allow to disassemble an instruction without copying the result. This is used if the given buffer of instruction bytes is larger than one instruction width. In this case, as many instructions as the buffer can hold are disassembled and buffered for later.
  - Generally enhance buffering of instructions.
  - Allow to mark a packet as valid before it is completely decoded (in case we know it must be valid, e.g. if it is a jump target of a valid packet).
- Fix (hopefully) all memory leaks of the Hexagon plugin.
- Changes to register getters, because RzIL needs finer control to translate alias or explicit register names to their real register.
  - Getter for register name is now done by table, so for future distinction between DSP version we can just select another table.
  - Translation functions from register alias or explicit name to their real register.
  - Each operand contains now it's variable ID (e.g. `d` for register `Rd`) as in the ISA (for mapping in the RzIL code).
- Ease debugging by tracking in more precision, if an instruction is added to a stale, active or new packet.
- Add registers `C20` - `C29` (not yet present in LLVM)
- Some renaming to make the code more readable.
2024-03-22 07:24:56 +00:00
..
auxiliary Use add_global_arguments instead of passing cflags/ldflags all around (#2812) 2022-07-17 21:33:51 +08:00
cpp Replace rz_core_cmd0 calls in tui/panels.c and port cmd_help commands to RzShell as cmd_math (#3421) 2023-03-30 18:36:48 +08:00
.gitignore
meson.build Move parse into arch. (#4342) 2024-03-07 23:50:22 +08:00
minunit.h Use Rizin specific macros instead of the ones from SDB 2022-07-17 12:11:13 +02:00
mock_io.inl Change len parameter type to size_t in RzIO API (#4012) 2023-12-03 19:28:16 +08:00
rz_arch_buffer.h
rz_test_cmd_test
test_addr_interval.c
test_agraph.c Add (i)CFG node type annotations + bug fix (#4221) 2024-02-14 23:40:00 +08:00
test_analysis_block.c Convert basic block into RzPVector (#4349) 2024-03-10 15:59:15 +08:00
test_analysis_block_invars.inl Convert basic block into RzPVector (#4349) 2024-03-10 15:59:15 +08:00
test_analysis_cc.c Remove hidden static in rz_analysis_cc_max_arg 2024-01-06 23:30:07 +08:00
test_analysis_class_graph.c Add different types of RzGraphNodeInfos. (#4189) 2024-02-09 22:23:36 +08:00
test_analysis_function.c Update tests 2023-06-05 22:41:20 +08:00
test_analysis_hints.c Format according to clang-format-13 2021-11-25 15:44:28 +08:00
test_analysis_meta.c
test_analysis_op.c Initialize RzAnalysisOp properly. (#4350) 2024-03-10 18:26:10 +08:00
test_analysis_var.c Add new API to calculate size of variable (#4028) 2023-12-11 23:21:09 +08:00
test_analysis_xrefs.c Rename RzAnalysisXRefType enum members 2022-05-12 09:24:12 +02:00
test_annotated_code.c Remove rz_pvector_index_ptr (#4351) 2024-03-10 18:40:26 +01:00
test_base64.c test: some base64 unit tests to demonstrate bugs 2023-10-13 09:42:50 +08:00
test_big.c
test_bin_lines.c
test_bin_mach0.c Parse and use dyld chained fixup imports 2023-06-25 19:39:56 +08:00
test_bitvector.c Adding missing operation in bitvector lib and core theory (#4078) 2024-01-08 23:10:14 +08:00
test_buf.c buf_format(): parse format string only once (#4365) 2024-03-17 10:18:56 +08:00
test_cmd.c Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
test_compare.c Port c commands to newshell (#1854) 2021-11-25 17:55:08 +05:30
test_config.c Fix some memleaks in unit tests (#1869) 2021-10-22 09:33:20 +08:00
test_config.h.in test: allow to run unit tests without installation 2022-05-10 16:57:44 +02:00
test_cons.c Remove global RzLine instance 2024-01-07 22:40:25 +08:00
test_contrbtree.c Improve cmd_help.yaml and fix random number generator (#3452) 2023-04-07 20:22:01 +08:00
test_core_analysis_stats.c Refactor rz_core_analysis_get_stats() and fix edge cases (#2645) 2022-05-30 04:59:47 +00:00
test_core_bin.c Refactor the maps in RzBinPlugin from list to pvector (#4081) 2024-01-07 12:42:54 +08:00
test_core_cmd.c core/cmd: just store RzCore reference instead of void *data 2022-08-26 07:53:43 +08:00
test_core_seek.c
test_core_task.c Replace rz_core_cmd0 calls in tui/panels.c and port cmd_help commands to RzShell as cmd_math (#3421) 2023-03-30 18:36:48 +08:00
test_crypto.c Fix plugin removal and clean code (#3277) 2023-01-16 13:32:46 +01:00
test_debruijn.c Finish conversion of w commands to rzshell (#2412) 2022-03-16 11:20:29 +00:00
test_debug.c Add specifiable size for watchpoints and tests 2023-09-16 22:35:20 +08:00
test_debug_session.c Add Hexagon register profile (#2490) 2022-04-03 18:26:17 +02:00
test_diff.c Remove agd and add rz_analysis_similarity/match + refactoring 2022-10-04 20:02:35 +02:00
test_ebcdic.c EBCDIC character support (#1643) 2021-11-22 09:48:57 +08:00
test_endian.c util: rz_endian cleanup and documentation (#3900) 2023-10-05 10:40:00 +08:00
test_event.c
test_file.c Introduce rz_file_dos_basename() API 2022-03-29 09:27:51 +08:00
test_flags.c Make rz_flag_set_next() try the addr before incremental numbers as suffix (#3986) 2023-11-18 23:15:50 +01:00
test_flirt.c [FLIRT] add info extraction 2021-12-23 17:06:55 +01:00
test_float.c Weaken f80 assertions in test_float for non-x86 (#4280) 2024-02-21 15:02:05 +01:00
test_glob.c
test_graph.c Enable generation of inter-procedual control flow graph. (#4001) 2023-12-14 22:34:43 +08:00
test_hash.c Add SM3 hash (#3769) 2023-08-17 21:59:06 +08:00
test_hex.c Document rz_hex_str2bin and add unit tests 2021-11-09 12:01:41 +01:00
test_id_storage.c Fix some memleaks in unit tests (#1869) 2021-10-22 09:33:20 +08:00
test_idpool.c
test_idstorage.c
test_il_definitions.c [RzIL] Add rz_il_value_eq() 2022-01-22 18:40:10 +01:00
test_il_helpers.c Add several common bit operations to RzIL. (#3977) 2023-12-03 17:23:41 +01:00
test_il_reg.c Enable specifying exact reg bindings in RzAnalysisILConfig (#2261) 2022-01-29 09:14:08 +00:00
test_il_validate.c Add a new helper to convert a long double to an 80-bit RzIL float (#4062) 2024-01-03 18:52:58 +05:30
test_il_vm.c rzil: switch event list to pvector (#3928) 2023-10-19 00:20:45 +08:00
test_inflate_deflate.c [FLIRT] Create signatures from RzAnalysis data (#2036) 2021-12-15 19:08:16 +01:00
test_intervaltree.c util: provide rz_time_gettimeofday API (#2811) 2022-07-17 09:57:00 +08:00
test_io.c io: return error when reading/writing to unmapped memory (#3323) 2023-02-11 11:36:27 +01:00
test_io_ihex.c
test_itv.c
test_json.c RzUtil add new API 2023-08-25 23:32:05 +08:00
test_list.c Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
test_log.c test/unit: Add small unit test for rz_log 2022-12-19 11:46:18 +01:00
test_lzma.c Add liblzma subproject 2022-07-02 10:12:26 +02:00
test_ovf.c
test_pj.c
test_rbtree.c
test_reg.c Rewrite RzReg to use RzBitVector 2022-11-01 10:58:16 +08:00
test_regex.c Fix several memleaks in regex.c (#4274) 2024-02-20 11:29:59 +08:00
test_run.c
test_rz_test.c
test_sdb.h DWARF improve DWARF5 support and refactor 2023-08-25 23:32:05 +08:00
test_sdb_array.c Move SDB into RzUtil 2022-07-19 08:45:20 +02:00
test_sdb_diff.c Move SDB into RzUtil 2022-07-19 08:45:20 +02:00
test_sdb_hash.c Remove ../include/rz_util from rz_util_includes (#3935) 2023-10-22 19:38:56 +08:00
test_sdb_ls.c Move SDB into RzUtil 2022-07-19 08:45:20 +02:00
test_sdb_sdb.c Move SDB into RzUtil 2022-07-19 08:45:20 +02:00
test_sdb_util.c Move SDB into RzUtil 2022-07-19 08:45:20 +02:00
test_serialize_analysis.c Convert basic block into RzPVector (#4349) 2024-03-10 15:59:15 +08:00
test_serialize_config.c
test_serialize_debug.c Add specifiable size for watchpoints and tests 2023-09-16 22:35:20 +08:00
test_serialize_flag.c
test_serialize_seek.c Serialize seek history (#3838) 2023-09-10 21:30:30 +08:00
test_serialize_spaces.c
test_serialize_types.c Add missing project migrations tests up to v9 and fix leaks (#3205) 2022-11-27 09:39:10 +08:00
test_skiplist.c Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
test_skyline.c
test_socket.c Rewrite and fix non-libuv tcp server (Rt command) 2022-08-06 13:20:52 +02:00
test_spaces.c
test_sparse.c
test_stack.c
test_str.c Replace current regex engine with PCRE2 (#4185) 2024-02-05 12:51:16 +08:00
test_str_search.c Better false-positives detection in rz_scan_strings (#2691) 2022-06-14 22:14:13 +08:00
test_strbuf.c RzStrBuf: remove weakref related code 2023-08-15 09:00:22 +08:00
test_subprocess.c Add *pty API (#3221) 2022-12-29 20:38:39 +08:00
test_table.c Convert from rz_str_new to rz_str_dup (#4178) 2024-02-07 00:07:53 +08:00
test_task.c
test_threads.c Add thread-safe hash tables (#3491) 2023-05-02 22:11:53 +08:00
test_tokens.c [Hexagon] RzIL uplifiting (#3837) 2024-03-22 07:24:56 +00:00
test_tree.c
test_type.c fix memory leaks in path_walker 2024-03-16 08:56:50 +00:00
test_uleb128.c Fix many pointer/int conversion warnings on arm32 (#2246) 2022-01-25 11:41:17 +01:00
test_unum.c Move bitmask creation to common rz_num_bitmask() 2022-01-23 18:29:31 +01:00
test_util.c RzUtil add new API 2023-08-25 23:32:05 +08:00
test_vector.c [Hexagon] RzIL uplifiting (#3837) 2024-03-22 07:24:56 +00:00
test_yank.c