[PATCH] D73886: [DebugInfo] Refine the condition to detect CIEs.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 06:25:23 PST 2020


ikudrin created this revision.
ikudrin added reviewers: probinson, dblaikie, aprantl.
ikudrin added projects: LLVM, debug-info.
Herald added a subscriber: hiraditya.
ikudrin added a child revision: D73887: [DebugInfo] Do not cut 64-bit values when dumping CIEs and FDEs..

The condition was not accurate enough and could interpret some FDEs in .eh_frame or 64-bit DWARF .debug_frame sections as CIEs. Even though such FDEs are unlikely in a normal situation, the wrong interpretation could hide an issue in a buggy generator.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73886

Files:
  llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
  llvm/test/DebugInfo/X86/debug-frame-cie-id-dwarf64.s
  llvm/test/DebugInfo/X86/eh-frame-cie-id.s


Index: llvm/test/DebugInfo/X86/eh-frame-cie-id.s
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/eh-frame-cie-id.s
@@ -0,0 +1,15 @@
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   not llvm-dwarfdump -debug-frame - 2>&1 | \
+# RUN:   FileCheck %s
+
+# CHECK: Parsing FDE data at 0 failed due to missing CIE
+
+        .section .eh_frame,"", at progbits
+## This FDE was formerly wrongly interpreted as a CIE because its CIE pointer
+## is similar to CIE id of a .debug_frame FDE.
+        .long .Lend - .LCIEptr  # Length
+.LCIEptr:
+        .long 0xffffffff        # CIE pointer
+        .quad 0x1111abcd        # Initial location
+        .quad 0x00010000        # Address range
+.Lend:
Index: llvm/test/DebugInfo/X86/debug-frame-cie-id-dwarf64.s
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-frame-cie-id-dwarf64.s
@@ -0,0 +1,16 @@
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-frame - | \
+# RUN:   FileCheck %s
+
+# CHECK: 00000000 {{.*}} FDE
+
+        .section .debug_frame,"", at progbits
+## This FDE was formerly wrongly interpreted as a CIE because its CIE pointer
+## is similar to DWARF32 CIE id.
+        .long 0xffffffff        # DWARF64 mark
+        .quad .Lend - .LCIEptr  # Length
+.LCIEptr:
+        .quad 0xffffffff        # CIE pointer
+        .quad 0x1111abcd        # Initial location
+        .quad 0x00010000        # Address range
+.Lend:
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
@@ -381,8 +381,9 @@
 
     // The Id field's size depends on the DWARF format
     Id = Data.getUnsigned(&Offset, (IsDWARF64 && !IsEH) ? 8 : 4);
-    bool IsCIE =
-        ((IsDWARF64 && Id == DW64_CIE_ID) || Id == DW_CIE_ID || (IsEH && !Id));
+    bool IsCIE = (!IsEH && ((!IsDWARF64 && Id == DW_CIE_ID) ||
+                            (IsDWARF64 && Id == DW64_CIE_ID))) ||
+                 (IsEH && !Id);
 
     if (IsCIE) {
       uint8_t Version = Data.getU8(&Offset);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73886.242048.patch
Type: text/x-patch
Size: 2274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200203/b069db31/attachment.bin>


More information about the llvm-commits mailing list