// Alignment of __cfi_check.
static constexpr uintptr_t kCfiCheckAlign = 1UL << kCfiCheckGranularity; // 4K
-#if defined(__aarch64__)
- static constexpr uintptr_t kMaxTargetAddr = 0x7fffffffff;
-#elif defined (__LP64__)
- static constexpr uintptr_t kMaxTargetAddr = 0x7fffffffffff;
+#if defined (__LP64__)
+ static constexpr uintptr_t kMaxTargetAddr = 0xffffffffffff;
#else
static constexpr uintptr_t kMaxTargetAddr = 0xffffffff;
#endif
LIBC_OMR1 { # future
global:
+ __cfi_shadow_size; # future
__cfi_slowpath; # future
__cfi_slowpath_diag; # future
} LIBC_N;
LIBC_OMR1 { # future
global:
+ __cfi_shadow_size; # future
__cfi_slowpath; # future
__cfi_slowpath_diag; # future
} LIBC_N;
LIBC_OMR1 { # future
global:
+ __cfi_shadow_size; # future
__cfi_slowpath; # future
__cfi_slowpath_diag; # future
} LIBC_N;
LIBC_OMR1 { # future
global:
+ __cfi_shadow_size; # future
__cfi_slowpath; # future
__cfi_slowpath_diag; # future
} LIBC_N;
LIBC_OMR1 { # future
global:
+ __cfi_shadow_size; # future
__cfi_slowpath; # future
__cfi_slowpath_diag; # future
} LIBC_N;
LIBC_OMR1 { # future
global:
+ __cfi_shadow_size; # future
__cfi_slowpath; # future
__cfi_slowpath_diag; # future
} LIBC_N;
LIBC_OMR1 { # future
global:
+ __cfi_shadow_size; # future
__cfi_slowpath; # future
__cfi_slowpath_diag; # future
} LIBC_N;
return &shadow_base_storage.v;
}
+// Returns the size of the CFI shadow mapping, or 0 if CFI is not (yet) used in this process.
+extern "C" size_t __cfi_shadow_size() {
+ return shadow_base_storage.v != 0 ? CFIShadow::kShadowSize : 0;
+}
+
static uint16_t shadow_load(void* p) {
uintptr_t addr = reinterpret_cast<uintptr_t>(p);
uintptr_t ofs = CFIShadow::MemToShadowOffset(addr);
extern "C" {
void __cfi_slowpath(uint64_t CallSiteTypeId, void* Ptr);
void __cfi_slowpath_diag(uint64_t CallSiteTypeId, void* Ptr, void* DiagData);
+size_t __cfi_shadow_size();
}
static void f() {}
handle = dlopen("libcfi-test.so", RTLD_NOW | RTLD_LOCAL);
ASSERT_TRUE(handle != nullptr) << dlerror();
+ EXPECT_NE(0U, __cfi_shadow_size());
+
#define SYM(type, name) auto name = reinterpret_cast<type>(dlsym(handle, #name))
SYM(int (*)(), get_count);
SYM(uint64_t(*)(), get_last_type_id);