[compiler-rt] r308676 - Revert "Add MemoryMappedSection struct for two-level memory map iteration"
Francis Ricci via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 20 14:23:14 PDT 2017
Author: fjricci
Date: Thu Jul 20 14:23:14 2017
New Revision: 308676
URL: http://llvm.org/viewvc/llvm-project?rev=308676&view=rev
Log:
Revert "Add MemoryMappedSection struct for two-level memory map iteration"
This probably broke lib0 tsan unit test on 10.11 buildbots
This reverts commit 35ad307c385e384f47a7fb348c14b3602d3a33c4.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h?rev=308676&r1=308675&r2=308676&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h Thu Jul 20 14:23:14 2017
@@ -37,8 +37,7 @@ static const uptr kProtectionWrite = 2;
static const uptr kProtectionExecute = 4;
static const uptr kProtectionShared = 8;
-class MemoryMappedSegment {
- public:
+struct MemoryMappedSegment {
MemoryMappedSegment(char *buff = nullptr, uptr size = 0)
: filename(buff), filename_size(size) {}
~MemoryMappedSegment() {}
@@ -56,22 +55,6 @@ class MemoryMappedSegment {
uptr protection;
ModuleArch arch;
u8 uuid[kModuleUUIDSize];
-
-#if SANITIZER_MAC
-
- private:
- friend class MemoryMappingLayout;
-
- template <typename Section>
- void NextSectionLoad(LoadedModule *module);
- void AddAddressRanges(LoadedModule *module);
-
- uptr nsects_;
- char *current_load_cmd_addr_;
- u32 lc_type_;
- uptr base_virt_addr_;
- uptr addr_mask_;
-#endif
};
class MemoryMappingLayout {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc?rev=308676&r1=308675&r2=308676&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc Thu Jul 20 14:23:14 2017
@@ -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 & addr_mask_) + 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,27 +143,21 @@ bool MemoryMappingLayout::NextSegmentLoa
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->addr_mask_ = 0xfffff;
+ 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->addr_mask_ = ~0;
+ const sptr dlloff = _dyld_get_image_vmaddr_slide(current_image_);
+ segment->start = sc->vmaddr + dlloff;
+ segment->end = sc->vmaddr + sc->vmsize + dlloff;
}
- segment->start =
- (sc->vmaddr & segment->addr_mask_) + segment->base_virt_addr_;
- segment->end = segment->start + sc->vmsize;
// Return the initial protection.
segment->protection = sc->initprot;
@@ -324,7 +292,7 @@ void MemoryMappingLayout::DumpListOfModu
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() &&
@@ -336,7 +304,8 @@ void MemoryMappingLayout::DumpListOfModu
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());
}
}
More information about the llvm-commits
mailing list