Commit graph

265 commits

Author SHA1 Message Date
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
Rot127
de1b126b5d
Disable PCRE2 JIT for Darwin (#4329) 2024-03-05 17:07:07 +08:00
Rot127
c2b9208fc2 Unset static flag if system pcre2 lib is used. 2024-03-01 01:14:07 -05:00
Anton Kochkov
7225e9b753 Bump version to v0.8.0 2024-02-24 12:09:08 +08:00
Rot127
5afc51f0e2
Replace current regex engine with PCRE2 (#4185)
* Replace OpenBSD regex library with PCRE2.

PCRE2 has way better performance than the OpenBSD
library (something around 20 times faster).

The following flags are enabled for every pattern:

- PCRE2_UTF
- PCRE2_MATCH_INVALID_UTF
- PCRE2_NO_UTF_CHECK

All the others are optional.

Changes made:

- Adds PCRE2 as subproject.
- Changes the API away from POSIX to PCRE2.
- Edits many regex patterns because:
 - ' ' is skipped in patterns, if the EXTENDED flag is set for matching. '\s' must be set now.
 - '.' doesn't match newlines by default.
- Changes the API so matches and their groups are bundled into PVectors.
- Moves the regex component to rz_util.

* Fix cross build - add copy of PCRE2 dependecy

Meson currently doesn't support subprojects to be native and non-native at the same time.
See: https://github.com/mesonbuild/meson/issues/10947
Unfortunately, sdb depends on rz_util which in turn depends on PCRE2.
Excluding PCRE2 from the native build makes linking of rz_util not possible anymore.
Adding it, will make Meson complain that the dependencies cannot be mixed.

Hence, we compile a copy of PCRE2 for the native build if required.
2024-02-05 12:51:16 +08:00
Rot127
9b227eb3c1
Make AArch64/ARM analysis and asm plugins Capstone v6 compatible. (#4011)
This commit refactors the AArch64 and partially the ARM
plugin to make it Capstone v6 compatible.
Due to the big API changes in Capstone v6 several changes
had to be made.

Because we need to be compatible to Capstone v4 and v5
many include guards are added as well.

Overview of changes done:

**ARM**

- Instruction alias were introduced. This leads to different
decoding and analysis paths taken for certain instructions.
Some alias have their IL code generated like the real
instruction now (no special handling needed anymore).
This change is responsible for many changes you'll encounter.

- The operand details of each instruction are now always the
one of the real instruction. Also for alias.
For example, if "MOV <Wd>, #<imm>" is an alias for `ORR <Wd>, WZR, #<imm>`,
the details by CS hold all three operands of "ORR".
Before, they held only the two of "MOV".

- Several bugs in variable and argument generation
were fixed. Especially the default variable width
for ARM Thumb was changed to 32bit instead of the 16bit.

**AArch64/ARM64**

The changes listed above for ARM, also apply to AArch64.

Additionally:

- Capstone v6 changed the name ARM64 now everywhere to AArch64.
To be compatible with Capstone v4/v5 AArch64 names must be wrapped
into macros which resolve the name, depending on the CS version used.

- Capstone v6 is now more consistent with
register real and alias names.
From now on we use the register alias by default.

**List squashed commit messages:**

[AArch64 CS v6 BEGIN] Change subproject config to use cs-auto-sync-aarch64 branch

Replace ARM64 with version sensitive macros.

Exclude alias if CS version >= 6

Update access to writeback member

Exclude instr alias from inclusion

Update memory operand printing to json.

Enable real instr. detail only for AArch64

Set correct arch name in meson.build for CS

Fix U/SBFM instructions and their alias.

Mark parameters with RZ_OUt/BORROW

Optimize register extension to skip some, if the width already matches.

Adapt width and lsb of U/SBFM alias instructions (ImmR and ImmS are from U/SBFM).

Fix tests correct semantic buy bad syntax

Pass alias MOV instructions to mov()

Handle CSET and CSETM alias

Fix lsl, lsr and asr by handling them as alias.

Fix mov alias.

Handle TST alias

Fix CNEG, CINV alias

Fix bfi and bfxil alias.

Fix sign extensions.

Fix compare instructions.

Fix NEG, NGC, NGCS, NEGS, MVN

Fix CINC

Fix multiply instructions.

Fix ROR

Run clang-format

Handle CMP for ESIL

Handle new position of memory disponents of post index operands.

Fix post-index operations.

Add missing writeback checks for Post and preindex

Handle UBFM and SBFM alias

Handl BFM alias

Handle CMP, CSET and CINC alias

Update meson file of for cs-aarch64 branch

Fix asm tests. Use reg alias now.

Fix condition confusion and incorrect operand usage.

Fix plf test.

Run clang-format

Use register alias in tests

Add support for fp and lr reg alias assembly.

Use reg alias in test

Rename cond tranlate functions r2 -> rz

Fix condition check which assume 0 == invalid.

Fix issues intruduced by rebase

Set CS commit to current next branch.

Rename ARM64 -> AArch64

Add missing source file to meson.build

Remove DisassemblerExtension.c file for CS v5

Update to newest capstone next branch

Bump up CS version

REVERT ME: Get Capstone v4/v5 via git clone until new tars are released.

Wrap setting of CS_DETAIL_REAL into CS version check

Add maybe-unitialized to Capstone C args.

Fix CS pre v6 build by adding guards.

Use reg alias now printed by default by CS.

Bump CS version to most recent next.

Fix build errors due to stircter alias handling in ARM.

Fix RzIL tests introduced by alias introduction to ARM.

Fix ESIL bugs introduced with ARM alias introduction.

- stackptr hasn't been set for POP and PUSH

Add support again for Thumb1 pop/push

Handle PUSHW and POPW alias

Update test case

Add more POP and PUSH alias and enrich detail for other versions of them.

Fix incorrect mem access width guesses for ARM thumb.

Set POP return info if it writes to PC

Fix tests about default var size and POP mem write direction.

Bump CS version to newest next.

Fix incorrect tests.

- TriCore: Functions were in ro section.
- Default arg width in ARM thumb is 32bit.

Revert check for a set stackptr.

stackptr is used in different ways:
1. Safes the offset from the stack frame base.
2. Is interpreted as somthing else for x86 and I cannot find out what, in a reasonably time.

Hence we cannot use it here consistently.

Remove check for non existing ARM_GRP_RET in CSv5

Fix incorrect stack offsets of variables.

'push <reg-list>' instructions for which the second register was the FP,
reset the stackptr variable to 0. This led to wrong bp offsets in the variable names.
In this case it was +0xc.

Bump CS version.

Add copy of meta-programming macros for capstone-sys build.

Update capstone-next.wrap

Use bracket-less met-programming macro to fix Windows build warnings.

Update wrap files for Capstone with branch names

Add new meta-programming macro

Add workaround for MSVC pre-processor bug.
2023-12-20 01:00:31 +08:00
Gleb Popov
9598b1af36
Try searching for backtrace() in libexecinfo. (#3901)
FreeBSD ships the function from this library.
2023-10-05 10:38:33 +08:00
Riccardo Schirone
738be8e7e4
build: allow to use system libzstd and fix includes/lib installation (#3858) 2023-09-15 14:38:37 +08:00
billow
5999d3e824
DWARF support for load zlib and zstd compressed section (#3795) 2023-08-29 07:23:48 +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
Riccardo Schirone
3dce9c0563
util, cmd: fix rz_rand64 and %r (#3742) 2023-08-10 18:06:52 +08:00
Anton Kochkov
7febd38e9d
Bump version to v0.7.0 (#3725) 2023-08-04 17:14:15 +08:00
Anton Kochkov
d497840b07
meson: reduce code duplication (#3707) 2023-08-01 16:45:09 +08:00
yossizap
4aadd18f7e Set the default capstone version to v5 instead of v4
Co-authored-by: wargio <wargio@libero.it>
2023-07-16 13:22:47 +08:00
billow
ff6817e084 Fix multiple memory leaks 2023-06-05 22:41:20 +08:00
Riccardo Schirone
478f74a95e build: Introduce EXTRA_PREFIX for loading plugins/resources from another path 2023-05-19 16:42:35 +02:00
Anton Kochkov
300fc28925 Remove dead code in RzUtil alloc 2023-03-01 11:12:03 +08:00
Anton Kochkov
7f6f9049a2
Bump version to v0.6.0 (#3369) 2023-02-16 09:30:58 +08:00
Rizan
bbc5457b7a
Use compiler intrinsics for rz_swap_* functions (#3300)
* Using `__builtin_swap*()` whenever available instead of `rz_swap*()`
* Moved `test_endian()` from test_utils.c to test_endian.h
* Added test cases
2023-01-22 21:30:21 +08:00
Riccardo Schirone
eaec1a8893
build: fix BINDIR_DEPTH computation on Windows (#3075)
Before there was a special case for the root dir and it was implemented
by using `os.sep` as the representation for the root. That did not work
on Windows. This commit rewrite the BINDIR_DEPTH computation's logic to
use Path objects instead.
2022-10-09 10:14:36 +08:00
Giovanni
5b1e5e6762
Support blake3 hash algo (#3030) 2022-09-17 18:38:21 +02:00
Florian Märkl
06ee5e3aaf
Replace meson cmake module usage by plain configure_file() (#2948)
As due to https://github.com/mesonbuild/meson/issues/9702 we are not
using the expansion of @PACKAGE_INIT@ anyway, the cmake module provides
little additional value over a plain configure_file().
More importantly, by not using it, we get full support for muon, which
does not implement the cmake module yet.
2022-08-21 22:01:54 +08:00
Khairul Azhar Kasmiran
54508aee39
Rename rz_version.h.in to rz_build_version.h.in (#2914) 2022-08-13 22:20:36 +08:00
Khairul Azhar Kasmiran
801567c0b7
Move gittip to share/rizin (#2907) 2022-08-11 23:13:38 +08:00
GustavoLCR
c40744eba4
Fix Windows cross build (#2897)
* Fix build without ZLIB
* Fix cyclic include when cross-compiling
* Fixes `rz_util/rz_version.h`->`rz_types.h`->`rz_userconf.h`->`rz_util/rz_version.h`
2022-08-10 21:49:17 +08:00
Khairul Azhar Kasmiran
dc8cd44db4
gittip: Use subprocess.PIPE instead for Python 3.6 compatibility (#2873) 2022-08-06 21:21:07 +08:00
Florian Märkl
b85636317c Drop libuv dependency
libuv was only ever used for the tcp server for almost 4 years. Since
the non-libuv implementation of that is working now, it can be dropped
entirely without sacrificing functionality.
2022-08-06 13:20:52 +02:00
Khairul Azhar Kasmiran
2588aa8a1a
gittip: Use Meson's capture: true for Python 3.6 compatibility (#2869) 2022-08-04 22:37:58 +08:00
Riccardo Schirone
95ea48f537 build: use meson.current_source_dir() instead of '.'
build: remove special code if rizin is compiled as subproject
2022-08-04 11:48:21 +02:00
Khairul Azhar Kasmiran
fc24887c5c
Update on every build the git hash shown by rizin -v (#2863) 2022-08-01 23:28:34 +08:00
GustavoLCR
d3446789c7 Windows: Various fixes
* Fix some XP incompatibility
* Use wide version of APIs
* Remove unused/unnecessary function pointers
2022-07-24 21:00:51 +08:00
GustavoLCR
1b144864a9 Windows: Refactor environment variables
* Implement `rz_sys_clearenv()`
* Use the CRT function `_wputenv_s()` and `_wdupenv_s()`
* Fix `rz_sys_set_environ()`
2022-07-24 21:00:51 +08:00
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
Riccardo Schirone
fd3a79f9e3 bin: remove Ldr plugins
RzBinLdrPlugins were not used. There was just one for Linux, but it was
not doing anything.
2022-07-20 22:04:02 +02:00
Riccardo Schirone
faac2436b1 Move SDB into RzUtil
* Make SDB code SPDX compliant
* Use some RzUtil functions inside SDB

util: compile natively without any extra dependency
2022-07-19 08:45:20 +02:00
Riccardo Schirone
33974fccc8 util: make zlib dependency optional 2022-07-18 08:39:11 +02:00
Riccardo Schirone
8939fdbd7d
Use add_global_arguments instead of passing cflags/ldflags all around (#2812)
See also 66a0e22293/docs/TESTING_WITH_SANITIZERS.md (clang)
2022-07-17 21:33:51 +08:00
Riccardo Schirone
6c665c6098 Use Rizin specific macros instead of the ones from SDB 2022-07-17 12:11:13 +02:00
Khairul Azhar Kasmiran
0603a78871
meson: Remove unused version_commit (#2808) 2022-07-14 23:09:49 +08:00
Khairul Azhar Kasmiran
b79201b49a
Remove RZ_BIRTH (#2803) 2022-07-13 17:01:42 +08:00
Anton Kochkov
481f7f5b56 Set default warning level 1 for Meson 2022-07-07 18:08:57 +08:00
Riccardo Schirone
395c2d745d build: keep using meson 0.55.0 functions 2022-07-04 19:05:50 +08:00
Riccardo Schirone
98acbb041a build: use gnu99 globally instead of per-project 2022-07-04 19:05:50 +08:00
Khairul Azhar Kasmiran
1b688fa89e
Meson: Simplify crca_crc hash plugin summary output (#2767) 2022-07-03 09:59:43 +08:00
Riccardo Schirone
2f1e39818e Add liblzma subproject 2022-07-02 10:12:26 +02:00
Giovanni
ea02b0d25f
Remove zignatures and move aaF[l] -> F[al] , zf[sdc] -> F[sdc] (#2682) 2022-06-29 07:49:43 +08:00
Riccardo Schirone
2987e035da hash: use RzHash in most hash APIs 2022-06-28 21:55:26 +08:00
Giovanni
648882d544
Add libmspack and add idpx to extracts compressed pdb (#2728)
* Add libmspack, cabextract and add idpx to extracts compressed pdb
* Remove cabextract from CIs since it is not anymore required.
2022-06-27 23:52:07 +02:00
Riccardo Schirone
d4a2a28bd5 build: check for 'backtrace' presence in meson 2022-06-24 13:30:50 +08:00