<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.

llvm-svn: 183247
This commit is contained in:
Greg Clayton
2013-06-04 20:27:06 +00:00
parent 2e35cb7508
commit a3f14d8bf1

View File

@@ -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))