[Lldb-commits] [lldb] r183247 - <rdar://problem/13941992>

Greg Clayton gclayton at apple.com
Tue Jun 4 13:27:07 PDT 2013


Author: gclayton
Date: Tue Jun  4 15:27:06 2013
New Revision: 183247

URL: http://llvm.org/viewvc/llvm-project?rev=183247&view=rev
Log:
<rdar://problem/13941992>

Accept mach-o files with bad segments. Many core files are not created correctly and we should still be able to glean any information we can from them.


Modified:
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=183247&r1=183246&r2=183247&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Jun  4 15:27:06 2013
@@ -994,8 +994,9 @@ ObjectFileMachO::ParseSections ()
                                                  lc_segment_name,
                                                  load_cmd.fileoff,
                                                  m_length);
-                        m_sections_ap->Clear();
-                        return 0;
+                        
+                        load_cmd.fileoff = 0;
+                        load_cmd.filesize = 0;
                     }
                     
                     if (load_cmd.fileoff + load_cmd.filesize > m_length)
@@ -1006,13 +1007,14 @@ ObjectFileMachO::ParseSections ()
                         // is null out the SectionList vector and if a process has been set up, dump a message
                         // to stdout.  The most common case here is core file debugging with a truncated file.
                         const char *lc_segment_name = load_cmd.cmd == LoadCommandSegment64 ? "LC_SEGMENT_64" : "LC_SEGMENT";
-                        GetModule()->ReportError("is a corrupt mach-o file: load command %u %s has a fileoff + filesize (0x%" PRIx64 ") that extends beyond the end of the file (0x%" PRIx64 ")",
+                        GetModule()->ReportError("is a corrupt mach-o file: load command %u %s has a fileoff + filesize (0x%" PRIx64 ") that extends beyond the end of the file (0x%" PRIx64 "), the segment will be truncated",
                                                  i,
                                                  lc_segment_name,
                                                  load_cmd.fileoff + load_cmd.filesize,
                                                  m_length);
-                        m_sections_ap->Clear();
-                        return 0;
+                        
+                        // Tuncase the length
+                        load_cmd.filesize = m_length - load_cmd.fileoff;
                     }
                 }
                 if (m_data.GetU32(&offset, &load_cmd.maxprot, 4))





More information about the lldb-commits mailing list