[llvm] 25f3cc0 - [elf2yaml] Fix dumping a debug section whose name is not recognized.
Xing GUO via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 05:07:54 PDT 2020
Author: Xing GUO
Date: 2020-09-09T20:07:05+08:00
New Revision: 25f3cc0ced1759af1911c2446ac40fab4f5e5571
URL: https://github.com/llvm/llvm-project/commit/25f3cc0ced1759af1911c2446ac40fab4f5e5571
DIFF: https://github.com/llvm/llvm-project/commit/25f3cc0ced1759af1911c2446ac40fab4f5e5571.diff
LOG: [elf2yaml] Fix dumping a debug section whose name is not recognized.
If the debug section's name isn't recognized, it should be
dumped as a raw content section.
Reviewed By: jhenderson, grimar
Differential Revision: https://reviews.llvm.org/D87346
Added:
llvm/test/tools/obj2yaml/ELF/DWARF/unrecognized-debug-section.yaml
Modified:
llvm/tools/obj2yaml/elf2yaml.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/obj2yaml/ELF/DWARF/unrecognized-debug-section.yaml b/llvm/test/tools/obj2yaml/ELF/DWARF/unrecognized-debug-section.yaml
new file mode 100644
index 000000000000..618ac3592b6d
--- /dev/null
+++ b/llvm/test/tools/obj2yaml/ELF/DWARF/unrecognized-debug-section.yaml
@@ -0,0 +1,19 @@
+## Test dumping a debug section when its name is not recognized by obj2yaml.
+
+# RUN: yaml2obj %s | obj2yaml | FileCheck %s
+
+# CHECK: Sections:
+# CHECK-NEXT: - Name: .debug_foo
+# CHECK-NEXT: Type: SHT_PROGBITS
+# CHECK-NEXT: Content: '01020304'
+# CHECK-NEXT: ...
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+Sections:
+ - Name: .debug_foo
+ Type: SHT_PROGBITS
+ Content: '01020304'
diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp
index 264bc4d1dbf3..94819cb8d87d 100644
--- a/llvm/tools/obj2yaml/elf2yaml.cpp
+++ b/llvm/tools/obj2yaml/elf2yaml.cpp
@@ -416,6 +416,8 @@ Optional<DWARFYAML::Data> ELFDumper<ELFT>::dumpDWARFSections(
Err = dumpDebugARanges(*DWARFCtx.get(), DWARF);
else if (RawSec->Name == ".debug_str")
Err = dumpDebugStrings(*DWARFCtx.get(), DWARF);
+ else
+ continue;
// If the DWARF section cannot be successfully parsed, emit raw content
// instead of an entry in the DWARF section of the YAML.
More information about the llvm-commits
mailing list