diff --git a/lib/DebugInfo/DWARF/DWARFContext.cpp b/lib/DebugInfo/DWARF/DWARFContext.cpp index 4858f3633d0..408214339a8 100644 --- a/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -689,9 +689,15 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj, } else if (auto *MObj = dyn_cast(&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: diff --git a/test/DebugInfo/Inputs/dwarfdump-test.cc b/test/DebugInfo/Inputs/dwarfdump-test.cc index 14295d3cffa..815c33dd3ac 100644 --- a/test/DebugInfo/Inputs/dwarfdump-test.cc +++ b/test/DebugInfo/Inputs/dwarfdump-test.cc @@ -27,3 +27,5 @@ int main() { // $ cp 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. diff --git a/test/DebugInfo/Inputs/dwarfdump-test.macho-i386.o b/test/DebugInfo/Inputs/dwarfdump-test.macho-i386.o new file mode 100644 index 00000000000..b53c8a6959e Binary files /dev/null and b/test/DebugInfo/Inputs/dwarfdump-test.macho-i386.o differ diff --git a/test/DebugInfo/dwarfdump-dump-flags.test b/test/DebugInfo/dwarfdump-dump-flags.test index 92b2d50f393..4c10bede6f8 100644 --- a/test/DebugInfo/dwarfdump-dump-flags.test +++ b/test/DebugInfo/dwarfdump-dump-flags.test @@ -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