am 00c16c1b: Merge "Label pages mapped by linker_allocator"
				
					
				
			* commit '00c16c1b921dfeab42eb92ac53c6d79addc9f549': Label pages mapped by linker_allocator
This commit is contained in:
		@@ -16,6 +16,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "dlmalloc.h"
 | 
					#include "dlmalloc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "private/bionic_prctl.h"
 | 
				
			||||||
#include "private/libc_logging.h"
 | 
					#include "private/libc_logging.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Send dlmalloc errors to the log.
 | 
					// 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 MMAP(s) named_anonymous_mmap(s)
 | 
				
			||||||
#define DIRECT_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.
 | 
					// Ugly inclusion of C file so that bionic specific #defines configure dlmalloc.
 | 
				
			||||||
#include "../upstream-dlmalloc/malloc.c"
 | 
					#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 <sys/mman.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "private/bionic_prctl.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct LinkerAllocatorPage {
 | 
					struct LinkerAllocatorPage {
 | 
				
			||||||
  LinkerAllocatorPage* next;
 | 
					  LinkerAllocatorPage* next;
 | 
				
			||||||
  uint8_t bytes[PAGE_SIZE-sizeof(LinkerAllocatorPage*)];
 | 
					  uint8_t bytes[PAGE_SIZE-sizeof(LinkerAllocatorPage*)];
 | 
				
			||||||
@@ -96,6 +98,9 @@ void LinkerBlockAllocator::create_new_page() {
 | 
				
			|||||||
  if (page == MAP_FAILED) {
 | 
					  if (page == MAP_FAILED) {
 | 
				
			||||||
    abort(); // oom
 | 
					    abort(); // oom
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, page, PAGE_SIZE, "linker_alloc");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  memset(page, 0, PAGE_SIZE);
 | 
					  memset(page, 0, PAGE_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  FreeBlockInfo* first_block = reinterpret_cast<FreeBlockInfo*>(page->bytes);
 | 
					  FreeBlockInfo* first_block = reinterpret_cast<FreeBlockInfo*>(page->bytes);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user