[asan] Implement GetObjectNameAndOffset on ARM.

llvm-svn: 148236
diff --git a/compiler-rt/lib/asan/asan_linux.cc b/compiler-rt/lib/asan/asan_linux.cc
index 8b05723..67acd52 100644
--- a/compiler-rt/lib/asan/asan_linux.cc
+++ b/compiler-rt/lib/asan/asan_linux.cc
@@ -214,6 +214,27 @@
   return true;
 }
 
+#ifdef __arm__
+
+// Gets the object name and the offset by walking AsanProcMaps.
+bool AsanProcMaps::GetObjectNameAndOffset(uintptr_t addr, uintptr_t *offset,
+                                          char filename[],
+                                          size_t filename_size) {
+  AsanProcMaps proc_maps;
+  uintptr_t start, end, file_offset;
+  while (proc_maps.Next(&start, &end, &file_offset, filename, filename_size)) {
+    if (addr >= start && addr < end) {
+      *offset = (addr - start) + file_offset;
+      return true;
+    }
+  }
+  if (filename_size)
+    filename[0] = '\0';
+  return false;
+}
+
+#else // __arm__
+
 struct DlIterateData {
   int count;
   uintptr_t addr;
@@ -258,6 +279,8 @@
   return false;
 }
 
+#endif // __arm__
+
 void AsanThread::SetThreadStackTopAndBottom() {
   if (tid() == 0) {
     // This is the main thread. Libpthread may not be initialized yet.