[PATCH] D44998: ObjectFileELF: Add support for arbitrarily named code sections

Konstantin Baladurin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 28 13:25:34 PDT 2018


kbaladurin created this revision.
kbaladurin added a reviewer: clayborg.
kbaladurin added a project: LLDB.
Herald added subscribers: llvm-commits, kristof.beyls, arichardson, emaste.

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 <https://github.com/dotnet/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.


Repository:
  rL LLVM

https://reviews.llvm.org/D44998

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1947,6 +1947,12 @@
         sect_type = kalimbaSectionType(m_header, header);
       }
 
+      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()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44998.140116.patch
Type: text/x-patch
Size: 688 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180328/920c5282/attachment.bin>


More information about the llvm-commits mailing list