代码拉取完成,页面将自动刷新
diff --git a/include/pub_tool_libcsetjmp.h b/include/pub_tool_libcsetjmp.h
index e9638c3..1a52715 100644
--- a/include/pub_tool_libcsetjmp.h
+++ b/include/pub_tool_libcsetjmp.h
@@ -150,6 +150,111 @@ UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
__attribute__((noreturn))
void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+#elif defined __aarch64__ && defined __clang__
+
+// __builtin_setjmp is not implemented by the standard C library
+// used on Android in current llvm-based toolchains as of NDK r19.
+//
+// Here is a custom implementation of Valgrind's "minimal" setjmp
+// interface. Per the comment at the top of this file, we only need
+// to save integer registers.
+//
+// Per the Procedure Call Standard for the ARM 64-bit Architecture
+// document,
+// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf
+// Section 5.1.1. General-purpose registers:
+// >
+// > A subroutine invocation must preserve the contents of the
+// > registers r19-r29 and SP."
+//
+// We also need to save and restore r30, the link register, i.e.
+// the default destination that a 'ret' instruction branches to.
+//
+// Note that this document is phrased in terms of 'r' registers
+// (e.g. "r30") because it aims to be agnostic as to A64 vs A32
+// instruction sets, but here we are targeting the A64 instruction
+// set, so we are dealing with 'x' registers.
+
+
+#define VG_MINIMAL_JMP_BUF(_name) UWord _name [13]
+
+__attribute__((returns_twice))
+inline UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env))
+{
+ asm volatile(
+ // x9 is the first of the regular temporary registers
+ // per the above-mentioned Procedule Call Standard document.
+ // Use it as temporary to hold the value of SP, since str does
+ // not accept SP as operand.
+ " mov x9, sp \n"
+ // Store the general-purpose registers that we need to save
+ // per the above discussion.
+ // Note that x30 is the link register.
+ " stp x19, x20, [%[_env], 0] \n"
+ " stp x21, x22, [%[_env], 0x10] \n"
+ " stp x23, x24, [%[_env], 0x20] \n"
+ " stp x25, x26, [%[_env], 0x30] \n"
+ " stp x27, x28, [%[_env], 0x40] \n"
+ " stp x29, x30, [%[_env], 0x50] \n"
+ // Store the value of SP.
+ " str x9, [%[_env], 0x60] \n"
+ :
+ // No outputs
+ :
+ // Inputs
+ [_env]"r"(_env)
+ :
+ // Clobbers.
+ // We have used x9 as a temporary
+ "x9",
+ // We have written to memory locations
+ "memory");
+
+ // Direct invokation of setjmp always returns 0.
+ // The pseudo returning of the value 1 as a return from longjmp
+ // is implemented in longjmp.
+ return 0;
+}
+
+__attribute__((noreturn))
+inline void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env))
+{
+ asm volatile(
+ // Loads to match the stores in the above setjmp implementation.
+ " ldp x19, x20, [%[_env], 0] \n"
+ " ldp x21, x22, [%[_env], 0x10] \n"
+ " ldp x23, x24, [%[_env], 0x20] \n"
+ " ldp x25, x26, [%[_env], 0x30] \n"
+ " ldp x27, x28, [%[_env], 0x40] \n"
+ " ldp x29, x30, [%[_env], 0x50] \n"
+ " ldr x9, [%[_env], 0x60] \n"
+ " mov sp, x9 \n"
+ // return as setjmp for the second time, returning 1.
+ // Since we have loaded the link register x30 from the saved buffer
+ // that was set by the above setjmp implementation, the 'ret' instruction
+ // here is going to return to where setjmp was called.
+ // Per the setjmp/longjmp contract, that pseudo second returning
+ // of setjmp should return the value 1.
+ // x0 is holds the integer return value.
+ " mov x0, 1 \n"
+ " ret \n"
+ :
+ // No outputs
+ :
+ // Inputs
+ [_env]"r"(_env)
+ :
+ // Clobbers.
+ // We have used x9 as a temporary
+ "x9");
+
+ // This statement is unreachable because the above asm statement
+ // unconditionally does a 'ret' instruction. The purpose of this
+ // statement is to silence clang warnings about this function returning
+ // while having the 'noreturn' attribute.
+ __builtin_unreachable();
+}
+
#else
/* The default implementation. */
diff --git a/include/pub_tool_libcsetjmp.h.orig b/include/pub_tool_libcsetjmp.h.orig
new file mode 100644
index 0000000..e9638c3
--- /dev/null
+++ b/include/pub_tool_libcsetjmp.h.orig
@@ -0,0 +1,166 @@
+
+/*--------------------------------------------------------------------*/
+/*--- A minimal setjmp/longjmp facility. pub_tool_libcsetjmp.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2010-2017 Mozilla Foundation
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+/* Contributed by Julian Seward <jseward@acm.org> */
+
+#ifndef __PUB_TOOL_LIBCSETJMP_H
+#define __PUB_TOOL_LIBCSETJMP_H
+
+#include "pub_tool_basics.h" // UWord
+
+//--------------------------------------------------------------------
+// PURPOSE: Provides a minimal setjmp/longjmp facility, that saves/
+// restores integer registers, but not necessarily anything more.
+//--------------------------------------------------------------------
+
+
+/* This provides an extremely minimal setjmp/longjmp facility, in
+ which only the host's integer registers are saved/restored. Or at
+ least, that is the minimal guaranteed functionality.
+
+ Until Apr 2011 we used __builtin_setjmp and __builtin_longjmp, but
+ it appears that that is not always correctly implemented. See
+ https://bugs.kde.org/show_bug.cgi?id=259977. So this module wraps
+ those functions up and facilitates replacing them with our own
+ implementations where necessary.
+*/
+
+/* --- !!! --- EXTERNAL HEADERS start --- !!! --- */
+#include <setjmp.h>
+/* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
+
+
+/* Don't use jmp_buf, __builtin_setjmp or __builtin_longjmp directly.
+ They don't always work reliably. Instead use these macros, which
+ provide the opportunity to supply alternative implementations as
+ necessary.
+
+ Note that the abstraction is done with macros (ick) rather than
+ functions and typedefs, since wrapping __builtin_setjmp up in a
+ second function (eg, VG_(minimal_setjmp)) doesn't seem to work for
+ whatever reason -- returns via a VG_(minimal_longjmp) go wrong.
+
+ VG_MINIMAL_SETJMP stores the current integer register state in the
+ supplied argument, and returns zero. VG_MINIMAL_LONGJMP resumes
+ with the previously saved state, and returns a nonzero, word-sized
+ value. The caller must test all bits of the value in order to make
+ a zero/non-zero determination.
+*/
+
+#if defined(VGP_ppc32_linux)
+
+#define VG_MINIMAL_JMP_BUF(_name) UInt _name [32+1+1]
+__attribute__((returns_twice))
+UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
+__attribute__((noreturn))
+void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+
+
+#elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
+
+#define VG_MINIMAL_JMP_BUF(_name) ULong _name [32+1+1]
+__attribute__((returns_twice))
+UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
+__attribute__((noreturn))
+void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+
+
+#elif defined(VGP_amd64_linux) || defined(VGP_amd64_darwin) || \
+ defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd)
+
+#define VG_MINIMAL_JMP_BUF(_name) ULong _name [16+1]
+__attribute__((returns_twice))
+UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
+__attribute__((noreturn))
+void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+
+
+#elif defined(VGP_x86_linux) || defined(VGP_x86_darwin) || \
+ defined(VGP_x86_solaris) || defined(VGP_x86_freebsd)
+
+#define VG_MINIMAL_JMP_BUF(_name) UInt _name [8+1]
+__attribute__((returns_twice))
+__attribute__((regparm(1))) // this is critical; don't delete
+UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
+__attribute__((noreturn))
+__attribute__((regparm(1))) // ditto
+void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+
+#elif defined(VGP_mips32_linux) || defined(VGP_nanomips_linux)
+
+#define VG_MINIMAL_JMP_BUF(_name) ULong _name [104 / sizeof(ULong)]
+__attribute__((returns_twice))
+UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
+__attribute__((noreturn))
+void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+
+#elif defined(VGP_mips64_linux)
+
+#define VG_MINIMAL_JMP_BUF(_name) ULong _name [168 / sizeof(ULong)]
+__attribute__((returns_twice))
+UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
+__attribute__((noreturn))
+void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+
+#elif defined(VGP_s390x_linux)
+
+#define VG_MINIMAL_JMP_BUF(_name) ULong _name [10 + 8]
+__attribute__((returns_twice))
+UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
+__attribute__((noreturn))
+void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+
+#elif defined(__clang__) && defined(VGP_arm64_linux)
+
+#define VG_MINIMAL_JMP_BUF(_name) UWord _name [13]
+__attribute__((returns_twice))
+UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
+__attribute__((noreturn))
+void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+
+#elif defined(VGP_arm64_freebsd)
+
+#define VG_MINIMAL_JMP_BUF(_name) UWord _name [22]
+__attribute__((returns_twice))
+UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env));
+__attribute__((noreturn))
+void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env));
+
+#else
+
+/* The default implementation. */
+#define VG_MINIMAL_JMP_BUF(_name) jmp_buf _name
+#define VG_MINIMAL_SETJMP(_env) ((UWord)(__builtin_setjmp((_env))))
+#define VG_MINIMAL_LONGJMP(_env) __builtin_longjmp((_env),1)
+
+#endif
+
+#endif // __PUB_TOOL_LIBCSETJMP_H
+
+/*--------------------------------------------------------------------*/
+/*--- end pub_tool_libcsetjmp.h ---*/
+/*--------------------------------------------------------------------*/
--
2.48.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。