Commit graph

125 commits

Author SHA1 Message Date
Anton Kochkov
3f7a8d382d type/format: do not read float unless asked to 2024-03-03 20:42:21 +08:00
Anton Kochkov
660146d520 type/format: fix union format generation 2024-03-03 20:42:21 +08:00
Anton Kochkov
91702ed767
type/format: fix typedefs self-reference (#4270) 2024-02-19 23:07:16 +08:00
Anton Kochkov
ceefb5e114
Convert pf commands to rzshell (#3467) 2024-02-16 10:30:59 +08:00
Huzaifa
e82033d92c
Convert from rz_str_new to rz_str_dup (#4178) 2024-02-07 00:07:53 +08:00
billow
7842557ac0 Fix rz_base_type_clone_into 2023-11-29 10:29:01 +08:00
Anton Kochkov
221f4da82e
Fix format generation out of types (#3974) 2023-11-14 21:20:16 +08:00
billow
753f9c2367
Stop purge typedb when rz_type_db_reload (#3949) 2023-11-03 14:12:23 +08:00
Riccardo Schirone
3b903caa96
librz: add some initial documentation (#3782) 2023-10-13 13:46:19 +08:00
Riccardo Schirone
9d68e9614f
Fix old math commands (#3828)
* core/cmd: Adjust math commands

* shell: make `?x` commands a parsing failure

We have moved the `?x` commands to `%x`, thus now no command should
start with `?`. This patch makes the parser fail to parse `?x`
strings.

* core/tui: use APIs in panels

* There's no `%q` anymore, use `%=`
2023-09-14 08:53:25 +08:00
billow
8e29b959b8 DWARF improve DWARF5 support and refactor
- `RZ_PROJECT_VERSION` 14
- Add `RzCallable`.has_unspecified_parameters
- Add `RzAnalysis`.debug_info
- Add `RzAnalysisVarStorageType` composite and `eval` `pending`
- Support for parse DWARF section "debug_loclists", "debug_ranges", "debug_rnglists"
- Partial support for eval DWARF expr_loc
- Support for anonymous Type, function variable, struct member
- Cache all DWARF information in `RzAnalysisDebugInfo` and remove `SDB` based caching.
- Add arm32, arm64, TriCore DWARF register name
- Fix same name basetype
2023-08-25 23:32:05 +08:00
billow
ec2cff8451 RzType add new APIs
- rz_base_type_clone_into
- rz_base_type_clone
2023-08-25 23:32:05 +08:00
billow
33dc654265 Add rz_type_db_update_base_type rz_type_func_update 2023-07-30 16:16:52 +08:00
Anton Kochkov
ba84a920ad Improve parsing C syntax up to C23 2023-07-23 19:04:05 +08:00
billow
ff6817e084 Fix multiple memory leaks 2023-06-05 22:41:20 +08:00
billow
94f2fae87e
Fix compile warnings (#3550) 2023-06-02 13:07:51 +08:00
wargio
cc08a23d03 Fix return types and args 2023-05-09 15:42:21 +08:00
Anton Kochkov
51e5868575
Fix crash for union type formatting with unknown member (#3389) 2023-02-21 17:03:19 +08:00
Giovanni
3ae2ea3157
Fix rizinorg/cutter#3117 null deref due unknown type (#3374) 2023-02-17 23:18:58 +08:00
Florian Märkl
953a81afc0
Make afs respect the cc (Fix #3291) (#3292)
Applying a function signature with afs to a function was using a
combination of the existing args and wrong stack addresses to apply the
args to function variables. This generally resulted in incorrect
locations. Instead, we now use the info from the cc.
2023-01-15 13:40:14 +01:00
Florian Märkl
d6bd4a57b0
Remove temporary type string conversion in DWARF integration (#3266)
Due to the DWARF parsing having been implemented before proper RzTypes,
it was still generating C-like strings that we then parsed into RzType.
This is fragile and was identified to be a major performance bottleneck
on OpenBSD/sparc64. Instead, we now generate RzTypes directly where
possible.
There are still cases left where strings have to be generated
from those types to be stored in an SDB. This should be changed in the
future too.

rz_type_pointer_of_type() is now also always creating a pointer type of
the given type. Before, it would have failed when the pointee was an
identifier that did not exist in the database. But this may be a valid
case e.g. while still building the database from DWARF and such
sanitization goes beyond what one would expect from
rz_type_pointer_of_type().
2023-01-05 19:14:59 +01:00
Florian Märkl
fa15d2fbab Fix type bitsizes for struct/union member loops
Even if the case is nonsensical in practice, we can't rule out the
possibility that a struct or union may contain itself as a member
(optionally through multiple recursion steps). This must be caught when
calculating the size of the type in order to not recurse infinitely.
Structs containing pointers to itself are not meant by this, as that is
perfectly valid and the size is determined without recursion.
However typedefs and arrays must be taken into account.
2023-01-04 09:39:10 +08:00
Florian Märkl
5a229ca6a7 Fix rz_type_db_get_bitsize() without specifier and add tests 2023-01-04 09:39:10 +08:00
Florian Märkl
3e75e1f6c7 Rewrite and extend type paths from offset
Tests and extends deriving paths into types at a given offset in the
following ways:
- Parameter for limiting the depth of the path
- Array support, e.g. `.member[5].anothermember`
- Typedef support
- Paths can be taken from arbitrary RzTypes, not only RzBaseType
- Removed the typename in the beginning of paths, which can be added by
  the caller if needed
2022-12-10 11:15:37 +01:00
Florian Märkl
ff778e7507 Unify and fix typedef loop handling
Even if the case is nonsensical in practice, we can't rule out the
possibility that the reference chain induced by a typedef may not
contain a loop, which could lead to infinite recursion when trying to
infer the actual underlying type.
Previously only the case where a typedef points to itself directly was
handled, but loops in multiple steps are possible too. So we introduce
rz_type_db_base_type_unwrap_typedef(), which handles the full
(multi-step) loop-aware unwrapping in one place and use it wherever
needed.
2022-12-10 11:15:37 +01:00
Florian Märkl
86269942d0
Fix leaks in rz_type and tests (#3223)
All leaks detected by running valgrind on test/unit/test_type.
2022-12-04 20:42:46 +01:00
wargio
7685bfe90e remove rz_mem_swaporcopy 2022-10-20 23:12:58 +02:00
Giovanni
3c3ad48545
Ensure double and float uses the proper method to decode it. (#3105) 2022-10-18 17:02:59 +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
Khairul Azhar Kasmiran
06000072af
Fix gcc12 format.c -Wmaybe-uninitialized warnings (#3008) 2022-09-06 20:54:04 +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
wingdeans
a6a7a5f530 Fix annotation inconsistencies 2022-08-03 00:29:56 -04:00
GustavoLCR
35cf52eb14
Fix double free of enum member name (#2817) 2022-07-19 09:20:29 +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
Anton Kochkov
2188b4564d
Various Coverity fixes (#2615)
* Fix CID 392733 - memory leak

* Fix CID 392732 - memory leak

* Fix CID 392730 - memory leak

* Fix CID 392729 - memory leak

* Fix `rz_analysis_diff_free()` API function

* Fix CID 392685 - memory leak

* Fix CID 392012 - use after free

* Fix CID 391968 - uninitialized pointer read

* Fix CID 391966 - memory leak

* Fix CID 391964 - uninitialized pointer read

* Fix CID 390013 - memory leak

* Fix CID 389939 - memory leak

* Fix CID 379249 - memory leak

* Fix CID 378881 - uninitialized scalar variable

* Fix CID 378973 - uninitialized scalar variable

* Fix CID 378850 - uninitialized scalar variable

* Fix CID 371079 - memory leak

* Fix CID 367478 - memory leak

* Fix CID 366821 - memory leak

* Fix CID 366736 - memory leak

* Fix CID 361684 - uninitialized scalar value

* Fix CID 352581 - memory leak

* Fix CID 352557 - memory leak

* Fix CID 348937 - memory leak

* Fix CID 322229 - memory leak

* Fix CID 320122 - memory leak

* Fix CID 317611 - memory leak
2022-05-15 23:15:28 +08:00
Giovanni
423617930c
[dalvik] handle move-exception after gotos/returns and mid op jumps (#2603)
* Fix dalvik analysis by looking for move-exception after gotos/returns
* Fixed Dalvik analysis due compiler optimizations
2022-05-12 13:16:54 +02:00
Riccardo Schirone
ce6ac3e467 meson: use major/minor only in the lib soversion 2022-05-10 21:04:43 +02:00
Giovanni
0dcdc842a2
SDB usage cleanup within rz_bin 2022-05-10 10:27:33 +08:00
Anton Kochkov
b1e48a0c1c
Various Coverity fixes (#2499)
* Fix CID 390322 - memory leak
* Fix CID 390031 - memory leak
* Fix CID 390014 - memory leak
* Fix CID 389941 - memory leak
* Fix CID 389093 - memory leak
* Fix CID 389090 - memory leak
* Fix CID 379250 - memory leak
* Fix CID 378897 - unterminated string
* Fix CID 378854 - memory leak
* Fix CID 373736 - memory leak
* Fix CID 371126 - memory leak
* Fix CID 371089 - memory leak
2022-04-05 22:42:36 +02:00
Anton Kochkov
c860486ce1 Better error message for type redefinition 2022-04-04 15:31:55 +08:00
Riccardo Schirone
3fd578ef7a build: use run_command(..., check: false) as return code is used
run_command(..., check: true) was introduced because of a breaking
change in newer meson versions
(https://github.com/mesonbuild/meson/issues/9300), however Rizin uses
the return code to see if the subproject is in the right state or not.

Revert back to check: false, so that meson will not fail and we can
detect the failure in our meson.build files.

Signed-off-by: Riccardo Schirone <sirmy15@gmail.com>
2022-03-29 16:53:15 +02:00
Florian Märkl
1cbd1d7b31
Introduce addr_bits to type db for e.g. thumb (#2457)
This has the same meaning as rz_analysis_get_address_bits(), i.e. the
size of an address, which is often, but not always the same as the
"asm.bits" bitness, especiall in thumb where it has to be 32, rather
than 16. This fixes pointer size calculation for such cases.

Fix #1835
2022-03-27 15:53:42 +02:00
Riccardo Schirone
57a5ab5d0b Keep targeting meson 0.55 2022-03-25 17:43:56 +01:00
Riccardo Schirone
230652aa98
Add -Wimplicit-fallthrough to meson file (#2438) 2022-03-24 08:27:18 +08:00
Riccardo Schirone
cf56eda58d RzType: variadic argument is now a separate token in the grammar 2022-03-18 17:29:39 +01:00
Peiwei Hu
d7cb78879e
Add hint for unexpected type definition (#2393) 2022-03-14 10:46:59 +08:00
Peiwei Hu
a5cb17c4ed
Fix rz_type_cond_invert (issue 2265) (#2397) 2022-03-10 19:57:44 +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
GustavoLCR
4cf676f91a Add rz_type_base_type_kind_as_string() API 2022-02-25 13:17:20 +08:00
GustavoLCR
2704a00803 Implement rz_type_db_struct_member_offset() 2022-02-13 11:40:31 +08:00