]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blobdiff - linker/linker_allocator.cpp
Support gethostbyname_r_ERANGE.
[android-sdk/platform-bionic.git] / linker / linker_allocator.cpp
index c8b97b121dae4702566ca6f18d9f34ec034c612d..92220e8c4944651ace82577958e987a3460390d2 100644 (file)
@@ -18,6 +18,8 @@
 #include <sys/mman.h>
 #include <unistd.h>
 
+#include "private/bionic_prctl.h"
+
 struct LinkerAllocatorPage {
   LinkerAllocatorPage* next;
   uint8_t bytes[PAGE_SIZE-sizeof(LinkerAllocatorPage*)];
@@ -28,17 +30,12 @@ struct FreeBlockInfo {
   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();
@@ -101,6 +98,9 @@ void LinkerBlockAllocator::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);