[compiler-rt] r308394 - Revert "Only scan global sections containing data in LSan on darwin"
Francis Ricci via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 16:51:44 PDT 2017
Author: fjricci
Date: Tue Jul 18 16:51:44 2017
New Revision: 308394
URL: http://llvm.org/viewvc/llvm-project?rev=308394&view=rev
Log:
Revert "Only scan global sections containing data in LSan on darwin"
This reverts commit 7e46d78d47832f03ce42adcf56417fbfd47cbaad.
Modified:
compiler-rt/trunk/lib/lsan/lsan_common_mac.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc
Modified: compiler-rt/trunk/lib/lsan/lsan_common_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common_mac.cc?rev=308394&r1=308393&r2=308394&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common_mac.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common_mac.cc Tue Jul 18 16:51:44 2017
@@ -92,15 +92,8 @@ LoadedModule *GetLinker() { return nullp
// required on Darwin.
void InitializePlatformSpecificModules() {}
-// Sections which may contain global variables
-static const char *kGlobalVarSecNames[] = {
- "__DATA", "__bss", "__common", "__data",
- "__objc_data", "__objc_opt_rw", "__objc_opt_ptrs"};
-
// Scans global variables for heap pointers.
void ProcessGlobalRegions(Frontier *frontier) {
- for (auto name : kGlobalVarSecNames) CHECK(ARRAY_SIZE(name) < kMaxSegName);
-
MemoryMappingLayout memory_mapping(false);
InternalMmapVector<LoadedModule> modules(/*initial_capacity*/ 128);
memory_mapping.DumpListOfModules(&modules);
@@ -111,10 +104,10 @@ void ProcessGlobalRegions(Frontier *fron
for (const __sanitizer::LoadedModule::AddressRange &range :
modules[i].ranges()) {
- for (auto name : kGlobalVarSecNames) {
- if (!internal_strcmp(range.name, name))
- ScanGlobalRange(range.beg, range.end, frontier);
- }
+ // Sections storing global variables are writable and non-executable
+ if (range.executable || !range.writable) continue;
+
+ ScanGlobalRange(range.beg, range.end, frontier);
}
}
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc?rev=308394&r1=308393&r2=308394&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc Tue Jul 18 16:51:44 2017
@@ -285,10 +285,9 @@ void LoadedModule::clear() {
}
void LoadedModule::addAddressRange(uptr beg, uptr end, bool executable,
- bool writable, const char *name) {
+ bool writable) {
void *mem = InternalAlloc(sizeof(AddressRange));
- AddressRange *r =
- new(mem) AddressRange(beg, end, executable, writable, name);
+ AddressRange *r = new(mem) AddressRange(beg, end, executable, writable);
ranges_.push_back(r);
if (executable && end > max_executable_address_)
max_executable_address_ = end;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=308394&r1=308393&r2=308394&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Tue Jul 18 16:51:44 2017
@@ -702,7 +702,6 @@ inline const char *ModuleArchToString(Mo
}
const uptr kModuleUUIDSize = 16;
-const uptr kMaxSegName = 16;
// Represents a binary loaded into virtual memory (e.g. this can be an
// executable or a shared object).
@@ -721,8 +720,7 @@ class LoadedModule {
void set(const char *module_name, uptr base_address, ModuleArch arch,
u8 uuid[kModuleUUIDSize], bool instrumented);
void clear();
- void addAddressRange(uptr beg, uptr end, bool executable, bool writable,
- const char *name = nullptr);
+ void addAddressRange(uptr beg, uptr end, bool executable, bool writable);
bool containsAddress(uptr address) const;
const char *full_name() const { return full_name_; }
@@ -738,17 +736,13 @@ class LoadedModule {
uptr end;
bool executable;
bool writable;
- char name[kMaxSegName];
- AddressRange(uptr beg, uptr end, bool executable, bool writable,
- const char *name)
+ AddressRange(uptr beg, uptr end, bool executable, bool writable)
: next(nullptr),
beg(beg),
end(end),
executable(executable),
- writable(writable) {
- internal_strncpy(this->name, (name ? name : ""), ARRAY_SIZE(this->name));
- }
+ writable(writable) {}
};
const IntrusiveList<AddressRange> &ranges() const { return ranges_; }
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=308394&r1=308393&r2=308394&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h Tue Jul 18 16:51:44 2017
@@ -58,7 +58,6 @@ class MemoryMappedSegment {
u8 uuid[kModuleUUIDSize];
#if SANITIZER_MAC
- char name[kMaxSegName];
private:
friend 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=308394&r1=308393&r2=308394&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc Tue Jul 18 16:51:44 2017
@@ -42,13 +42,12 @@ void MemoryMappedSegment::NextSectionLoa
uptr sec_start = sc->addr + base_virt_addr_;
uptr sec_end = sec_start + sc->size;
- module->addAddressRange(sec_start, sec_end, IsExecutable(), IsWritable(),
- sc->sectname);
+ module->addAddressRange(sec_start, sec_end, IsExecutable(), IsWritable());
}
void MemoryMappedSegment::AddAddressRanges(LoadedModule *module) {
if (!nsects_) {
- module->addAddressRange(start, end, IsExecutable(), IsWritable(), name);
+ module->addAddressRange(start, end, IsExecutable(), IsWritable());
return;
}
@@ -200,7 +199,6 @@ bool MemoryMappingLayout::NextSegmentLoa
: _dyld_get_image_name(current_image_);
internal_strncpy(segment->filename, src, segment->filename_size);
}
- internal_strncpy(segment->name, sc->segname, ARRAY_SIZE(segment->name));
segment->arch = current_arch_;
internal_memcpy(segment->uuid, current_uuid_, kModuleUUIDSize);
return true;
More information about the llvm-commits
mailing list