[PATCH] D81146: [MC] Generate .debug_aranges in the 64-bit DWARF format [4/7]
Igor Kudrin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 08:52:21 PDT 2020
ikudrin updated this revision to Diff 268811.
ikudrin marked 3 inline comments as done.
ikudrin added a comment.
- Extended a test for Mach-O so that all changed code paths are covered.
- Added more checks for the .debug_aranges section to validate that it is not skewed.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81146/new/
https://reviews.llvm.org/D81146
Files:
llvm/lib/MC/MCDwarf.cpp
llvm/test/MC/ELF/gen-dwarf64.s
llvm/test/MC/MachO/gen-dwarf64.s
Index: llvm/test/MC/MachO/gen-dwarf64.s
===================================================================
--- llvm/test/MC/MachO/gen-dwarf64.s
+++ llvm/test/MC/MachO/gen-dwarf64.s
@@ -10,5 +10,10 @@
// CHECK: DW_TAG_label [2]
// CHECK-NEXT: DW_AT_name [DW_FORM_string] ("foo")
+// CHECK: .debug_aranges contents:
+// CHECK-NEXT: Address Range Header: length = 0x0000000000000034, format = DWARF64, version = 0x0002, cu_offset = 0x0000000000000000, addr_size = 0x08, seg_size = 0x00
+// CHECK-NEXT: [0x0000000000000000, 0x0000000000000001)
+// CHECK-EMPTY:
+
_foo:
nop
Index: llvm/test/MC/ELF/gen-dwarf64.s
===================================================================
--- llvm/test/MC/ELF/gen-dwarf64.s
+++ llvm/test/MC/ELF/gen-dwarf64.s
@@ -8,6 +8,8 @@
# REL: Section ({{[0-9]+}}) .rela.debug_info {
# REL-NEXT: R_X86_64_64 .debug_abbrev 0x0
# REL-NEXT: R_X86_64_64 .debug_line 0x0
+# REL: Section ({{[0-9]+}}) .rela.debug_aranges {
+# REL-NEXT: R_X86_64_64 .debug_info 0x0
# REL5: Section ({{[0-9]+}}) .rela.debug_line {
# REL5-NEXT: R_X86_64_64 .debug_line_str 0x0
# REL5-NEXT: R_X86_64_64 .debug_line_str 0x
@@ -19,6 +21,11 @@
# DUMP: DW_TAG_label [2]
# DUMP-NEXT: DW_AT_name [DW_FORM_string] ("foo")
+# DUMP: .debug_aranges contents:
+# DUMP-NEXT: Address Range Header: length = 0x0000000000000034, format = DWARF64, version = 0x0002, cu_offset = 0x0000000000000000, addr_size = 0x08, seg_size = 0x00
+# DUMP-NEXT: [0x0000000000000000, 0x0000000000000001)
+# DUMP-EMPTY:
+
# DUMP: .debug_line contents:
# DUMP-NEXT: debug_line[0x00000000]
# DUMP-NEXT: Line table prologue:
Index: llvm/lib/MC/MCDwarf.cpp
===================================================================
--- llvm/lib/MC/MCDwarf.cpp
+++ llvm/lib/MC/MCDwarf.cpp
@@ -875,9 +875,13 @@
MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfARangesSection());
+ unsigned UnitLengthBytes =
+ dwarf::getUnitLengthFieldByteSize(context.getDwarfFormat());
+ unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(context.getDwarfFormat());
+
// This will be the length of the .debug_aranges section, first account for
// the size of each item in the header (see below where we emit these items).
- int Length = 4 + 2 + 4 + 1 + 1;
+ int Length = UnitLengthBytes + 2 + OffsetSize + 1 + 1;
// Figure the padding after the header before the table of address and size
// pairs who's values are PointerSize'ed.
@@ -895,17 +899,21 @@
Length += 2 * AddrSize;
// Emit the header for this section.
- // The 4 byte length not including the 4 byte value for the length.
- MCOS->emitInt32(Length - 4);
+ if (context.getDwarfFormat() == dwarf::DWARF64)
+ // The DWARF64 mark.
+ MCOS->emitInt32(dwarf::DW_LENGTH_DWARF64);
+ // The 4 (8 for DWARF64) byte length not including the length of the unit
+ // length field itself.
+ MCOS->emitIntValue(Length - UnitLengthBytes, OffsetSize);
// The 2 byte version, which is 2.
MCOS->emitInt16(2);
- // The 4 byte offset to the compile unit in the .debug_info from the start
- // of the .debug_info.
+ // The 4 (8 for DWARF64) byte offset to the compile unit in the .debug_info
+ // from the start of the .debug_info.
if (InfoSectionSymbol)
- MCOS->emitSymbolValue(InfoSectionSymbol, 4,
+ MCOS->emitSymbolValue(InfoSectionSymbol, OffsetSize,
asmInfo->needsDwarfSectionOffsetDirective());
else
- MCOS->emitInt32(0);
+ MCOS->emitIntValue(0, OffsetSize);
// The 1 byte size of an address.
MCOS->emitInt8(AddrSize);
// The 1 byte size of a segment descriptor, we use a value of zero.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81146.268811.patch
Type: text/x-patch
Size: 3699 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/751bfe68/attachment-0001.bin>
More information about the llvm-commits
mailing list