OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CRAZY_LINKER_PROC_MAPS_H |
| 6 #define CRAZY_LINKER_PROC_MAPS_H |
| 7 |
| 8 // Helper classes and functions to extract useful information out of |
| 9 // /proc/self/maps. |
| 10 |
| 11 #include <stdint.h> |
| 12 #include <sys/mman.h> // for PROT_READ etc... |
| 13 |
| 14 namespace crazy { |
| 15 |
| 16 // Find which loaded ELF binary contains |address|. |
| 17 // On success, returns true and sets |*load_address| to its load address, |
| 18 // and fills |path_buffer| with the path to the corresponding file. |
| 19 bool FindElfBinaryForAddress(void* address, |
| 20 uintptr_t* load_address, |
| 21 char* path_buffer, |
| 22 size_t path_buffer_len); |
| 23 |
| 24 // Returns the current protection bit flags for the page holding a given |
| 25 // |address|. On success, returns true and sets |*prot_flags|. |
| 26 bool FindProtectionFlagsForAddress(void* address, int* prot_flags); |
| 27 |
| 28 // Return the load address of a given ELF binary. |
| 29 // If |file_name| contains a slash, this will try to perform an |
| 30 // exact match with the content of /proc/self/maps. Otherwise, |
| 31 // it will be taken as a base name, and the load address of the first |
| 32 // matching entry will be returned. |
| 33 // On success, returns true and sets |*load_address| to the load address, |
| 34 // and |*load_offset| to the load offset. |
| 35 bool FindLoadAddressForFile(const char* file_name, |
| 36 uintptr_t* load_address, |
| 37 uintptr_t* load_offset); |
| 38 |
| 39 } // namespace crazy |
| 40 |
| 41 #endif // CRAZY_LINKER_PROC_MAPS_H |
OLD | NEW |