 +struct ExplicitSymbolHolder {
 +  ExplicitSymbolHolder() {
 +    PopulateSpecialSymbolsImpl(Map);
- 
-+// This macro returns the address of a well-known, explicit symbol
-+#define EXPLICIT_SYMBOL(SYM) \
-+    Map[#SYM] = &SYM
-+
-+// On linux we have a weird situation. The stderr/out/in symbols are both
-+// macros and global variables because of standards requirements. So, we
-+// boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
-+#if defined(__linux__) and !defined(__ANDROID__)
-+  {
-+    EXPLICIT_SYMBOL(stderr);
-+    EXPLICIT_SYMBOL(stdout);
-+    EXPLICIT_SYMBOL(stdin);
-+  }
-+#else
-+  // For everything else, we want to check to make sure the symbol isn't defined
-+  // as a macro before using EXPLICIT_SYMBOL.
-+  {
-+#ifndef stdin
-+    EXPLICIT_SYMBOL(stdin);
-+#endif
-+#ifndef stdout
-+    EXPLICIT_SYMBOL(stdout);
-+#endif
-+#ifndef stderr
-+    EXPLICIT_SYMBOL(stderr);
-+#endif
-+  }
-+#endif
-+#undef EXPLICIT_SYMBOL
-+  }
-+
++  }
+ 
 +  // Symbol name/value pairs to be searched prior to any libraries.
 +  StringMap<void *> Map;
 +};

+// Close the shared library.
+static void  CloseLibraryImpl(void *dlHandle);
+// Get the address of the symbol named symname from the library with dlhandle.
+static void *GetAddressOfSymbolImpl(void *dlHandle, const char *symbolName);
+// Inject special platform symbols into the map of explicitly defined symbols.
+static void PopulateSpecialSymbolsImpl(StringMap<void *>& symMap);
+

 static llvm::sys::SmartMutex<true>& getMutex() {
   static llvm::sys::SmartMutex<true> HandlesMutex;
   return HandlesMutex;
@@ -46,144 +69,85 @@ void llvm::sys::DynamicLibrary::AddSymbol(StringRe
                                           void *symbolValue) {
   SmartScopedLock<true> lock(getMutex());
   if (ExplicitSymbols == 0)
