Skip to content

Commit

Permalink
Improve Build System & Fix Analysis Name
Browse files Browse the repository at this point in the history
This is a release patch for v0.1.0 -> v0.1.1
  • Loading branch information
brightprogrammer committed Aug 13, 2024
1 parent daf5a4e commit 6025548
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 37 deletions.
46 changes: 24 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ set(CMAKE_C_EXTENSIONS OFF)

# Build parameters.
if(MSVC) # Windows
# Disable warnings (there are too many of them, including warnings from
# third-party libraries, which cannot be selectively disabled when using MSVC).
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")

# Disable the min() and max() macros to prevent errors when using e.g.
# std::numeric_limits<...>::max()
# (http://stackoverflow.com/questions/1904635/warning-c4003-and-errors-c2589-and-c2059-on-x-stdnumeric-limitsintmax).
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX")
# Disable warnings (there are too many of them, including warnings from
# third-party libraries, which cannot be selectively disabled when using MSVC).
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")

# Disable the min() and max() macros to prevent errors when using e.g.
# std::numeric_limits<...>::max()
# (http://stackoverflow.com/questions/1904635/warning-c4003-and-errors-c2589-and-c2059-on-x-stdnumeric-limitsintmax).
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX")
elseif(UNIX) # Linux or macOS
# Set C flags
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
else()
# Set the sanitizer flags
# Set C flags
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
else()
# Set the sanitizer flags
set(SANITIZER_FLAGS "-fsanitize=address,undefined")

# Apply the sanitizer flags to all configurations
Expand All @@ -68,12 +68,12 @@ elseif(UNIX) # Linux or macOS
add_link_options(${SANITIZER_FLAGS})
endif()

# Compile flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra")
endif()
# Compile flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra")
endif()
else()
message(FATAL_ERROR "Unsupported system type: ${CMAKE_SYSTEM_NAME}")
message(FATAL_ERROR "Unsupported system type: ${CMAKE_SYSTEM_NAME}")
endif()

# On Linux and macOS, set RPATH relative to the origin of the installed
Expand Down Expand Up @@ -102,10 +102,12 @@ endif()
# build the plugin.
if(AUTOINSTALL_REQUIRED)
FetchContent_Declare(CREAIT
GIT_REPOSITORY "git@github.com:RevEngAI/creait.git"
GIT_TAG master
URL "https://github.com/RevEngAI/creait/archive/refs/tags/v0.1.1.tar.gz"
DOWNLOAD_EXTRACT_TIMESTAMP true
)
FetchContent_MakeAvailable(CREAIT)
FetchContent_GetProperties(CREAIT SOURCE_DIR CREAIT_SOURCE_DIR)
set(CREAIT_INCLUDE_DIRS ${CREAIT_SOURCE_DIR} CACHE PATH "Include directory for creait library.")
endif()

# This will give us path where plugins are installed on this sytem, also libraries to be linked.
Expand Down
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,31 @@ RevEng.AI plugins for Rizin & Cutter.

## Installation

Before any of the following commands are executed, you must first build & install
[`creait`](https://github.com/RevEngAI/creait).
PyYaml is a required dependency for the plugin commands. If your package manager manages
python packages instead of `pip`, then `pipx` will help get an easy installation.
`pipx` needs to be installed from package manager.

``` sh
git clone [email protected]:RevEngAI/reai-rz.git
cd reai-rz
mkdir Build
cd Build
cmake .. -G Ninja -D CMAKE_BUILD_TYPE=Debug
ninja
ninja install # Prepend "sudo" if required, or change prefix path using -D CMAKE_INSTALL_PREFIX=/to/install/path in configure step
# Get plugin or download a release
git clone [email protected]:RevEngAI/reai-rz.git && cd reai-rz

# Configure the build. Remove -G Ninja if you prefer GNU Makefiles (requires make)
cmake -B Build -G Ninja

# Build & Install plugin
ninja -C Build && sudo ninja -C Build install
```

The above sequence of commands will install rizin & cutter plugins automatically and when you
launch rizin or cutter, the plugins will be automatically loaded. The rizin plugin is a core
plugin so to check whether it's loaded or not, execute the command `Lc` in rizin shell. The
plugin name will be visible as `reai_rizin`
### Dependencies

Before running any of the above commands, you must install cmake, make, ninja, meson, gcc/g++ (if required), pkg-config, libcurl (development package), sqlite3 (development package) and [rizin](https://github.com/rizinorg/rizin?tab=readme-ov-file#how-to-build).

If while running rizin, you get address sanitizer (ASAN) issues, reconfigure rizin build again with `-bsanitize=address` and pass a `-D CMAKE_BUILD_TYPE=Debug` when building this plugin.

## CMake Configure Options

- `AUTOINSTALL_REQUIRED = ON/OFF` : When enabled, will automatically fetch required dependencies to build plugin. `ON` by default.
- `BUILD_RIZIN_PLUGIN_ONLY = ON/OFF` : When enabled will build rizin plugin only. This is useful when you only have rizin installed. `ON` by default.

## Basic Usage

Expand All @@ -35,6 +43,8 @@ db_dir_path = "/home/<user>/.reai"
log_dir_path = "/tmp"
```

### Generating Config File

This config file can be generated using the `REi` command after plugin installation.
Without a config, the plugin will keep erroring out for all other commands.

Expand All @@ -44,6 +54,8 @@ Execute the above command to automatically create a config file similar to the o
You can get the api key in `https://portal.reveng.ai/settings` API Key section. Once
the config file is generated, exit rizin using `q` command and then run rizin again.

### Command List

After installing rizin plugin, you'll see the following commands listed when you execute the
`RE?` command in rizin shell.

Expand Down
1 change: 0 additions & 1 deletion Source/Rizin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ else()
target_link_directories(
reai_rizin PUBLIC
${cJSON_LIBRARY_DIRS}
${SQLite3_INCLUDE_DIRS}
)
endif()

Expand Down
3 changes: 2 additions & 1 deletion Source/Rizin/CmdHandlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <rz_cons.h>
#include <rz_list.h>
#include <rz_util/rz_assert.h>
#include <rz_util/rz_file.h>
#include <rz_util/rz_num.h>
#include <rz_util/rz_path.h>
#include <rz_util/rz_table.h>
Expand Down Expand Up @@ -188,7 +189,7 @@ RZ_IPI RzCmdStatus rz_create_analysis_handler (RzCore* core, int argc, const cha
fn_boundaries,
True,
sha256,
binfile->file,
rz_file_basename (binfile_path),
Null,
binfile->size
);
Expand Down

0 comments on commit 6025548

Please sign in to comment.