diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-03-13 06:51:02 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-03-13 06:51:02 +0000 |
commit | 45717c9d5e39a434749ae10509111f9df1b2cdf4 (patch) | |
tree | 21356f373baa2d0aa2853f3c68f4faedc63d0a6a /lib/sanitizer_common/sanitizer_procmaps.h | |
parent | af9297b9be5e8993326c87ed32e44a8d2a5d7598 (diff) |
[Sanitizer] Change MemoryMappingLayout methods to also report memory protection flags (for future use in leak checker). Patch by Sergey Matveev.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@176931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_procmaps.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_procmaps.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/sanitizer_common/sanitizer_procmaps.h b/lib/sanitizer_common/sanitizer_procmaps.h index 1b8ea7aff..1b6151527 100644 --- a/lib/sanitizer_common/sanitizer_procmaps.h +++ b/lib/sanitizer_common/sanitizer_procmaps.h @@ -42,28 +42,37 @@ class MemoryMappingLayout { public: MemoryMappingLayout(); bool Next(uptr *start, uptr *end, uptr *offset, - char filename[], uptr filename_size); + char filename[], uptr filename_size, uptr *protection); void Reset(); // Gets the object file name and the offset in that object for a given // address 'addr'. Returns true on success. bool GetObjectNameAndOffset(uptr addr, uptr *offset, - char filename[], uptr filename_size); + char filename[], uptr filename_size, + uptr *protection); // In some cases, e.g. when running under a sandbox on Linux, ASan is unable // to obtain the memory mappings. It should fall back to pre-cached data // instead of aborting. static void CacheMemoryMappings(); ~MemoryMappingLayout(); + // Memory protection masks. + static const uptr kProtectionRead = 1; + static const uptr kProtectionWrite = 2; + static const uptr kProtectionExecute = 4; + static const uptr kProtectionShared = 8; + private: void LoadFromCache(); // Default implementation of GetObjectNameAndOffset. // Quite slow, because it iterates through the whole process map for each // lookup. bool IterateForObjectNameAndOffset(uptr addr, uptr *offset, - char filename[], uptr filename_size) { + char filename[], uptr filename_size, + uptr *protection) { Reset(); uptr start, end, file_offset; - for (int i = 0; Next(&start, &end, &file_offset, filename, filename_size); + for (int i = 0; Next(&start, &end, &file_offset, filename, filename_size, + protection); i++) { if (addr >= start && addr < end) { // Don't subtract 'start' for the first entry: |