Add code to ReplaceDSYMSectionsWithExecutableSections() to handle the case where
a new section is added to the executable after the dSYM has been created, e.g.
the CTF segment added to mach_kernel after all other linking and processing has
been finished.
<rdar://problem/13258780> 


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181375 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index 4b271b4..56c04ba 100644
--- a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -107,6 +107,16 @@
                 // and in the dSYM with those from the executable. If we fail to
                 // replace the one in the dSYM, then add the executable section to
                 // the dSYM.
+                SectionSP dsym_sect_sp(dsym_section_list->FindSectionByID(exec_sect_sp->GetID()));
+                if (dsym_sect_sp.get() && dsym_sect_sp->GetName() != exec_sect_sp->GetName())
+                {
+                    // The sections in a dSYM are normally a superset of the sections in an executable.
+                    // If we find a section # in the exectuable & dSYM that don't have the same name,
+                    // something has changed since the dSYM was written.  The mach_kernel DSTROOT binary
+                    // has a CTF segment added, for instance, and it's easiest to simply not add that to
+                    // the dSYM - none of the nlist entries are going to have references to that section.
+                    continue;
+                }
                 if (dsym_section_list->ReplaceSection(exec_sect_sp->GetID(), exec_sect_sp, 0) == false)
                     dsym_section_list->AddSection(exec_sect_sp);
             }