[llvm] 7686b29 - [DWARFYAML][debug_info] Teach yaml2obj emit correct DWARF64 unit header.
Xing GUO via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 26 04:21:19 PDT 2020
Author: Xing GUO
Date: 2020-06-26T19:25:26+08:00
New Revision: 7686b2958416e27b4076bbb231c06825dd446a41
URL: https://github.com/llvm/llvm-project/commit/7686b2958416e27b4076bbb231c06825dd446a41
DIFF: https://github.com/llvm/llvm-project/commit/7686b2958416e27b4076bbb231c06825dd446a41.diff
LOG: [DWARFYAML][debug_info] Teach yaml2obj emit correct DWARF64 unit header.
This patch helps teach yaml2obj emit correct DWARF64 unit header of the .debug_info section.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D82621
Added:
Modified:
llvm/include/llvm/ObjectYAML/DWARFYAML.h
llvm/lib/ObjectYAML/DWARFEmitter.cpp
llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
Removed:
################################################################################
diff --git a/llvm/include/llvm/ObjectYAML/DWARFYAML.h b/llvm/include/llvm/ObjectYAML/DWARFYAML.h
index f6dc4e07dc1a..73965dc6d570 100644
--- a/llvm/include/llvm/ObjectYAML/DWARFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DWARFYAML.h
@@ -120,7 +120,7 @@ struct Unit {
InitialLength Length;
uint16_t Version;
llvm::dwarf::UnitType Type; // Added in DWARF 5
- uint32_t AbbrOffset;
+ yaml::Hex64 AbbrOffset;
uint8_t AddrSize;
std::vector<Entry> Entries;
};
diff --git a/llvm/lib/ObjectYAML/DWARFEmitter.cpp b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
index 8a938d321180..b9b8c0e52842 100644
--- a/llvm/lib/ObjectYAML/DWARFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
@@ -212,9 +212,13 @@ class DumpVisitor : public DWARFYAML::ConstVisitor {
if (CU.Version >= 5) {
writeInteger((uint8_t)CU.Type, OS, DebugInfo.IsLittleEndian);
writeInteger((uint8_t)CU.AddrSize, OS, DebugInfo.IsLittleEndian);
- writeInteger((uint32_t)CU.AbbrOffset, OS, DebugInfo.IsLittleEndian);
+ cantFail(writeVariableSizedInteger(CU.AbbrOffset,
+ CU.Length.isDWARF64() ? 8 : 4, OS,
+ DebugInfo.IsLittleEndian));
} else {
- writeInteger((uint32_t)CU.AbbrOffset, OS, DebugInfo.IsLittleEndian);
+ cantFail(writeVariableSizedInteger(CU.AbbrOffset,
+ CU.Length.isDWARF64() ? 8 : 4, OS,
+ DebugInfo.IsLittleEndian));
writeInteger((uint8_t)CU.AddrSize, OS, DebugInfo.IsLittleEndian);
}
}
diff --git a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
index f369dbe7e9bc..f69d664f21b5 100644
--- a/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/DWARF/debug-info.yaml
@@ -669,3 +669,68 @@ DWARF:
- AbbrCode: 1
Values:
- Value: 0x1234
+
+## j) Test that yaml2obj emits the correct DWARF64 unit headers.
+
+## DWARFv5 unit header.
+
+# RUN: yaml2obj --docnum=11 %s -o %t11.o
+# RUN: llvm-readelf --hex-dump=.debug_info %t11.o | \
+# RUN: FileCheck %s --check-prefix=DWARFV5-HEADER
+
+# DWARFV5-HEADER: Hex dump of section '.debug_info':
+# DWARFV5-HEADER-NEXT: 0x00000000 ffffffff 0c000000 00000000 05000208 ................
+## ^------------------------- unit_length (12-byte)
+## ^--- version (2-byte)
+## ^- unit_type (1-byte)
+## ^- address_size (1-byte)
+# DWARFV5-HEADER-NEXT: 0x00000010 34120000 00000000 4.......
+## ^---------------- debug_abbrev_offset (8-byte)
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+DWARF:
+ debug_info:
+ - Length:
+ TotalLength: 0xffffffff
+ TotalLength64: 0x0c
+ Version: 5
+ UnitType: DW_UT_type
+ AbbrOffset: 0x1234
+ AddrSize: 8
+ Entries: []
+
+## DWARFv4 unit header.
+
+# RUN: yaml2obj --docnum=12 %s -o %t12.o
+# RUN: llvm-readelf --hex-dump=.debug_info %t12.o | \
+# RUN: FileCheck %s --check-prefix=DWARFV4-HEADER
+
+# DWARFV4-HEADER: Hex dump of section '.debug_info':
+# DWARFV4-HEADER-NEXT: 0x00000000 ffffffff 0c000000 00000000 04003412 ..............4.
+## ^------------------------- unit_length (12-byte)
+## ^--- version (2-byte)
+## ^--- debug_abbrev_offset (8-byte)
+# DWARFV4-HEADER-NEXT: 0x00000010 00000000 000008 .......
+## -------------
+## ^- address_size (1-byte)
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+DWARF:
+ debug_info:
+ - Length:
+ TotalLength: 0xffffffff
+ TotalLength64: 0x0c
+ Version: 4
+ AbbrOffset: 0x1234
+ AddrSize: 8
+ Entries: []
More information about the llvm-commits
mailing list