summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt')
-rwxr-xr-xcompiler-rt/lib/asan/scripts/asan_symbolize.py33
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_mac.cc10
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h1
3 files changed, 11 insertions, 33 deletions
diff --git a/compiler-rt/lib/asan/scripts/asan_symbolize.py b/compiler-rt/lib/asan/scripts/asan_symbolize.py
index a4f91c8a01d..78910419571 100755
--- a/compiler-rt/lib/asan/scripts/asan_symbolize.py
+++ b/compiler-rt/lib/asan/scripts/asan_symbolize.py
@@ -146,39 +146,8 @@ class DarwinSymbolizer(Symbolizer):
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:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
index aaf95d528e0..6be53cdbfbe 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
@@ -151,6 +151,7 @@ void MemoryMappingLayout::Reset() {
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 @@ bool MemoryMappingLayout::NextSegmentLoad(
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 @@ bool MemoryMappingLayout::Next(uptr *start, uptr *end, uptr *offset,
// 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: {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
index 126c8951b79..4763e1f1f67 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
@@ -84,6 +84,7 @@ class MemoryMappingLayout {
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
OpenPOWER on IntegriCloud