Commit graph

28708 commits

Author SHA1 Message Date
Rot127
b16471fa53
Remove Capstone 3 (fix CS 4 & 5) (#3934)
* Remove macros checking for CS_API_VERSION 3

* Remove CS 3 from meson_options and subprojects.

* Remove Capstone v3 from CI

* Remove CS_API_VERSION >= 4 checks since always true from now on.

* Add CSv5 workflow to CI.

* Handle ARM pre v6 build errors.

* Fix PPC build errors for CS < v6

* Fix correct macro name

* Remove wrong include.

* Fix fallthrough warning

* Fix getter macros for WB and post-fix flags.

* Fix faulty macro name

* Check for all float extensions for vabs.

* Add return to assert cases.

* Update cs to 46154e8605aaefdcca5fecf4ea88b92db5a40ad3

* Remove cs3 wrap file.

---------

Co-authored-by: wargio <wargio@libero.it>
2023-10-25 18:30:15 +08:00
Khairul Azhar Kasmiran
d8332c50d7
Remove sdb from rz_util_includes (#3938) 2023-10-23 23:47:57 +08:00
vansh
a15bd0284b
Fix quit confirmation during debuggin session. (#3916) 2023-10-23 13:35:21 +08:00
byteninjaa0
1c236f55ce
rz_util.h was included twice. (#3936) 2023-10-22 22:01:17 +08:00
Khairul Azhar Kasmiran
7a7945c1f7
Remove ../include/rz_util from rz_util_includes (#3935) 2023-10-22 19:38:56 +08:00
billow
7982454d4c
Load split DWARF (#3833)
- Add `read_debuglink` and `read_build_id`
- Fix `*.dwo` loading
- Try process DW_UT_skeleton
- Fix dwo_id
- Check buffer size
- Add `bin.dbginfo.debug_file_directory`
- Add test "Debugging Information in Separate Files"
2023-10-21 18:51:15 +08:00
Khairul Azhar Kasmiran
febfdd5a2f
Fix rz-ghidra build due to ht_* move (#3932) 2023-10-20 22:13:48 +08:00
Riccardo Schirone
913a0a4c51
Demangle flags symbols (#3915)
* core: do not show realnames in flags if not set
* core: show flag name as comments when realnames are displayed
* test: fix db/analysis/riscv test

Just fix the test, because the pseudo code seems wrong.`sym.printf` should already be present in the instruction, thus the flag is redudant.
2023-10-20 09:33:30 +02:00
Maksim Kostin
24bfd59b7f
le: Fix segfault in le.c (#3927) 2023-10-19 20:08:25 +08:00
billow
cfb1679b21
Fix typedb reload (#3931)
* Fix typedb reload
* Fix `rz_analysis_set_cpu`
* Add test
2023-10-19 18:46:10 +08:00
billow
77778e9311
dwarf: fix heap overflow (#3930) 2023-10-19 00:25:46 +08:00
wungfuh
6b0fbb6e49
rzil: switch event list to pvector (#3928)
* switch from RzList to RzPvector

* Removed the commented line of code

* Removed tab to support clang format

* Added space after foreach statement to support clang format
2023-10-19 00:20:45 +08:00
Rot127
1018286648
[PPC/ARM] Update to Capstone v6/auto-sync (#3648)
ARM
- Updated ARM identifiers and API changes.
- Fixed shift amounts to be always decimal.
- Fixed incorrect usages of memory disponents.
- Fixed restoring of condition codes.
- Updated IDs for new ones.
- Fixed 8-byte stores.
- Added flag checking for MOV with shifts.
Capstone Integration
- Removed capstone-auto-sync subproject and replaced with next.
- Checked for NEON features.
- Used https://github.com/capstone-engine/capstone/pull/2122 for better system operand support.
- Distinguished between 32 and 64-bit cc checks.
- Checked for CS API version >5.
- Checked for CS_NEXT_VERSION instead of CS_API_MAJOR.
- Fixed VSTn and VLDn instructions to use corrected memory operands.
- Excluded multiple instruction aliases that are no longer valid IDs.
- Used CS_NEXT_VERSION as include guard.
- Added CS v6 include guards.
- Added CS v6 support to branch conditions for Rzil.
- Added more CSv6 guards.
PPC
- Fixed: Compare instructions do not use the branch predicate.
- Fixed conditional and CTR checks.
- Fixed MTSPR and MFSPR instructions.
- Excluded more branch aliases no longer present in v6 from switch cases.
- Fixed incorrectly assigned variables.
- Fixed condition checks for branches.
- Used ITE for condition checks, to prevent unnecessary reads of CTR or CR.
- Fixed rzil tests with new semantics using register 0.
- Updated include guards for Capstone versions to use CS_NEXT_VERSION.
- Initialized spr_name to prevent uninitialized use.
- Used mem.offset register for CSv6.
- Always used real operand details.
- Used mem operand for DCBZ.
- Fixed tests that are semantically identical.
- Handled LI LIS alias.
- Fixed rzil tests (with simplified semantics).
- Fixed branch alias with new cond test method.
- Handled clrl. alias.
- Handled SL/SR alias.
- Fixed conditional branches in ESIL.
- Fixed possible multiplication result overflow.
- Added RZ_NONNULL.
- Added 0 register.
- Handled LIS alias.
- Fixed: Print crX reg name in CS v6.
- Handled all general branch instructions into a single case statement.
- Fixed no semantic issues in tests.
- Added newly discovered calls.
- Moved direction check to inline function.
- Added link of root cause for broken test.
- Added QPX support.
- Set Capstone next branch to latest commit.
- Fixed uninitialized warning.
- Set CS next branch to newest commit.
2023-10-18 10:36:25 +08:00
Rot127
58ee80d0ee
Replace RZ_ASM_NOPLUGINS and RZ_BIN_NOPLUGINS with more general RZ_NOPLUGINS. (#3919) 2023-10-16 22:41:20 +08:00
Maksim Kostin
bfef56652a
pyc: fix fpe and heap buffer overflow (#3922)
* Fix div by zero in le_create_maps()

* Fix heap buffer overflow in marshal.c

* Make error messages like in cpython

* Refactor le_create_maps()

* Refactor marshal.c
2023-10-16 22:40:36 +08:00
Rot127
51c8be0a1b
Fix a double free. (#3918)
If the operand is rw, av gets assigned to op->src[i] and op->dst.
Later when op is freed, op->src[i] and op->dst are freed both and
so we run into the double free.
2023-10-15 22:02:39 -05:00
Anton Kochkov
7c4ceb3b80
Mention RL78 in README (#3924) 2023-10-14 17:22:18 +08:00
billow
a974cbc864
fix: DWARF memleaks (#3923) 2023-10-14 08:43:58 +08:00
Bastian Engel
6df64dbbe8
Renesas RL78 disassembler plugin (#3649) 2023-10-14 00:15:03 +08:00
Nikolaos Chatzikonstantinou
908b8805c7 sdb: add documentation to buffer functions 2023-10-13 21:32:03 +08:00
Nikolaos Chatzikonstantinou
5b8f00e081 sdb: cleanup unused functions and macros 2023-10-13 21:32:03 +08:00
Tomáš Golembiovský
a564f13856
librz: syscalls in Linux 6.5.3 (#3854)
Update Linux syscalls list to those of Linux 6.5.3 for x86 and aarch64.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2023-10-13 13:47:28 +08:00
Riccardo Schirone
3b903caa96
librz: add some initial documentation (#3782) 2023-10-13 13:46:19 +08:00
Nikolaos Chatzikonstantinou
6eec2fe0d1 librz: add nullable pointer modifier 2023-10-13 09:42:50 +08:00
Nikolaos Chatzikonstantinou
d50179096f librz: fix type signature in header to include ownership 2023-10-13 09:42:50 +08:00
Nikolaos Chatzikonstantinou
d28cfe4ddb librz: add ownership marks and update copyright 2023-10-13 09:42:50 +08:00
Nikolaos Chatzikonstantinou
ac2092cb6d librz: add copyright header and change char to ut8 in example 2023-10-13 09:42:50 +08:00
Nikolaos Chatzikonstantinou
7a36831391 librz: update documentation and fix overflow bug
We update the documentation with examples and fix an overflow bug in
the calculation of the decoded message. The documentation for this
decoded message length is also updated.
2023-10-13 09:42:50 +08:00
Nikolaos Chatzikonstantinou
acd24d4719 librz: address PR review issues
1. Add name to copyright.
2. Modify public API type from int to st64.

For style reasons, also:

1. Remove 'else' statements.
2. Add brackets.
3. Prefer ! operator to NULL comparison.
2023-10-13 09:42:50 +08:00
Nikolaos Chatzikonstantinou
447546d476 librz: rewrite base64 code
The new Base64 code is fixing the previous bugs which were illustrated
with unit tests. Documentation is added and as a "breaking" API
change, the input and output parameters are allowed to be NULL
consistently (not just some, but all.) The rest of the behavior is the
same, save for the bugs that were fixed, and the decoding function
which is now even laxer in what it is able to decode (which seemed to
be the original intention but had a bug as demonstrated by a unit
test.)

An integer overflow bug, in the calculation of the string length, is
also fixed.
2023-10-13 09:42:50 +08:00
Nikolaos Chatzikonstantinou
0e8eae6032 test: some base64 unit tests to demonstrate bugs
The Base64 implementation has some bugs in its decoding function that
we demonstrate with unit tests:

- In test_rz_base64_decode_invalid, we add a unit test to show that
the invalid characters are not ignored correctly. I believe the
intention of the original code is to ignore them, however this is not
correctly achieved. The two common options, ignoring invalid
characters or rejecting the message, are mentioned in RFC 4648. What
the current base64 decoding function does is a complicated logic that
may reject, or otherwise, it appears to overwrite previously encoded
data.

We show this in the test by decoding two inequivalent Base64-encoded
messages, which under current implementation both result in the same
string "foo", but they should be different.

- In test_rz_base64_decode_offby1, we demonstrate an off-by-1 buffer
overflow. An initial buffer of content { 'A', 0, 'B', 0 } is passed to
the encoding function with intention of encoding the single character
'A'. When decoding back into plaintext, the decoding function is:

1) inserting a NUL byte (out of courtesy?) which may not be
desirable. However, this NUL byte is already present in our original
buffer.
2) Reaching past the NUL byte, overwriting the character 'B' with a
NUL byte.

We demonstrate 2) with the assertion in the unit test.
2023-10-13 09:42:50 +08:00
vansh
fb863aeb1c
Move Hashtable and Set primitives to RzUtil (#3910)
* update meson.build for changed file paths
* move ht_*.h to librz/include/rz_util
* add librz/include/rz_util/ht_*.h to librz/include/meson.build
2023-10-12 17:45:48 +02:00
Riccardo Schirone
19dbb57739 ci: switch to softprops/action-gh-release 2023-10-11 10:01:40 +02:00
Khairul Azhar Kasmiran
398b4ae8de
dsui: Remove error msg on success (#3913) 2023-10-08 22:21:50 +02:00
Riccardo Schirone
a1cb888f95
core/cmd: fix some leftover of ?i command (#3911) 2023-10-05 21:31:21 +08:00
Nikolaos Chatzikonstantinou
7c7b4c02d1
util: rz_endian cleanup and documentation (#3900)
* librz: rename function parameter

The function parameter is renamed from _dest to dest. In the body of
the function, the identifiers _dest and dest are swapped
accordingly. This makes these functions have the same parameter name
as all others of the same kind in the header.

* librz: add swap macros when builtins missing

The rz_swap_ macros are only defined when the compiler builtins are
available. We define them in case they are not for uniformity of
presence in the preprocessor namespace.

* librz: add documentation for rz_endian.h

Every function and macro is documented except for the signed swap
macros.

* librz: return max value in read if parameter is NULL

The read functions in rz_endian.h sometimes returned the MAX value
when the source parameter was NULL and sometimes didn't. For example,
compare rz_read_be16 which doesn't check NULL and rz_read_le16 which
does.

We fix this by inserting checks for NULL in every integer read
function.

We also insert these checks for the floating-point read
functions. They also too sometimes checked for NULL indirectly by
calling the corresponding integer read functions, but the read
functions with the offset parameter did not check for NULL.

Separately, The NULL checks in rz_read_le8 and rz_read_me8 were
removed because they were duplicate; they call rz_read_ble8 which
checks for NULL.

* librz: add documentation in swap functions for NULL source parameter

The case where the source parameter is NULL is documented in all the
read functions in rz_endian.h

A mistake in the documentation of rz_read_at_ble64 is fixed; it
incorrectly mentioned 128-bit instead of 64-bit integers.

* librz: add missing 24-bit macros

The 24-bit macros for minimum and maximum value are added.

* librz: add missing endianness functions

For the readers and writers, certain endianness and bit number
combinations were missing. Some missing big-endian, little-endian,
middle-endian functions as well as helper functions are added.

The documentation of some read blue functions is corrected to mention
"specified" order instead of "big-endian".

* librz: fixing some compiler errors from typos

* librz: remove UT24 macros

We remove the UT24_ macros due to PR review.

* librz: replace UT24_MAX with UT32_MAX

It is better to return the maximum value held by the return type
instead of returning a max 24-bit value.

* test: add more rz_endian tests

All the integral endian functions for read and write are ran through
some basic tests.

* librz: remove unused internal functions

The signed rz_swap functions are removed because they are not used
anywhere in the source code. They are duplicates of the corresponding
unsigned functions. Moreover, the rz_swap_st16 function has an
incorrect implementation when the compiler builtin is missing.

Instead of fixing, adding documentation, and unit tests, which means
we would also need to create an environment with the compiler builtin
check undefined, we simply remove them, because they are not used
anywhere.

* librz: remove unnecessary define macros

These macros were added during the PR and were requested to be removed
again.

* test: fix MSVC complaining on erroneous commas

The string literal #__VA_ARGS__ is equal to "" in a conforming
implementation when there is an empty list of variadic arguments. On
MSVC 2017, it is completely missing, causing an error. These issues
appear to have been fixed in VS2019 v16.5 and later using the
/Zc:preprocessor compiler switch and in Visual Studio 2017 version
15.8 using /experimental:preprocessor.

In any case, we use string concatenating to force an empty string to
appear even if #__VA_ARGS__ is missing.
2023-10-05 10:40:00 +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
Khairul Azhar Kasmiran
15edd1f504
Move DWARF attribute class enum into file scope (#3906) 2023-10-04 19:54:11 +08:00
Nikolaos Chatzikonstantinou
66687aa1c7
Update DEVELOPERS.md (#3891)
* Be explicit about where docstrings go.
* End sentences with period.
2023-09-29 21:14:28 +08:00
Nikolaos Chatzikonstantinou
1669d5a704
Add note on sys/clang-format.py script to DEVELOPERS.md (#3898) 2023-09-29 12:37:58 +08:00
Nikolaos Chatzikonstantinou
5211cdcfb0 Remove old cdb allocation methods in favor of rz_alloc 2023-09-28 14:53:25 +08:00
Nikolaos Chatzikonstantinou
70ee2976b1 sdb: replace custom packing of integers with rz_endian.h functions 2023-09-28 14:53:25 +08:00
Nikolaos Chatzikonstantinou
376f8b8250 doc: Add Doxygen documentation to cdb
The source and header file of cdb is documented. There is also
documentation added for the private sdb header which contains helpful
macros and static functions.
2023-09-28 14:53:25 +08:00
billow
19c889f690
DWARF loading '.debug_str_offsets', '.debug_line_str' and relocate (#3848)
* Try Load '.debug_str_offsets'
* DWARF unify names
* Add endian_reader.c to process relocate
* Remove RzBinDwarfLineInfoMask RzBinDWARFFlags and RzBinDWARFOption
* Fix debug_line
* Add .debug_line_str
* RzBinReloc: Add section_vaddr
* Fix info->offset_comp_dir
* Fix convert_raw in loclists and rnglists
* Remove macro `UX_OR` and relocate support for read_address
* Add RzBinDwarfLineHdr->encoding
* Remove macro 'OK_None'
* Fix loclists and rnglists
* Allow void typedef
* Fix DW_AT_name reference DW_AT_specification
2023-09-28 10:15:42 +08:00
Riccardo Schirone
404e58671b
core/tui: fix j/k movements when in hexdump mode (#3897) 2023-09-27 23:39:15 +08:00
Anton Kochkov
209433f3d3
visual: add HJKL selection in help (#3895) 2023-09-27 23:38:16 +08:00
Anton Kochkov
e9d017697c
util: remove SDB journal (#3893) 2023-09-27 15:57:20 +08:00
Anton Kochkov
71679b0800
Fix CI build 2023-09-26 08:03:54 +08:00
Dhruv Maroo
714c338e0f
Remove designated array initializers in rz_analysis.h (#3876)
* Do not use designater array initializer because MSVC complains
* Add new Appveyor CI test for including C headers from C++ files

    * Need to test whether Rizin headers can be included in C++ when
      using MSVC, needed for Cutter to build successfully
    * Changed the name of `build-cpp` CI job in GitHUb jobs to
      `build-cpp-linux` to make it obvious that it only performs the
      test for Linux
2023-09-26 07:36:40 +08:00
Anton Kochkov
833c59c6eb
Pin Meson to 0.61.5 for old CentOS and Debian (#3887) 2023-09-25 20:29:43 +08:00