emacs: disable fdsan

https://github.com/termux/termux-packages/issues/6592
This commit is contained in:
Leonid Pliushch 2021-04-10 17:05:37 +03:00
parent bb62878def
commit 7699c97b23
No known key found for this signature in database
GPG Key ID: 45F2964132545795
2 changed files with 35 additions and 0 deletions

View File

@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="Extensible, customizable text editor-and more"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=27.2
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://ftp.gnu.org/gnu/emacs/emacs-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=b4a7cc4e78e63f378624e0919215b910af5bb2a0afc819fad298272e9f40c1b9
TERMUX_PKG_DEPENDS="ncurses, gnutls, libxml2"

View File

@ -0,0 +1,34 @@
diff -uNr emacs-27.2/src/emacs.c emacs-27.2.mod/src/emacs.c
--- emacs-27.2/src/emacs.c 2021-01-28 19:52:38.000000000 +0200
+++ emacs-27.2.mod/src/emacs.c 2021-04-10 17:04:56.744343967 +0300
@@ -120,6 +120,11 @@
#include "pdumper.h"
#include "epaths.h"
+#ifdef __ANDROID__
+#include <android/fdsan.h>
+#include <dlfcn.h>
+#endif
+
static const char emacs_version[] = PACKAGE_VERSION;
static const char emacs_copyright[] = COPYRIGHT;
static const char emacs_bugreport[] = PACKAGE_BUGREPORT;
@@ -954,6 +959,18 @@
/* Record (approximately) where the stack begins. */
stack_bottom = (char *) &stack_bottom_variable;
+#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 newlevel) = 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
+
const char *dump_mode = NULL;
int skip_args = 0;
char *temacs = NULL;