ThrowExceptionFromContextInternal, RtlCaptureContext: fix for asan (dotnet/coreclr...
authorKonstantin Baladurin <k.baladurin@partner.samsung.com>
Tue, 30 Jan 2018 14:05:57 +0000 (17:05 +0300)
committerJan Vorlicek <janvorli@microsoft.com>
Tue, 30 Jan 2018 14:05:57 +0000 (15:05 +0100)
- Save arguments on stack before calling __asan_handle_no_return in
  ThrowExceptionFromContextInternal

- Fix saving arguments on stack before calling __asan_handle_no_return
  in RtlCaptureContext for arm64

Commit migrated from https://github.com/dotnet/coreclr/commit/b039a4c266b3d64549c4a809b7ea28a69b600358

src/coreclr/src/pal/src/arch/amd64/exceptionhelper.S
src/coreclr/src/pal/src/arch/arm/exceptionhelper.S
src/coreclr/src/pal/src/arch/arm64/context2.S
src/coreclr/src/pal/src/arch/arm64/exceptionhelper.S

index 72a1393..cb9a545 100644 (file)
@@ -17,7 +17,11 @@ LEAF_ENTRY ThrowExceptionFromContextInternal, _TEXT
 #ifdef HAS_ASAN
         // Need to call __asan_handle_no_return explicitly here because we re-intialize RSP before
         // throwing exception in ThrowExceptionHelper
+        push_nonvol_reg rdi
+        push_nonvol_reg rsi
         call    EXTERNAL_C_FUNC(__asan_handle_no_return)
+        pop_nonvol_reg rsi
+        pop_nonvol_reg rdi
 #endif
 
         // Save the RBP to the stack so that the unwind can work at the instruction after
index dad48de..4e324ce 100644 (file)
@@ -14,7 +14,9 @@ LEAF_ENTRY ThrowExceptionFromContextInternal, _TEXT
 #ifdef HAS_ASAN
     // Need to call __asan_handle_no_return explicitly here because we re-intialize SP before
     // throwing exception in ThrowExceptionHelper
+    push_nonvol_reg "{r0, r1}"
     bl  EXTERNAL_C_FUNC(__asan_handle_no_return)
+    pop_nonvol_reg "{r0, r1}"
 #endif
 
     push_nonvol_reg {r7} /* FP. x64-RBP */
index ac3661a..64a19c9 100644 (file)
@@ -138,9 +138,9 @@ LEAF_ENTRY RtlRestoreContext, _TEXT
     ldr w17, [x0, #(CONTEXT_ContextFlags)]
     tbz w17, #CONTEXT_CONTROL_BIT, LOCAL_LABEL(Restore_CONTEXT_FLOATING_POINT)
 
-    stp x0, x1, [sp]
+    stp x0, x1, [sp, -16]!
     bl EXTERNAL_C_FUNC(__asan_handle_no_return)
-    ldp x0, x1, [sp]
+    ldp x0, x1, [sp], 16
 
 LOCAL_LABEL(Restore_CONTEXT_FLOATING_POINT):
 #endif
index 7deeee6..c4499fb 100644 (file)
@@ -15,7 +15,9 @@ LEAF_ENTRY ThrowExceptionFromContextInternal, _TEXT
 #ifdef HAS_ASAN
         // Need to call __asan_handle_no_return explicitly here because we re-intialize SP before
         // throwing exception in ThrowExceptionHelper
+        stp x0, x1, [sp, -16]!
         bl  EXTERNAL_C_FUNC(__asan_handle_no_return)
+        ldp x0, x1, [sp], 16
 #endif
 
     // Save the FP & LR to the stack so that the unwind can work at the instruction after