[llvm] 66fb3c3 - [DebugInfo/DWARF] - Report .eh_frame sections of version != 1.

Georgii Rymar via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 16 05:54:26 PDT 2020


Author: Georgii Rymar
Date: 2020-06-16T15:46:26+03:00
New Revision: 66fb3c39cbc61845ba8ccdd8cb854c49281ed94b

URL: https://github.com/llvm/llvm-project/commit/66fb3c39cbc61845ba8ccdd8cb854c49281ed94b
DIFF: https://github.com/llvm/llvm-project/commit/66fb3c39cbc61845ba8ccdd8cb854c49281ed94b.diff

LOG: [DebugInfo/DWARF] - Report .eh_frame sections of version != 1.

Specification (https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html#AEN1349)
says that the value of Version field for .eh_frame should be 1.

Though we accept other values and might perform an attempt to read
it as a .debug_frame because of that, what is wrong.

This patch adds a version check.

Differential revision: https://reviews.llvm.org/D81469

Added: 
    llvm/test/DebugInfo/X86/eh-frame-invalid-version-zero.s
    llvm/test/DebugInfo/X86/eh-frame-invalid-version.s

Modified: 
    llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
index 159bde9adf16..746ba379c0ce 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
@@ -415,6 +415,11 @@ Error DWARFDebugFrame::parse(DWARFDataExtractor Data) {
       uint8_t Version = Data.getU8(&Offset);
       const char *Augmentation = Data.getCStr(&Offset);
       StringRef AugmentationString(Augmentation ? Augmentation : "");
+      // TODO: we should provide a way to report a warning and continue dumping.
+      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);

diff  --git a/llvm/test/DebugInfo/X86/eh-frame-invalid-version-zero.s b/llvm/test/DebugInfo/X86/eh-frame-invalid-version-zero.s
new file mode 100644
index 000000000000..0c773671ddca
--- /dev/null
+++ b/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", at unwind
+ .long .Lend - .LCIEptr ## Length
+.LCIEptr:
+ .long 0x00000000       ## CIE ID
+ .byte 0                ## Version
+.Lend:

diff  --git a/llvm/test/DebugInfo/X86/eh-frame-invalid-version.s b/llvm/test/DebugInfo/X86/eh-frame-invalid-version.s
new file mode 100644
index 000000000000..c2f7317c9e31
--- /dev/null
+++ b/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", at unwind
+ .long .Lend - .LCIEptr ## Length
+.LCIEptr:
+ .long 0x00000000       ## CIE ID
+ .byte 2                ## Version
+.Lend:


        


More information about the llvm-commits mailing list