For PR804:
[oota-llvm.git] / include / llvm / System / DynamicLibrary.h
index 5edbfd6f22f7d76adc363c9d37a12393caa8fdab..f90126c7360bdcc096a68c9c5ae088cfbd83c558 100644 (file)
@@ -26,6 +26,9 @@ namespace sys {
   /// operating system interface, this class provides a portable interface that
   /// allows dynamic libraries to be loaded and and searched for externally
   /// defined symbols. This is typically used to provide "plug-in" support.
+  /// It also allows for symbols to be defined which don't live in any library,
+  /// but rather the main program itself, useful on Windows where the main
+  /// executable cannot be searched.
   /// @since 1.4
   /// @brief Portable dynamic library abstraction.
   class DynamicLibrary {
@@ -42,7 +45,7 @@ namespace sys {
       DynamicLibrary();
 
       /// This is the constructor for DynamicLibrary instances. It will open
-      /// the dynamic library specified by the \filename Path.
+      /// the dynamic library specified by the filename Path.
       /// @throws std::string indicating why the library couldn't be opened.
       /// @brief Open a dynamic library.
       DynamicLibrary(const char* filename);
@@ -81,6 +84,17 @@ namespace sys {
         return SearchForAddressOfSymbol(symbolName.c_str());
       }
 
+      /// This functions permanently adds the symbol \p symbolName with the
+      /// value \p symbolValue.  These symbols are searched before any
+      /// libraries.
+      /// @brief Add searchable symbol/value pair.
+      static void AddSymbol(const char* symbolName, void *symbolValue);
+
+      /// @brief Convenience function for C++ophiles.
+      static void AddSymbol(const std::string& symbolName, void *symbolValue) {
+        AddSymbol(symbolName.c_str(), symbolValue);
+      }
+
     /// @}
     /// @name Accessors
     /// @{