[llvm] [obj2yaml] Add support for ELF .debug_info and .debug_abbrev (PR #91193)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 6 04:56:57 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-objectyaml
Author: Andrew Savonichev (asavonic)
<details>
<summary>Changes</summary>
Support for these DWARF sections was already in obj2yaml for MachO, but not enabled for ELF.
---
Full diff: https://github.com/llvm/llvm-project/pull/91193.diff
2 Files Affected:
- (added) llvm/test/tools/obj2yaml/ELF/DWARF/debug-info-abbrev.yaml (+121)
- (modified) llvm/tools/obj2yaml/elf2yaml.cpp (+4)
``````````diff
diff --git a/llvm/test/tools/obj2yaml/ELF/DWARF/debug-info-abbrev.yaml b/llvm/test/tools/obj2yaml/ELF/DWARF/debug-info-abbrev.yaml
new file mode 100644
index 00000000000000..fda6c5a6400499
--- /dev/null
+++ b/llvm/test/tools/obj2yaml/ELF/DWARF/debug-info-abbrev.yaml
@@ -0,0 +1,121 @@
+# RUN: yaml2obj %s | obj2yaml | FileCheck %s
+
+# CHECK: debug_abbrev:
+# CHECK: - ID: 0
+# CHECK: Table:
+# CHECK: - Code: 0x1
+# CHECK: Tag: DW_TAG_compile_unit
+# CHECK: Children: DW_CHILDREN_no
+# CHECK: Attributes:
+# CHECK: - Attribute: DW_AT_low_pc
+# CHECK: Form: DW_FORM_addr
+# CHECK: - ID: 1
+# CHECK: Table:
+# CHECK: - Code: 0x1
+# CHECK: Tag: DW_TAG_compile_unit
+# CHECK: Children: DW_CHILDREN_no
+# CHECK: Attributes:
+# CHECK: - Attribute: DW_AT_low_pc
+# CHECK: Form: DW_FORM_data4
+# CHECK: - ID: 2
+# CHECK: Table:
+# CHECK: - Code: 0x1
+# CHECK: Tag: DW_TAG_compile_unit
+# CHECK: Children: DW_CHILDREN_no
+# CHECK: Attributes:
+# CHECK: - Attribute: DW_AT_low_pc
+# CHECK: Form: DW_FORM_udata
+#
+# CHECK: debug_info:
+# CHECK: - Length: 0xC
+# CHECK: Version: 4
+# CHECK: AbbrevTableID: 1
+# CHECK: AbbrOffset: 0x8
+# CHECK: AddrSize: 8
+# CHECK: Entries:
+# CHECK: - AbbrCode: 0x1
+# CHECK: Values:
+# CHECK: - Value: 0x1234
+# CHECK: - Length: 0xC
+# CHECK: Version: 4
+# CHECK: AbbrevTableID: 1
+# CHECK: AbbrOffset: 0x8
+# CHECK: AddrSize: 8
+# CHECK: Entries:
+# CHECK: - AbbrCode: 0x1
+# CHECK: Values:
+# CHECK: - Value: 0x4321
+# CHECK: - Length: 0x10
+# CHECK: Version: 4
+# CHECK: AbbrevTableID: 0
+# CHECK: AbbrOffset: 0x0
+# CHECK: AddrSize: 8
+# CHECK: Entries:
+# CHECK: - AbbrCode: 0x1
+# CHECK: Values:
+# CHECK: - Value: 0x5678
+# CHECK: - Length: 0xB
+# CHECK: Version: 4
+# CHECK: AbbrevTableID: 2
+# CHECK: AbbrOffset: 0x10
+# CHECK: AddrSize: 8
+# CHECK: Entries:
+# CHECK: - AbbrCode: 0x1
+# CHECK: Values:
+# CHECK: - Value: 0x8765
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+DWARF:
+ debug_abbrev:
+ - Table:
+ - Code: 1
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_low_pc
+ Form: DW_FORM_addr
+ - ID: 2
+ Table:
+ - Code: 1
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_low_pc
+ Form: DW_FORM_data4
+ - ID: 1
+ Table:
+ - Code: 1
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_low_pc
+ Form: DW_FORM_udata
+ debug_info:
+ - Version: 4
+ AbbrevTableID: 2
+ Entries:
+ - AbbrCode: 1
+ Values:
+ - Value: 0x1234
+ - Version: 4
+ AbbrevTableID: 2
+ Entries:
+ - AbbrCode: 1
+ Values:
+ - Value: 0x4321
+ - Version: 4
+ AbbrevTableID: 0
+ Entries:
+ - AbbrCode: 1
+ Values:
+ - Value: 0x5678
+ - Version: 4
+ AbbrevTableID: 1
+ Entries:
+ - AbbrCode: 1
+ Values:
+ - Value: 0x8765
diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp
index 6b9af906736c35..8222f0cc4a36d4 100644
--- a/llvm/tools/obj2yaml/elf2yaml.cpp
+++ b/llvm/tools/obj2yaml/elf2yaml.cpp
@@ -536,6 +536,10 @@ std::optional<DWARFYAML::Data> ELFDumper<ELFT>::dumpDWARFSections(
Err = dumpDebugRanges(*DWARFCtx, DWARF);
else if (RawSec->Name == ".debug_addr")
Err = dumpDebugAddr(*DWARFCtx, DWARF);
+ else if (RawSec->Name == ".debug_abbrev")
+ Err = dumpDebugAbbrev(*DWARFCtx, DWARF);
+ else if (RawSec->Name == ".debug_info")
+ dumpDebugInfo(*DWARFCtx, DWARF);
else
continue;
``````````
</details>
https://github.com/llvm/llvm-project/pull/91193
More information about the llvm-commits
mailing list