[llvm] r243778 - [dwarfdump] Ignore scattered relocations for mach-o.

Frederic Riss friss at apple.com
Fri Jul 31 13:22:50 PDT 2015


Author: friss
Date: Fri Jul 31 15:22:50 2015
New Revision: 243778

URL: http://llvm.org/viewvc/llvm-project?rev=243778&view=rev
Log:
[dwarfdump] Ignore scattered relocations for mach-o.

When encountering a scattered relocation, the code would assert trying to
access an unexisting section. I couldn't find a way to expose the result
of the processing of a scattered reloc, and I'm really unsure what the
right thing to do is. This patch just skips them during the processing in
DwarfContext and adds a mach-o file to the tests that exposed the asserting
behavior.
(This is a new failure that is being exposed by Rafael's recent work on
the libObject interfaces. I think the wrong behavior has always happened,
but now it's asserting)

Added:
    llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.macho-i386.o
Modified:
    llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
    llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.cc
    llvm/trunk/test/DebugInfo/dwarfdump-dump-flags.test

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=243778&r1=243777&r2=243778&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Fri Jul 31 15:22:50 2015
@@ -689,9 +689,15 @@ DWARFContextInMemory::DWARFContextInMemo
         } else if (auto *MObj = dyn_cast<MachOObjectFile>(&Obj)) {
           // MachO also has relocations that point to sections and
           // scattered relocations.
-          // FIXME: We are not handling scattered relocations, do we have to?
-          RSec = MObj->getRelocationSection(Reloc.getRawDataRefImpl());
-          SymAddr = RSec->getAddress();
+          auto RelocInfo = MObj->getRelocation(Reloc.getRawDataRefImpl());
+          if (MObj->isRelocationScattered(RelocInfo)) {
+            // FIXME: it's not clear how to correctly handle scattered
+            // relocations.
+            continue;
+          } else {
+            RSec = MObj->getRelocationSection(Reloc.getRawDataRefImpl());
+            SymAddr = RSec->getAddress();
+          }
         }
 
         // If we are given load addresses for the sections, we need to adjust:

Modified: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.cc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.cc?rev=243778&r1=243777&r2=243778&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.cc (original)
+++ llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.cc Fri Jul 31 15:22:50 2015
@@ -27,3 +27,5 @@ int main() {
 // $ cp <output> output2.dwz
 // $ dwz -m output.dwz -r output1.dwz output2.dwz
 // $ rm output2.dwz
+
+// The mach-o version was generated using clang-3.6.2.

Added: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.macho-i386.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.macho-i386.o?rev=243778&view=auto
==============================================================================
Binary files llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.macho-i386.o (added) and llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test.macho-i386.o Fri Jul 31 15:22:50 2015 differ

Modified: llvm/trunk/test/DebugInfo/dwarfdump-dump-flags.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-dump-flags.test?rev=243778&r1=243777&r2=243778&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/dwarfdump-dump-flags.test (original)
+++ llvm/trunk/test/DebugInfo/dwarfdump-dump-flags.test Fri Jul 31 15:22:50 2015
@@ -1,6 +1,9 @@
 ; RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test.elf-x86-64 -debug-dump=all | FileCheck %s -check-prefix DUMP_ALL
 ; RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test.elf-x86-64 -debug-dump=info | FileCheck %s -check-prefix DUMP_INFO
 ; RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test.elf-x86-64 -debug-dump=ranges | FileCheck %s -check-prefix DUMP_RANGES
+; RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test.macho-i386.o -debug-dump=all | FileCheck %s -check-prefix DUMP_ALL
+; RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test.macho-i386.o -debug-dump=info | FileCheck %s -check-prefix DUMP_INFO
+; RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test.macho-i386.o -debug-dump=ranges | FileCheck %s -check-prefix DUMP_RANGES
 
 ; DUMP_ALL: .debug_info
 ; DUMP_ALL: .debug_ranges





More information about the llvm-commits mailing list