Skip to content

Commit 5d5f629

Browse files
committed
Reverting change r362121 due to lld-x86_64-ubuntu-fast test failures
llvm-svn: 362123
1 parent 0f4446b commit 5d5f629

File tree

2 files changed

+6
-68
lines changed

2 files changed

+6
-68
lines changed

llvm/test/tools/llvm-objdump/X86/macho-disassemble-g-dsym.test

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,3 @@
55
// RUN: FileCheck --input-file %t0 %s
66

77
CHECK: Disassembly of section __TEXT,__text:
8-
9-
// RUN: dsymutil %p/../../dsymutil/Inputs/fat-test.dylib -o fat-test.dylib.dSYM
10-
// 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
11-
// RUN: dsymutil %p/../../dsymutil/Inputs/basic.macho.x86_64 -o basic.macho.x86_64.dSYM
12-
// 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
13-
14-
MACHO_DSYM: (__TEXT,__text) section
15-
16-
// 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
17-
18-
BAD_INPUT: is not a Mach-O or Universal file type.

llvm/tools/llvm-objdump/MachODump.cpp

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7223,13 +7223,11 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
72237223
raw_ostream &DebugOut = nulls();
72247224
#endif
72257225

7226-
// Try to find debug info and set up the DIContext for it.
72277226
std::unique_ptr<DIContext> diContext;
7228-
std::unique_ptr<Binary> DSYMBinary;
7227+
ObjectFile *DbgObj = MachOOF;
72297228
std::unique_ptr<MemoryBuffer> DSYMBuf;
7229+
// Try to find debug info and set up the DIContext for it.
72307230
if (UseDbg) {
7231-
ObjectFile *DbgObj = MachOOF;
7232-
72337231
// A separate DSym file path was specified, parse it as a macho file,
72347232
// get the sections and supply it to the section name parsing machinery.
72357233
if (!DSYMFile.empty()) {
@@ -7240,61 +7238,12 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
72407238
return;
72417239
}
72427240

7241+
std::unique_ptr<MachOObjectFile> DbgObjCheck = unwrapOrError(
7242+
ObjectFile::createMachOObjectFile(BufOrErr.get()->getMemBufferRef()),
7243+
DSYMFile.getValue());
7244+
DbgObj = DbgObjCheck.release();
72437245
// We need to keep the file alive, because we're replacing DbgObj with it.
72447246
DSYMBuf = std::move(BufOrErr.get());
7245-
7246-
Expected<std::unique_ptr<Binary>> BinaryOrErr =
7247-
createBinary(DSYMBuf.get()->getMemBufferRef());
7248-
if (!BinaryOrErr) {
7249-
report_error(BinaryOrErr.takeError(), DSYMFile);
7250-
return;
7251-
}
7252-
7253-
// We need to keep the Binary elive with the buffer
7254-
DSYMBinary = std::move(BinaryOrErr.get());
7255-
7256-
if (ObjectFile *O = dyn_cast<ObjectFile>(DSYMBinary.get())) {
7257-
// this is a Mach-O object file, use it
7258-
if (MachOObjectFile *MachDSYM = dyn_cast<MachOObjectFile>(&*O)) {
7259-
DbgObj = MachDSYM;
7260-
}
7261-
else {
7262-
WithColor::error(errs(), "llvm-objdump")
7263-
<< DSYMFile << " is not a Mach-O file type.\n";
7264-
return;
7265-
}
7266-
}
7267-
else if (auto UB = dyn_cast<MachOUniversalBinary>(DSYMBinary.get())){
7268-
// this is a Universal Binary, find a Mach-O for this architecture
7269-
uint32_t CPUType, CPUSubType;
7270-
const char *ArchFlag;
7271-
if (MachOOF->is64Bit()) {
7272-
const MachO::mach_header_64 H_64 = MachOOF->getHeader64();
7273-
CPUType = H_64.cputype;
7274-
CPUSubType = H_64.cpusubtype;
7275-
} else {
7276-
const MachO::mach_header H = MachOOF->getHeader();
7277-
CPUType = H.cputype;
7278-
CPUSubType = H.cpusubtype;
7279-
}
7280-
Triple T = MachOObjectFile::getArchTriple(CPUType, CPUSubType, nullptr,
7281-
&ArchFlag);
7282-
Expected<std::unique_ptr<MachOObjectFile>> MachDSYM =
7283-
UB->getObjectForArch(ArchFlag);
7284-
if (!MachDSYM) {
7285-
report_error(MachDSYM.takeError(), DSYMFile);
7286-
return;
7287-
}
7288-
7289-
// We need to keep the Binary elive with the buffer
7290-
DbgObj = &*MachDSYM.get();
7291-
DSYMBinary = std::move(*MachDSYM);
7292-
}
7293-
else {
7294-
WithColor::error(errs(), "llvm-objdump")
7295-
<< DSYMFile << " is not a Mach-O or Universal file type.\n";
7296-
return;
7297-
}
72987247
}
72997248

73007249
// Setup the DIContext

0 commit comments

Comments
 (0)