diff --git a/mozglue/linker/CustomElf.cpp b/mozglue/linker/CustomElf.cpp index a8c74e86756..8e2676af44f 100644 --- a/mozglue/linker/CustomElf.cpp +++ b/mozglue/linker/CustomElf.cpp @@ -86,10 +86,12 @@ public: , mappable(mappable) { } +private: + friend class GenericMappedPtr; void munmap(void *buf, size_t length) { mappable->munmap(buf, length); } -private: + Mappable *mappable; }; diff --git a/mozglue/linker/Mappable.cpp b/mozglue/linker/Mappable.cpp index 9ea6b6af9cb..657d5417182 100644 --- a/mozglue/linker/Mappable.cpp +++ b/mozglue/linker/Mappable.cpp @@ -206,7 +206,7 @@ public: #ifdef ANDROID ~_MappableBuffer() { /* Free the additional page we allocated. See _MappableBuffer::Create */ - munmap(this + ((GetLength() + PAGE_SIZE) & ~(PAGE_SIZE - 1)), PAGE_SIZE); + ::munmap(this + ((GetLength() + PAGE_SIZE) & ~(PAGE_SIZE - 1)), PAGE_SIZE); } #endif diff --git a/mozglue/linker/Mappable.h b/mozglue/linker/Mappable.h index 17fec1f9ffb..14a0e157088 100644 --- a/mozglue/linker/Mappable.h +++ b/mozglue/linker/Mappable.h @@ -26,10 +26,16 @@ public: virtual void *mmap(const void *addr, size_t length, int prot, int flags, off_t offset) = 0; + +private: virtual void munmap(void *addr, size_t length) { ::munmap(addr, length); } + /* Limit use of Mappable::munmap to classes that keep track of the address + * and size of the mapping. This allows to ignore ::munmap return value. */ + friend class Mappable1stPagePtr; +public: /** * Indicate to a Mappable instance that no further mmap is going to happen. */ diff --git a/mozglue/linker/Utils.h b/mozglue/linker/Utils.h index 439843d19b8..554187e5bc7 100644 --- a/mozglue/linker/Utils.h +++ b/mozglue/linker/Utils.h @@ -247,6 +247,8 @@ struct MappedPtr: public GenericMappedPtr : GenericMappedPtr(buf, length) { } MappedPtr(): GenericMappedPtr() { } +private: + friend class GenericMappedPtr; void munmap(void *buf, size_t length) { ::munmap(buf, length);