[PATCH] D82139: [DWARFYAML][debug_info] Fix array index out of bounds error
Xing GUO via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 20 00:29:36 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG677034959285: [DWARFYAML][debug_info] Fix array index out of bounds error (authored by Higuoxing).
Changed prior to commit:
https://reviews.llvm.org/D82139?vs=272029&id=272243#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82139/new/
https://reviews.llvm.org/D82139
Files:
llvm/lib/ObjectYAML/DWARFVisitor.cpp
llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
===================================================================
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
@@ -548,3 +548,30 @@
Entries:
- AbbrCode: 0
Values: []
+
+## h) Test that yaml2obj doesn't crash when the 'Entries' of a compilation unit is empty.
+
+# RUN: yaml2obj --docnum=8 %s -o %t8.o
+# RUN: llvm-readelf --hex-dump=.debug_info %t8.o | \
+# RUN: FileCheck %s --check-prefix=EMPTY-ENTRIES --match-full-lines
+
+# EMPTY-ENTRIES: Hex dump of section '.debug_info':
+# EMPTY-ENTRIES-NEXT: 0x00000000 34120000 05000204 34120000 4.......4...
+# EMPTY-ENTRIES-EMPTY:
+## ^- 'Entries' is empty
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+DWARF:
+ debug_info:
+ - Length:
+ TotalLength: 0x1234
+ Version: 5
+ UnitType: DW_UT_type
+ AbbrOffset: 0x1234
+ AddrSize: 4
+ Entries: []
Index: llvm/lib/ObjectYAML/DWARFVisitor.cpp
===================================================================
--- llvm/lib/ObjectYAML/DWARFVisitor.cpp
+++ llvm/lib/ObjectYAML/DWARFVisitor.cpp
@@ -46,6 +46,8 @@
template <typename T> void DWARFYAML::VisitorImpl<T>::traverseDebugInfo() {
for (auto &Unit : DebugInfo.CompileUnits) {
onStartCompileUnit(Unit);
+ if (Unit.Entries.empty())
+ continue;
auto FirstAbbrevCode = Unit.Entries[0].AbbrCode;
for (auto &Entry : Unit.Entries) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82139.272243.patch
Type: text/x-patch
Size: 1609 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200620/44eab89c/attachment-0001.bin>
More information about the llvm-commits
mailing list