Add r2plugin support

This commit is contained in:
pancake committed 2026-08-07 13:08:50 +02:00
1 parent 794795ef33
commit 3f02b55414
7 files changed
+61 -2

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
# r2plugin
This directory contains the make and meson files required
to link r2yara statically inside radare2 (XPS).
```console
cd radare2
mkdir -p libr/xps/p
ln -s ../../../../r2yara libr/xps/p/r2yara
cp libr/xps/p/r2yara/r2plugin/config.mk libr/xps/config.mk
make -C libr/xps
```
Then build radare2 as usual (`./configure && make` or meson).
The build requires libyara to be available via pkg-config.
Verify with:
```console
r2 -q -c 'Lc~r2yara' --
```
+5
View File
@@ -0,0 +1,5 @@
/* r2yara - LGPLv3 - Copyright 2014-2026 - pancake */
#ifdef R2_CORE_H
extern RCorePlugin r_core_plugin_r2yara;
#endif
+7
View File
@@ -0,0 +1,7 @@
R2YARA_CORE_WD=$(LIBR)/xps/p/r2yara
R2YARA_YARA_CFLAGS=$(shell pkg-config --cflags yara 2>/dev/null)
R2YARA_YARA_LDFLAGS=$(shell pkg-config --libs yara 2>/dev/null || echo -lyara)
CFLAGS+=-I$(R2YARA_CORE_WD)/src $(R2YARA_YARA_CFLAGS)
LDFLAGS+=$(R2YARA_YARA_LDFLAGS)
R2YARA_CORE_OBJ=$(R2YARA_CORE_WD)/src/core_r2yara.o
EXTERNAL_STATIC_OBJS+=$(R2YARA_CORE_OBJ)
+16
View File
@@ -0,0 +1,16 @@
# r2yara XPS integration for radare2.
# Included from libr/xps/meson.build when r2yara sources live under
# libr/xps/p/r2yara/. Appends sources and include paths to the r_core
# aggregate so the static plugin is linked into libr_core.
core_plugins += ['r2yara']
r_core_additional_inc += include_directories(join_paths('..', 'src'))
r_core_additional_sources += files(
'../src/core_r2yara.c',
)
# XPS has no per-plugin dependency hook; platform_deps is consumed by
# libr_core's dependency list, so libyara is appended there.
platform_deps += dependency('yara')
+5
View File
@@ -0,0 +1,5 @@
/* r2yara - LGPLv3 - Copyright 2014-2026 - pancake */
#ifdef R2_CORE_H
#include "core/deps.h"
#endif
+1
View File
@@ -0,0 +1 @@
core.r2yara
+6 -2
View File
@@ -6,6 +6,10 @@
#define R_LIB_ABIVERSION R2_ABIVERSION
#endif
#ifndef R2Y_VERSION
#define R2Y_VERSION "1.5.0"
#endif
#if R_LIB_ABIVERSION >= 125
#define r2yara_cmd_help(core, msg) r_cons_cmd_help ((core)->cons, msg)
#define r2yara_cmd_help_match(core, msg, command) r_cons_cmd_help_match ((core)->cons, msg, command, 0, false)
@@ -1232,7 +1236,7 @@ static bool cmd_yara_fini(RCorePluginSession *cps) {
return true;
}
RCorePlugin r_core_plugin_yara = {
RCorePlugin r_core_plugin_r2yara = {
.meta = {
.name = "yara",
.desc = "YARA integration",
@@ -1247,7 +1251,7 @@ RCorePlugin r_core_plugin_yara = {
#ifndef CORELIB
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_CORE,
.data = &r_core_plugin_yara,
.data = &r_core_plugin_r2yara,
.abiversion = R2_ABIVERSION,
.version = R2_VERSION
};