[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
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp
index ba136d1..484c86a 100644
--- a/llvm/tools/dsymutil/DwarfLinker.cpp
+++ b/llvm/tools/dsymutil/DwarfLinker.cpp
@@ -1410,6 +1410,11 @@
const DWARFDebugInfoEntryMinimal *DIE = nullptr) const;
bool createStreamer(Triple TheTriple, StringRef OutputFilename);
+
+ /// \brief Attempt to load a debug object from disk.
+ ErrorOr<const object::ObjectFile &> loadObject(BinaryHolder &BinaryHolder,
+ DebugMapObject &Obj,
+ const DebugMap &Map);
/// @}
private:
@@ -3008,6 +3013,19 @@
}
}
+ErrorOr<const object::ObjectFile &>
+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 @@
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)) {