summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-10-25 10:23:49 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-10-25 10:23:49 +0000
commitdb07f4c8a7d27039cb9b8e6c850de11f91060412 (patch)
tree58fde608b3d23679ebc7c1883d5f687410a96393 /test
parent36ed9f491536a45f54afb59f2fe780c9cbef0fc0 (diff)
[llvm-dwarfdump] - Fix array out of bounds access crash.
This fixes possible out of bound access in DWARFDie::getFirstChild() which might happen when .debug_info section is corrupted, like shown in testcase. Differential revision: https://reviews.llvm.org/D39185 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316566 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/tools/llvm-dwarfdump/X86/verify_debug_info2.s42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/tools/llvm-dwarfdump/X86/verify_debug_info2.s b/test/tools/llvm-dwarfdump/X86/verify_debug_info2.s
new file mode 100644
index 00000000000..71b95579839
--- /dev/null
+++ b/test/tools/llvm-dwarfdump/X86/verify_debug_info2.s
@@ -0,0 +1,42 @@
+# RUN: llvm-mc %s -filetype obj -triple=i686-pc-linux -o %t
+# RUN: not llvm-dwarfdump -v -verify %t 2>&1 | FileCheck %s
+# CHECK: The length for this unit is too large for the .debug_info provided.
+
+## Check we do not crash when trying to parse truncated .debug_info.
+.section .debug_info,"",@progbits
+ .long 0x1c
+ .value 0x4
+ .long .Ldebug_abbrev0
+ .byte 0x4
+
+ .uleb128 0x1 # DW_TAG_compile_unit [1] *
+ .long 0 # DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000000] = "test")
+ .byte 0x4 # DW_AT_language [DW_FORM_data1] (DW_LANG_C_plus_plus)
+ .long 0 # DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000000] = "test")
+ .long 0 # DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x00000000] = "test")
+ .long 0 # DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
+ .long 0 # DW_AT_high_pc [DW_FORM_data4] (0x00000000)
+
+.section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .uleb128 0x1
+ .uleb128 0x11 # DW_TAG_compile_unit, DW_CHILDREN_yes
+ .byte 0x1
+ .uleb128 0x25 # DW_AT_producer, DW_FORM_strp
+ .uleb128 0xe
+ .uleb128 0x13 # DW_AT_language, DW_FORM_data1
+ .uleb128 0xb
+ .uleb128 0x3 # DW_AT_name, DW_FORM_strp
+ .uleb128 0xe
+ .uleb128 0x1b # DW_AT_comp_dir, DW_FORM_strp
+ .uleb128 0xe
+ .uleb128 0x11 # DW_AT_low_pc, DW_FORM_addr
+ .uleb128 0x1
+ .uleb128 0x12 # DW_AT_high_pc, DW_FORM_data4
+ .uleb128 0x6
+ .byte 0
+ .byte 0
+ .byte 0
+
+.section .debug_str,"MS",@progbits,1
+.string "test"