Index: lldb/include/lldb/Symbol/SymbolFile.h
===================================================================
--- lldb/include/lldb/Symbol/SymbolFile.h
+++ lldb/include/lldb/Symbol/SymbolFile.h
@@ -130,7 +130,13 @@
 
   virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0;
   /// Return the Xcode SDK comp_unit was compiled against.
-  virtual XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) { return {}; }
+  ///
+  /// \param module
+  ///     If non-null, the SDK and sysroot will be registered with
+  ///     this module.
+  virtual XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit, Module *module) {
+    return {};
+  }
   virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0;
   virtual bool ParseLineTable(CompileUnit &comp_unit) = 0;
   virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -106,8 +106,8 @@
   lldb::LanguageType
   ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
 
-  lldb_private::XcodeSDK
-  ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
+  lldb_private::XcodeSDK ParseXcodeSDK(lldb_private::CompileUnit &comp_unit,
+                                       lldb_private::Module *module) override;
 
   size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -772,19 +772,27 @@
     return eLanguageTypeUnknown;
 }
 
-XcodeSDK SymbolFileDWARF::ParseXcodeSDK(CompileUnit &comp_unit) {
+XcodeSDK SymbolFileDWARF::ParseXcodeSDK(CompileUnit &comp_unit, Module *module) {
   std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   if (DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit))
-    if (ModuleSP module_sp = m_objfile_sp->GetModule())
-      if (const DWARFBaseDIE cu_die =
-              dwarf_cu->GetNonSkeletonUnit().GetUnitDIEOnly())
-        if (const char *sdk =
-                cu_die.GetAttributeValueAsString(DW_AT_APPLE_sdk, nullptr)) {
-          const char *sysroot =
-              cu_die.GetAttributeValueAsString(DW_AT_LLVM_sysroot, "");
-          module_sp->RegisterXcodeSDK(sdk, sysroot);
-          return {sdk};
-        }
+    if (const DWARFBaseDIE cu_die =
+            dwarf_cu->GetNonSkeletonUnit().GetUnitDIEOnly())
+      if (const char *sdk =
+              cu_die.GetAttributeValueAsString(DW_AT_APPLE_sdk, nullptr)) {
+        const char *sysroot =
+            cu_die.GetAttributeValueAsString(DW_AT_LLVM_sysroot, "");
+        // Register the sysroot path remapping with this symbol file's module.
+        if (ModuleSP module_sp = m_objfile_sp->GetModule())
+          if (module_sp.get() != module)
+            module_sp->RegisterXcodeSDK(sdk, sysroot);
+        // Register the sysroot path remapping with the module that
+        // was passed in. The two would be different if this is an OSO
+        // object and module is the corresponding debug map., in which
+        // case both should be updated.
+        if (module)
+          module->RegisterXcodeSDK(sdk, sysroot);
+        return {sdk};
+      }
   return {};
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -58,8 +58,8 @@
   lldb::LanguageType
   ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
 
-  lldb_private::XcodeSDK
-  ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
+  lldb_private::XcodeSDK ParseXcodeSDK(lldb_private::CompileUnit &comp_unit,
+                                       lldb_private::Module *module) override;
 
   size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -628,12 +628,12 @@
   return eLanguageTypeUnknown;
 }
 
-XcodeSDK
-SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) {
+XcodeSDK SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit,
+                                                Module *module) {
   std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
   SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
   if (oso_dwarf)
-    return oso_dwarf->ParseXcodeSDK(comp_unit);
+    return oso_dwarf->ParseXcodeSDK(comp_unit, module);
   return {};
 }
 
Index: lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
===================================================================
--- lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/XcodeSDKModuleTests.cpp
@@ -70,7 +70,10 @@
   SymbolFileDWARF &sym_file = dwarf_cu->GetSymbolFileDWARF();
   CompUnitSP comp_unit = sym_file.GetCompileUnitAtIndex(0);
   ASSERT_TRUE((bool)comp_unit.get());
-  XcodeSDK sdk = sym_file.ParseXcodeSDK(*comp_unit);
+  ModuleSP module = t.GetModule();
+  ASSERT_EQ(module->GetSourceMappingList().GetSize(), 0u);
+  XcodeSDK sdk = sym_file.ParseXcodeSDK(*comp_unit, module.get());
   ASSERT_EQ(sdk.GetType(), XcodeSDK::Type::MacOSX);
+  ASSERT_EQ(module->GetSourceMappingList().GetSize(), 1u);
 }
 #endif