Commit graph

27091 commits

Author SHA1 Message Date
Anton Kochkov
5b38d04bfb
Use GitHub mirror for TinyC compiler (#2202) 2022-01-13 21:21:12 +01:00
Florian Märkl
a7d3875cf5 Remove Capstone 6502 plugins in favor of our own 2022-01-14 00:47:33 +08:00
Florian Märkl
4f1e4ee6d5 Add asm tests for all legal 6502 ops
Ops with relative addressing now also only pad with 4 leading zeroes.
2022-01-14 00:47:33 +08:00
Khairul Azhar Kasmiran
4a9d3f2438
Fix #2135: Add ..( command (#2184)
* Fix #2135 - Add `..(` command
* Use `RZ_LOG_ERROR` instead of `eprintf` inside `macro_call()`
* Improve `(?`
2022-01-13 18:10:23 +08:00
Giovanni
e90d770e4a
Fix muon issue due type casting (#2198) 2022-01-12 18:37:21 +01:00
Florian Märkl
ca301b9a24
Add support for DYLD_CHAINED_PTR_ARM64E_USERLAND24 (#2197)
Original commit: 169c643a7ad7a1978ff39fba0c326bd26c9f1d4c
Original author: Francesco Tamagni <mrmacete@protonmail.ch>
2022-01-12 16:44:12 +01:00
Florian Märkl
4185ee34cf
Add asm auto-fix and diff to rz-test (#2196) 2022-01-11 19:41:53 +01:00
Riccardo Schirone
afc635f6d1
Convert om commands to rzshell (#2192)
* removal of `omo` command
* use of `oml`, `oml.` and `oml=` to list maps instead of `om`
* removal of RIZIN output from `oml`
* removal of `omn.` and just assume `omn` uses core->offset
2022-01-11 17:29:20 +01:00
Florian Märkl
c8a6359d83
Change IL string syntax to s-expressions (#2193)
Before:
	store(key:var(v:ptr), value:add(x:load(key:var(v:ptr), mem:0),
	    y:int(value:1, length:8)), mem:0)
After:
	(store 0 (var ptr) (+ (load 0 (var ptr)) (bv 8 0x1)))

S-Expressions like this are more concise and will be trivial to parse,
in case we want a parser for this later. It is also very similar to what
BAP uses, so it will be easier to compare.
2022-01-11 10:08:41 +01:00
Florian Märkl
7e36f4bd38 Add IL lifting testing to rz-test 2022-01-10 19:27:09 +01:00
Florian Märkl
cd938d2083 Add -I (IL lifting) option to rz-asm
$? is also set to the return value of a command run by ! for testing
this.
2022-01-10 19:27:09 +01:00
Florian Märkl
157e40d65b
[RzIL] Add Validator (Type-checker) (#2182)
This adds the IL validator, which performs static type-checking of both
pure and effect ops among other checks. In particular, assuming the
validator is correctly implemented, if it considers an op to be valid
under some context, evaluating the op in the vm will never yield a
runtime error, that is, an error where the vm itself errors, not an
expected error state of the code being executed. In our case, this
includes for example:

* Any kind of type error: Conditions not being bool, bitvector sizes not
  matching, ...
* Variables not being available when they are accessed Using local
* variables with multiple different types in a single effect etc.

Any code that we lift must obey these rules. Thus, any analysis can rely
on it. The plan for this is to use the validator primarily in testing,
development of lifters and for IL code coming from the outside. If our
lifting code is covered well enough by tests using the validator, we can
omit the validation at runtime.

The only ops that do not have well-defined validation yet are blk and
goto since their semantics, in particular regarding label handling are
still a bit vague. This also removes the concat and unk ops since they
are unimplemented and not needed.
2022-01-10 16:54:13 +01:00
Anton Kochkov
1b2748604e
Fix the RZ_BIN_PREFIX test for Windows (#2189)
* Fix the RZ_BIN_PREFIX test for Windows
* Do not use previous VS2019 image
2022-01-09 13:47:38 +08:00
Florian Märkl
880201d556
Add Documentation for RzIL (#2178) 2022-01-08 16:46:03 +01:00
Anton Kochkov
4487d7e1ac Port fd commands to the rzshell 2022-01-08 10:59:10 +08:00
Anton Kochkov
d80d70a361 Port fz commands to the rzshell 2022-01-08 10:59:10 +08:00
Paul I
dd6de07c96
Convert ac commands to rzshell (#2160) 2022-01-08 10:58:43 +08:00
Florian Märkl
191b9b103d
Fix installing new RzIL headers (#2181) 2022-01-06 10:57:29 +01:00
Rot127
1409025ecf
Adapt basic block analysis for the Hexagon architecture. (#2073)
* Rebase onto branch 'dev' and resolve conflicts.
* Add tests for unmapped jumps.
* Fix test: Flags are correctly detected.
2022-01-05 16:51:44 +00:00
Florian Märkl
54318a2268
[RzIL] Rework Variable Handling (#2174)
There are now three kinds of vars: global, local and local pure. Global
and local pure are exactly like in BAP, local ones are defined by their
initial set op and have the scope of a single lifted instruction.

The set op now handles both global and local vars, let is now pure and
binds only inside its body. Vars have static types, global and local are
always mutable, local pure naturally immutable.

The var op specifies the kind of variable to take from, and the
individual variable sets are separate. This corresponds to BAP's
behavior where the kind of variable is part of the identifier.

Variable content storage has also been rewritten and RzILBag removed.
2022-01-05 11:16:47 +00:00
GustavoLCR
2e065789a7
Fix #1377 - Handle forward definitions in PDB parser 2022-01-05 18:38:02 +08:00
Paul I
263e103fee Remove optional <addr> argument for afb commands 2022-01-05 11:30:16 +01:00
Rot127
63a3fbde2d
Search RzAnalysisOp.analysis_vals[] for xrefs. (#2067)
* Add documentation for 'rz_core_analysis_search_xrefs'

* Search RzAnalysisOp.analysis_vals for references as well.

* Add test case for string search in RzAnalysisOp.analysis_vals.

* Replace int with RzOutputMode to indicate the output mode of the commands.

* Let `rz_core_analysis_refs()` use the `RzOutputMode` enum.

* Split `found_xref()` to `is_valid_xref()` and `print_xref()`.
2022-01-04 18:09:16 +08:00
Florian Märkl
5ddb19c692 [RzIL] Clarify what append actually does
high/low is more descriptive than x/y. Test has also been added.
2022-01-03 17:18:33 +01:00
Florian Märkl
b338949dd4 [RzIL] Fix PC initialization and instruction fetch
Intruction was fetched from possibly outdated RzIL PC.
2022-01-03 17:18:33 +01:00
Dhruv Maroo
386008482f
[RzIL] Implement effects: BLK and REPEAT (#2119) 2022-01-03 12:41:52 +00:00
Giovanni
3e9598d298
RzDiff optimizations and fix #1770 (#2156)
* Added infinite scroll
* Avoid analyzing the whole bin when graph diffing functions
2022-01-03 13:10:44 +01:00
Florian Märkl
c34ae1a7b5
Rename RZIL occurences to RZ_IL 2022-01-03 10:20:11 +01:00
Anton Kochkov
638872ca47
Use API instead of commands in Visual Panels (#2163) 2022-01-03 11:05:22 +08:00
Florian Märkl
9938a85c4b
[RzIL] Add RzReg/Variable Binding (#2155)
Plugins do not create register-based variables themselves anymore, but
they are derived from the register profile. However not all registers
may be bound and not all variables may be actual registers. The concrete
relations between an RzILVM and registers is described by an
RzILRegBinding object. It is simply a list of register names and
variables are created of the same names. When stepping with aezs, the
registers are synchronized automatically. From now on, aezv is primarily
useful for debugging, but interacting with emulation from the user side
should be done with ar.
2022-01-02 17:56:19 +00:00
Anton Kochkov
9c18ea0dc6
Port ft commands to the rzshell (#2162) 2022-01-03 00:33:01 +08:00
Khairul Azhar Kasmiran
e0fe262360
Show error if no-arg macro is called with args (#2161) 2022-01-03 00:26:36 +08:00
Paul I
cdb4832cc8
Use analysis_get_function_in() wherever possible (#2157) 2022-01-01 11:54:17 +08:00
Pedro-Bernardo
4f9fe46b34
Fix optype-to-string conversion (#2158) 2022-01-01 01:35:29 +08:00
Giovanni
0ad92708d7
[RzIL] Fix shift, definitions and export (#2159) 2021-12-31 16:00:44 +01:00
Florian Märkl
e91f3a64d1 [RzIL] Various Renaming and Restructuring
rzil should be either rz_il when prefixed for Rizin API, or just il
whenever it's used in some local identifier/name.
In addition, the unclear notion of "vm_layer" has been removed. The VM
source files are split into management and evaluation instead.
2021-12-30 18:53:41 +01:00
Florian Märkl
7a8d5af180 [RzIL] Add rz_il_op_new_(unsigned|signed)() 2021-12-30 10:21:45 +01:00
Florian Märkl
97aba39cf3 [RzIL] Add rz_il_op_pure_dup()
This dups a pure opcode, in particular to be able to reuse a single
expression multiple times in lifting. For effects, we do not neet this
so far since those usually only appear a single time.
2021-12-30 10:21:45 +01:00
Paul I
f8d222e138
Convert ah commands to rzshell (#2130) 2021-12-30 12:44:51 +08:00
Riccardo Schirone
ae081043d9
Update rzshell.md (#2150) 2021-12-30 10:11:32 +08:00
Florian Märkl
86a7439519
Add IO/Map-based RzBuffer Implementation (#2147)
This adds an RzBuffer implementation that binds against RzIO's
rz_io_read_at/rz_io_write_at in order to access the mapped memory. This
is in contrast to the previous io RzBuffer, which has been renamed to
..._io_fd and which reads directly from a single file descriptor without
mapping.
To keep bf working, bin_bf now maps an area of zeroes because
otherwise the initial memory contents in RzIL would read as 0xff.
2021-12-29 10:28:55 +01:00
Florian Märkl
5d93ca3330
[RzIL] Flatten out all RzILOpArgs* structs (#2151)
This reduces heap usage and indirection.
2021-12-28 20:47:10 +00:00
Florian Märkl
aa80d2870f
[RzIL] Make cast work as in BAP (#2152) 2021-12-28 21:22:30 +01:00
Florian Märkl
f9a41796bf
Fix overlapped memcpy in sparse RzBuffer (#2148) 2021-12-28 17:51:38 +01:00
Florian Märkl
d556d57d3f [RzIL] Fix minor leaks 2021-12-28 13:37:54 +01:00
Florian Märkl
6a09385746 [RzIL] Remove vector-oplists in favor of seq
The root type of a lifted op is now simply a single RzILOpEffect, which
can be for example a chain of seq ops. This is in line with what BAP
uses.
For convenient creation of sequences, `rz_il_op_new_seqn(ut32 n, ...)`
is a drop-in replacement for `rz_il_make_oplist(ut32 n, ...)`.
2021-12-28 13:37:54 +01:00
Florian Märkl
20ed5b924f [RzIL] Remove unused ct_opcodes table 2021-12-28 13:37:54 +01:00
Paul I
5b11e88736
Fix several memleaks (#2143) 2021-12-27 18:19:34 +01:00
Paul I
6fca51c6cb
Convert afn commands to rzshell (#2139)
* Convert afn commands to rzshell
* Remove oldshell help for afn
2021-12-27 18:19:01 +01:00
Florian Märkl
78025648ea
[RzIL] Make RzILOp statically typed (#2140) 2021-12-27 00:13:24 +08:00