Reset prologue_location before calling code_end
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_procmaps_solaris.cpp
blob4063ec8deaa12dd53a656a11ac31c592ed939ffd
1 //===-- sanitizer_procmaps_solaris.cpp ------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Information about the process mappings (Solaris-specific parts).
10 //===----------------------------------------------------------------------===//
12 #include "sanitizer_platform.h"
13 #if SANITIZER_SOLARIS
14 #include "sanitizer_common.h"
15 #include "sanitizer_procmaps.h"
17 // Before Solaris 11.4, <procfs.h> doesn't work in a largefile environment.
18 #undef _FILE_OFFSET_BITS
19 #include <procfs.h>
20 #include <limits.h>
22 namespace __sanitizer {
24 void ReadProcMaps(ProcSelfMapsBuff *proc_maps) {
25 if (!ReadFileToBuffer("/proc/self/xmap", &proc_maps->data,
26 &proc_maps->mmaped_size, &proc_maps->len)) {
27 proc_maps->data = nullptr;
28 proc_maps->mmaped_size = 0;
29 proc_maps->len = 0;
33 bool MemoryMappingLayout::Next(MemoryMappedSegment *segment) {
34 if (Error()) return false; // simulate empty maps
35 char *last = data_.proc_self_maps.data + data_.proc_self_maps.len;
36 if (data_.current >= last) return false;
38 prxmap_t *xmapentry =
39 const_cast<prxmap_t *>(reinterpret_cast<const prxmap_t *>(data_.current));
41 segment->start = (uptr)xmapentry->pr_vaddr;
42 segment->end = (uptr)(xmapentry->pr_vaddr + xmapentry->pr_size);
43 segment->offset = (uptr)xmapentry->pr_offset;
45 segment->protection = 0;
46 if ((xmapentry->pr_mflags & MA_READ) != 0)
47 segment->protection |= kProtectionRead;
48 if ((xmapentry->pr_mflags & MA_WRITE) != 0)
49 segment->protection |= kProtectionWrite;
50 if ((xmapentry->pr_mflags & MA_EXEC) != 0)
51 segment->protection |= kProtectionExecute;
53 if (segment->filename != NULL && segment->filename_size > 0) {
54 char proc_path[PATH_MAX + 1];
56 internal_snprintf(proc_path, sizeof(proc_path), "/proc/self/path/%s",
57 xmapentry->pr_mapname);
58 internal_readlink(proc_path, segment->filename, segment->filename_size);
61 data_.current += sizeof(prxmap_t);
63 return true;
66 } // namespace __sanitizer
68 #endif // SANITIZER_SOLARIS