[PATCH] [Sanitizers] Fix ForEachMappedRegion() to work on FreeBSD

Viktor Kutuzov vkutuzov at accesssoftek.com
Wed Jan 28 11:30:20 PST 2015


Hi kcc, samsonov, eugenis, emaste,

http://reviews.llvm.org/D7233

Files:
  lib/sanitizer_common/sanitizer_linux.cc

Index: lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux.cc
+++ lib/sanitizer_common/sanitizer_linux.cc
@@ -801,7 +801,12 @@
 #if !SANITIZER_ANDROID
 // Call cb for each region mapped by map.
 void ForEachMappedRegion(link_map *map, void (*cb)(const void *, uptr)) {
-#if !SANITIZER_FREEBSD
+  CHECK_NE(map, nullptr);
+#if SANITIZER_FREEBSD
+  // FreeBSD's dlopen() returns a pointer to an Obj_Entry structure that
+  // incroporates the map structure.
+  map = (link_map*)((char*)map + 544);
+#else
   typedef ElfW(Phdr) Elf_Phdr;
   typedef ElfW(Ehdr) Elf_Ehdr;
 #endif  // !SANITIZER_FREEBSD

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7233.18910.patch
Type: text/x-patch
Size: 694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150128/f008c0ca/attachment.bin>


More information about the llvm-commits mailing list