[PATCH] D73886: [DebugInfo] Refine the condition to detect CIEs.
Igor Kudrin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 5 03:19:09 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1a837569db3b: [DebugInfo] Refine the condition to detect CIEs. (authored by ikudrin).
Changed prior to commit:
https://reviews.llvm.org/D73886?vs=246886&id=248418#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73886/new/
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 --crash llvm-dwarfdump -debug-frame - 2>&1 | \
+# RUN: FileCheck %s
+
+# CHECK: Parsing FDE data at 0 failed due to missing CIE
+
+ .section .eh_frame,"a", at unwind
+## 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
@@ -285,6 +285,18 @@
}
}
+// Returns the CIE identifier to be used by the requested format.
+// CIE ids for .debug_frame sections are defined in Section 7.24 of DWARFv5.
+// For CIE ID in .eh_frame sections see
+// https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html
+constexpr uint64_t getCIEId(bool IsDWARF64, bool IsEH) {
+ if (IsEH)
+ return 0;
+ if (IsDWARF64)
+ return DW64_CIE_ID;
+ return DW_CIE_ID;
+}
+
void CIE::dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH) const {
OS << format("%08x %08x %08x CIE", (uint32_t)Offset, (uint32_t)Length,
IsEH ? 0 : DW_CIE_ID)
@@ -379,10 +391,7 @@
// The Id field's size depends on the DWARF format
bool IsDWARF64 = Format == DWARF64;
Id = Data.getRelocatedValue((IsDWARF64 && !IsEH) ? 8 : 4, &Offset);
- bool IsCIE =
- ((IsDWARF64 && Id == DW64_CIE_ID) || Id == DW_CIE_ID || (IsEH && !Id));
-
- if (IsCIE) {
+ if (Id == getCIEId(IsDWARF64, IsEH)) {
uint8_t Version = Data.getU8(&Offset);
const char *Augmentation = Data.getCStr(&Offset);
StringRef AugmentationString(Augmentation ? Augmentation : "");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73886.248418.patch
Type: text/x-patch
Size: 3000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200305/d19183a1/attachment.bin>
More information about the llvm-commits
mailing list