From a3f14d8bf1cf6955cd1a0714f22128c5681cfdf4 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 4 Jun 2013 20:27:06 +0000 Subject: [PATCH] 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. llvm-svn: 183247 --- .../Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 140272e09128..9f27c1c5107b 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -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))