Label pages mapped by linker_allocator
Change-Id: I7e0bf29bc1a480e9be0d1ae573ca1063d90d82ff
This commit is contained in:
parent
a0db464187
commit
51a22a12ab
3 changed files with 32 additions and 5 deletions
|
@ -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 @@ static void* named_anonymous_mmap(size_t length);
|
|||
#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"
|
||||
|
||||
|
|
26
libc/private/bionic_prctl.h
Normal file
26
libc/private/bionic_prctl.h
Normal file
|
@ -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
|
|
@ -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 @@ 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);
|
||||
|
|
Loading…
Reference in a new issue