Index: test/tools/llvm-objdump/X86/macho-disassembly-g-dsym.test =================================================================== --- /dev/null +++ test/tools/llvm-objdump/X86/macho-disassembly-g-dsym.test @@ -0,0 +1,4 @@ +// RUN: dsymutil -f -oso-prepend-path=%p/../../dsymutil/ %p/../../dsymutil/Inputs/basic.macho.x86_64 -o %t1 +// RUN: llvm-objdump -d -g -dsym=%t1 %p/../../dsymutil/Inputs/basic.macho.x86_64 | FileCheck %s + +CHECK: Disassembly of section __TEXT,__text: Index: tools/llvm-objdump/MachODump.cpp =================================================================== --- tools/llvm-objdump/MachODump.cpp +++ tools/llvm-objdump/MachODump.cpp @@ -6947,6 +6947,7 @@ std::unique_ptr diContext; ObjectFile *DbgObj = MachOOF; + std::unique_ptr DSYMBuf; // Try to find debug info and set up the DIContext for it. if (UseDbg) { // A separate DSym file path was specified, parse it as a macho file, @@ -6964,6 +6965,8 @@ if (DbgObjCheck.takeError()) report_error(MachOOF->getFileName(), DbgObjCheck.takeError()); DbgObj = DbgObjCheck.get().release(); + // We need to keep the file alive, because we're replacing DbgObj with it. + DSYMBuf = std::move(BufOrErr.get()); } // Setup the DIContext