Skip to content

Commit fa02950

Browse files
committed
arm64e/ptrauth unified patch: compiler-rt
1 parent 6133884 commit fa02950

File tree

7 files changed

+20
-2
lines changed

7 files changed

+20
-2
lines changed

compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set(WASM64 wasm64)
1818
set(VE ve)
1919

2020
if(APPLE)
21-
set(ARM64 arm64)
21+
set(ARM64 arm64 arm64e)
2222
set(ARM32 armv7 armv7s armv7k)
2323
set(X86_64 x86_64 x86_64h)
2424
endif()

compiler-rt/lib/asan/scripts/asan_symbolize.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def is_valid_arch(s):
5959
"armv7s",
6060
"armv7k",
6161
"arm64",
62+
"arm64e",
6263
"powerpc64",
6364
"powerpc64le",
6465
"s390x",

compiler-rt/lib/sanitizer_common/sanitizer_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ enum ModuleArch {
721721
kModuleArchARMV7S,
722722
kModuleArchARMV7K,
723723
kModuleArchARM64,
724+
kModuleArchARM64E,
724725
kModuleArchLoongArch64,
725726
kModuleArchRISCV64,
726727
kModuleArchHexagon
@@ -794,6 +795,8 @@ inline const char *ModuleArchToString(ModuleArch arch) {
794795
return "armv7k";
795796
case kModuleArchARM64:
796797
return "arm64";
798+
case kModuleArchARM64E:
799+
return "arm64e";
797800
case kModuleArchLoongArch64:
798801
return "loongarch64";
799802
case kModuleArchRISCV64:

compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#ifndef CPU_TYPE_ARM64
3333
#define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64)
3434
#endif
35+
#ifndef CPU_SUBTYPE_ARM64_E
36+
#define CPU_SUBTYPE_ARM64_E ((cpu_subtype_t)2)
37+
#endif
3538

3639
namespace __sanitizer {
3740

@@ -323,6 +326,8 @@ ModuleArch ModuleArchFromCpuType(cpu_type_t cputype, cpu_subtype_t cpusubtype) {
323326
CHECK(0 && "Invalid subtype of ARM");
324327
return kModuleArchUnknown;
325328
case CPU_TYPE_ARM64:
329+
if (cpusubtype == CPU_SUBTYPE_ARM64_E)
330+
return kModuleArchARM64E;
326331
return kModuleArchARM64;
327332
default:
328333
CHECK(0 && "Invalid CPU type");

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#include "sanitizer_platform.h"
1818
#include "sanitizer_ptrauth.h"
1919

20+
#if __has_feature(ptrauth_returns)
21+
#include <ptrauth.h>
22+
#endif
23+
2024
namespace __sanitizer {
2125

2226
uptr StackTrace::GetNextInstructionPc(uptr pc) {
@@ -132,6 +136,9 @@ void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr stack_top,
132136
// a platform where this isn't true, we need to reconsider this check.
133137
if (pc1 < kPageSize)
134138
break;
139+
#if __has_feature(ptrauth_returns)
140+
pc1 = (uhwptr)ptrauth_strip((void *)pc1, ptrauth_key_return_address);
141+
#endif
135142
if (pc1 != pc) {
136143
trace_buffer[size++] = (uptr) pc1;
137144
}

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ class LLVMSymbolizerProcess final : public SymbolizerProcess {
263263
const char *const kSymbolizerArch = "--default-arch=loongarch64";
264264
#elif SANITIZER_RISCV64
265265
const char *const kSymbolizerArch = "--default-arch=riscv64";
266+
#elif defined(__arm64e__)
267+
const char* const kSymbolizerArch = "--default-arch=arm64e";
266268
#elif defined(__aarch64__)
267269
const char* const kSymbolizerArch = "--default-arch=arm64";
268270
#elif defined(__arm__)

compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ struct VtablePrefix {
207207
std::type_info *TypeInfo;
208208
};
209209
VtablePrefix *getVtablePrefix(void *Vtable) {
210-
Vtable = ptrauth_auth_data(Vtable, ptrauth_key_cxx_vtable_pointer, 0);
210+
Vtable = ptrauth_strip(Vtable, ptrauth_key_cxx_vtable_pointer);
211211
VtablePrefix *Vptr = reinterpret_cast<VtablePrefix*>(Vtable);
212212
VtablePrefix *Prefix = Vptr - 1;
213213
if (!IsAccessibleMemoryRange((uptr)Prefix, sizeof(VtablePrefix)))

0 commit comments

Comments
 (0)