Commit graph

1997 commits

Author SHA1 Message Date
Anton Kochkov
38c3bed6c9 librz/arch/tms320/c5x: classify BSAR as a right shift in analysis
Some checks failed
Code scanning / build (CodeQL-cpp) (push) Has been cancelled
Code scanning / build (CodeQL-javascript) (push) Has been cancelled
Code scanning / build (CodeQL-python) (push) Has been cancelled
Mixed linter and checks / changes (push) Has been cancelled
Mixed linter and checks / licenses (push) Has been cancelled
Muon build / ubuntu-muon (push) Has been cancelled
TinyCC build / ubuntu-tcc-test (push) Has been cancelled
Mixed linter and checks / clang-format (push) Has been cancelled
Mixed linter and checks / prettier (push) Has been cancelled
Mixed linter and checks / cmd_descs_yaml_check (push) Has been cancelled
Mixed linter and checks / bindgen-linter (push) Has been cancelled
Mixed linter and checks / python (push) Has been cancelled
BSAR (Barrel Shift ACC Right) was grouped with the left-shift ops and
reported RZ_ANALYSIS_OP_TYPE_SHL. It shifts the accumulator right (1..16
bits, sign-extended under SXM), so it belongs with the SHR group next to
RORB/SFRB. The decode (shift code + 1) was already correct and continues
to match the reference disassembler bit-for-bit.
2026-08-17 01:53:33 +08:00
Anton Kochkov
ad462e7ede librz/arch/tms320: add TMS320C5x RzIL lifter
Lift the TMS320C5x instruction set to RzIL. Shared-semantics
instructions reuse the C2x lifter (the C5x-only forms that are a renamed
C2x op, such as the delayed branches, map onto their non-delayed
equivalents); the C5x-only core instructions (the ACCB accumulator-buffer
loads and logical ops, the swap, the zero-accumulator forms, the control
bits and the store-long-immediate) are lifted directly. Instructions with
effects the per-instruction RzIL cannot model cleanly (conditional
control transfers, block moves, parallel-logic, memory-mapped register
access, the MAC fetch forms) are decoded and analysed but left without
IL. Wired into the analysis plugin's il_config under cpu "c5x", with the
C5x register bindings (ACCB and the C5x-specific registers). The asm
tests assert the lifted RzIL, with execution tests covering the IL VM.
2026-08-17 01:53:33 +08:00
Anton Kochkov
79bec39195 librz/arch/tms320: add TMS320C2x RzIL lifter
Lift the TMS320C2x instruction set to RzIL: the 32-bit accumulator and
product paths, the auxiliary-register file with all indirect addressing
modes, the status bits (carry, overflow, OVM saturation, SXM sign
extension, product-mode shifts, TC), and the load/store, multiply,
accumulate, shift, logical and control-flow instructions. Wired into the
analysis plugin's il_config under cpu "c2x". The asm tests now assert the
lifted RzIL for every instruction, with execution tests covering the IL
VM end to end.
2026-08-17 01:53:33 +08:00
Anton Kochkov
148b54a9fc librz/arch/tms320: add TMS320C5x disassembler and analysis
Add the real TMS320C5x (C50/C51/C53) object encoding. The C5x is
source-compatible with the C2x but encodes instructions differently, so
it cannot reuse the C2x decode table: a dedicated C5x decode front-end
fills the shared C55 instruction representation, carrying the C2x ids for
shared-semantics instructions (so the common consumers apply unchanged)
and new C5x-only ids for the C5x additions (ACCB ops, parallel-logic,
memory-mapped register access, conditional execute/call/return, block
moves, ...). Wired into the tms320 asm and analysis plugins under cpu
"c5x", with the C5x mnemonic and op-type tables and register profile.
Includes disassembly and opcode classification tests.
2026-08-17 01:53:33 +08:00
Anton Kochkov
7b36a031ca librz/arch/tms320: add TMS320C2x disassembler and analysis
Add support for the legacy TMS320C2x (C25-class) fixed-point DSP family
to the shared C55 decode-IR engine: the C2x opcode table, operand
extractors, mnemonic and op-type tables, and the register profile, wired
into the tms320 asm and analysis plugins under cpu "c2x". The decoder
fills the shared C55 instruction representation so the common formatter
and analysis filler apply unchanged. Includes disassembly and opcode
classification tests, plus a COFF-loading test exercising the new bin
autodetect.
2026-08-17 01:53:33 +08:00
Anton Kochkov
fee84c7f5c librz/bin/coff: scale addresses on word-addressed TI targets
The C54x and C28x address 16-bit words, so their loadable section sizes
and every address in the file count words. Rizin's address space is
byte-based, so reading those unscaled mapped only half of each loadable
section and placed every symbol at half its true offset: _main in the
c54x emulateme object landed mid-instruction instead of on its prologue.

Scale section VAs, loadable section sizes and symbol addresses by the
target's address unit. Debug sections are byte streams even on these
targets and keep a scale of one, matching the loadable mask already used
for mapping. The C55x addresses program memory by byte and is left
alone; the ids were checked against the objects in rizin-testbins by
comparing each section's declared size against its extent in the file.

Branch and call targets on the C54x count program words too, and reached
analysis and RzIL unscaled. That went unnoticed while the sections were
half-mapped: the emulateme RzIL test ran from a mid-instruction address
whose decode happened to lift, so it pinned values produced by garbage.
Scale those as well and drive the test the way its C55x sibling does,
decrypting seckrit with the real key.

With the sections fully mapped, analysis now finds every routine the
c54x fixtures declare, so the function counts change.
2026-08-17 01:53:33 +08:00
SSharshunov
5e0afe5402
[c166] Fix CIDs (overflows) (#6599)
CID 911455

CID 911454

CID 909873
2026-08-12 12:04:56 +00:00
Rot127
38d0a78e36
Add example to change the search prefix temporarily. (#6662) 2026-08-12 09:24:25 +00:00
billow
19b1783c88
Improve RzIL floating-point support (#6626)
The `RzFloat` changes fix or improve:

- binary80 explicit-integer-bit, pseudo-value, infinity, and NaN handling;
- binary16 conversions;
- gradual underflow and directed rounding;
- overflow, underflow, invalid-operation, and inexact exception reporting;
- exception propagation through nested conversions and arithmetic operations;
- binary80 fused multiply-add rounding, including reduced-precision and double-rounding edge cases;
- thread-local SoftFloat state, preventing rounding state from leaking between threads.

The `RzIL` changes add scoped binary80 precision support through `RzFloatRPrecision` and `FWITH_RPREC`. The supported precisions are 32, 64, and 80. Precision scopes restore the
previous thread-local SoftFloat state after successful evaluation and evaluation failures.

Runtime rounding modes are represented explicitly by dedicated pure opcodes:

- `FCONVERT_WITH_RMODE`
- `FROUND_WITH_RMODE`
- `FSQRT_WITH_RMODE`
- `FADD_WITH_RMODE`
- `FSUB_WITH_RMODE`
- `FMUL_WITH_RMODE`
- `FDIV_WITH_RMODE`
- `FMOD_WITH_RMODE`

Their rounding-mode operand is a 32-bit IL bitvector whose values correspond to `RzFloatRMode`: RNE, RNA, RTP, RTN, and RTZ. Invalid operand widths are rejected by validation,
while invalid runtime values cause evaluation to fail with an error.

Dedicated opcodes keep runtime-controlled floating-point expressions compact. This is useful for architectures whose rounding mode is selected from register state and avoids the
expression duplication caused by expanding every operation into nested `ITE` branches.

The new operations are supported by:

- construction, duplication, and destruction;
- type and operand validation;
- VM evaluation;
- plain, Unicode, and JSON exporters;
- graph output and opcode stringification.

`FEXCEPT` now emits a VM event only when the queried exception is present, while preserving exceptions raised by nested conversions and arithmetic operations.
2026-08-10 01:06:17 +08:00
Rot127
6f264e7019
Improve default behavior of string search (NUL = new line) (#6573)
* Allow to set dotall and multiline flag also for normal regex patterns.

* String search sees NUL as newline by default.

That is the most intuitive option for binary searches.
The behavior can still be changed. An example us added.
2026-08-05 17:18:11 +00:00
Rot127
e8818d1888
Bump Capstone v6 to Alpha10 (#6644)
* Bump Capstone v6 to Alpha10

* Bump capstone-next to latest commit.

* Remove Alpha check for upper case enums.

* Add Xtensa ESP32s3 CPU.

Moves the asm tests to a properly configured test file.

* Document db/asm file naming

* Fix leaks
2026-08-04 13:00:50 +00:00
Khairul Azhar Kasmiran
bceffc3e9f
Fix missing "RUN" in db/rzil/x86 (#6652) 2026-08-01 10:27:02 +08:00
مصطفي محمود كمال الدين
cd413986ac
fix zimg to have sections (#6653) 2026-08-01 10:26:36 +08:00
Naren Sirigere
c85a1fdde7
librz/arch: fix M680x instruction mappings (#6609)
* Fix M680x instruction mappings
* Make the CPU mode checks case insensitive
* Share CPU mode selection
2026-07-31 02:47:50 +08:00
Rot127
f05d8e228b
Fix call flag in CFG json output. (#6639) 2026-07-29 14:54:41 +00:00
Rot127
dd618bb30a
Hexagon fix for abstract interpretation overestimation of jump targets (#6634)
Some checks failed
Manpage lint / mandoc (push) Has been cancelled
Muon build / ubuntu-muon (push) Has been cancelled
Mixed linter and checks / licenses (push) Has been cancelled
Code scanning / build (CodeQL-cpp) (push) Has been cancelled
Code scanning / build (CodeQL-javascript) (push) Has been cancelled
Code scanning / build (CodeQL-python) (push) Has been cancelled
Mixed linter and checks / changes (push) Has been cancelled
TinyCC build / ubuntu-tcc-test (push) Has been cancelled
Mixed linter and checks / cmd_descs_yaml_check (push) Has been cancelled
Mixed linter and checks / bindgen-linter (push) Has been cancelled
Mixed linter and checks / clang-format (push) Has been cancelled
Mixed linter and checks / prettier (push) Has been cancelled
Mixed linter and checks / python (push) Has been cancelled
The jump addresses of call and jump instructions are now written to their own
and unique local variables. Before this, all jump instructions wrote to the
same local variable.

This was a problem for abstract interpretation: Because if multiple writes to
the same local var happen due to a previous TOP condition, the local variable
content is also TOP. If the jump target is TOP, the interpreter can't follow it
anymore.

Added tests for all the funny packet configurations with 0-2 jumps in it.
2026-07-27 22:50:13 +02:00
Anton Kochkov
0d362aab25 test: do not pin a libm pow() result to full precision
% 2**4.5 asserted both the %.17g rendering and the exact bit pattern of
pow(2.0, 4.5). The exact value is 22.62741699796952078...; glibc and the
UCRT return the correctly rounded 0x4036a09e667f3bcd, while FreeBSD and
NetBSD return 0x4036a09e667f3bcc, one ULP low. msun's pow is documented as
under one ULP, not correctly rounded, so the test asserted bit-exact libm
behaviour for a transcendental and could not pass everywhere.

Filter the output down to the rounded line, which every implementation
within one ULP agrees on. The full float/scifmt/hex table stays covered by
the tests whose results are exactly representable.
2026-07-24 10:36:25 +02:00
Anton Kochkov
689bafb7a4
Rewrite the RzNum parser and calculator on tree-sitter (#4326)
Replace the hand-written parser in calc.c with a tree-sitter grammar
(subprojects/rizin-math-parser) and a typed evaluator. The old parser
could only ever produce a ut64 and folded anything it failed to read to
0, which left callers unable to tell a failed expression from one that
evaluated to zero.

Expressions now evaluate to an RzNumValue, a tagged union over ut64,
double, RzBitVector, arbitrary-precision integer and arbitrary-precision
decimal, carrying an RzNumError rather than signalling failure as 0.
Literals keep the width they were written with (5u8, 0xffu128, any width
from 1 to 65536), results that outgrow 64 bits promote to a big number on
their own, and a parse error, division by zero or unresolved identifier
reaches the caller.

rz_num_math() is deprecated. rz_num_math_ut64() keeps its exact behaviour
for callers that want a ut64, and rz_num_math_value() exposes the typed
result. rz_core_math() adds the RzCore-backed form used by the % command,
with rz_core_math_ut64() deprecated alongside it. rz-ax routes through the
typed API, so it prints values at full precision, reports errors on stderr
and exits non-zero. rz_il_lift_num() converts an expression to an
RzILOpPure, so a numeric argument can be lifted instead of pre-evaluated.

Legacy input still works: trailing base suffixes (101b, 35o, 212t), the
trailing-'h' hex form and the k/m/g scale suffixes are all accepted and
warn once, pointing at the 0b/0o/0t prefixes. doc/math.md documents the
language and doc/math-il-lift.md the lift; the grammar, the evaluator,
rz-ax and the % command are covered by unit and db tests.
2026-07-24 02:57:27 +08:00
Farhan Saiyed
fa2db74f86
Change rz_config variables to use Set instead of List (#6623)
* Update rz_config list variables to set variables

* Linking error fix

* Update rz_config_get_options in cautocmpl.c

* Update rz_config_get_options in core/tui/config.c

* Test fix

* Assertion error fix
2026-07-23 15:09:58 +00:00
Farhan Saiyed
78045e8fc6
Fix x-axis address overflow in histogram (#6563) 2026-07-23 15:06:28 +00:00
Florian Märkl
3a22989501
Replace self-jmp in SPARC RzIL (#6632)
To perform the effect in a delay slot, if the branch was not taken, the
IL, which is already lifted as part of the delay slot instruction, would
explicitly jump to itself again, to execute the effect as normal.
This would create erroneous loop edges in the cfg.
It is actually not necessary to perform this jmp since we already have
the lifted effect and can inline it.
2026-07-23 14:57:14 +02:00
MrQuantum1915
6150ac78bc
Fix classification of xrefs as data xrefs(#6612)
While processing xrefs for marking them as data:

1. classify target using `xref_ref_kind` for data section too, previously it was only classified if target was in exec segment. Which caused false positive when the target was in non-exec section. Happens when the immediate value is small and it points in data section.

2. restrict data block from bleeding into other sections. Currently it correctly caps data block  at next "detected" function (or next data) but when the function is not detected yet (like in stripped bins) and the area onward from data ref is empty, the data block bleeds into other sections specifically executable section. This should never happen.
2026-07-21 14:43:58 +00:00
Dmitry Opokin
cd1ad98598
Enhance milstd1750 analysis (#6557) 2026-07-21 16:53:41 +08:00
Farhan Saiyed
12cf18e7b0
unicode version update (#6595) 2026-07-19 17:54:12 +08:00
Jagath P
1d0320367b
Capstone eBPF disassembly (#6611) 2026-07-19 17:51:24 +08:00
مصطفي محمود كمال الدين
faf4afc0e3
Implement file download from the remote machine in GDB protocol (#6576) 2026-07-18 14:49:31 +08:00
billow
ffacc9e08f
Update capstone-next and support Alpha instruction ID variants (#6621)
* Support Capstone Alpha instruction ID variants
* Update capstone-next to ae11e423
* Fix memory leaks in rz-asm
2026-07-17 00:53:43 +08:00
Florian Märkl
1c4bcf6ef7
Fix and test lm32 disasm and replace unsafe string handling (#6620)
Tests are added for covering all edited lines and bugs fixed that were
discovered from these tests.
2026-07-14 16:12:32 +02:00
Khairul Azhar Kasmiran
5d699e8feb
Allow seek to flag realnames (#6593)
Flags are sorted into the name hashtable with their realnames as well.
Refcounting is used to prevent double-free and similar issues that would
be caused by this.
2026-07-14 16:12:05 +02:00
Florian Märkl
9836b05b05 Rewrite unsafe string handling in i8080 disasm 2026-07-13 19:44:09 +02:00
Florian Märkl
f762b37ca8 Replace sprintf usages in 8051 disassembly 2026-07-13 19:44:09 +02:00
Florian Märkl
5353b06952 Replace unsafe string functions in gb plugins
None of these should be exploitable, but we want to get rid of these
unsafe functions.
2026-07-11 15:57:50 +02:00
MrQuantum1915
de80709985
lbrz/core/cmd: fix config print for plugins (#6567) 2026-07-09 22:25:59 +08:00
Farhan Saiyed
d2859bbfdd
Update cconfig.c to make =? behave like =?? (#6546) 2026-07-09 09:58:26 +08:00
wargio
f941f85187 Optimize cmd_0 tests. 2026-07-07 23:14:47 +08:00
wargio
c7dd1a9787 Fix behaviour of pb and ensure buffer is always smaller than block. 2026-07-07 23:14:47 +08:00
NOT XVilka
155ead6822
librz/reg: derive CC with more than four argument registers (#6600)
rz_reg_profile_to_cc() only emitted the first four argument registers
(A0-A3), so architectures that pass more arguments in registers -- the
C6000 EABI uses ten, and x86-64/riscv/ppc all declare more than four --
got a truncated convention. Walk the whole A0-A9 role range, stopping at
the first role the profile leaves undefined, and build the cc string with
RzStrBuf. Covered by a new test_reg unit test.

Co-authored-by agent: Claude/claude-opus-4-8

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2026-07-06 03:35:41 +08:00
Khairul Azhar Kasmiran
4897885c5c
Uniquify function flag realnames (#6601) 2026-07-05 22:33:25 +08:00
Naren Sirigere
3c02fa5618
Fix x64 and x86 SEH analysis (#6558) 2026-07-04 15:46:13 +08:00
Khairul Azhar Kasmiran
6249c2e5f2
Fix tn- <flag> (#6589) 2026-07-04 11:51:58 +08:00
Khairul Azhar Kasmiran
90a2b56509
Fix tn- <hex_number> (#6585) 2026-07-02 11:11:28 +08:00
Naren Sirigere
6dbd1198c8
Recognize objc_msgSendSuper2 and objc rtti information (#6529) 2026-07-02 11:10:20 +08:00
Naren Sirigere
478117db3b
Bump rz-libdemangle to get the dlang demangler (#6566)
Fix check_dlang() to check if the string starts with "_D" followed by any digit
2026-06-28 12:50:08 +08:00
Rot127
39ab034d28
Don't print meta items which are not at the current seek. (#6559)
* Don't print meta items which are not at the current seek.

The old code tried (unsuccessfully) to print _any_ meta item _covering_ the seek (ds->at).

There seems to be several bugs getting triggered with that.
One of them giving the behavior of https://github.com/rizinorg/rizin/issues/6556.

If the current seek is in a _data_ region, the disassembler logic doesn't care.
It just assumes that RzAsmOp.size is equivalent to the size of the objects there.
Even though there are only Meta items.

But since some meta items are like 4K bytes, RzAsmOp.size gets
trimmed down.
Anyways, that completely messes up the size calculation (as can be seen in the issue),
and the navigation.
I couldn't figure out where stuff broke.
But the library closes and I have to leave, so I push that.

That "fix" makes it at least behave somewhat consistently.

* Fix leaks

* Fix and add interactive test
2026-06-27 10:36:12 +00:00
Ashish Kumar
53e8999271
implement shake-128 and shake-256 (#6490) 2026-06-23 11:47:13 +08:00
Dmitry Opokin
9d37b7cdf2
Add MediaTek md1img and GFH firmware image parsers (#5974)
- Introduced md1img.h and md1img.c for parsing MediaTek md1img container format.
- Implemented mtk.h and mtk.c for parsing MediaTek GFH firmware images (md1rom).
- Added plugin support for md1img and mtk formats in bin_md1img.c and bin_mtk.c.
- Updated meson.build to include new source files and plugins.
- Enhanced RzBuffer utility with LZMA alone decompression support.

---------

Co-authored-by: Giovanni <561184+wargio@users.noreply.github.com>
2026-06-22 20:25:48 +00:00
billow
bb3b7cc7b1
Add JSON projection grep (#6522) 2026-06-22 17:17:20 +00:00
Rot127
da228d11cf
Add all call and other xrefs to the abl output (#6269)
* Ensure call targets are only added once for each block.
* Fix abl printing correct xrefs
2026-06-21 13:02:40 +08:00
NOT XVilka
c351d5f32a
librz/cons: new "underwater" color theme (#6538)
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2026-06-20 21:57:01 +08:00
NOT XVilka
06217cd05e
librz/type: fix forward type for enums (#6539)
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2026-06-20 17:32:06 +08:00