mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-13 05:40:59 +00:00
[scudo] The BaseAddr should be MappedBase in releasePagesToOS()
This is used to make MemMapDefault be compliant with legacy APIs. Reviewed By: fabio-d Differential Revision: https://reviews.llvm.org/D148141
This commit is contained in:
parent
384fca554a
commit
bfa02523b2
@ -19,16 +19,19 @@ bool MemMapDefault::mapImpl(uptr Addr, uptr Size, const char *Name,
|
||||
if (MappedAddr == nullptr)
|
||||
return false;
|
||||
Base = reinterpret_cast<uptr>(MappedAddr);
|
||||
MappedBase = Base;
|
||||
Capacity = Size;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemMapDefault::unmapImpl(uptr Addr, uptr Size) {
|
||||
if (Size == Capacity) {
|
||||
Base = Capacity = 0;
|
||||
Base = MappedBase = Capacity = 0;
|
||||
} else {
|
||||
if (Base == Addr)
|
||||
if (Base == Addr) {
|
||||
Base = Addr + Size;
|
||||
MappedBase = MappedBase == 0 ? Base : Max(MappedBase, Base);
|
||||
}
|
||||
Capacity -= Size;
|
||||
}
|
||||
|
||||
@ -37,13 +40,17 @@ void MemMapDefault::unmapImpl(uptr Addr, uptr Size) {
|
||||
|
||||
bool MemMapDefault::remapImpl(uptr Addr, uptr Size, const char *Name,
|
||||
uptr Flags) {
|
||||
void *RemappedAddr =
|
||||
void *RemappedPtr =
|
||||
::scudo::map(reinterpret_cast<void *>(Addr), Size, Name, Flags, &Data);
|
||||
return reinterpret_cast<uptr>(RemappedAddr) == Addr;
|
||||
const uptr RemappedAddr = reinterpret_cast<uptr>(RemappedPtr);
|
||||
MappedBase = MappedBase == 0 ? RemappedAddr : Min(MappedBase, RemappedAddr);
|
||||
return RemappedAddr == Addr;
|
||||
}
|
||||
|
||||
void MemMapDefault::releaseAndZeroPagesToOSImpl(uptr From, uptr Size) {
|
||||
return ::scudo::releasePagesToOS(Base, From - Base, Size, &Data);
|
||||
DCHECK_NE(MappedBase, 0U);
|
||||
DCHECK_GE(From, MappedBase);
|
||||
return ::scudo::releasePagesToOS(MappedBase, From - MappedBase, Size, &Data);
|
||||
}
|
||||
|
||||
void MemMapDefault::setMemoryPermissionImpl(uptr Addr, uptr Size, uptr Flags) {
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
private:
|
||||
uptr Base = 0;
|
||||
uptr Capacity = 0;
|
||||
uptr MappedBase = 0;
|
||||
MapPlatformData Data = {};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user