Index: base/android/linker/crazy_linker/src/crazy_linker_proc_maps.h |
diff --git a/base/android/linker/crazy_linker/src/crazy_linker_proc_maps.h b/base/android/linker/crazy_linker/src/crazy_linker_proc_maps.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8fde718d112fcb5a71e6d860dcccd0cf382c771d |
--- /dev/null |
+++ b/base/android/linker/crazy_linker/src/crazy_linker_proc_maps.h |
@@ -0,0 +1,41 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CRAZY_LINKER_PROC_MAPS_H |
+#define CRAZY_LINKER_PROC_MAPS_H |
+ |
+// Helper classes and functions to extract useful information out of |
+// /proc/self/maps. |
+ |
+#include <stdint.h> |
+#include <sys/mman.h> // for PROT_READ etc... |
+ |
+namespace crazy { |
+ |
+// Find which loaded ELF binary contains |address|. |
+// On success, returns true and sets |*load_address| to its load address, |
+// and fills |path_buffer| with the path to the corresponding file. |
+bool FindElfBinaryForAddress(void* address, |
+ uintptr_t* load_address, |
+ char* path_buffer, |
+ size_t path_buffer_len); |
+ |
+// Returns the current protection bit flags for the page holding a given |
+// |address|. On success, returns true and sets |*prot_flags|. |
+bool FindProtectionFlagsForAddress(void* address, int* prot_flags); |
+ |
+// Return the load address of a given ELF binary. |
+// If |file_name| contains a slash, this will try to perform an |
+// exact match with the content of /proc/self/maps. Otherwise, |
+// it will be taken as a base name, and the load address of the first |
+// matching entry will be returned. |
+// On success, returns true and sets |*load_address| to the load address, |
+// and |*load_offset| to the load offset. |
+bool FindLoadAddressForFile(const char* file_name, |
+ uintptr_t* load_address, |
+ uintptr_t* load_offset); |
+ |
+} // namespace crazy |
+ |
+#endif // CRAZY_LINKER_PROC_MAPS_H |