[llvm] 5a9ef6c - [DWARF] Support 64-bit DWARF in .debug_pubnames and similar tables.

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 23:51:29 PST 2020


Author: Igor Kudrin
Date: 2020-01-23T14:51:00+07:00
New Revision: 5a9ef6c15f37b5908fcf34e6b509bde0e0f70118

URL: https://github.com/llvm/llvm-project/commit/5a9ef6c15f37b5908fcf34e6b509bde0e0f70118
DIFF: https://github.com/llvm/llvm-project/commit/5a9ef6c15f37b5908fcf34e6b509bde0e0f70118.diff

LOG: [DWARF] Support 64-bit DWARF in .debug_pubnames and similar tables.

Differential Revision: https://reviews.llvm.org/D73103

Added: 
    llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s

Modified: 
    llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
    llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
index ae57306b90e1..5f7d812ec0f6 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
@@ -42,7 +42,7 @@ class DWARFDebugPubTable {
   struct Set {
     /// The total length of the entries for that set, not including the length
     /// field itself.
-    uint32_t Length;
+    uint64_t Length;
 
     /// This number is specific to the name lookup table and is independent of
     /// the DWARF version number.
@@ -54,7 +54,7 @@ class DWARFDebugPubTable {
 
     /// The size in bytes of the contents of the .debug_info section generated
     /// to represent that compilation unit.
-    uint32_t Size;
+    uint64_t Size;
 
     std::vector<Entry> Entries;
   };

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
index ab71b239cb67..bfa10441ba3a 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
@@ -28,13 +28,20 @@ DWARFDebugPubTable::DWARFDebugPubTable(const DWARFObject &Obj,
     Sets.push_back({});
     Set &SetData = Sets.back();
 
+    dwarf::DwarfFormat Format = dwarf::DWARF32;
     SetData.Length = PubNames.getU32(&Offset);
+    if (SetData.Length == dwarf::DW_LENGTH_DWARF64) {
+      Format = dwarf::DWARF64;
+      SetData.Length = PubNames.getU64(&Offset);
+    }
+    const unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(Format);
+
     SetData.Version = PubNames.getU16(&Offset);
-    SetData.Offset = PubNames.getRelocatedValue(4, &Offset);
-    SetData.Size = PubNames.getU32(&Offset);
+    SetData.Offset = PubNames.getRelocatedValue(OffsetSize, &Offset);
+    SetData.Size = PubNames.getUnsigned(&Offset, OffsetSize);
 
     while (Offset < Sec.Data.size()) {
-      uint32_t DieRef = PubNames.getU32(&Offset);
+      uint64_t DieRef = PubNames.getUnsigned(&Offset, OffsetSize);
       if (DieRef == 0)
         break;
       uint8_t IndexEntryValue = GnuStyle ? PubNames.getU8(&Offset) : 0;
@@ -47,10 +54,10 @@ DWARFDebugPubTable::DWARFDebugPubTable(const DWARFObject &Obj,
 
 void DWARFDebugPubTable::dump(raw_ostream &OS) const {
   for (const Set &S : Sets) {
-    OS << "length = " << format("0x%08x", S.Length);
+    OS << "length = " << format("0x%08" PRIx64, S.Length);
     OS << " version = " << format("0x%04x", S.Version);
     OS << " unit_offset = " << format("0x%08" PRIx64, S.Offset);
-    OS << " unit_size = " << format("0x%08x", S.Size) << '\n';
+    OS << " unit_size = " << format("0x%08" PRIx64, S.Size) << '\n';
     OS << (GnuStyle ? "Offset     Linkage  Kind     Name\n"
                     : "Offset     Name\n");
 

diff  --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s b/llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s
new file mode 100644
index 000000000000..1ac4e13bfc1e
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s
@@ -0,0 +1,26 @@
+# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \
+# RUN:   llvm-dwarfdump -debug-pubnames - | \
+# RUN:   FileCheck %s
+
+# CHECK: .debug_pubnames contents:
+# CHECK-NEXT: length = 0x00000032
+# CHECK-SAME: version = 0x0002
+# CHECK-SAME: unit_offset = 0x1122334455667788
+# CHECK-SAME: unit_size = 0x1100220033004400
+# CHECK-NEXT: Offset     Name
+# CHECK-NEXT: 0xaa01aaaabbbbbbbb "foo"
+# CHECK-NEXT: 0xaa02aaaabbbbbbbb "bar"
+
+    .section .debug_pubnames,"", at progbits
+    .long 0xffffffff            # DWARF64 mark
+    .quad .Lend - .Lversion     # Unit Length
+.Lversion:
+    .short 2                    # Version
+    .quad 0x1122334455667788    # Debug Info Offset
+    .quad 0x1100220033004400    # Debug Info Length
+    .quad 0xaa01aaaabbbbbbbb    # Tuple0: Offset
+    .asciz "foo"                #         Name
+    .quad 0xaa02aaaabbbbbbbb    # Tuple1: Offset
+    .asciz "bar"                #         Name
+    .quad 0                     # Terminator
+.Lend:


        


More information about the llvm-commits mailing list