[PATCH] D49608: Mark REAL(swapcontext) with indirect_return attribute on x86

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 20 12:29:32 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT337603: Mark REAL(swapcontext) with indirect_return attribute on x86 (authored by hjl, committed by ).

Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D49608

Files:
  lib/asan/asan_interceptors.cc
  lib/sanitizer_common/sanitizer_internal_defs.h


Index: lib/asan/asan_interceptors.cc
===================================================================
--- lib/asan/asan_interceptors.cc
+++ lib/asan/asan_interceptors.cc
@@ -275,7 +275,15 @@
   uptr stack, ssize;
   ReadContextStack(ucp, &stack, &ssize);
   ClearShadowMemoryForContextStack(stack, ssize);
+#if __has_attribute(__indirect_return__) && \
+    (defined(__x86_64__) || defined(__i386__))
+  int (*real_swapcontext)(struct ucontext_t *, struct ucontext_t *)
+    __attribute__((__indirect_return__))
+    = REAL(swapcontext);
+  int res = real_swapcontext(oucp, ucp);
+#else
   int res = REAL(swapcontext)(oucp, ucp);
+#endif
   // swapcontext technically does not return, but program may swap context to
   // "oucp" later, that would look as if swapcontext() returned 0.
   // We need to clear shadow for ucp once again, as it may be in arbitrary
Index: lib/sanitizer_common/sanitizer_internal_defs.h
===================================================================
--- lib/sanitizer_common/sanitizer_internal_defs.h
+++ lib/sanitizer_common/sanitizer_internal_defs.h
@@ -122,6 +122,11 @@
 # define __has_feature(x) 0
 #endif
 
+// Older GCCs do not understand __has_attribute.
+#if !defined(__has_attribute)
+# define __has_attribute(x) 0
+#endif
+
 // For portability reasons we do not include stddef.h, stdint.h or any other
 // system header, but we do need some basic types that are not defined
 // in a portable way by the language itself.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49608.156566.patch
Type: text/x-patch
Size: 1466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180720/6a2a0485/attachment.bin>


More information about the llvm-commits mailing list