[PATCH] D81147: [MC] Generate .debug_rnglists in the 64-bit DWARF format [5/7]

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 05:24:48 PDT 2020


ikudrin created this revision.
ikudrin added reviewers: dblaikie, jhenderson, aprantl, probinson, MaskRay, echristo.
ikudrin added projects: LLVM, debug-info.
Herald added subscribers: hiraditya, emaste.
Herald added a reviewer: espindola.
ikudrin added a parent revision: D81146: [MC] Generate .debug_aranges in the 64-bit DWARF format [4/7].
ikudrin added a child revision: D81148: [MC] Fix DWARF forms for 64-bit DWARFv3 files [6/7].

In addition, the patch fixes referencing the section within a compilation unit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81147

Files:
  llvm/lib/MC/MCDwarf.cpp
  llvm/test/MC/ELF/gen-dwarf64.s


Index: llvm/test/MC/ELF/gen-dwarf64.s
===================================================================
--- llvm/test/MC/ELF/gen-dwarf64.s
+++ llvm/test/MC/ELF/gen-dwarf64.s
@@ -9,6 +9,7 @@
 # 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
+# REL5-NEXT:     R_X86_64_64 .debug_rnglists 0x14
 # REL:         Section ({{[0-9]+}}) .rela.debug_aranges {
 # REL-NEXT:      R_X86_64_64 .debug_info 0x0
 # REL5:        Section ({{[0-9]+}}) .rela.debug_line {
@@ -20,11 +21,15 @@
 # DUMP-SAME:    format = DWARF64
 # DUMP:       DW_TAG_compile_unit [1] *
 # DUMP5-NEXT:   DW_AT_stmt_list [DW_FORM_sec_offset] (0x0000000000000000)
+# DUMP5-NEXT:   DW_AT_ranges [DW_FORM_sec_offset] (0x0000000000000014
+# DUMP-NEXT:      [0x0000000000000000, 0x0000000000000001) ".foo"
+# DUMP-NEXT:      [0x0000000000000000, 0x0000000000000001) ".bar")
 
 # DUMP:       .debug_aranges contents:
 # DUMP-NEXT:  Address Range Header: 
 # DUMP-SAME:    format = DWARF64
 # DUMP-NEXT:  [0x0000000000000000,  0x0000000000000001)
+# DUMP-NEXT:  [0x0000000000000000,  0x0000000000000001)
 # DUMP-EMPTY:
 
 # DUMP:       .debug_line contents:
@@ -41,6 +46,18 @@
 # DUMP5-NEXT: 0x00000000: "[[DIR]]"
 # DUMP5-NEXT: 0x[[FILEOFF]]: "[[FILE]]"
 
+# DUMP5:      .debug_rnglists contents:
+# DUMP5-NEXT: 0x00000000: range list header:
+# DUMP5-SAME:   format = DWARF64
+# DUMP5-NEXT: ranges:
+# DUMP5-NEXT: 0x00000014: [DW_RLE_start_length]: 0x0000000000000000, 0x0000000000000001 => [0x0000000000000000, 0x0000000000000001)
+# DUMP5-NEXT: 0x0000001e: [DW_RLE_start_length]: 0x0000000000000000, 0x0000000000000001 => [0x0000000000000000, 0x0000000000000001)
+# DUMP5-NEXT: 0x00000028: [DW_RLE_end_of_list ]
+
     .section .foo, "ax", @progbits
 foo:
     nop
+
+    .section .bar, "ax", @progbits
+bar:
+    nop
Index: llvm/lib/MC/MCDwarf.cpp
===================================================================
--- llvm/lib/MC/MCDwarf.cpp
+++ llvm/lib/MC/MCDwarf.cpp
@@ -50,8 +50,14 @@
       S.getContext().createTempSymbol("debug_list_header_start", true, true);
   MCSymbol *End =
       S.getContext().createTempSymbol("debug_list_header_end", true, true);
+  auto DwarfFormat = S.getContext().getDwarfFormat();
+  if (DwarfFormat == dwarf::DWARF64) {
+    S.AddComment("DWARF64 mark");
+    S.emitInt32(dwarf::DW_LENGTH_DWARF64);
+  }
   S.AddComment("Length");
-  S.emitAbsoluteSymbolDiff(End, Start, 4);
+  S.emitAbsoluteSymbolDiff(End, Start,
+                           dwarf::getDwarfOffsetByteSize(DwarfFormat));
   S.emitLabel(Start);
   S.AddComment("Version");
   S.emitInt16(S.getContext().getDwarfVersion());
@@ -1012,9 +1018,9 @@
 
   if (RangesSymbol) {
     // There are multiple sections containing code, so we must use
-    // .debug_ranges/.debug_rnglists. AT_ranges, the 4 byte offset from the
+    // .debug_ranges/.debug_rnglists. AT_ranges, the 4/8 byte offset from the
     // start of the .debug_ranges/.debug_rnglists.
-    MCOS->emitSymbolValue(RangesSymbol, 4);
+    MCOS->emitSymbolValue(RangesSymbol, OffsetSize);
   } else {
     // If we only have one non-empty code section, we can use the simpler
     // AT_low_pc and AT_high_pc attributes.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81147.268430.patch
Type: text/x-patch
Size: 3243 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200604/e0e476c2/attachment.bin>


More information about the llvm-commits mailing list