[llvm-commits] [compiler-rt] r160498 - in /compiler-rt/trunk/lib/sanitizer_common: sanitizer_linux.cc sanitizer_symbolizer.cc sanitizer_symbolizer.h

Alexey Samsonov samsonov at google.com
Thu Jul 19 00:51:20 PDT 2012


Author: samsonov
Date: Thu Jul 19 02:51:20 2012
New Revision: 160498

URL: http://llvm.org/viewvc/llvm-project?rev=160498&view=rev
Log:
[Sanitizer] When obtaining the data for loaded modules, add address ranges of loadable segments only. Looks like address range of PT_TLS segment may intersect with loadable segments of other modules.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=160498&r1=160497&r2=160498&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Thu Jul 19 02:51:20 2012
@@ -166,6 +166,7 @@
 // ------------------ sanitizer_symbolizer.h
 typedef ElfW(Ehdr) Elf_Ehdr;
 typedef ElfW(Shdr) Elf_Shdr;
+typedef ElfW(Phdr) Elf_Phdr;
 
 bool FindDWARFSection(uptr object_file_addr, const char *section_name,
                       DWARFSection *section) {
@@ -219,12 +220,16 @@
   if (module_name == 0 || module_name[0] == '\0')
     return 0;
   void *mem = &data->modules[data->current_n];
-  ModuleDIContext *cur_module = new(mem) ModuleDIContext(module_name);
+  ModuleDIContext *cur_module = new(mem) ModuleDIContext(module_name,
+                                                         info->dlpi_addr);
   data->current_n++;
   for (int i = 0; i < info->dlpi_phnum; i++) {
-    uptr cur_beg = info->dlpi_addr + info->dlpi_phdr[i].p_vaddr;
-    uptr cur_end = cur_beg + info->dlpi_phdr[i].p_memsz;
-    cur_module->addAddressRange(cur_beg, cur_end);
+    const Elf_Phdr *phdr = &info->dlpi_phdr[i];
+    if (phdr->p_type == PT_LOAD) {
+      uptr cur_beg = info->dlpi_addr + phdr->p_vaddr;
+      uptr cur_end = cur_beg + phdr->p_memsz;
+      cur_module->addAddressRange(cur_beg, cur_end);
+    }
   }
   InternalFree(module_name);
   return 0;

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.cc?rev=160498&r1=160497&r2=160498&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.cc Thu Jul 19 02:51:20 2012
@@ -38,7 +38,7 @@
   internal_memset(this, 0, sizeof(AddressInfo));
 }
 
-ModuleDIContext::ModuleDIContext(const char *module_name) {
+ModuleDIContext::ModuleDIContext(const char *module_name, uptr base_address) {
   full_name_ = internal_strdup(module_name);
   short_name_ = internal_strrchr(module_name, '/');
   if (short_name_ == 0) {
@@ -46,7 +46,7 @@
   } else {
     short_name_++;
   }
-  base_address_ = (uptr)-1;
+  base_address_ = base_address;
   n_ranges_ = 0;
   mapped_addr_ = 0;
   mapped_size_ = 0;
@@ -56,7 +56,6 @@
   CHECK_LT(n_ranges_, kMaxNumberOfAddressRanges);
   ranges_[n_ranges_].beg = beg;
   ranges_[n_ranges_].end = end;
-  base_address_ = Min(base_address_, beg);
   n_ranges_++;
 }
 
@@ -130,7 +129,7 @@
     }
     return 0;
   }
-  static const uptr kMaxNumberOfModuleContexts = 256;
+  static const uptr kMaxNumberOfModuleContexts = 4096;
   // Array of module debug info contexts is leaked.
   ModuleDIContext *modules_;
   uptr n_modules_;

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h?rev=160498&r1=160497&r2=160498&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h Thu Jul 19 02:51:20 2012
@@ -68,7 +68,7 @@
 
 class ModuleDIContext {
  public:
-  explicit ModuleDIContext(const char *module_name);
+  ModuleDIContext(const char *module_name, uptr base_address);
   void addAddressRange(uptr beg, uptr end);
   bool containsAddress(uptr address) const;
   void getAddressInfo(AddressInfo *info);
@@ -85,7 +85,7 @@
   char *full_name_;
   char *short_name_;
   uptr base_address_;
-  static const uptr kMaxNumberOfAddressRanges = 16;
+  static const uptr kMaxNumberOfAddressRanges = 8;
   AddressRange ranges_[kMaxNumberOfAddressRanges];
   uptr n_ranges_;
   uptr mapped_addr_;





More information about the llvm-commits mailing list