Commit graph

2118 commits

Author SHA1 Message Date
Giovanni
d19fc9d0d8
Add N_THREAD_LIMIT to limit the max number of threads (upper limit). (#4510) 2024-05-24 16:12:08 +08:00
Giovanni
60657d7780
Fix NULL dereference due invalid command. (#4511) 2024-05-23 16:47:42 +08:00
wargio
bce7bd76c1 Refactoring rz-test to use thread safe functions. 2024-05-22 22:27:41 +08:00
Khairul Azhar Kasmiran
84e63af3d2
rz_core_task_join: Return fine-grained error values (#4505) 2024-05-22 12:03:35 +08:00
timiv
c7464ab983
Support ARM ELF THM_PC22 / THM_JUMP24 relocs (#4503)
* Support ARM ELF THM_PC22 / THM_JUMP24 relocs

This revision adds proper support for the following ARM ELF relocations:

- RZ_ARM_THM_PC22
- RZ_ARM_THM_JUMP24

These require a rather special encoding as some bits of the relative
offset are encoded in a non-common fashion.
2024-05-21 07:12:32 +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
pelijah
9c34738977
Remove SdbList (#4496) 2024-05-17 19:23:04 +08:00
Peiwei Hu
48c2c5f287 Add file percentage in visual mode (V/Vv) 2024-05-17 18:06:50 +08:00
pelijah
01203509ff
Add extended insert/update methods for HT (#4489)
* Return more info from HT insert/update methods

* Fix bug with tracking

* More doc comments

* Update tests

* Separate extented insert/update methods

* Reuse code

* Update docs

* Fix insert_update() usage

* Rehashing -> modification

* Trigger buckets reallocation

* Return enum
2024-05-17 18:06:01 +08:00
Khairul Azhar Kasmiran
a6d4a6bd02
Fix dbg_dmh test based on libc6 2.35-0ubuntu3.7 (#4495) 2024-05-16 21:31:40 +08:00
pelijah
706a6bf6c2
sdb: remove unused cas and expire features (#4487) 2024-05-12 18:27:54 +08:00
pelijah
ca2bbc076c Refactor rz_bin_pe_get_libs() to use SetS and RzPVector 2024-05-11 08:09:59 +08:00
pelijah
f818ca4296
Refactor sdb_foreach and related APIs (#4471)
* Refactor sdb_foreach and related APIs
* Strengthen bounds check in sdb_dump_next()
* Switch to RzPVector
* Use length info in filter_noreturn()
* Fix cmp function
* Remove unused sdb_like() API
* Pass SdbKv to SdbForeachCallback
* Add sdbkv_dup_value() helper
2024-05-07 07:57:52 +08:00
Khairul Azhar Kasmiran
2efd34a305
rz_core_task_join: Return true on join (#4474) 2024-05-06 21:10:43 +08:00
Khairul Azhar Kasmiran
e283bda5de
Fix debuginfod test timeout under -q (#4470) 2024-05-05 10:41:12 +08:00
Heersin
ba780a78dc
Relocation and analysis improvement for Renesas RX (#4461)
* Improve RX analysis of stack pointer
* Add Renesas RX ELF e_flag and reloc type macros
* Add Renesas RX relocation patch and elf_reloc to rz_reloc converter
* Update Renesas RX 'ir-info relocs' cmd test
* Add Renesas RX instruction description sdb
2024-05-01 09:34:52 +08:00
z3phyr
a7a29f110d
Revert memory leak fix for relocs (#4463) 2024-04-27 17:31:41 +08:00
pelijah
b5898d0203
Add rz_pvector_enumerate macro (#4462) 2024-04-27 11:07:06 +08:00
Anton Kochkov
9526b6c0bc
Remove NIOS-II architecture (#4457) 2024-04-24 20:11:17 +08:00
pelijah
c2e0348437
RzIL: add unit-tests for float cmp helpers (#4458)
* RzIL: add unit-tests for float cmp helpers
* Add NaN cases
2024-04-24 20:09:03 +08:00
Rot127
34f1a9e7b4
Add rz_log and rz_core_notify functions usable with not-formatted strings. (#4448) 2024-04-22 07:31:37 +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
Khairul Azhar Kasmiran
652591f826
..(: Declare macro args as raw (#4453) 2024-04-21 12:16:30 +08:00
z3phyr
0551f2545f
Fix memory leaks in linux heap parser (#4426)
* Fix memory leaks in debug path
* Fix memory leaks in mach and mdmp format
* Update the fix for mach
* Add support for aarch64 tcache parsing
* Test case fix
* Comment update

---------

Co-authored-by: Giridhar Prasath R <giridh1337@gmail.com>
2024-04-21 12:14:06 +08:00
Khairul Azhar Kasmiran
688c2bbe7c
.(: Don't unescape macro args (#4450) 2024-04-21 09:58:38 +08:00
Giovanni
3033f62865
Refactor logging. (#4446)
* Remove globals and refactor to complete implementation of logging.
* Renamed log.traplevel to log.abortlevel and hide it on release builds.
2024-04-19 13:02:58 +08:00
pelijah
11cb44af98
Remove ht_pp.h include from rz_list.h (#4441) 2024-04-18 13:39:49 +03:00
pelijah
f2d8e0db3d
Add HtSP, HtSS, HtSU, SetS (#4415)
- All `ht_*_new0()` are removed
- `freefn` field of HT options was renamed to `finiKV`
- `finiKV_user` fields was added to HT options
- Added `ht_*_new_opt_size` API
- `HtSP` and `HtUP` are created with `ValueFree` callback  that allows to reduce extra LOC and prevent bugs
- `SetP` replaced with `SetS` (based on `HtSP`)
- `rz_th_ht_*_new0()` and `rz_th_ht_*_new_opt()` are replaced with `rz_th_ht_*_new(HtXX *)`
2024-04-16 20:27:48 +08:00
Khairul Azhar Kasmiran
36ce78bc38
.(: Don't unwrap quoted args (#4417) 2024-04-15 18:32:12 +08:00
Khairul Azhar Kasmiran
73d85d270a
rz_cmd_desc_get_arg: Remove unused cmd param (#4427) 2024-04-11 17:57:18 +08:00
Dhruv Maroo
c6537d917e
Fix EXEC_WITH_RMODE macro and make the IL generated more concise (#4413)
* Use local variables in methods using `EXEC_WITH_RMODE` instead of
      `DUP`ing the values. Do the same for ST register stack popping.
      This leads to lesser code in the IL since the same long expression
      does not get repeated in the IL everytime (since we don't `DUP`
      anymore).
2024-04-05 08:30:35 +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
f223247b46 Remove fb command
The fb command can modify the offset of a flag, but does not update the
skiplist they are stored in, leading to a corrupted flag database. This
can be seen for example when executing
f test @ 0x4; fb 0x10 test; fl; pd 0x8 @ 0
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
3d93397dd8
RzIL: replace float comparison macros with functions (#4400)
* Replace float comparison macros with functions
* Move to float operations into il_routines.c
* Add RZ_OWN/RZ_BORROW tags
2024-04-02 09:18:21 +08:00
Giovanni
5cd4cff7eb
Update libdemangle to latest main and add LD command as alias of iDl (#4411) 2024-04-01 14:39:35 +08:00
billow
8f7f03cff6
TriCore IL: fix CSUB/CSUBN (#4409) 2024-04-01 07:45:33 +08:00
Khairul Azhar Kasmiran
754538fd8a
Fix unescaping of \\ esc seq (#4402) 2024-03-31 11:48:15 +08:00
Khairul Azhar Kasmiran
508bbae8a5
izj/izzj: Fix escaping of special chars (#4392) 2024-03-26 22:52:06 +08:00
pelijah
576d4b8a5e
Fix several memleaks in DWARF related code (#4391) 2024-03-26 22:11:08 +08:00
Rot127
b4fe418375
Fix broken CI (#4376)
* Increase timeout for OpenBSD

* Reset all members of a packet.

* Replace calloc with Rizin macros

* Add returns after fatal logs

* Init time structs with 0.

* Use monotonic clock to set last access timestamps.

Because instruction packets get pushed out of the buffer based in their last access,
using the real-time clock leads to problems. On Windows the real time clock seems to
not always give ascending values with multiple calls
(real-time clock = best bet of machine of current day time, which can fluctuate).

Using the monotonic clock will always give strictly ascending timestamps.

Due to the use of the real-clock, the instruction packets got
sometimes pushed out of the buffer non-deterministically.
2024-03-25 19:15:56 +08:00
Khairul Azhar Kasmiran
c52750ccfe
$: Use rz_flag_get to check if flag exists (#4377) 2024-03-22 22:12:20 +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
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
94099b860e
Add RzIL info to rz-asm -L and La (#4369) 2024-03-18 21:16:13 +08:00
Khairul Azhar Kasmiran
547732cd58
$: Refactor out code for $* and $** (#4368) 2024-03-17 21:23:13 +08:00
pelijah
d43bb152df
buf_format(): parse format string only once (#4365) 2024-03-17 10:18:56 +08:00
Rockrid3r
b5a703fbc3 fix memory leaks in path_walker 2024-03-16 08:56:50 +00:00
Rockrid3r
6f1de19e04 Updated documentation for rz_type_parse_string_single. Removed remaining comments 2024-03-16 08:56:50 +00:00