// Base address of the CFI shadow. Passed down from the linker in __cfi_init() // and does not change after that. The contents of the shadow change in // dlopen/dlclose. staticstruct {
uintptr_t v; char padding[max_android_page_size() - sizeof(v)];
} shadow_base_storage alignas(max_android_page_size());
// __cfi_init is called by the loader as soon as the shadow is mapped. This may happen very early // during startup, before libdl.so global constructors, and, on i386, even before __libc_sysinfo is // initialized. This function should not do any system calls. extern"C" uintptr_t* __cfi_init(uintptr_t shadow_base) {
shadow_base_storage.v = shadow_base;
static_assert(sizeof(shadow_base_storage) == max_android_page_size(), ""); 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) { // Untag the pointer to move it into the address space covered by the shadow.
uintptr_t addr = reinterpret_cast<uintptr_t>(untag_address(p));
uintptr_t ofs = CFIShadow::MemToShadowOffset(addr); if (ofs > CFIShadow::kShadowSize) return CFIShadow::kInvalidShadow; return *reinterpret_cast<uint16_t*>(shadow_base_storage.v + ofs);
}
static uintptr_t cfi_check_addr(uint16_t v, void* Ptr) {
uintptr_t addr = reinterpret_cast<uintptr_t>(Ptr); // The aligned range of [0, kShadowAlign) uses a single shadow element, therefore all pointers in // this range must get the same aligned_addr below. This matches CFIShadowWriter::Add; not the // same as just __builtin_align_up().
uintptr_t aligned_addr = __builtin_align_down(addr, CFIShadow::kShadowAlign) + CFIShadow::kShadowAlign;
uintptr_t p = aligned_addr - (static_cast<uintptr_t>(v - CFIShadow::kRegularShadowMin)
<< CFIShadow::kCfiCheckGranularity); #ifdef __arm__ // Assume Thumb encoding. FIXME: force thumb at compile time?
p++; #endif return p;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.