Commit graph

24 commits

Author SHA1 Message Date
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
c89b12a046
Removed plenty of eprintfs in rz_core (#2950) 2022-08-29 00:32:17 +08:00
billow
6a7cb865b4
Fix OOB in overlapping variables resolution (#2222)
* Fix a crash during variables type propagation
* Fix test int64_t variable overlapping removal

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2022-01-25 10:14:54 +01:00
Florian Märkl
f9e01ba07d [RzIL] Rewrite RzAnalysisRzil as RzAnalysisILVM with config
RzAnalysisILVM wraps around the low-level RzILVM and enables emulation
of real code from disassembly, rather than raw IL.
Analysis plugins now don't actively initialize the vm anymore, but
return a fully declarative description RzAnalysisILConfig of how to set
up the vm and optionally its initial state.
This also enables multiple IL vms to exist at the same time as plugins
can not mess with the global vm anymore. See the added integration test
for an example.
2022-01-17 16:50:40 +01:00
Florian Märkl
9b60670013 Prepare various RzReg accesses for splitting
Common accesses for both debug and analysis must not use
debug->reg or analysis->reg, but go through rz_core_reg_default().
2021-12-21 13:14:08 +01:00
Riccardo Schirone
21584e416c Initialize retctx,ctx before freeing the inner elements
In rz_core_analysis_type_match retctx structure was initialized on the
stack only after a "goto out_function", where a field of that structure
was freed. When the goto path is taken, the field is not properly
initialized and it cause cause a crash of Rizin or have other effects.

Fixes: CVE-2021-4022
2021-11-27 00:48:44 +08:00
Heersin
e0d3d6bc66
New RZIL integration (#1663)
The new intermediate language is based on the BAP (Binary Analysis Platform) Core Theory.
It operates on SMT-like bitvectors and their arrays to represent values and memory.
Apart from that, it has also representation for the data and code side effects.
2021-10-09 18:14:44 +08:00
Khairul Azhar Kasmiran
1354473f81
Add RZ_IL namespace to TRACE_INS_HAS_* enums (#1557) 2021-08-31 00:42:24 +08:00
Anton Kochkov
8b7822bd58
Fix some of the Coverity reports (#1501)
* Fix CID 355574
* Fix CID 355087
* Fix CID 354877
* Fix CID 354875
* Fix CID 354868
* Fix CID 354874
* Fix CID 354666
* Fix CID 354864
* Fix CID 354665
* Fix CID 354646
* Fix CID 352578
* Fix CID 352571
* Fix CID 352553
* Fix CID 352501
* Fix CID 352494
2021-08-23 18:38:37 +08:00
Anton Kochkov
3d9baa149d
Fix some of the Coverity issues in types and analysis code (#1474)
* Fix CID 354663
* Fix CID 352572
* Fix CID 352560
* Fix CID 352557
* Fix CID 352537
* Fix CID 352536
* Fix CID 352490
* Fix CID 352488
* Fix CID 352486
* Fix CID 352484
* Fix CID 352480
* Fix CID 352475
* Fix CID 352471
* Fix CID 352464
* Fix CID 352461
* Fix CID 352455
* Fix CID 352452
* Fix CID 352448
2021-08-18 15:19:08 +08:00
Paul I
528459fbab
Fix several memleaks (#1473)
* Fix several memleaks
* Fix another one memleak in type_match()
* Fix memleak in rz_core_analysis_type_match()
2021-08-18 09:22:43 +08:00
Anton Kochkov
c5052041a5
Fix function type derivation memory leak (#1467) 2021-08-17 17:34:41 +08:00
Paul I
0c3da795a1
Fix several memleaks (#1435)
* Fix memleak in rz_core_analysis_type_match()
* Fix memleak in rz_type_typeclass_get_default_sized()
2021-08-11 12:50:11 +08:00
Heersin
d7d2c053ea
Migrate ESIL trace to use vectors instead of SDB (#1410)
* Migrate SDB ESIL trace storage to RzPVector and ht_uu_*
* Remove {dtek} command and outdated TODO
* Fix a bug which causes type info lost
2021-08-10 13:03:33 +08:00
Basstorm
8b065fc06c
Migrate the constrained type from RzAnalysis to RzType (#1397) 2021-08-04 16:08:54 +08:00
Anton Kochkov
3c59df7e98
Refactor RzTypes to use structs instead of SDB + New Tree-Sitter based C Parser (#1047)
- Removed oldshell version of `t` (types) commands
- Removed `tk` command because types storage switched to the hashtable
- Added `tfc` command to show the calling convention of the function or set it
- Added `tsl` (RZ_OUTPUT_MODE_LONG) to show structure members' sizes and offsets
- Added `tul` (RZ_OUTPUT_MODE_LONG) to show union members' sizes
- Switched the types storage to the hashtable instead of SDB
- Added load and export from/to SDB for standard type libraries and serialization for Projects
- Changed all `char *type` occurences to the proper `RzType`
- Added `RzCallable` type for the function/class method types
- Changed all function types API to use the `RzCallable` API
- Switched the function types (`RzCallable`) storage to the hashtable instead of SDB
- Added a connection between `RzAnalysisFunction` and `RzCallable` - `rz_analysis_function_derive_type()` API function to derive new `RzCallable` type from the `RzAnalysisFunction` even if it doesn't exist in the RzTypeDB.
- Moved type links to the RzAnalysis where they belong
- Removed TCC and MPC-based parsers
- Added Tree-Sitter-based parser for C grammar (see `librz/type/parser/*`)
- Reworked type databases in `librz/analysis/d/` to be consistent with C standard, libc, platform-specific definitions
- Switched the type links from `char *` to `RzType`
- Switched the type links from SDB to the hashtable
- Added concept of the "type paths", e.g. `a.b[20].c` where `b` is a member of `a` (`a` is either structure or a union) and `c` is a member of `b`, and `b` is an array where we take 20-th element.
- Added concept of the typeclasses (a bit similar to Haskell) for numerical types: `None` (the most generic one), `Num` (includes `Integral` and `Floating`), `Integral` (includes `Signed Integral` and `Unsigned Integral`), `Floating`.
- Added concept of type equality (`rz_types_equal(a, b)` API function)
- Added Doxygen documentation to every API function in the `librz/type/*`.
- Updated the project format from **V2** to **V3**, added migration.
2021-07-20 01:46:45 +08:00
Anton Kochkov
788fdb3d8e
Extracting types handling into RzType (librz/type) ##refactor (#896)
* RzType introduction
* Move format processing to RzTypes from RzUtil
* Rename RzType to RzTypeDB
* Join RzType and RzAnalysis noreturn functions
* Add noreturn column in `aflt` output
* Remove D (disassembly) pf tests
* Fix `tn` test
* Add function noreturn serialization
* Modify meaningless type test
* Fix wrongly written `Cf` test
* Fix `za t` (zignature type) command
* Fix signature type test
2021-04-06 18:04:00 +08:00
Paul I
8d9b2be0c9
Reuse analysis data in rz_core_analysis_type_match() (#795) 2021-03-23 11:41:13 +08:00
Riccardo Schirone
53bf5c497f SPDX Copyright text for all files based on history
- Add LICENSES directory
- Download additional licenses used
- Add .reuse directory
- Add doc about SPDX/reuse

Co-authored-by: Florian Märkl <info@florianmaerkl.de>
2021-03-05 19:39:15 +08:00
ChD1
0e97b00ae2 Fix memory leaks and small logic bugs (#18297) 2021-02-03 19:27:30 +08:00
Anton Kochkov
a0be4e2e64 Run clang-format 2021-01-21 22:05:44 +08:00
Dennis Goodlett
4e081a714b Prevent corruption of ##types __var_retype (#18017) 2020-12-14 11:23:54 +01:00
Florian Märkl
d53d1e3845
Final Analysis Renaming (#124)
* Rename missing Analysis Defines
* Rename analysis config vars and other lower case stuff
* Rename test/db/analysis
* Fix analysis tests

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2020-12-08 15:05:24 +08:00
Anton Kochkov
ad36954adb
More renames of *anal* to *analysis* (#123) 2020-12-07 13:20:29 +01:00
Renamed from librz/core/anal_tp.c (Browse further)