From c16c871c0e32637e6fca07e083348bfc57cb60b4 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Tue, 3 Sep 2019 20:47:58 +0300 Subject: [PATCH] uftrace: do not attempt to hook "backtrace" Fixes segmentation fault on ARM devices at least. backtrace (from execinfo.h) is not available on Android. %ci:reset-backlog --- packages/uftrace/build.sh | 2 +- packages/uftrace/libmcount-wrap.c.patch | 48 +++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/packages/uftrace/build.sh b/packages/uftrace/build.sh index a5385ead4..99b85c398 100644 --- a/packages/uftrace/build.sh +++ b/packages/uftrace/build.sh @@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=https://uftrace.github.io/slide TERMUX_PKG_DESCRIPTION="Function (graph) tracer for user-space" TERMUX_PKG_LICENSE="GPL-2.0" TERMUX_PKG_VERSION=0.9.3 -TERMUX_PKG_REVISION=4 +TERMUX_PKG_REVISION=5 TERMUX_PKG_SRCURL=https://github.com/namhyung/uftrace/archive/v${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=d801d72e3cdd83c510aeecc5160482d879498cf08fffd21e64f84151001e18ea TERMUX_PKG_DEPENDS="capstone, libandroid-glob, libandroid-spawn, libelf, ncurses, python2" diff --git a/packages/uftrace/libmcount-wrap.c.patch b/packages/uftrace/libmcount-wrap.c.patch index 4f6721210..fe568012f 100644 --- a/packages/uftrace/libmcount-wrap.c.patch +++ b/packages/uftrace/libmcount-wrap.c.patch @@ -1,5 +1,47 @@ -+++ ./libmcount/wrap.c 2019-08-26 04:38:48.830364663 +0300 -@@ -324,7 +324,8 @@ +diff -uNr uftrace-0.9.3/libmcount/wrap.c uftrace-0.9.3.mod/libmcount/wrap.c +--- uftrace-0.9.3/libmcount/wrap.c 2019-07-13 17:25:47.000000000 +0300 ++++ uftrace-0.9.3.mod/libmcount/wrap.c 2019-09-03 20:46:52.430226391 +0300 +@@ -216,7 +216,6 @@ + /* + * hooking functions + */ +-static int (*real_backtrace)(void **buffer, int sz); + static void (*real_cxa_throw)(void *exc, void *type, void *dest); + static void (*real_cxa_rethrow)(void); + static void * (*real_cxa_begin_catch)(void *exc); +@@ -241,7 +240,6 @@ + + void mcount_hook_functions(void) + { +- real_backtrace = dlsym(RTLD_NEXT, "backtrace"); + real_cxa_throw = dlsym(RTLD_NEXT, "__cxa_throw"); + real_cxa_rethrow = dlsym(RTLD_NEXT, "__cxa_rethrow"); + real_cxa_begin_catch = dlsym(RTLD_NEXT, "__cxa_begin_catch"); +@@ -258,22 +256,7 @@ + + __visible_default int backtrace(void **buffer, int sz) + { +- int ret; +- struct mcount_thread_data *mtdp; +- +- if (unlikely(real_backtrace == NULL)) +- mcount_hook_functions(); +- +- mtdp = get_thread_data(); +- if (!check_thread_data(mtdp)) +- mcount_rstack_restore(mtdp); +- +- ret = real_backtrace(buffer, sz); +- +- if (!check_thread_data(mtdp)) +- mcount_rstack_reset(mtdp); +- +- return ret; ++ return 0; + } + + __visible_default void __cxa_throw(void *exception, void *type, void *dest) +@@ -324,7 +307,8 @@ real_cxa_rethrow(); } @@ -9,7 +51,7 @@ { struct mcount_thread_data *mtdp; -@@ -345,7 +346,7 @@ +@@ -345,7 +329,7 @@ mcount_rstack_restore(mtdp); }