OSDN Git Service

dwarfdump: Support/process relocations on a CU's abbrev_off
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 16 Dec 2016 16:31:10 +0000 (16:31 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 16 Dec 2016 16:31:10 +0000 (16:31 +0000)
Input can be produced by ld -r, for example (a normal LLVM workflow
never hits this - LLVM only ever produces a single abbrev table in an
object (shared by multiple CUs), so the reloc's always 0, and when it's
linked together the relocation's resolved so it doesn't need to be
handled)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289954 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DebugInfo/DWARF/DWARFUnit.cpp
test/DebugInfo/Inputs/dwarfdump-abbrev-off.elf-x86-64 [new file with mode: 0644]
test/DebugInfo/dwarfdump-abbrev-off.test [new file with mode: 0644]

index 2ddbc50..8e5691a 100644 (file)
@@ -87,7 +87,10 @@ bool DWARFUnit::getStringOffsetSectionItem(uint32_t Index,
 bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
   Length = debug_info.getU32(offset_ptr);
   Version = debug_info.getU16(offset_ptr);
+  auto AI = InfoSection.Relocs.find(*offset_ptr);
   uint64_t AbbrOffset = debug_info.getU32(offset_ptr);
+  if (AI != InfoSection.Relocs.end())
+    AbbrOffset += AI->second.second;
   if (IndexEntry) {
     if (AbbrOffset)
       return false;
diff --git a/test/DebugInfo/Inputs/dwarfdump-abbrev-off.elf-x86-64 b/test/DebugInfo/Inputs/dwarfdump-abbrev-off.elf-x86-64
new file mode 100644 (file)
index 0000000..bc196b5
Binary files /dev/null and b/test/DebugInfo/Inputs/dwarfdump-abbrev-off.elf-x86-64 differ
diff --git a/test/DebugInfo/dwarfdump-abbrev-off.test b/test/DebugInfo/dwarfdump-abbrev-off.test
new file mode 100644 (file)
index 0000000..2937d8c
--- /dev/null
@@ -0,0 +1,8 @@
+RUN: llvm-dwarfdump -debug-dump=info %p/Inputs/dwarfdump-abbrev-off.elf-x86-64 | FileCheck %s
+
+Check that we apply relocations to the abbr_offset - while LLVM never produces
+an object file like this, a reproduction can be produced by linking two simple
+object files together with ld -r.
+
+CHECK: abbr_offset = 0x0000
+CHECK: abbr_offset = 0x0010