[asan] don't use dl_iterate_phdr on linux, go back to using /proc/self/maps. Hopefully fixes the problem reported by our mozilla friends.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@152341 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/Makefile.old b/lib/asan/Makefile.old
index ace105b..9792367 100644
--- a/lib/asan/Makefile.old
+++ b/lib/asan/Makefile.old
@@ -175,6 +175,7 @@
asan_lock.h \
asan_mac.h \
asan_mapping.h \
+ asan_procmaps.h \
asan_stack.h \
asan_stats.h \
asan_thread.h \
diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
index 14fc3e5..40f9f94 100644
--- a/lib/asan/asan_linux.cc
+++ b/lib/asan/asan_linux.cc
@@ -213,7 +213,7 @@
return true;
}
-#ifdef __arm__
+#if 1
// Gets the object name and the offset by walking AsanProcMaps.
bool AsanProcMaps::GetObjectNameAndOffset(uintptr_t addr, uintptr_t *offset,
@@ -222,8 +222,9 @@
return IterateForObjectNameAndOffset(addr, offset, filename, filename_size);
}
-#else // __arm__
-
+#else
+// dl_iterate_phdr machinery is not working well for us.
+// We either need to fix it or get rid of it.
struct DlIterateData {
int count;
uintptr_t addr;
diff --git a/lib/asan/asan_procmaps.h b/lib/asan/asan_procmaps.h
index 6dd42f9..5ae5fb2 100644
--- a/lib/asan/asan_procmaps.h
+++ b/lib/asan/asan_procmaps.h
@@ -37,10 +37,11 @@
char filename[], size_t filename_size) {
Reset();
uintptr_t start, end, file_offset;
- while (Next(&start, &end, &file_offset,
- filename, filename_size)) {
+ for (int i = 0; Next(&start, &end, &file_offset, filename, filename_size);
+ i++) {
if (addr >= start && addr < end) {
- *offset = (addr - start) + file_offset;
+ // Don't subtract 'start' for the first entry. Don't ask me why.
+ *offset = (addr - (i ? start : 0)) + file_offset;
return true;
}
}