From: Michael Trent Date: Thu, 30 May 2019 18:17:10 +0000 (+0000) Subject: Reverting change r362121 due to lld-x86_64-ubuntu-fast test failures X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=55e67e44b91686c3398a5156634dee0f35af5341;p=llvm Reverting change r362121 due to lld-x86_64-ubuntu-fast test failures git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362123 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/tools/llvm-objdump/X86/macho-disassemble-g-dsym.test b/test/tools/llvm-objdump/X86/macho-disassemble-g-dsym.test index 01ccd3044c0..f06567764b8 100644 --- a/test/tools/llvm-objdump/X86/macho-disassemble-g-dsym.test +++ b/test/tools/llvm-objdump/X86/macho-disassemble-g-dsym.test @@ -5,14 +5,3 @@ // RUN: FileCheck --input-file %t0 %s CHECK: Disassembly of section __TEXT,__text: - -// RUN: dsymutil %p/../../dsymutil/Inputs/fat-test.dylib -o fat-test.dylib.dSYM -// RUN: llvm-objdump -m -d -g -dsym fat-test.dylib.dSYM/Contents/Resources/DWARF/fat-test.dylib %p/../../dsymutil/Inputs/fat-test.dylib | FileCheck -check-prefix MACHO_DSYM %s -// RUN: dsymutil %p/../../dsymutil/Inputs/basic.macho.x86_64 -o basic.macho.x86_64.dSYM -// RUN: llvm-objdump -m -d -g -dsym basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 %p/../../dsymutil/Inputs/basic.macho.x86_64 | FileCheck -check-prefix MACHO_DSYM %s - -MACHO_DSYM: (__TEXT,__text) section - -// RUN: llvm-objdump -m -d -g -dsym %p/../Inputs/libbogus11.a %p/../../dsymutil/Inputs/basic.macho.x86_64 2>&1 | FileCheck -check-prefix BAD_INPUT %s - -BAD_INPUT: is not a Mach-O or Universal file type. diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index b684daacb61..ea92ef9268a 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -7223,13 +7223,11 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, raw_ostream &DebugOut = nulls(); #endif - // Try to find debug info and set up the DIContext for it. std::unique_ptr diContext; - std::unique_ptr DSYMBinary; + ObjectFile *DbgObj = MachOOF; std::unique_ptr DSYMBuf; + // Try to find debug info and set up the DIContext for it. if (UseDbg) { - ObjectFile *DbgObj = MachOOF; - // A separate DSym file path was specified, parse it as a macho file, // get the sections and supply it to the section name parsing machinery. if (!DSYMFile.empty()) { @@ -7240,61 +7238,12 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, return; } + std::unique_ptr DbgObjCheck = unwrapOrError( + ObjectFile::createMachOObjectFile(BufOrErr.get()->getMemBufferRef()), + DSYMFile.getValue()); + DbgObj = DbgObjCheck.release(); // We need to keep the file alive, because we're replacing DbgObj with it. DSYMBuf = std::move(BufOrErr.get()); - - Expected> BinaryOrErr = - createBinary(DSYMBuf.get()->getMemBufferRef()); - if (!BinaryOrErr) { - report_error(BinaryOrErr.takeError(), DSYMFile); - return; - } - - // We need to keep the Binary elive with the buffer - DSYMBinary = std::move(BinaryOrErr.get()); - - if (ObjectFile *O = dyn_cast(DSYMBinary.get())) { - // this is a Mach-O object file, use it - if (MachOObjectFile *MachDSYM = dyn_cast(&*O)) { - DbgObj = MachDSYM; - } - else { - WithColor::error(errs(), "llvm-objdump") - << DSYMFile << " is not a Mach-O file type.\n"; - return; - } - } - else if (auto UB = dyn_cast(DSYMBinary.get())){ - // this is a Universal Binary, find a Mach-O for this architecture - uint32_t CPUType, CPUSubType; - const char *ArchFlag; - if (MachOOF->is64Bit()) { - const MachO::mach_header_64 H_64 = MachOOF->getHeader64(); - CPUType = H_64.cputype; - CPUSubType = H_64.cpusubtype; - } else { - const MachO::mach_header H = MachOOF->getHeader(); - CPUType = H.cputype; - CPUSubType = H.cpusubtype; - } - Triple T = MachOObjectFile::getArchTriple(CPUType, CPUSubType, nullptr, - &ArchFlag); - Expected> MachDSYM = - UB->getObjectForArch(ArchFlag); - if (!MachDSYM) { - report_error(MachDSYM.takeError(), DSYMFile); - return; - } - - // We need to keep the Binary elive with the buffer - DbgObj = &*MachDSYM.get(); - DSYMBinary = std::move(*MachDSYM); - } - else { - WithColor::error(errs(), "llvm-objdump") - << DSYMFile << " is not a Mach-O or Universal file type.\n"; - return; - } } // Setup the DIContext