Commit graph

23 commits

Author SHA1 Message Date
Riccardo Schirone
27e0d7ae82
RzBin: improve handling of addresses in ELF (#2591)
* RzBin/ELF: avoid the creation of useless flags at 0

Use UT64_MAX as an error value for addresses like symbols, imports,
sections, etc., and do not create flags for those because they are not
meaningful. This is useful for imports that do not have an address in
the virtual/file space and for non-alloc sections (e.g. .comment).
2022-05-10 10:17:35 +08:00
Florian Märkl
bfb98ed20c
[RzIL] Add lifter for 32-bit Arm, including thumb (#2241) 2022-02-22 12:23:28 +00:00
Florian Märkl
102549102d
Refactor Arm IT handling and fix for 4-byte ops (#2336)
The code was duplicated in both asm and anylsis, so now it's in
arm_it.c.
Previously, conditions were applied to N offsets after an IT instruction
using a fixed stride of 2 bytes. This obviously breaks for 4-byte thumb2
instructions, but whenever we find such an instruction, we can check if
there is a condition inside of it and readjust if necessary.
2022-02-19 17:16:15 +01:00
Florian Märkl
f729512817
Fix pcalign after changing analysis bits (#2306)
This fixes a bug that showed up after 2bdec10f98
because the bits value was set after cpu, but pcalign was already 4 then
and not updated by bits for example in:

rz-asm -a arm -b 16 -o 0x1059e -A dff81000
2022-02-13 09:28:33 +01:00
Riccardo Schirone
dea0918afd
Convert wa commands to rzshell (#2293) 2022-02-09 18:49:11 +08:00
Anton Kochkov
2f638cad1e Convert f commands to rzshell
* Changed behavior of `f` to only add flag if there is none
* Changed behavior of `f+` to add flag in any case
* Moved listing subcommands from `f` to `fl`
* Moved listing subcommands from `f.` to `f.l`
* Added subcommand `f.l*` to list all local flags in all functions
* Listing flags at the current offset became `fl.`
* Moved `f=` to `fl=`
* Old `fl` (flag length) now became `fL`
* Removed original `fe` commands
* Old `f?` (check if flag exists) now became `fe`
* Removed `fV` commands
* Removed `fn` commands in favor of `fl` and `asm.flags.real=true`
* Removed `fS` commands (`fSo` and `fSn`)
* `fo` became `fortune` and moved from "flags" to "shell" category
* Removed oldshell handlers of the `z` commands
2022-02-03 21:46:42 +08:00
Anton Kochkov
715dd14811
Remove unused, unupdated and largely untested ARM WineDBG and GNU (Binutils) plugins (#2085)
* Remove WineDBG ARM RzAsm plugin
* Remove unused and untested ARM GNU target
2021-12-10 16:40:58 +01:00
Florian Märkl
3c2e4bf63a
Rewrite ar and dr with newshell (#2006)
* Show group-level details of commands

Details can be defined at either a group command or its subcommand of
the same name. If define on group-level it will also be shown in the
group help without needing ??.

* Fix > $ redirection for errored command and leak

* Rewrite ar and dr commands with newshell

Breaking changes:
ar* => arf, ar- => arf-, ar. => ar*
ar, => art, ar? => arq
ar0 => ara0, arb => arab, ars => araS
arC => arpC
arn => arR
art => arT
arf => arF
Removed: drm, aer
2021-12-06 19:02:43 +01:00
Riccardo Schirone
589ab9299c Fix tests after more rigid wx 2021-11-09 12:01:41 +01:00
Riccardo Schirone
2a90781e7f Fix all db/analysis tests 2021-10-27 09:31:50 +02:00
Anton Kochkov
39613b5c16
Port C (metainformation) commands to the rzshell (#1752)
* Do not escape strings during the search
* Port `C` (metainformation) commands to the rzshell
* Improve string autodetection
* Remove `Cr` and RZ_META_TYPE_RUN
* Escape `\x1b` as `\e` character in strings
* Move string encoding options to `RzStrEncOptions` struct
* Add `esc_double_quotes` option to `RzStrEncOptions`
* Do not filter out unprintable characters for uppercase check
* Use `esc_double_quotes` when printing the string between '"' in disasm
* Use signed chars on all platforms/architectures

Co-authored-by: Riccardo Schirone <sirmy15@gmail.com>
2021-10-15 16:48:18 +08:00
Paul I
15409562c9
Port ax commands to newshell (#1655)
Co-authored-by: Riccardo Schirone <ret2libc@users.noreply.github.com>
2021-09-23 22:05:57 +00:00
Giovanni
35558f4180
Pseudo refactoring (#1308)
* License fix
* Implemented common pseudo
* Refactored MIPS pseudo
* Refactored ARM pseudo
* Refactored AVR pseudo
* Refactored 6502 pseudo
* Refactored dalvik pseudo
* Refactored arm64 pseudo
* Refactored z80 pseudo
* Refactored TMS320 pseudo
* Refactored v850 pseudo
* Refactored SuperH pseudo
* Refactored Motorola 68K pseudo
* Avoid selecting a pseudo plugin when the arch is not found.
* rz_parse_parse -> rz_parse_pseudocode
2021-07-22 11:55:05 +02:00
Anton Kochkov
3c59df7e98
Refactor RzTypes to use structs instead of SDB + New Tree-Sitter based C Parser (#1047)
- Removed oldshell version of `t` (types) commands
- Removed `tk` command because types storage switched to the hashtable
- Added `tfc` command to show the calling convention of the function or set it
- Added `tsl` (RZ_OUTPUT_MODE_LONG) to show structure members' sizes and offsets
- Added `tul` (RZ_OUTPUT_MODE_LONG) to show union members' sizes
- Switched the types storage to the hashtable instead of SDB
- Added load and export from/to SDB for standard type libraries and serialization for Projects
- Changed all `char *type` occurences to the proper `RzType`
- Added `RzCallable` type for the function/class method types
- Changed all function types API to use the `RzCallable` API
- Switched the function types (`RzCallable`) storage to the hashtable instead of SDB
- Added a connection between `RzAnalysisFunction` and `RzCallable` - `rz_analysis_function_derive_type()` API function to derive new `RzCallable` type from the `RzAnalysisFunction` even if it doesn't exist in the RzTypeDB.
- Moved type links to the RzAnalysis where they belong
- Removed TCC and MPC-based parsers
- Added Tree-Sitter-based parser for C grammar (see `librz/type/parser/*`)
- Reworked type databases in `librz/analysis/d/` to be consistent with C standard, libc, platform-specific definitions
- Switched the type links from `char *` to `RzType`
- Switched the type links from SDB to the hashtable
- Added concept of the "type paths", e.g. `a.b[20].c` where `b` is a member of `a` (`a` is either structure or a union) and `c` is a member of `b`, and `b` is an array where we take 20-th element.
- Added concept of the typeclasses (a bit similar to Haskell) for numerical types: `None` (the most generic one), `Num` (includes `Integral` and `Floating`), `Integral` (includes `Signed Integral` and `Unsigned Integral`), `Floating`.
- Added concept of type equality (`rz_types_equal(a, b)` API function)
- Added Doxygen documentation to every API function in the `librz/type/*`.
- Updated the project format from **V2** to **V3**, added migration.
2021-07-20 01:46:45 +08:00
Aswin C
381f22d7cc
Introduce RzArchPlatform and support for platform profiles (#1254)
* Remove the unnecessary `sdb` pointer of `RzArchTarget`

The SDB pointer in `RzArchTarget` is not needed as `sdb_load_arch_profile_by_path` 
creates a new SDB pointer and takes care of our requirements.

* Introduce `RzArchPlatformTarget` and `RzArchPlatformItem` and the new APIs

Also define a new flagspace: `RZ_FLAGS_FS_PLATFORM_PORTS`

* Introduce a new configuration variable `asm.platform` to choose the
platform profile

* Define and call the APIs for platform profiles

* Add the SDB file for BCM 2835 and a unit test

* Check for NULL at various places and run `clang-format`

* Use `RZ_NONULL` for the parameters of `rz_arch_platform_init`

* Add `RZ_NONNULL` to all of the arguments which gets `rz_return[_val]_if()`-ed

* Let `platform` be NULLABLE and fix the ASAN tests
2021-07-02 12:55:31 +08:00
Giovanni
4261f5b172
Avoid using pcache when emulating functions. (#1226) 2021-06-19 20:25:22 +02:00
seanachao
a2f8631b6c
Change -, --, = argument and = command meaning (#930)
* Swap = & - R (#615)&(#616)
* Fix R replace =
2021-04-21 16:20:24 +08:00
Yuuoniy
fe1648f8b5
Fix function signature and function size output (#820) 2021-03-15 20:37:52 +02:00
Anton Kochkov
ad6a580a1c Fix tests 2021-01-05 23:33:32 -06:00
Itay Cohen
4ac005d489
Set asm.tabs to 6 and enable asm.tabs.once by default ##config (#290)
* Set asm.tabs to 6
* Enabl asm.tabs.once by default
2021-01-04 17:45:35 +02:00
Maijin
feb7feb19a
Remove a2f (#219)
Co-authored-by: Maijin <maijin21@gmail.com>
Co-authored-by: Riccardo Schirone <ret2libc@users.noreply.github.com>
2020-12-18 20:37:00 +08:00
Aswin C
d42cde8ca5
Disable asm.bytes by default ##cons (#155)
* Disable `asm.bytes` by default

* Fix tests by adding `e asm.bytes=true` (1/n)

* Fix tests by adding  (2/n)

* Fix tests by adding `e asm.bytes=true` (3/n)

* Fix tests by adding `asm.bytes=true` (4/n)

* Fix test by adding `asm.bytes=true` (5/n)

* Fix mostly all broken tests

* Attemp to fix the rzpipe test

* Attempt to fix the tests in `db/cmd/cmd_pipe`

* Fix tests again

* Fix cmd_pipe test

* Add a test where `asm.bytes` is false

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2020-12-15 12:47:33 +01:00
Florian Märkl
d53d1e3845
Final Analysis Renaming (#124)
* Rename missing Analysis Defines
* Rename analysis config vars and other lower case stuff
* Rename test/db/analysis
* Fix analysis tests

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2020-12-08 15:05:24 +08:00
Renamed from test/db/anal/arm (Browse further)