dart-sdk/runtime/platform/safe_stack.h
Ryan Macnak f0b2a46734 [vm, fuchsia, arm64] Restore the shadow call stack on exceptions.
Fuchsia is about to turn on ShadowCallStack for ARM64. Once this is enabled, we need to treat R18 like a preserved register. Generated Dart has not accessed this register because it is reserved on iOS, and in the absence of Dart exceptions this would be sufficient for us to be ShadowCallStack compatible. However, our exception handling mechanism jumps past all the C++ frames between the Dart exit frame and Exceptions::JumpToFrame, skipping code that would pop from R18.

Add save/restore of R18 in the invocation stubs, and restore of R18 in the jump stub. The latter prevents the ShadowCallStack from overflowing for code that has lots of exceptions without a native call.

Bug: https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=37449
Change-Id: I2ce6e46624c8d72507e7afa7a44839b1f0def556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119481
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-10-02 05:33:29 +00:00

35 lines
903 B
C

// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_PLATFORM_SAFE_STACK_H_
#define RUNTIME_PLATFORM_SAFE_STACK_H_
#include "platform/globals.h"
#if defined(__has_feature)
#if __has_feature(safe_stack)
#define USING_SAFE_STACK
#endif
#endif
#if defined(USING_SAFE_STACK)
#define NO_SANITIZE_SAFE_STACK __attribute__((no_sanitize("safe-stack")))
#else
#define NO_SANITIZE_SAFE_STACK
#endif
#if defined(__has_feature)
#if __has_feature(shadow_call_stack)
#define USING_SHADOW_CALL_STACK
#endif
#endif
#if defined(USING_SHADOW_CALL_STACK)
#define NO_SANITIZE_SHADOW_CALL_STACK __attribute__((no_sanitize("shadow-call-stack")))
#else
#define NO_SANITIZE_SHADOW_CALL_STACK
#endif
#endif // RUNTIME_PLATFORM_SAFE_STACK_H_