ObjectFileELF: Add support for arbitrarily named code sections

ObjectFileELF assumes that code section has ".text" name. There is an
exception for kalimba toolchain that can use arbitrary names, but other
toolchains also could use arbitrary names for code sections. For
example, corert uses separate section for compiled managed code. As lldb
doesn't recognize such section it leads to problem with breakpoints on
arm, because debugger cannot determine instruction set (arm/thumb) and
uses incorrect breakpoint opcode that breaks program execution.

This change allows debugger to correctly handle such code sections. We
assume that section is a code section if it has SHF_EXECINSTR flag set
and has SHT_PROGBITS type.

Patch by Konstantin Baladurin <k.baladurin@partner.samsung.com>.
Differential Revision: https://reviews.llvm.org/D44998

llvm-svn: 331173
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index a5f577f..61186ae 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1950,6 +1950,16 @@
         sect_type = kalimbaSectionType(m_header, header);
       }
 
+      // In common case ELF code section can have arbitrary name (for example,
+      // we can specify it using section attribute for particular function) so
+      // assume that section is a code section if it has SHF_EXECINSTR flag set
+      // and has SHT_PROGBITS type.
+      if (eSectionTypeOther == sect_type &&
+          llvm::ELF::SHT_PROGBITS == header.sh_type &&
+          (header.sh_flags & SHF_EXECINSTR)) {
+        sect_type = eSectionTypeCode;
+      }
+
       const uint32_t target_bytes_size =
           (eSectionTypeData == sect_type || eSectionTypeZeroFill == sect_type)
               ? m_arch_spec.GetDataByteSize()