diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index c427b476089e4..3d65f49674209 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -437,6 +437,14 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() { m_initial_modules_added = true; } for (; I != E; ++I) { + // Don't load a duplicate copy of ld.so if we have already loaded it + // earlier in LoadInterpreterModule. If we instead loaded then unloaded it + // later, the section information for ld.so would be removed. That + // information is required for placing breakpoints on Arm/Thumb systems. + if ((m_interpreter_module.lock() != nullptr) && + (I->base_addr == m_interpreter_base)) + continue; + ModuleSP module_sp = LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true); if (!module_sp.get()) @@ -450,15 +458,6 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() { } else if (module_sp == interpreter_sp) { // Module already loaded. continue; - } else { - // If this is a duplicate instance of ld.so, unload it. We may end - // up with it if we load it via a different path than before - // (symlink vs real path). - // TODO: remove this once we either fix library matching or avoid - // loading the interpreter when setting the rendezvous breakpoint. - UnloadSections(module_sp); - loaded_modules.Remove(module_sp); - continue; } }