summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_linux_x86_64.S
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2016-06-13 15:42:39 +0000
committerDerek Bruening <bruening@google.com>2016-06-13 15:42:39 +0000
commitd5a0419aecd169af9f26b6f7254ff2ef555e497f (patch)
treec969efaae3f2a01befbd5c81c9c5a21988cd680e /lib/sanitizer_common/sanitizer_linux_x86_64.S
parent51be894d7708c17d006a298b247facc796305db0 (diff)
[sanitizer][esan] Add internal_sigaction_syscall
Summary: Adds a version of sigaction that uses a raw system call, to avoid circular dependencies and support calling sigaction prior to setting up interceptors. The new sigaction relies on an assembly sigreturn routine for its restorer, which is Linux x86_64-only for now. Uses the new sigaction to initialize the working set tool's shadow fault handler prior to libc interceptor being set up. This is required to support instrumentation invoked during interceptor setup, which happens with an instrumented tcmalloc or other allocator compiled with esan. Adds a test that emulates an instrumented allocator. Reviewers: aizatsky Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D21083 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272553 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_linux_x86_64.S')
-rw-r--r--lib/sanitizer_common/sanitizer_linux_x86_64.S25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_linux_x86_64.S b/lib/sanitizer_common/sanitizer_linux_x86_64.S
new file mode 100644
index 000000000..8ff909542
--- /dev/null
+++ b/lib/sanitizer_common/sanitizer_linux_x86_64.S
@@ -0,0 +1,25 @@
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+
+// Avoid being marked as needing an executable stack:
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
+
+// Further contents are x86_64-only:
+#if defined(__linux__) && defined(__x86_64__)
+
+#include "../builtins/assembly.h"
+
+// If the "naked" function attribute were supported for x86 we could
+// do this via inline asm.
+.text
+.balign 4
+DEFINE_COMPILERRT_FUNCTION(internal_sigreturn)
+ mov $0xf, %eax // 0xf == SYS_rt_sigreturn
+ mov %rcx, %r10
+ syscall
+ ret // Won't normally reach here.
+END_COMPILERRT_FUNCTION(internal_sigreturn)
+
+#endif // defined(__linux__) && defined(__x86_64__)