Changeset View
Changeset View
Standalone View
Standalone View
compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
Show First 20 Lines • Show All 605 Lines • ▼ Show 20 Lines | static uptr GetPreferredBase(const char *modname) { | ||||
// Check for more magic in the PE header. | // Check for more magic in the PE header. | ||||
if (pe_header->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC) | if (pe_header->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC) | ||||
return 0; | return 0; | ||||
// Finally, return the ImageBase. | // Finally, return the ImageBase. | ||||
return (uptr)pe_header->ImageBase; | return (uptr)pe_header->ImageBase; | ||||
} | } | ||||
#ifdef __clang__ | |||||
#pragma clang diagnostic push | |||||
#pragma clang diagnostic ignored "-Wframe-larger-than=" | |||||
#endif | |||||
void ListOfModules::init() { | void ListOfModules::init() { | ||||
clearOrInit(); | clearOrInit(); | ||||
HANDLE cur_process = GetCurrentProcess(); | HANDLE cur_process = GetCurrentProcess(); | ||||
// Query the list of modules. Start by assuming there are no more than 256 | // Query the list of modules. Start by assuming there are no more than 256 | ||||
// modules and retry if that's not sufficient. | // modules and retry if that's not sufficient. | ||||
HMODULE *hmodules = 0; | HMODULE *hmodules = 0; | ||||
uptr modules_buffer_size = sizeof(HMODULE) * 256; | uptr modules_buffer_size = sizeof(HMODULE) * 256; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < num_modules; ++i) { | ||||
cur_module.set(module_name, adjusted_base); | cur_module.set(module_name, adjusted_base); | ||||
// We add the whole module as one single address range. | // We add the whole module as one single address range. | ||||
cur_module.addAddressRange(base_address, end_address, /*executable*/ true, | cur_module.addAddressRange(base_address, end_address, /*executable*/ true, | ||||
/*writable*/ true); | /*writable*/ true); | ||||
modules_.push_back(cur_module); | modules_.push_back(cur_module); | ||||
} | } | ||||
UnmapOrDie(hmodules, modules_buffer_size); | UnmapOrDie(hmodules, modules_buffer_size); | ||||
} | } | ||||
#ifdef __clang__ | |||||
#pragma clang diagnostic pop | |||||
#endif | |||||
void ListOfModules::fallbackInit() { clear(); } | void ListOfModules::fallbackInit() { clear(); } | ||||
// We can't use atexit() directly at __asan_init time as the CRT is not fully | // We can't use atexit() directly at __asan_init time as the CRT is not fully | ||||
// initialized at this point. Place the functions into a vector and use | // initialized at this point. Place the functions into a vector and use | ||||
// atexit() as soon as it is ready for use (i.e. after .CRT$XIC initializers). | // atexit() as soon as it is ready for use (i.e. after .CRT$XIC initializers). | ||||
InternalMmapVectorNoCtor<void (*)(void)> atexit_functions; | InternalMmapVectorNoCtor<void (*)(void)> atexit_functions; | ||||
▲ Show 20 Lines • Show All 468 Lines • Show Last 20 Lines |