uftrace: apply clang mcount hook patch

Was proposed in https://github.com/namhyung/uftrace/issues/851.
This commit is contained in:
Leonid Pliushch 2019-09-10 23:29:24 +03:00
parent 89acd4050b
commit 369d94bfbb
2 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,31 @@
diff --git a/arch/arm/mcount.S b/arch/arm/mcount.S
index bbfc597..eb28831 100644
--- a/arch/arm/mcount.S
+++ b/arch/arm/mcount.S
@@ -60,6 +60,26 @@ GLOBAL(__gnu_mcount_nc)
bx ip
END(__gnu_mcount_nc)
+/* for clang */
+GLOBAL(mcount)
+ push {r0-r3, lr}
+ ands r3, lr, #1 /* check lr for ARM/THUMB detection */
+ add r0, fp, #4 /* r0 points to pushed LR */
+ bne 1f
+ ldr r1, [fp] /* fp (=r11) might point to return address on ARM */
+ ldr r2, [r0]
+ cmp r1, r2
+ moveq r0, lr
+1:
+ mov r1, lr /* child ip */
+ mov r2, sp /* mcount_args */
+
+ bl mcount_entry
+
+ pop {r0-r3, lr}
+ bx lr
+END(mcount)
+
ENTRY(mcount_return)
push {r0-r3, lr, pc} /* ensure 8-byte alignment */

View File

@ -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=5
TERMUX_PKG_REVISION=6
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"