Path: blob/main/contrib/llvm-project/compiler-rt/lib/hwasan/hwasan_registers.h
96334 views
//===-- hwasan_registers.h --------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This describes the register state retrieved by hwasan when error reporting.9//10//===----------------------------------------------------------------------===//1112#ifndef HWASAN_REGISTERS_H13#define HWASAN_REGISTERS_H1415#include "sanitizer_common/sanitizer_common.h"16#include "sanitizer_common/sanitizer_platform.h"1718#if defined(__aarch64__)1920# define CAN_GET_REGISTERS 12122struct Registers {23uptr x[32];24};2526__attribute__((always_inline, unused)) static Registers GetRegisters() {27Registers regs;28__asm__ volatile(29"stp x0, x1, [%1, #(8 * 0)]\n"30"stp x2, x3, [%1, #(8 * 2)]\n"31"stp x4, x5, [%1, #(8 * 4)]\n"32"stp x6, x7, [%1, #(8 * 6)]\n"33"stp x8, x9, [%1, #(8 * 8)]\n"34"stp x10, x11, [%1, #(8 * 10)]\n"35"stp x12, x13, [%1, #(8 * 12)]\n"36"stp x14, x15, [%1, #(8 * 14)]\n"37"stp x16, x17, [%1, #(8 * 16)]\n"38"stp x18, x19, [%1, #(8 * 18)]\n"39"stp x20, x21, [%1, #(8 * 20)]\n"40"stp x22, x23, [%1, #(8 * 22)]\n"41"stp x24, x25, [%1, #(8 * 24)]\n"42"stp x26, x27, [%1, #(8 * 26)]\n"43"stp x28, x29, [%1, #(8 * 28)]\n"44: "=m"(regs)45: "r"(regs.x));46regs.x[30] = reinterpret_cast<uintptr_t>(__builtin_return_address(0));47regs.x[31] = reinterpret_cast<uintptr_t>(__builtin_frame_address(0));48return regs;49}5051#else52# define CAN_GET_REGISTERS 053#endif5455#endif // HWASAN_REGISTERS_H565758