From eb85c8fb099ec65b47467d15b9ea1018ca201f6b Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Fri, 24 Jul 2015 06:41:11 +0000 Subject: [dsymutil] Implement support for universal mach-o object files. This patch allows llvm-dsymutil to read universal (aka fat) macho object files and archives. The patch touches nearly everything in the BinaryHolder, but it is fairly mechinical: the methods that returned MemoryBufferRefs or ObjectFiles now return a vector of those, and the high-level access function takes a triple argument to select the architecture. There is no support yet for handling fat executables and thus no support for writing fat object files. llvm-svn: 243096 --- llvm/tools/dsymutil/DwarfLinker.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'llvm/tools/dsymutil/DwarfLinker.cpp') diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index ba136d1d96f..484c86aa5df 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/tools/dsymutil/DwarfLinker.cpp @@ -1410,6 +1410,11 @@ private: const DWARFDebugInfoEntryMinimal *DIE = nullptr) const; bool createStreamer(Triple TheTriple, StringRef OutputFilename); + + /// \brief Attempt to load a debug object from disk. + ErrorOr loadObject(BinaryHolder &BinaryHolder, + DebugMapObject &Obj, + const DebugMap &Map); /// @} private: @@ -3008,6 +3013,19 @@ void DwarfLinker::patchFrameInfoForObject(const DebugMapObject &DMO, } } +ErrorOr +DwarfLinker::loadObject(BinaryHolder &BinaryHolder, DebugMapObject &Obj, + const DebugMap &Map) { + auto ErrOrObjs = + BinaryHolder.GetObjectFiles(Obj.getObjectFilename(), Obj.getTimestamp()); + if (std::error_code EC = ErrOrObjs.getError()) + reportWarning(Twine(Obj.getObjectFilename()) + ": " + EC.message()); + auto ErrOrObj = BinaryHolder.Get(Map.getTriple()); + if (std::error_code EC = ErrOrObj.getError()) + reportWarning(Twine(Obj.getObjectFilename()) + ": " + EC.message()); + return ErrOrObj; +} + bool DwarfLinker::link(const DebugMap &Map) { if (Map.begin() == Map.end()) { @@ -3027,12 +3045,9 @@ bool DwarfLinker::link(const DebugMap &Map) { if (Options.Verbose) outs() << "DEBUG MAP OBJECT: " << Obj->getObjectFilename() << "\n"; - auto ErrOrObj = - BinHolder.GetObjectFile(Obj->getObjectFilename(), Obj->getTimestamp()); - if (std::error_code EC = ErrOrObj.getError()) { - reportWarning(Twine(Obj->getObjectFilename()) + ": " + EC.message()); + auto ErrOrObj = loadObject(BinHolder, *Obj, Map); + if (!ErrOrObj) continue; - } // Look for relocations that correspond to debug map entries. if (!findValidRelocsInDebugInfo(*ErrOrObj, *Obj)) { -- cgit v1.2.3