From 3abcd55aae5f9b180a3bff7e87671088bad59aa1 Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Mon, 13 Dec 2021 09:32:03 +0100 Subject: [PATCH] cgdb: add patch to disable fdsan Similar to patch for texlive-bin, inetutils, emacs and zsh. Cast from void to function pointer had to be modified though, , or else we get a compilation error: cgdb.cpp:1770:12: error: cannot initialize a variable of type 'void (*)(enum android_fdsan_error_level)' with an rvalue of type 'void *' void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level"); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Not sure why we have not seen the same error for the other packages with this patch. Fixes https://github.com/termux/termux-packages/issues/7881. --- packages/cgdb/build.sh | 2 +- packages/cgdb/disable-fdsan.patch | 35 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 packages/cgdb/disable-fdsan.patch diff --git a/packages/cgdb/build.sh b/packages/cgdb/build.sh index 4bb578f21b..78db3cf0a7 100644 --- a/packages/cgdb/build.sh +++ b/packages/cgdb/build.sh @@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="A lightweight curses (terminal-based) interface to the G TERMUX_PKG_LICENSE="GPL-2.0" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION=0.7.1 -TERMUX_PKG_REVISION=1 +TERMUX_PKG_REVISION=2 TERMUX_PKG_SRCURL=https://cgdb.me/files/cgdb-${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=bb723be58ec68cb59a598b8e24a31d10ef31e0e9c277a4de07b2f457fe7de198 TERMUX_PKG_DEPENDS="libc++, ncurses, readline, gdb" diff --git a/packages/cgdb/disable-fdsan.patch b/packages/cgdb/disable-fdsan.patch new file mode 100644 index 0000000000..9036f5d256 --- /dev/null +++ b/packages/cgdb/disable-fdsan.patch @@ -0,0 +1,35 @@ +--- ./cgdb/cgdb.cpp~ 2021-12-13 09:02:26.731050742 +0100 ++++ ./cgdb/cgdb.cpp 2021-12-13 09:07:32.078899611 +0100 +@@ -84,6 +84,11 @@ + #include "rline.h" + #include "usage.h" + ++#ifdef __ANDROID__ ++#include ++#include ++#endif ++ + /* --------- */ + /* Constants */ + /* --------- */ +@@ -1757,6 +1762,20 @@ + { + parse_long_options(&argc, &argv); + ++ ++ #ifdef __ANDROID__ ++ // For Android 11+. ++ void *lib_handle = dlopen("libc.so", RTLD_LAZY); ++ if (lib_handle) { ++ void (*set_fdsan_error_level)(enum android_fdsan_error_level); ++ set_fdsan_error_level = (void (*)(enum android_fdsan_error_level))dlsym(lib_handle, "android_fdsan_set_error_level"); ++ if (set_fdsan_error_level) { ++ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED); ++ } ++ dlclose(lib_handle); ++ } ++ #endif ++ + /* Debugging helper - wait for debugger to attach to us before continuing */ + if (wait_for_debugger_to_attach) { + if (cgdb_supports_debugger_attach_detection()) {