summaryrefslogtreecommitdiffstats
path: root/llvm/tools/dsymutil/DwarfLinker.cpp
diff options
context:
space:
mode:
authorFrederic Riss <friss@apple.com>2015-07-24 06:41:11 +0000
committerFrederic Riss <friss@apple.com>2015-07-24 06:41:11 +0000
commiteb85c8fb099ec65b47467d15b9ea1018ca201f6b (patch)
treecb3f6944d5153d5eedfc710456ea8d7dc30b0fc2 /llvm/tools/dsymutil/DwarfLinker.cpp
parent65f0abf275ccc1eb249bb12ce4ac826c9df37986 (diff)
downloadbcm5719-llvm-eb85c8fb099ec65b47467d15b9ea1018ca201f6b.tar.gz
bcm5719-llvm-eb85c8fb099ec65b47467d15b9ea1018ca201f6b.zip
[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
Diffstat (limited to 'llvm/tools/dsymutil/DwarfLinker.cpp')
-rw-r--r--llvm/tools/dsymutil/DwarfLinker.cpp25
1 files changed, 20 insertions, 5 deletions
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<const object::ObjectFile &> loadObject(BinaryHolder &BinaryHolder,
+ DebugMapObject &Obj,
+ const DebugMap &Map);
/// @}
private:
@@ -3008,6 +3013,19 @@ void DwarfLinker::patchFrameInfoForObject(const DebugMapObject &DMO,
}
}
+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 @@ 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)) {
OpenPOWER on IntegriCloud