[scudo] Temporariy dispatch region from `RegionBeg`
In general, a region is located from region base and has size
`RegionSize`. However, some platforms may not support mapping from
region base. Before we have each platform implements their specific
MemMap to handle the offset. Temporarily dispatch the region from
`RegionBeg` instead.
Reviewed By: cferris, fabio-d
Differential Revision: https://reviews.llvm.org/D147792
GitOrigin-RevId: 9d9a7732e14d7d4c0db7b46d6ebe588e8f43b951
diff --git a/primary64.h b/primary64.h
index dad6d26..4ea1ba3 100644
--- a/primary64.h
+++ b/primary64.h
@@ -747,8 +747,14 @@
}
// TODO: Consider allocating MemMap in init().
if (!Region->MemMap.isAllocated()) {
- Region->MemMap = ReservedMemory.dispatch(
- getRegionBaseByClassId(ClassId), RegionSize);
+ // TODO: Ideally, a region should reserve RegionSize because the memory
+ // between `RegionBeg` and region base is still belong to a region and
+ // it's just not used. In order to make it work on every platform (some
+ // of them don't support `remap()` across the unused range), dispatch
+ // from `RegionBeg` for now.
+ const uptr ReserveSize =
+ RegionSize - (RegionBeg - getRegionBaseByClassId(ClassId));
+ Region->MemMap = ReservedMemory.dispatch(RegionBeg, ReserveSize);
}
DCHECK(Region->MemMap.isAllocated());