MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / makeImportsPatchable

Method makeImportsPatchable

src/codeCache.cpp:264–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264bool CodeCache::makeImportsPatchable() {
265 void** min_import = (void**)-1;
266 void** max_import = NULL;
267 for (int i = 0; i < NUM_IMPORTS; i++) {
268 for (int j = 0; j < NUM_IMPORT_TYPES; j++) {
269 void** entry = _imports[i][j];
270 if (entry == NULL) continue;
271 if (entry < min_import) min_import = entry;
272 if (entry > max_import) max_import = entry;
273 }
274 }
275
276 if (max_import != NULL) {
277 uintptr_t patch_start = (uintptr_t)min_import & ~OS::page_mask;
278 uintptr_t patch_end = (uintptr_t)max_import & ~OS::page_mask;
279 if (OS::mprotect((void*)patch_start, patch_end - patch_start + OS::page_size, PROT_READ | PROT_WRITE) != 0) {
280 Log::warn("Could not patch %s", name());
281 return false;
282 }
283 }
284
285 _imports_patchable = true;
286 return true;
287}
288
289void CodeCache::setDwarfTable(FrameDesc* table, int length) {
290 _dwarf_table = table;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected