[MC] Generate .debug_aranges in the 64-bit DWARF format [4/7]

Differential Revision: https://reviews.llvm.org/D81146
This commit is contained in:
Igor Kudrin
2020-06-16 15:50:13 +07:00
parent 1dfcce5395
commit b5f8959bcd
3 changed files with 28 additions and 8 deletions
+15 -7
View File
@@ -875,9 +875,13 @@ static void EmitGenDwarfAranges(MCStreamer *MCOS,
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 @@ static void EmitGenDwarfAranges(MCStreamer *MCOS,
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.
+8 -1
View File
@@ -1,13 +1,15 @@
## This checks that llvm-mc is able to produce 64-bit debug info.
# RUN: llvm-mc -g -dwarf-version 5 -dwarf64 -triple x86_64 %s -filetype=obj -o %t5.o
# RUN: llvm-readobj -r %t5.o | FileCheck --check-prefixes=REL,REL5 %s
# RUN: llvm-readobj -r %t5.o | FileCheck --check-prefixes=REL,REL5 %s --implicit-check-not="R_{{.*}} .debug_"
# RUN: llvm-dwarfdump -v %t5.o | FileCheck --check-prefixes=DUMP,DUMP5 %s
## The references to other debug info sections are 64-bit, as required for DWARF64.
# 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:
+5
View File
@@ -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