Fixed debug map in executable + DWARF in .o debugging on Mac OS X.

Added the ability to dump any file in the global module cache using any of
the "image dump" commands. This allows us to dump the .o files that are used
with DWARF + .o since they don't belong the the target list for the current
target.

llvm-svn: 107100
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 21860e1..89b0bce 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -341,6 +341,20 @@
                                     segment->GetChildren().Slide (-slide_amount, false);
                                     segment->SetByteSize (curr_seg_max_addr - sect64_min_addr);
                                 }
+
+                                // Grow the section size as needed.
+                                if (sect64.offset)
+                                {
+                                    const lldb::addr_t segment_min_file_offset = segment->GetFileOffset();
+                                    const lldb::addr_t segment_max_file_offset = segment_min_file_offset + segment->GetFileSize();
+
+                                    const lldb::addr_t section_min_file_offset = sect64.offset;
+                                    const lldb::addr_t section_max_file_offset = section_min_file_offset + sect64.size;
+                                    const lldb::addr_t new_file_offset = std::min (section_min_file_offset, segment_min_file_offset);
+                                    const lldb::addr_t new_file_size = std::max (section_max_file_offset, segment_max_file_offset) - new_file_offset;
+                                    segment->SetFileOffset (new_file_offset);
+                                    segment->SetFileSize (new_file_size);
+                                }
                             }
                             else
                             {