index c8b97b121dae4702566ca6f18d9f34ec034c612d..92220e8c4944651ace82577958e987a3460390d2 100644 (file)
#include <sys/mman.h>
#include <unistd.h>
+#include "private/bionic_prctl.h"
+
struct LinkerAllocatorPage {
LinkerAllocatorPage* next;
uint8_t bytes[PAGE_SIZE-sizeof(LinkerAllocatorPage*)];
size_t num_free_blocks;
};
-LinkerBlockAllocator::LinkerBlockAllocator()
- : block_size_(0),
+LinkerBlockAllocator::LinkerBlockAllocator(size_t block_size)
+ : block_size_(block_size < sizeof(FreeBlockInfo) ? sizeof(FreeBlockInfo) : block_size),
page_list_(nullptr),
free_block_list_(nullptr)
{}
-void LinkerBlockAllocator::init(size_t block_size) {
- block_size_ = block_size < sizeof(FreeBlockInfo) ? sizeof(FreeBlockInfo) : block_size;
-}
-
-
void* LinkerBlockAllocator::alloc() {
if (free_block_list_ == nullptr) {
create_new_page();
if (page == MAP_FAILED) {
abort(); // oom
}
+
+ prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, page, PAGE_SIZE, "linker_alloc");
+
memset(page, 0, PAGE_SIZE);
FreeBlockInfo* first_block = reinterpret_cast<FreeBlockInfo*>(page->bytes);