[ORC] Add a 'plugin' interface to ObjectLinkingLayer for events/configuration.

ObjectLinkingLayer::Plugin provides event notifications when objects are loaded,
emitted, and removed. It also provides a modifyPassConfig callback that allows
plugins to modify the JITLink pass configuration.

This patch moves eh-frame registration into its own plugin, and teaches
llvm-jitlink to only add that plugin when performing execution runs on
non-Windows platforms. This should allow us to re-enable the test case that was
removed in r359198.

llvm-svn: 359357
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 383442f..5ecf66a 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -214,13 +214,27 @@
   }
 }
 
-Session::Session(Triple TT)
-    : ObjLayer(ES, MemMgr, ObjectLinkingLayer::NotifyLoadedFunction(),
-               ObjectLinkingLayer::NotifyEmittedFunction(),
-               [this](const Triple &TT, PassConfiguration &PassConfig) {
-                 modifyPassConfig(TT, PassConfig);
-               }),
-      TT(std::move(TT)) {}
+Session::Session(Triple TT) : ObjLayer(ES, MemMgr), TT(std::move(TT)) {
+
+  /// Local ObjectLinkingLayer::Plugin class to forward modifyPassConfig to the
+  /// Session.
+  class JITLinkSessionPlugin : public ObjectLinkingLayer::Plugin {
+  public:
+    JITLinkSessionPlugin(Session &S) : S(S) {}
+    void modifyPassConfig(MaterializationResponsibility &MR, const Triple &TT,
+                          PassConfiguration &PassConfig) {
+      S.modifyPassConfig(TT, PassConfig);
+    }
+
+  private:
+    Session &S;
+  };
+
+  if (!NoExec && !TT.isOSWindows())
+    ObjLayer.addPlugin(llvm::make_unique<LocalEHFrameRegistrationPlugin>());
+
+  ObjLayer.addPlugin(llvm::make_unique<JITLinkSessionPlugin>(*this));
+}
 
 void Session::dumpSessionInfo(raw_ostream &OS) {
   OS << "Registered addresses:\n" << SymbolInfos << FileInfos;