Merge "Label pages mapped by linker_allocator"
diff --git a/libc/bionic/dlmalloc.c b/libc/bionic/dlmalloc.c
index d582071..e89c5d1 100644
--- a/libc/bionic/dlmalloc.c
+++ b/libc/bionic/dlmalloc.c
@@ -16,6 +16,7 @@
 
 #include "dlmalloc.h"
 
+#include "private/bionic_prctl.h"
 #include "private/libc_logging.h"
 
 // Send dlmalloc errors to the log.
@@ -30,11 +31,6 @@
 #define MMAP(s) named_anonymous_mmap(s)
 #define DIRECT_MMAP(s) named_anonymous_mmap(s)
 
-// Local definitions of custom prctl arguments to set a vma name in Android kernels.
-#include <sys/prctl.h>
-#define PR_SET_VMA           0x53564d41
-#define PR_SET_VMA_ANON_NAME 0
-
 // Ugly inclusion of C file so that bionic specific #defines configure dlmalloc.
 #include "../upstream-dlmalloc/malloc.c"
 
diff --git a/libc/private/bionic_prctl.h b/libc/private/bionic_prctl.h
new file mode 100644
index 0000000..103cccb
--- /dev/null
+++ b/libc/private/bionic_prctl.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BIONIC_PRCTL_H
+#define BIONIC_PRCTL_H
+
+#include <sys/prctl.h>
+
+// This is only supported by Android kernels, so it's not in the uapi headers.
+#define PR_SET_VMA   0x53564d41
+#define PR_SET_VMA_ANON_NAME    0
+
+#endif // BIONIC_PRCTL_H
diff --git a/linker/linker_allocator.cpp b/linker/linker_allocator.cpp
index f5d3745..92220e8 100644
--- a/linker/linker_allocator.cpp
+++ b/linker/linker_allocator.cpp
@@ -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*)];
@@ -96,6 +98,9 @@
   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);