[PATCH] D15728: [cfi] Support for dlopen and dlclose

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 15 14:05:19 PST 2016


eugenis added inline comments.

================
Comment at: lib/cfi/cfi.cc:237-263
@@ +236,29 @@
+void ShadowUpdater::update() {
+  LoadedModule *modules_after = (LoadedModule *)MmapOrDie(
+      kMaxModules * sizeof(LoadedModule), "ShadowUpdater");
+  uptr modules_after_cnt =
+      GetListOfModules(modules_after, kMaxModules, nullptr);
+
+  InternalSort(&modules_before, modules_before_cnt, LoadedModuleCompare);
+  InternalSort(&modules_after, modules_after_cnt, LoadedModuleCompare);
+
+  LoadedModule *p = modules_before;
+  LoadedModule *p_end = p + modules_before_cnt;
+  LoadedModule *q = modules_after;
+  LoadedModule *q_end = q + modules_after_cnt;
+  while (p < p_end && q < q_end) {
+    if (p->base_address() < q->base_address()) {
+      remove_module(p++);
+    } else if (p->base_address() > q->base_address()) {
+      add_module(q++);
+    } else {
+      p++;
+      q++;
+    }
+  }
+  while (p < p_end)
+    remove_module(p++);
+  while (q < q_end)
+    add_module(q++);
+
+  UnmapOrDie(modules_before, kMaxModules * sizeof(LoadedModule));
----------------
pcc wrote:
> Can you avoid needing to take the set difference by rebuilding from scratch?
Do you mean unmap or clean the entire shadow and then add the existing modules? That would be racy, we can not ensure that there are no concurrent virtual/indirect calls.


================
Comment at: lib/sanitizer_common/sanitizer_common.h:637
@@ -633,1 +636,3 @@
 
+  bool operator<(const LoadedModule &other) const {
+    return base_address_ < other.base_address_;
----------------
pcc wrote:
> Is this function needed? Looks like you're passing a comparator to your sort function above.
removed


Repository:
  rL LLVM

http://reviews.llvm.org/D15728





More information about the llvm-commits mailing list