Commit graph

70 commits

Author SHA1 Message Date
billow
e72cec47ea
librz/arch: add RZIL support for H8/300 and H8/300H (#5119)
* Refactor H8/300 disassembly plugin
* Add support for H8/300H architecture
* Extract ESIL uplifting for H8/300
* Implement RzIL uplifting for H8/300 and H8/300H
* Add `rz_bits_sign_ext{8,16,32,64}`
2025-08-04 12:40:43 +08:00
NOT XVilka
59a375f7f8
Remove incomplete RISC-V ESIL uplifting (#5273)
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2025-07-18 02:26:00 +08:00
Giovanni
a8bd1dd9f6
Rewrite of RzBin AVR plugin to detect known the vectors and handlers. (#5228) 2025-06-28 19:09:12 +08:00
Rot127
1f6c6147ec Add the Qualcomm Peripheral Image loader (MDT files, 32bit only).
It loads .mdt firmware layout files, searches for the other parts in the same directory and loads them.
It resolves symbols, sections etc automatically, and maps them according to the layout
to the virtual address space.

- The iH command provides details about each firmware part as well.
- Memory maps and segment names are prefixed with the parts file name to make them distinct.
- If a firmware part is an ELF library it loads, and resolves its functions, segments etc.

Due to the design of the ELF binary plugin (code duplication with macros for 32/64bit versions),
this only supports 32bit firmware images for now.
This can relatively easily be fixed, by duplicating this plugin but including the 64bit ELF headers.
This requires more tests though.
2025-06-11 15:41:03 +00:00
Premade
b93153b9f4
librz/bin: improve plugin descriptions (#5199)
* Make bin plugins descriptions uniform
* Refactor: swap desc column with author
2025-06-11 22:41:28 +08:00
Giovanni
181c74f4f2
librz/hash: add descriptions to all crypto & hash plugins (#5194) 2025-06-10 23:21:45 +08:00
Premade
bed6ed17ae
Improve rz-bin -L output (#5190)
* Refactor: improve `rz-bin -L` output

Added `author` + `license` cols
Removed `bin/xtr` col

* Refactor: move `license` column + change table output

moved license column before description
table output for bin/xtr now contains `author` + `license` cols

* Add: author field for `librz/bin/p/*`

author selected on oldest SPDX owner
if same time-period then author is chosen based on git history
2025-06-10 12:05:44 +08:00
Seva D.
915d03e307
Add calculation of total information content and information temperature (#5167) 2025-05-30 00:30:24 +08:00
NOT XVilka
ba8c170852
Migrate from Capstone to Zydis (x86 architecture) (#5164)
* Added build files [Capstone to Zydis]

* x86 Analysis [Capstone to Zydis]

* Changed x86 RzIL [Capstone to Zydis]

* Changed asm and arch files [Capstone to Zydis]

* Compilation, build error and test fixes [Capstone to Zydis]

* Test changes [Capstone to Zydis]

* Remaining changes [Capstone to Zydis]

* Added BE support [Capstone to Zydis]

---------

Co-authored-by: tushar3q34 <tushar3q34@gmail.com>
2025-05-23 13:03:46 +00:00
Giovanni
dbe651db33
Normalize the output of L subcommands (#5077) 2025-04-08 16:46:27 +08:00
Rot127
a17da6c712
Fix: Emitted the license instead of the author. (#5073) 2025-04-06 04:14:14 +08:00
NOT XVilka
30ae60a759
Remove RAP protocol (#5046)
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2025-03-27 00:55:06 +08:00
NOT XVilka
e282e551f3
librz/asm: improve plugin descriptions (#5012)
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2025-03-19 03:14:03 +08:00
Giovanni
cd4cd62084
Add RzIL implementation of MIPS32 ops (#4882)
Implements most of the normal MIPS32 isa from MD00086 Rev 5.04
Breakpoints, syscalls, interrupts, TLB, cache, prefetch and traps are NOP

Does not implement MIPS64, FP, COP2 and HW operations.
2025-02-18 18:07:28 +08:00
Giovanni
b019d9d4ca
Add initial support to loongarch 32/64 (#4810) 2025-01-01 15:36:23 +08:00
Giovanni
f623f70c01
Remove mips.gnu (#4802) 2024-12-28 17:29:34 +08:00
well-mannered-goat
d771043899
cmd: filtering La commands output (#4786) 2024-12-26 23:45:40 +08:00
billow
42302da16d
librz/arch: add Xtensa RzIL support (#4712)
- **Add support for rzIL**: Implement various Xtensa instructions and functionalities.
- **Instruction Set Additions**:
  - **Arithmetic and Logical Operations**: sub*, add*, and*, or*, xor*, mul*, div*, rem*, neg*, abs, addi*, addmi, addexp*, addexpm*, addx2|4|8
  - **Bitwise Operations**: srl*, sra*, sll*, andb, andbc, nsau, nsa
  - **Branching and Jumps**: b*, beq*, bne*, ball, bany, bnall, bnone, j, jx, loop*, loopgez, loopnez
  - **Data Transfer**: st*, ld*, l32*, l16*, l8ui, ssi*, ssa*, src
  - **Floating Point**: sqrt0.s, float.s, floor.s, trunc*, ueq*, ule*, ult*, ufloat*, neg.s, oeq.s, ole.s, olt.s, min, max, clamps, nex
  - **System Calls and Synchronization**: syscall, simcall, entry, isync, dsync, esync, rsync, memw
  - **Miscellaneous**: const_s, extui, extw, excw, sext, witlb, wur, rur.*, mksadj.ss, mkdadj.s, const_s
- **Testing and Patches**:
  - Implement asm tests for all
- **Miscellaneous Improvements**:
  - Update Capstone and fix ARM architecture support for building.
2024-12-26 01:55:38 +08:00
Anton Kochkov
a8da505c5f
DEC Alpha disassembly and analysis plugins (#4059) 2024-11-24 21:17:29 +08:00
billow
c3c494d961
librz/arch: migrate Xtensa to Capstone (#4654)
* Add xtensa arch capstone plugin
* Remove xtensa-gnu
* fix: `asm.cpu` is not set correctly, when there is no “,” in asm plugin -> cpus
* fix core_disassembly when n_bytes==0
* fix xtensa_analyze_op_esil
* fix xtensa esil pc mod
* fix xtensa esil l32r
* fix xtensa esil call0
* fix xtensa esil extui
* fix xtensa esil store
* fix xtensa stack inc and ret
* keep `asm.cpu` when valid in cb_asmarch
* fix cb_asmarch
* fix max op size
* xtensa: add cpu select
* xtensa: mark PUSH POP
* xtensa: set src dst
* xtensa: set dir
* xtensa: fix stackframe
2024-11-11 00:38:54 +08:00
Rot127
30953d3bf6
refactor: Use HtSP for storing plugins. (#4687)
* Refactor: Use HtSP for storing plugins.

This saves iterations when searching for a plugin of a given name.
It also allows to save plugin configurations and data in hash table,
all addressed by their name. Hence, usage is more streamlined.

* Fix: iterators iterate over pointers of pointers.

* Soften the NULL check.

If arch is passed on from another struct, NULL is an allowed invalid value.

* Fix some leaks

* Fix NULL checks and incorrect inits

* Fix more leaks

* Add warning if plugin with same name was added before and is overwritten.

* Document rz_str_cmp

* Add function to create new list from iterator.

* Sort plugins alphabetically when listed.

* Fix parameter attributes, NULL checks, leaks and single rename.
2024-10-26 16:31:13 +08:00
مصطفي محمود كمال الدين
3e258f5a08
arch/msp430: implement RzIL uplfiting (#4379)
Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com>
2024-07-01 19:51:54 +08:00
billow
a02e608075
Fix "pic18 call instructions not detected" (#4532)
* pic18: add test and fix analysis
2024-06-04 12:31:59 +08:00
billow
14e97874a3
pic: add RzIL uplifting (#4322)
- Add uplifters
- Add memory maps for different devices in PIC16F family
- Fix pic18 register mapping
- Fix pic18 asm
- Detect pic arch
- Add pic_archinfo
- Extract ESIL uplifting to a separate file
- Support RZ_ANALYSIS_OP_MASK_DISASM
- Add pic18 emulateme test
- Add pic16 emulateme test

---------

Co-authored-by: brightprogrammer <bshock665@gmail.com>
2024-05-19 12:17:53 +08:00
Anton Kochkov
9526b6c0bc
Remove NIOS-II architecture (#4457) 2024-04-24 20:11:17 +08:00
Rot127
fb6efca4b5
[Hexagon] RzIL uplifiting (#3837)
Uplift Hexagon architecture to RzIL

The general structure is, that every (sub-)instruction has a getter for it's RzIL code.
Calling the getter will return the RzIL operation.
If RzIL for an instruction is requested, the plugin makes a decision. Because Hexagon only executes whole instruction packets. If the instruction is not the last instruction in a packet, it will simply return `EMPTY()`. If the RzIL for the last instruction in a packet is requested, it will get the RzIL operations for all instructions in the packet, shuffles them into the correct execution order (according to some rules) and returns the complete operation for the packet.

The RzIL code was entirely generated with the [rzil-compiler](https://github.com/Rot127/rzil-compiler/), using the semantic definition of the [QEMU Hexagon module](https://github.com/qemu/qemu/tree/master/target/hexagon).

Currently successful compile instructions (and tested):
```
[*] 1581/1733 standard instructions compiled.
[*] 431/643 HVX instructions compiled.
[*] In total: 2012/2376 instructions compiled.
```

It was tested with:
- (Semantic tests) `rz-tracetest` against the execution trace of the QEMU Hexagon test binaries.
- (Bug free and semi-semtantic test) Adding tests which simply execute the test binaries to ensure leak and segfault free execution. Also it is executed until a certain instruction is reached (end of `main` or `loc.pass` symbol), partially testing it executes correctly.

For the uplifting several changes and modernization had to be made:

- Enhance consistency of decoding
  - Allow to disassemble an instruction without copying the result. This is used if the given buffer of instruction bytes is larger than one instruction width. In this case, as many instructions as the buffer can hold are disassembled and buffered for later.
  - Generally enhance buffering of instructions.
  - Allow to mark a packet as valid before it is completely decoded (in case we know it must be valid, e.g. if it is a jump target of a valid packet).
- Fix (hopefully) all memory leaks of the Hexagon plugin.
- Changes to register getters, because RzIL needs finer control to translate alias or explicit register names to their real register.
  - Getter for register name is now done by table, so for future distinction between DSP version we can just select another table.
  - Translation functions from register alias or explicit name to their real register.
  - Each operand contains now it's variable ID (e.g. `d` for register `Rd`) as in the ISA (for mapping in the RzIL code).
- Ease debugging by tracking in more precision, if an instruction is added to a stale, active or new packet.
- Add registers `C20` - `C29` (not yet present in LLVM)
- Some renaming to make the code more readable.
2024-03-22 07:24:56 +00:00
Giovanni
94099b860e
Add RzIL info to rz-asm -L and La (#4369) 2024-03-18 21:16: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
Heersin
5c79c42a56
Disassembler arch for RX microcontroller (MCU) family (#4198)
* Basic framework of rx implemented
* Add match and parse flow
* Add part of description for RxV1 instruction set
* Add datasheet for rxv1
* Implement stringify op for rx
* Add missing TST instruction in datasheet
* Test to div instruction and fix bugs
* Test known rxv1 instruction set
* Fix bugs in rx disasm plugin and add SPDX
* Add rz_analysis for renesas rx
* Fix rz_analysis bug for renesas rx
* Add rz_asm test and fix bug in datasheet
* Add analysis test and fix bugs for renesas rx
2024-02-17 22:29:16 +08:00
Bastian Engel
6df64dbbe8
Renesas RL78 disassembler plugin (#3649) 2023-10-14 00:15:03 +08:00
Giovanni
305a2cb3ae
Add SM3 hash (#3769) 2023-08-17 21:59:06 +08:00
billow
e456c60e20 Fix tests for capstone v3/v4/v5
Co-authored-by: wargio <wargio@libero.it>
2023-07-16 13:22:47 +08:00
Anton Kochkov
f29171ceb1
Remove rzk and gprobe IO plugins (#3654) 2023-07-12 00:21:43 +08:00
swedenspy
655ea987cc
MD2 - hash implementation added according to RFC 1319 (#3585) 2023-06-18 23:01:57 +08:00
billow
6eb14128ad
Adding tricore support for rz_debug_plugin_gdb (#3557) 2023-06-06 12:53:51 +08:00
Anton Kochkov
e924ea7f11
Remove incomplete ESIL support for RSP (#3531) 2023-05-26 14:36:00 +08:00
Anton Kochkov
c7c42afb61
Remove incomplete ESIL support for WASM (#3497) 2023-05-04 16:33:39 +08:00
Florian Märkl
70c1a3e109
Fix some tests for platforms without native debugger (#3278) 2023-01-09 17:57:39 +01:00
wargio
a3b8ed48b7 Remove esil debugger since it is a big todo 2022-12-04 16:53:58 +01:00
Giovanni
3e5217456d
Fix mdmp endianness (#3126)
* MiniDmpHeader & MiniDmpLocDescr32/64 & MiniDmpMemDescr32/64

* MiniDmpException & MiniDmpExcStream

* MiniDmpModule

* MiniDmpThread & MiniDmpThreadList

* MiniDmpThreadEx & MiniDmpThreadExList

* Removed struct minidump_string

* MiniDmpDir

* MiniDmpExcPointers & MiniDmpExcInfo & MiniDmpFuncTableDescr

* MiniDmpFuncTableStream & MiniDmpHandleDataStream

* MiniDmpExcRecord & MiniDmpHandleDescr/2

* MiniDmpHandleObjInfo

* MiniDmpMemList64 & MiniDmpMemDescr64 (init)

* MiniDmpMemInfo & MiniDmpMemInfoList

* MiniDmpMiscInfo

* MiniDmpMiscInfo2

* MiniDmpSysInfo

* MiniDmpThreadInfoList & MiniDmpThreadInfo

* MiniDmpTokenInfo & MiniDmpTokenInfoList

* MiniDmpUnloadedModule & MiniDmpUnloadedModuleList

* MiniDmpUserStream & MiniDmpUserStreamInfo

* MiniDmpIncludeThreadCallback

* MiniDmpModuleCallback

* MiniDmpIncludeModuleCallback

* MiniDmpIOCallback

* MiniDmpReadMemoryFailureCallback

* MiniDmpCallbackOutput

* AVRFBacktraceInfo & AVRFHandleOp & MiniDmpHandleOpList

* MiniDmpObj
2022-10-25 09:37:05 +08:00
wargio
3b19487f87 Cleanup plugin names. 2022-10-23 11:36:17 +02:00
Giovanni
171612c5e1
Add ssdeep hash (#3084) 2022-10-10 17:03:26 +02:00
Giovanni
5b1e5e6762
Support blake3 hash algo (#3030) 2022-09-17 18:38:21 +02:00
Dhruv Maroo
d44b5748eb
[RzIL] IL lifting of SuperH ISA (#2518)
* Add an assembler for the SuperH ISA
	* Rewrite GPL GNU disassembler code
2022-08-02 02:37:03 +05:30
Riccardo Schirone
a689f0a86e librz: refactor a bit how plugins are built
Rely on RZ_ARRAY_SIZE to add librz plugins instead of NULL terminators.
2022-07-20 22:04:02 +02:00
Dean
bf2871c7eb
Add dotnet PE support (#2528)
* Add CIL support

* refactor dotnet parsing to pe/dotnet.c
* parse PE CLR metatables (based on yara implementation)
* use CLR methoddefs to add binsymbols (including method namespace/class)
* parse CLR method headers
* CIL disassembler using .NET opcodes.def
* CIL analysis plugin
2022-06-21 09:20:47 +08:00
Ben Demick
49680257af
Fix default ELF arch for x86 binaries 2022-06-13 21:16:47 +08:00
Florian Märkl
b40dde5fbf
Move DEBUGGER checks from C to meson.build (#2577)
Entire files are now avoided to be built by checking in meson rather
than using #if DEBUGGER. This now also includes bsd_debug.c, which
is currently slightly broken on OpenBSD/sparc64 and caused compile
errors even with -Ddebugger=false.
2022-05-02 11:22:35 +02:00
wargio
5c8db619f7 Implemented dex/dexs/dexe core cmds for dumping dex info like for java 2022-04-12 22:14:05 +02:00