Patch from Keno Fischer to enable JITLoaderGDB with mach-o file support.

The patch is as is with the functionality left disabled for apple vendors because of performance regressions. If this is enabled it ends up searching for symbols in all shared libraries that are loadeded.

llvm-svn: 211638
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index e4de46e..688b64c 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1236,6 +1236,7 @@
                                               vm_size,            // VM size in bytes of this section.
                                               header.sh_offset,   // Offset of this section in the file.
                                               file_size,          // Size of the section as found in the file.
+                                              __builtin_ffs(header.sh_addralign), // Alignment of the section
                                               header.sh_flags));  // Flags for this section.
 
             if (is_thread_specific)
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 9eab3a1..9341e27 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1346,6 +1346,7 @@
                                                           load_cmd.vmsize,        // VM size in bytes of this section
                                                           load_cmd.fileoff,       // Offset to the data for this section in the file
                                                           load_cmd.filesize,      // Size in bytes of this section as found in the the file
+                                                          0,                      // Segments have no alignment information
                                                           load_cmd.flags));       // Flags for this section
 
                             segment_sp->SetIsEncrypted (segment_is_encrypted);
@@ -1474,6 +1475,7 @@
                                                                       sect64.size,           // VM size in bytes of this section
                                                                       sect64.offset,         // Offset to the data for this section in the file
                                                                       sect64.offset ? sect64.size : 0,        // Size in bytes of this section as found in the the file
+                                                                      sect64.align,
                                                                       load_cmd.flags));      // Flags for this section
                                         segment_sp->SetIsFake(true);
                                         
@@ -1612,6 +1614,7 @@
                                                                   sect64.size,
                                                                   sect64.offset,
                                                                   sect64.offset == 0 ? 0 : sect64.size,
+                                                                  sect64.align,
                                                                   sect64.flags));
                                 // Set the section to be encrypted to match the segment
 
@@ -2022,7 +2025,7 @@
         
         uint32_t memory_module_load_level = eMemoryModuleLoadLevelComplete;
 
-        if (process)
+        if (process && m_header.filetype != llvm::MachO::MH_OBJECT)
         {
             Target &target = process->GetTarget();
             
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index ca70b96..7b85342 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -753,6 +753,7 @@
                                                    m_sect_headers[idx].vmsize,   // VM size in bytes of this section
                                                    m_sect_headers[idx].offset,   // Offset to the data for this section in the file
                                                    m_sect_headers[idx].size,     // Size in bytes of this section as found in the the file
+                                                   m_coff_header_opt.sect_alignment, // Section alignment
                                                    m_sect_headers[idx].flags));  // Flags for this section
 
                 //section_sp->SetIsEncrypted (segment_is_encrypted);