[Lldb-commits] [lldb] r154860 - in /lldb/trunk: include/lldb/Target/SectionLoadList.h source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp source/Target/SectionLoadList.cpp

Greg Clayton gclayton at apple.com
Mon Apr 16 14:01:30 PDT 2012


Author: gclayton
Date: Mon Apr 16 16:01:30 2012
New Revision: 154860

URL: http://llvm.org/viewvc/llvm-project?rev=154860&view=rev
Log:
Fixed the ability to load multiple __LINKEDIT segments at the same address for darwin shared cache entries. Now when registering the load address of a section, the DynamicLoader objects can specify if they should warn or not. This will fix the ability to load the nlist entries for shared libraries in the darwin shared caches when no on disk representation is available for a shared library.


Modified:
    lldb/trunk/include/lldb/Target/SectionLoadList.h
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
    lldb/trunk/source/Target/SectionLoadList.cpp

Modified: lldb/trunk/include/lldb/Target/SectionLoadList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/SectionLoadList.h?rev=154860&r1=154859&r2=154860&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/SectionLoadList.h (original)
+++ lldb/trunk/include/lldb/Target/SectionLoadList.h Mon Apr 16 16:01:30 2012
@@ -53,7 +53,7 @@
     ResolveLoadAddress (lldb::addr_t load_addr, Address &so_addr) const;
 
     bool
-    SetSectionLoadAddress (const Section *section, lldb::addr_t load_addr);
+    SetSectionLoadAddress (const Section *section, lldb::addr_t load_addr, bool warn_multiple = false);
 
     // The old load address should be specified when unloading to ensure we get
     // the correct instance of the section as a shared library could be loaded

Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=154860&r1=154859&r2=154860&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Mon Apr 16 16:01:30 2012
@@ -440,18 +440,18 @@
 
                         if (section_sp)
                         {
-                            // Don't ever load any __LINKEDIT sections since the ones in the shared
-                            // cached will be coalesced into a single section and we will get warnings
-                            // about multiple sections mapping to the same address.
-                            if (section_sp->GetName() != g_section_name_LINKEDIT)
+                            // __LINKEDIT sections from files in the shared cache
+                            // can overlap so check to see what the segment name is
+                            // and pass "false" so we don't warn of overlapping
+                            // "Section" objects, and "true" for all other sections.
+                            const bool warn_multiple = section_sp->GetName() != g_section_name_LINKEDIT;
+
+                            const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section_sp.get());
+                            if (old_section_load_addr == LLDB_INVALID_ADDRESS ||
+                                old_section_load_addr != new_section_load_addr)
                             {
-                                const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section_sp.get());
-                                if (old_section_load_addr == LLDB_INVALID_ADDRESS ||
-                                    old_section_load_addr != new_section_load_addr)
-                                {
-                                    if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), new_section_load_addr))
-                                        changed = true;
-                                }
+                                if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), new_section_load_addr, warn_multiple))
+                                    changed = true;
                             }
                         }
                         else

Modified: lldb/trunk/source/Target/SectionLoadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/SectionLoadList.cpp?rev=154860&r1=154859&r2=154860&view=diff
==============================================================================
--- lldb/trunk/source/Target/SectionLoadList.cpp (original)
+++ lldb/trunk/source/Target/SectionLoadList.cpp Mon Apr 16 16:01:30 2012
@@ -57,7 +57,7 @@
 }
 
 bool
-SectionLoadList::SetSectionLoadAddress (const Section *section, addr_t load_addr)
+SectionLoadList::SetSectionLoadAddress (const Section *section, addr_t load_addr, bool warn_multiple)
 {
     LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER | LIBLLDB_LOG_VERBOSE));
 
@@ -77,6 +77,7 @@
     if (section->GetByteSize() == 0)
         return false; // No change
 
+    // Fill in the section -> load_addr map
     Mutex::Locker locker(m_mutex);
     sect_to_addr_collection::iterator sta_pos = m_sect_to_addr.find(section);
     if (sta_pos != m_sect_to_addr.end())
@@ -89,10 +90,21 @@
     else
         m_sect_to_addr[section] = load_addr;
 
+    // Fill in the load_addr -> section map
     addr_to_sect_collection::iterator ats_pos = m_addr_to_sect.find(load_addr);
     if (ats_pos != m_addr_to_sect.end())
     {
-        if (section != ats_pos->second)
+        // Some sections are ok to overlap, and for others we should warn. When
+        // we have multiple load addresses that correspond to a section, we will
+        // allways attribute the section to the be last section that claims it
+        // exists at that address. Sometimes it is ok for more that one section
+        // to be loaded at a specific load address, and other times it isn't.
+        // The "warn_multiple" parameter tells us if we should warn in this case
+        // or not. The DynamicLoader plug-in subclasses should know which
+        // sections should warn and which shouldn't (darwin shared cache modules
+        // all shared the same "__LINKEDIT" sections, so the dynamic loader can
+        // pass false for "warn_multiple").
+        if (warn_multiple && section != ats_pos->second)
         {
             ModuleSP module_sp (section->GetModule());
             if (module_sp)





More information about the lldb-commits mailing list