summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorFrederic Riss <friss@apple.com>2015-07-24 06:41:04 +0000
committerFrederic Riss <friss@apple.com>2015-07-24 06:41:04 +0000
commit65f0abf275ccc1eb249bb12ce4ac826c9df37986 (patch)
treec3154244cd9f5c78e6447fe7f14dcd45e3a2f039 /llvm/tools
parent9388406c2131a7e3c1e26524ba62d4f9e000168d (diff)
downloadbcm5719-llvm-65f0abf275ccc1eb249bb12ce4ac826c9df37986.tar.gz
bcm5719-llvm-65f0abf275ccc1eb249bb12ce4ac826c9df37986.zip
[dsymutil] Make the triple detection more strict.
MachOObjectFile offers a method for detecting the correct triple, use it instead of the previous approximation. This doesn't matter right now, but it will become important for mach-o universal (fat) binaries. llvm-svn: 243095
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/dsymutil/BinaryHolder.cpp10
-rw-r--r--llvm/tools/dsymutil/BinaryHolder.h3
-rw-r--r--llvm/tools/dsymutil/MachODebugMapParser.cpp9
3 files changed, 14 insertions, 8 deletions
diff --git a/llvm/tools/dsymutil/BinaryHolder.cpp b/llvm/tools/dsymutil/BinaryHolder.cpp
index 1774cf21e71..3f0c9b11260 100644
--- a/llvm/tools/dsymutil/BinaryHolder.cpp
+++ b/llvm/tools/dsymutil/BinaryHolder.cpp
@@ -13,11 +13,21 @@
//===----------------------------------------------------------------------===//
#include "BinaryHolder.h"
+#include "llvm/Object/MachO.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
namespace dsymutil {
+Triple BinaryHolder::getTriple(const object::MachOObjectFile &Obj) {
+ // If a ThumbTriple is returned, use it instead of the standard
+ // one. This is because the thumb triple always allows to create a
+ // target, whereas the non-thumb one might not.
+ Triple ThumbTriple;
+ Triple T = Obj.getArch(nullptr, &ThumbTriple);
+ return ThumbTriple.getArch() ? ThumbTriple : T;
+}
+
void BinaryHolder::changeBackingMemoryBuffer(
std::unique_ptr<MemoryBuffer> &&Buf) {
CurrentArchive.reset();
diff --git a/llvm/tools/dsymutil/BinaryHolder.h b/llvm/tools/dsymutil/BinaryHolder.h
index c072acac2b2..e4558580f9a 100644
--- a/llvm/tools/dsymutil/BinaryHolder.h
+++ b/llvm/tools/dsymutil/BinaryHolder.h
@@ -14,6 +14,7 @@
#ifndef LLVM_TOOLS_DSYMUTIL_BINARYHOLDER_H
#define LLVM_TOOLS_DSYMUTIL_BINARYHOLDER_H
+#include "llvm/ADT/Triple.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/Error.h"
#include "llvm/Object/ObjectFile.h"
@@ -108,6 +109,8 @@ public:
template <typename ObjectFileType> const ObjectFileType &GetAs() {
return cast<ObjectFileType>(*CurrentObjectFile);
}
+
+ static Triple getTriple(const object::MachOObjectFile &Obj);
};
}
}
diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp
index 8f3ca6ca004..cda43494b9b 100644
--- a/llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -103,13 +103,6 @@ void MachODebugMapParser::switchToNewDebugMapObject(StringRef Filename,
CurrentDebugMapObject = &Result->addDebugMapObject(Path, Timestamp);
}
-static Triple getTriple(const object::MachOObjectFile &Obj) {
- Triple TheTriple("unknown-unknown-unknown");
- TheTriple.setArch(Triple::ArchType(Obj.getArch()));
- TheTriple.setObjectFormat(Triple::MachO);
- return TheTriple;
-}
-
/// This main parsing routine tries to open the main binary and if
/// successful iterates over the STAB entries. The real parsing is
/// done in handleStabSymbolTableEntry.
@@ -120,7 +113,7 @@ ErrorOr<std::unique_ptr<DebugMap>> MachODebugMapParser::parse() {
const MachOObjectFile &MainBinary = *MainBinOrError;
loadMainBinarySymbols();
- Result = make_unique<DebugMap>(getTriple(MainBinary));
+ Result = make_unique<DebugMap>(BinaryHolder::getTriple(MainBinary));
MainBinaryStrings = MainBinary.getStringTableData();
for (const SymbolRef &Symbol : MainBinary.symbols()) {
const DataRefImpl &DRI = Symbol.getRawDataRefImpl();
OpenPOWER on IntegriCloud