Commit graph

79 commits

Author SHA1 Message Date
pelijah
706a6bf6c2
sdb: remove unused cas and expire features (#4487) 2024-05-12 18:27:54 +08:00
pelijah
b8ebd5ac42
Add missing vector foreach macros to clang-format cfg (#4456)
* Add rz_vector_foreach to clang-format cfg
* Add other vector foreach macros
2024-04-22 07:16:46 +08:00
billow
ea460e54c2
DWARF: fix type process with the same name (#4454)
* DWARF: Remove memory allocation for RzBinDwarfLocListEntry->range
* DWARF: fix type process with the same name
2024-04-21 22:56:22 +08:00
Florian Märkl
eeda6b1b59 Remove RzFlag.base
The only place where this field was set to a non-zero value was the now
removed fb command, and it was never used for anything sensible. Thus it
is safe to remove.
2024-04-04 13:22:57 +02:00
Florian Märkl
c7f670296f Add missing tests for 15->16 migration 2024-04-04 13:22:57 +02:00
pelijah
576d4b8a5e
Fix several memleaks in DWARF related code (#4391) 2024-03-26 22:11:08 +08:00
z3phyr
de4a3c7419
Enhance dmht tcache command (#4355)
- Add tcache heap heuristics
- Fetch glibc version from libc
- Add unit testcases for glibc version

Co-authored-by: Giridhar Prasath R <giridh1337@gmail.com>
2024-03-22 11:00:58 +08:00
Giovanni
461a2fed87
Remove rz_pvector_index_ptr (#4351)
Unlike rz_vector_index_ptr, which is very important, there do not seem
to be any valid usages of rz_pvector_index_ptr in rizin, cutter or
rz-ghidra that could not be replaced by rz_pvector_at.
In case there will be a use-case for it in the future, it can also be
done by rz_pvector_data(...) + i.
2024-03-10 18:40:26 +01:00
Giovanni
c17881ba2f
Initialize RzAnalysisOp properly. (#4350) 2024-03-10 18:26:10 +08:00
Giovanni
c7ddd77546
Remove rz_list_get_top/bottom & rz_list_get_head/tail_data (#4348) 2024-03-09 18:24:23 +08:00
billow
30eef53291 dwarf: refactor
- Remove dwarf's dependency on RzBuffer

- Delete `cdwarf.c` and move dwarfdump (`id`) related functions to their respective modules

- Improved output of dwarfdump (`id`)

- add more DW_AT*

- fix escape

- fix debuglink

- remove cache in RzBinDwarfStr

- replace `rz_bin_dwarf_rnglists_parse_at` with `rz_bin_dwarf_rnglists_get`

- remove rz_bin_dwarf_loclists_parse_at

- fix logging

- cache all escaped strings
2024-03-09 09:41:13 +08:00
Giovanni
64f8a5ae57
Move parse into arch. (#4342) 2024-03-07 23:50:22 +08:00
wargio
d47ceedbd3 Merge rz_asm and rz_analysis into one library but keep deprecated apis.
The tms320c64x has been merged into tms320.
2024-03-07 18:38:49 +08:00
Peiwei Hu
5d053f0448
Refactor the <entries> in RzBinPlugin from list to pvector (#4118) 2024-02-25 19:42:25 +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
Rot127
7558233da1
Prevent creation of node duplicates. (#4233)
Because list-based graph implementation cannot differentiate nodes by their data,
node duplicates are added, if we don't take care of it.
2024-02-15 15:50:22 +08:00
Rot127
7ab605a142
Add (i)CFG node type annotations + bug fix (#4221)
* Read bytes at curr_op->fail/jump into buffer before decoding them.
* Add meta information of iCFG and CFG nodes to dot graph labels.
* Add subtype annotations to CFG and iCFG nodes.
* Test reading of buffer before node to RzAnalysisOp.jump/fail is added.
* Fix CFG tests by adding node type annotations.
* Add iCFG graph with 'alloc' annotations.
* Wrap ascii annotation symbols in brackets.
* Add doxygen to rz_str_append(f)
2024-02-14 23:40:00 +08:00
Anton Kochkov
25fd417a28
Add user pointer to RzListComparator (#4204) 2024-02-11 13:28:33 +08:00
Rot127
fcf4f7182f
Add different types of RzGraphNodeInfos. (#4189)
* Add different types of GraphNodeInfos.

This adds support for multiple graph node infos.
It removes the assumption that information of
a graph node must be some strings and an offset.

* Increase buffer for printing graph node body

* Don't hardcode maximum label size

* Add graph node info for icfg

* Add node type info to CFG.

* Access address members properly for iCFG and CFG nodes

* Update test. Function names are no longer saved.

* Fix reachable double free of label

* Split graph node type from its sub-type to make it less confusing.

* Add integration tests for iCFG nodes.

* Fix, add mising buffer read

* Recognize more calls

* Add test for iCFG generation and its node details.
2024-02-09 22:23:36 +08:00
billow
88f6c787cb
Add cache for source line (#4129)
* Fix DWARF source line file path

* Add cache for source line

* Fix cache for source line

* Optimization

* revert formatting
2024-01-20 15:48:19 +08:00
Peiwei Hu
3a2148e1cd
Refactor sections in RzBinPlugin from list to pvector (#4089) 2024-01-11 12:19:22 +08:00
Peiwei Hu
886dfa5c17
Transition from list to pvector for symbols in RzBinPlugin (#4077) 2024-01-06 19:54:19 +08:00
Peiwei Hu
b43fe31877
Transition of strings in RzBinPlugin (from RzList to RzPVector) (#4052) 2024-01-04 22:23:31 +08:00
Giovanni
8fba9b4189
Force usage of RzList methods instead of direct access of the fields (#4036) 2023-12-18 21:05:57 +08:00
billow
d5d29fcb37
Load symbols in modules from PDB (#4025)
* PDB: add module info parsing
* Refactor PDB component
* Refactor PDB/tpi
* Fix read_pascal_string
* Fix memory leaks
* Add test `Modules from PDB`
2023-12-10 14:14:14 +08:00
billow
bfe19a784b
Create global variables from PDB (#4021) 2023-12-06 13:57:41 +08:00
billow
8b8d5c7769 Fix stack location in composite 2023-11-29 10:29:01 +08:00
billow
947e9b574e
Create global variable from DWARF (#3985)
* Create global variable from DWARF
* Update test
* Add test "Static variables inside function"
* Clean typedb when apply_dwarf
2023-11-19 22:58:50 +08:00
s1gse9v
a667489e3d
Allow configuring bin hashes (#3951)
* Add `bin.hashes.default` config option
* Make rz_bin_file_compute_hashes use `bin.hashes.default`
* Add test `iT3` in `db/cmd/cmd_i` for new feature
* Fix test/integration/test_bin.c
* Because the hashes computed for a given bin are now set by
  cb_binhashes in bin->default_hashes, they have to be set manually in
  test_bin.c
2023-11-05 19:00:28 +08:00
billow
7982454d4c
Load split DWARF (#3833)
- Add `read_debuglink` and `read_build_id`
- Fix `*.dwo` loading
- Try process DW_UT_skeleton
- Fix dwo_id
- Check buffer size
- Add `bin.dbginfo.debug_file_directory`
- Add test "Debugging Information in Separate Files"
2023-10-21 18:51:15 +08:00
billow
19c889f690
DWARF loading '.debug_str_offsets', '.debug_line_str' and relocate (#3848)
* Try Load '.debug_str_offsets'
* DWARF unify names
* Add endian_reader.c to process relocate
* Remove RzBinDwarfLineInfoMask RzBinDWARFFlags and RzBinDWARFOption
* Fix debug_line
* Add .debug_line_str
* RzBinReloc: Add section_vaddr
* Fix info->offset_comp_dir
* Fix convert_raw in loclists and rnglists
* Remove macro `UX_OR` and relocate support for read_address
* Add RzBinDwarfLineHdr->encoding
* Remove macro 'OK_None'
* Fix loclists and rnglists
* Allow void typedef
* Fix DW_AT_name reference DW_AT_specification
2023-09-28 10:15:42 +08:00
Peiwei Hu
2477d90855
Refactor <hashes> from RzList to RzPVector (#3870) 2023-09-18 09:10:19 +08:00
Peiwei Hu
63c7fa5b19
Refactor relocs-related stuff from RzList to RzPVector (#3852)
* also include patch_relocs
2023-09-14 10:46:38 +08:00
Gleb Popov
08091e64b2 Fix the analysis_global_var test when running from the build dir. 2023-09-12 22:00:36 +02:00
Quentin Minster
700c7d898b
Serialize seek history (#3838)
* Save/load seek history ##projects

* Add unit test for seek history serialization

* Bump project version to 15 for seek history serialization
2023-09-10 21:30:30 +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
Peiwei Hu
a5780a3855
Refactor imports-related stuff from RzList to RzPVector (#3781)
+ Switch the member imports in RzBinPlugin from RzList to RzPVector
+ Also switch the member imports in RzBinObject from RzList to RzPVector to meet the refactor of RzBinPlugin
+ Modify the traverse and invocation related to the aforementioned changes
+ Remove the deprecated API rz_bin_get_imports
2023-08-24 16:14:32 +08:00
Gleb Popov
30ba928f54 test/unit/test_analysis_var: Use types DB from the build dir. 2023-08-03 15:35:25 +08:00
Anton Kochkov
8e41d975bf
Easier API for creating global variable (#3655) 2023-07-11 20:53:34 +08:00
Anton Kochkov
8c1ce710e1
Remove type links and use global vars (#3618) 2023-07-03 02:02:12 +08:00
billow
d0732c5c88 Update tests 2023-06-05 22:41:20 +08:00
billow
c0154a26a0
Fix function arguments augmentation with DWARF (#3530)
* Add `VariableKind` to Dwarf `Variable`
* Refactor `rz_analysis_dwarf_integrate_functions`
* Add `RzAnalysisVarKind` to `RzAnalysisVar`
* Add function parameters tests for x86, ARM, Tricore
2023-05-30 16:40:09 +08:00
billow
9497f711eb
Add project migrate v12 (#3515)
* Revert rzdb change in 59f32b6db8
* Add `rz_project_migrate_v11_v12` and integration test
* Add v12 rzdb
2023-05-17 06:28:39 +08:00
Anton Kochkov
309398b1ca
Add RzBin symbols API test (#3458) 2023-04-13 19:35:41 +08:00
brightprogrammer
16e722cffc
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
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
d9950f7479
Replace bp/sp-vars by generic stack-based ones (#3167)
Variables on the stack are not identified by bp/sp+<offset> anymore, but
by their address from the bottom of the stack frame (RzStackAddr),
independent of how they are accessed.
So now there are only two kinds of variables: stack and register.

This required some major refactoring and other changes:
* RzAnalysisVar.isarg was removed. Whether a variable is an argument is
  now specified implicitly by its storage location.
* Varsub of struct fields had to be rewritten so fields can be queried
  by arbitrary stack addresses using the recently introduced sp
  tracking, as the old approach to fill a list with all fields would not
  work anymore.
* analysis.vars.stackname was removed, new behavior is more similar to
  this being true before.
* Variables will not be created at stack+0 now, because the return
  address is there. Before, vars were only created sometimes in such
  cases.
* Variables created from bp offsets in x86 are not deleted anymore if
  the function's bp_frame is false (see removed
  rz_analysis_function_delete_vars_by_kind(fcn,
  RZ_ANALYSIS_VAR_KIND_BPV); calls). This may lead to some
  false-positive detected variables. Whether this really is a practical
  issue is yet to be seen. At least there are no meaningful tests that
  are broken by this.
* Applying variables from dwarf needed some fixes for determining the
  correct stack locations of variables in order to write meaningful
  tests. The handling is still not entirely correct for all
  possibilities of dwarf info, but at least the changed/added test cases
  are right and serve as a reference for future changes.
* Projects version 11 is introduced.
* afvb commands have been removed, afvs now handles all stack vars.
2023-01-02 11:36:21 +08:00
Dhruv Maroo
61e8ace32a
Fixing some Coverity issues (#3261)
* Use signed long long for `src_readlen`, so we can check for -1

    * Fixes Coverity defect 396947 and 356103

* Replace Unicode quotes with ASCII

* Ue signed structure in case -1 is returned (CID 396933)

* Need signed to check negative (CID 395560)

* Fix memleaks in `test_autocmplt_global`

    * Related CIDs: 356309, 356307

* Set initial value of `ret` to false
2022-12-31 16:57:19 +08:00
Florian Märkl
13cd3942d1
Rewrite stack pointer tracking and storage (#3207)
The stack pointer was previously already tracked during analysis for
variables and their accesses, but not stored in any sensible form for
further use. RzAnalysisBlock.stackptr and parent_stackptr were used in
some places, but they had no evident meaning.
Now we store the sp at the entry of a basic block and the difference
from that for every instruction inside the block to allow for efficient
querying of the sp value at arbitrary analyzed addresses.
RzAnalysisFunction.stackptr is now deprecated as its previous use was
primarily as a temporary accumulator, which is now handled locally, but
full removal of it would go beyond the scope here.

asm.stackptr visualizes both the absolute sp value and the delta of each
instruction in disassembly.

Changes in librz/analysis/p fix some test cases with the new tracking.

Introduces project version v10 with sp_entry/sp_delta instead of
stackptr/parent_stackptr.
2022-12-23 15:01:15 +01:00
Florian Märkl
6479bd53ab
Add missing project migrations tests up to v9 and fix leaks (#3205)
Even though many of the migrations were trivial, for all previous
versions X it is important to have both tests for X->X+1 migrations
and loading X in current rizin.
See leading comment in test_project_migrate.c for details.
Leaks detected by these tests were also fixed.
2022-11-27 09:39:10 +08:00