[llvm-commits] [compiler-rt] r165018 - in /compiler-rt/trunk/lib: asan/scripts/asan_symbolize.py sanitizer_common/sanitizer_mac.cc sanitizer_common/sanitizer_procmaps.h
Alexander Potapenko
glider at google.com
Tue Oct 2 08:42:24 PDT 2012
Author: glider
Date: Tue Oct 2 10:42:24 2012
New Revision: 165018
URL: http://llvm.org/viewvc/llvm-project?rev=165018&view=rev
Log:
Do not patch the instruction address when symbolizing the reports.
Instead, print the correct address at runtime.
Modified:
compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py
compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h
Modified: compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py?rev=165018&r1=165017&r2=165018&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py (original)
+++ compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py Tue Oct 2 10:42:24 2012
@@ -146,39 +146,8 @@
self.vmaddr = None
self.pipe = None
- def get_binary_vmaddr(self):
- """Get the slide value to be added to the address.
-
- We're looking for the following piece in otool -l output:
- Load command 0
- cmd LC_SEGMENT
- cmdsize 736
- segname __TEXT
- vmaddr 0x00000000
- """
- if self.vmaddr:
- return self.vmaddr
- cmdline = ['otool', '-l', self.binary]
- pipe = subprocess.Popen(cmdline,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE)
- is_text = False
- vmaddr = 0
- for line in pipe.stdout:
- line = line.strip()
- if line.startswith('segname'):
- is_text = (line == 'segname __TEXT')
- continue
- if line.startswith('vmaddr') and is_text:
- sv = line.split(' ')
- vmaddr = int(sv[-1], 16)
- break
- self.vmaddr = vmaddr
- return self.vmaddr
-
def write_addr_to_pipe(self, offset):
- slide = self.get_binary_vmaddr()
- print >> self.pipe.stdin, '0x%x' % (int(offset, 16) + slide)
+ print >> self.pipe.stdin, '0x%x' % int(offset, 16)
def open_atos(self):
if DEBUG:
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc?rev=165018&r1=165017&r2=165018&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc Tue Oct 2 10:42:24 2012
@@ -151,6 +151,7 @@
current_load_cmd_count_ = -1;
current_load_cmd_addr_ = 0;
current_magic_ = 0;
+ current_filetype_ = 0;
}
// Next and NextSegmentLoad were inspired by base/sysinfo.cc in
@@ -171,7 +172,13 @@
const SegmentCommand* sc = (const SegmentCommand *)lc;
if (start) *start = sc->vmaddr + dlloff;
if (end) *end = sc->vmaddr + sc->vmsize + dlloff;
- if (offset) *offset = sc->fileoff;
+ if (offset) {
+ if (current_filetype_ == /*MH_EXECUTE*/ 0x2) {
+ *offset = sc->vmaddr;
+ } else {
+ *offset = sc->fileoff;
+ }
+ }
if (filename) {
internal_strncpy(filename, _dyld_get_image_name(current_image_),
filename_size);
@@ -190,6 +197,7 @@
// Set up for this image;
current_load_cmd_count_ = hdr->ncmds;
current_magic_ = hdr->magic;
+ current_filetype_ = hdr->filetype;
switch (current_magic_) {
#ifdef MH_MAGIC_64
case MH_MAGIC_64: {
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=165018&r1=165017&r2=165018&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps.h Tue Oct 2 10:42:24 2012
@@ -84,6 +84,7 @@
char filename[], uptr filename_size);
int current_image_;
u32 current_magic_;
+ u32 current_filetype_;
int current_load_cmd_count_;
char *current_load_cmd_addr_;
# endif
More information about the llvm-commits
mailing list