summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc
diff options
context:
space:
mode:
authorFrancis Ricci <francisjricci@gmail.com>2017-07-18 23:51:47 +0000
committerFrancis Ricci <francisjricci@gmail.com>2017-07-18 23:51:47 +0000
commitbf60f68c2c6dcbf0983b0b51ca688e11a5f9ecda (patch)
tree0a63a4e7e26231b1c28e6e68801cb159c2061764 /compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc
parent1b5f7738598d97a1566043ea288b5da773d0460e (diff)
downloadbcm5719-llvm-bf60f68c2c6dcbf0983b0b51ca688e11a5f9ecda.tar.gz
bcm5719-llvm-bf60f68c2c6dcbf0983b0b51ca688e11a5f9ecda.zip
Revert "Add MemoryMappedSection struct for two-level memory map iteration"
This reverts commit c8095ce74118dee8544b0f1ffaba8f46aa10215c. Reverted due to some buildbot timeouts, perhaps due to 10.11 issues. llvm-svn: 308395
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc45
1 files changed, 8 insertions, 37 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc
index 411bbd39dc9..560451a16d9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc
@@ -35,32 +35,6 @@
#endif
namespace __sanitizer {
-template <typename Section>
-void MemoryMappedSegment::NextSectionLoad(LoadedModule *module) {
- const Section *sc = (const Section *)current_load_cmd_addr_;
- current_load_cmd_addr_ += sizeof(Section);
-
- uptr sec_start = sc->addr + base_virt_addr_;
- uptr sec_end = sec_start + sc->size;
- module->addAddressRange(sec_start, sec_end, IsExecutable(), IsWritable());
-}
-
-void MemoryMappedSegment::AddAddressRanges(LoadedModule *module) {
- if (!nsects_) {
- module->addAddressRange(start, end, IsExecutable(), IsWritable());
- return;
- }
-
- do {
- if (lc_type_ == LC_SEGMENT) {
- NextSectionLoad<struct section>(module);
-#ifdef MH_MAGIC_64
- } else if (lc_type_ == LC_SEGMENT_64) {
- NextSectionLoad<struct section_64>(module);
-#endif
- }
- } while (--nsects_);
-}
MemoryMappingLayout::MemoryMappingLayout(bool cache_enabled) {
Reset();
@@ -169,25 +143,21 @@ bool MemoryMappingLayout::NextSegmentLoad(MemoryMappedSegment *segment) {
current_load_cmd_addr_ += ((const load_command *)lc)->cmdsize;
if (((const load_command *)lc)->cmd == kLCSegment) {
const SegmentCommand* sc = (const SegmentCommand *)lc;
- segment->current_load_cmd_addr_ = (char *)lc + sizeof(SegmentCommand);
- segment->lc_type_ = kLCSegment;
- segment->nsects_ = sc->nsects;
if (current_image_ == kDyldImageIdx) {
- segment->base_virt_addr_ = (uptr)get_dyld_hdr();
// vmaddr is masked with 0xfffff because on macOS versions < 10.12,
// it contains an absolute address rather than an offset for dyld.
// To make matters even more complicated, this absolute address
// isn't actually the absolute segment address, but the offset portion
// of the address is accurate when combined with the dyld base address,
// and the mask will give just this offset.
- segment->start = (sc->vmaddr & 0xfffff) + segment->base_virt_addr_;
+ segment->start = (sc->vmaddr & 0xfffff) + (uptr)get_dyld_hdr();
+ segment->end = (sc->vmaddr & 0xfffff) + sc->vmsize + (uptr)get_dyld_hdr();
} else {
- segment->base_virt_addr_ =
- (uptr)_dyld_get_image_vmaddr_slide(current_image_);
- segment->start = sc->vmaddr + segment->base_virt_addr_;
+ const sptr dlloff = _dyld_get_image_vmaddr_slide(current_image_);
+ segment->start = sc->vmaddr + dlloff;
+ segment->end = sc->vmaddr + sc->vmsize + dlloff;
}
- segment->end = segment->start + sc->vmsize;
// Return the initial protection.
segment->protection = sc->initprot;
@@ -322,7 +292,7 @@ void MemoryMappingLayout::DumpListOfModules(
Reset();
InternalScopedString module_name(kMaxPathLength);
MemoryMappedSegment segment(module_name.data(), kMaxPathLength);
- while (Next(&segment)) {
+ for (uptr i = 0; Next(&segment); i++) {
if (segment.filename[0] == '\0') continue;
LoadedModule *cur_module = nullptr;
if (!modules->empty() &&
@@ -334,7 +304,8 @@ void MemoryMappingLayout::DumpListOfModules(
cur_module->set(segment.filename, segment.start, segment.arch,
segment.uuid, current_instrumented_);
}
- segment.AddAddressRanges(cur_module);
+ cur_module->addAddressRange(segment.start, segment.end,
+ segment.IsExecutable(), segment.IsWritable());
}
}
OpenPOWER on IntegriCloud