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); 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,"",@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/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,"",@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: