- update to radare2-4.3.1

- rework how extra modules are fetched to make it easier to update this port
  in the future
- add patch to unbreak debugging with r2 on OpenBSD; patch from upstream
  via edd@ who also reported the initial breakge

ok edd@ (MAINTAINER)
This commit is contained in:
jasper 2020-04-11 18:51:44 +00:00
parent f9cd2a2e5f
commit ac9639c5a0
4 changed files with 96 additions and 9 deletions

View File

@ -1,17 +1,27 @@
# $OpenBSD: Makefile,v 1.18 2020/01/26 11:14:31 jasper Exp $
# $OpenBSD: Makefile,v 1.19 2020/04/11 18:51:44 jasper Exp $
COMMENT = libre and portable reverse engineering framework
V = 4.1.1
V = 4.3.1
SUBST_VARS += V
GH_PROJECT = radare2
GH_TAGNAME = ${V}
# upstream tarball with dependencies clone in shlr/
MASTER_SITES = https://distfiles.sigtrap.nl/
# When updating, use the output from the command below to set
# the extra distfiles so as not to invoke clone_3rd_repo.sh during build:
# grep -E '^(TS|SHELLPARSER)_TIP' ${WRKSRC}/shlr/Makefile
TREESITTER_COMMIT = f049ba35
SHELLPARSER_COMMIT = 1a49d280
MASTER_SITES0 = https://github.com/tree-sitter/tree-sitter/archive/
MASTER_SITES1 = https://github.com/ret2libc/radare2-shell-parser/archive/
DISTFILES = ${DISTNAME}${EXTRACT_SUFX} \
treesitter-{}${TREESITTER_COMMIT}.tar.gz:0 \
shellparser-{}${SHELLPARSER_COMMIT}.tar.gz:1
# In radare, all libs have the same version
LIBV = 7.0 # 4.0.0
LIBV = 7.1 # 4.3.1
.for _lib in r_anal r_asm r_bin r_bp r_config r_cons r_core \
r_crypto r_debug r_egg r_flag r_fs r_hash r_io r_lang \
r_main r_magic r_parse r_reg r_search r_socket \
@ -38,6 +48,11 @@ CONFIGURE_ARGS += --mandir=${PREFIX}/man \
CONFIGURE_ENV += LDFLAGS="-L${LOCALBASE}/lib"
MAKE_ENV = HOST_CC="${CC}"
post-extract:
mv ${WRKDIR}/tree-sitter-${TREESITTER_COMMIT}* ${WRKSRC}/shlr/tree-sitter
mv ${WRKDIR}/radare2-shell-parser-${SHELLPARSER_COMMIT}* \
${WRKSRC}/shlr/radare2-shell-parser
post-patch:
sed -i 's/>mips/>mipsen/' ${WRKSRC}/libr/anal/p/anal_mips_cs.c

View File

@ -1,2 +1,6 @@
SHA256 (radare2-4.1.1.tar.gz) = 9lYKL2gxaZ6MVVq5I4Ye6qRoUU20p03Zr0yBpBPWzEU=
SIZE (radare2-4.1.1.tar.gz) = 19398753
SHA256 (radare2-4.3.1.tar.gz) = Sry5yd/yTqtE1k05LhFa53SrGtkNBPLJg9ltfX+Udqo=
SHA256 (shellparser-1a49d280.tar.gz) = 5ps8mQGp9hJ98UnvWsV9sVeMeLdJweNekbnSI2gLhVg=
SHA256 (treesitter-f049ba35.tar.gz) = ELsKFSJPgLOcYhejlEE8/oVX6SEsnleURgF6NptHX48=
SIZE (radare2-4.3.1.tar.gz) = 8113591
SIZE (shellparser-1a49d280.tar.gz) = 63802
SIZE (treesitter-f049ba35.tar.gz) = 461019

View File

@ -0,0 +1,69 @@
$OpenBSD: patch-libr_io_p_io_ptrace_c,v 1.1 2020/04/11 18:51:44 jasper Exp $
Fix debugger:
https://github.com/radareorg/radare2/issues/16432
Index: libr/io/p/io_ptrace.c
--- libr/io/p/io_ptrace.c.orig
+++ libr/io/p/io_ptrace.c
@@ -178,14 +178,18 @@ static bool __plugin_open(RIO *io, const char *file, b
return false;
}
-static inline bool is_pid_already_attached (RIO *io, int pid, void *data) {
+static inline bool is_pid_already_attached(RIO *io, int pid) {
#if defined(__linux__)
- siginfo_t *sig = (siginfo_t *)data;
- return -1 != r_io_ptrace (io, PTRACE_GETSIGINFO, pid, NULL, sig);
+ siginfo_t sig = { 0 };
+ return r_io_ptrace (io, PTRACE_GETSIGINFO, pid, NULL, &sig) != -1;
#elif defined(__FreeBSD__)
- struct ptrace_lwpinfo *info = (struct ptrace_lwpinfo *)data;
- int len = (int)sizeof (*info);
- return -1 != r_io_ptrace (io, PT_LWPINFO, pid, info, len);
+ struct ptrace_lwpinfo info = { 0 };
+ int len = (int)sizeof (info);
+ return r_io_ptrace (io, PT_LWPINFO, pid, &info, len) != -1;
+#elif __OpenBSD__
+ ptrace_state_t state = { 0 };
+ int len = (int)sizeof (state);
+ return r_io_ptrace (io, PT_GET_PROCESS_STATE, pid, &state, len) != -1;
#else
return false;
#endif
@@ -194,13 +198,6 @@ static inline bool is_pid_already_attached (RIO *io, i
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
RIODesc *desc = NULL;
int ret = -1;
-#if defined(__linux__)
- siginfo_t sig = { 0 };
-#elif defined(__FreeBSD__)
- struct ptrace_lwpinfo sig = { 0 };
-#else
- int sig = 0;
-#endif
if (!__plugin_open (io, file, 0)) {
return NULL;
@@ -210,7 +207,7 @@ static RIODesc *__open(RIO *io, const char *file, int
// Safely check if the PID has already been attached to avoid printing errors
// and attempt attaching on failure
- if (!is_pid_already_attached(io, pid, &sig)) {
+ if (!is_pid_already_attached (io, pid)) {
ret = r_io_ptrace (io, PTRACE_ATTACH, pid, 0, 0);
if (ret == -1) {
#ifdef __ANDROID__
@@ -225,9 +222,11 @@ static RIODesc *__open(RIO *io, const char *file, int
perror ("ptrace: Cannot attach");
eprintf ("ERRNO: %d (EINVAL)\n", errno);
break;
+ default:
+ break;
}
-#endif
return NULL;
+#endif
} else if (__waitpid (pid)) {
ret = pid;
} else {

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST,v 1.13 2019/12/30 13:20:19 jasper Exp $
@comment $OpenBSD: PLIST,v 1.14 2020/04/11 18:51:44 jasper Exp $
bin/r2
@bin bin/r2agent
bin/r2p
@ -16,7 +16,6 @@ include/libr/
include/libr/r2naked.h
include/libr/r_agraph.h
include/libr/r_anal.h
include/libr/r_anal_ex.h
include/libr/r_asm.h
include/libr/r_bin.h
include/libr/r_bin_dwarf.h