Index: llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -415,6 +415,10 @@ uint8_t Version = Data.getU8(&Offset); const char *Augmentation = Data.getCStr(&Offset); StringRef AugmentationString(Augmentation ? Augmentation : ""); + if (IsEH && Version != 1) + return createStringError(errc::not_supported, + "unsupported CIE version: %" PRIu8, Version); + uint8_t AddressSize = Version < 4 ? Data.getAddressSize() : Data.getU8(&Offset); Data.setAddressSize(AddressSize); Index: llvm/test/DebugInfo/X86/eh-frame-invalid-version-zero.s =================================================================== --- /dev/null +++ llvm/test/DebugInfo/X86/eh-frame-invalid-version-zero.s @@ -0,0 +1,13 @@ +## Check we do not support .eh_frame sections of version 0. + +# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t +# RUN: not llvm-dwarfdump -debug-frame %t 2>&1 | FileCheck %s + +# CHECK: unsupported CIE version: 0 + +.section .eh_frame,"a",@unwind + .long .Lend - .LCIEptr ## Length +.LCIEptr: + .long 0x00000000 ## CIE ID + .byte 0 ## Version +.Lend: Index: llvm/test/DebugInfo/X86/eh-frame-invalid-version.s =================================================================== --- /dev/null +++ llvm/test/DebugInfo/X86/eh-frame-invalid-version.s @@ -0,0 +1,13 @@ +## Check we do not support .eh_frame sections of versions greater than 1. + +# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t +# RUN: not llvm-dwarfdump -debug-frame %t 2>&1 | FileCheck %s + +# CHECK: unsupported CIE version: 2 + +.section .eh_frame,"a",@unwind + .long .Lend - .LCIEptr ## Length +.LCIEptr: + .long 0x00000000 ## CIE ID + .byte 2 ## Version +.Lend: