summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorVlad Tsyrklevich <vlad@tsyrklevich.net>2017-09-19 02:22:48 +0000
committerVlad Tsyrklevich <vlad@tsyrklevich.net>2017-09-19 02:22:48 +0000
commitde62046d68083a9a39ab29194adb6258a7ac76a9 (patch)
tree6a630da690f61f56d52287c94920b5b363f6e4d7 /llvm/tools/llvm-objdump/llvm-objdump.cpp
parentb7fdaf2cd403e99f3079efafc1793e3e7868a245 (diff)
downloadbcm5719-llvm-de62046d68083a9a39ab29194adb6258a7ac76a9.tar.gz
bcm5719-llvm-de62046d68083a9a39ab29194adb6258a7ac76a9.zip
Allow public Triple deduction from ObjectFiles.
Move logic that allows for Triple deduction from an ObjectFile object out of llvm-objdump.cpp into a public factory, found in the ObjectFile class. This should allow other tools in the future to use this logic without reimplementation. Patch by Mitch Phillips Differential Revision: https://reviews.llvm.org/D37719 llvm-svn: 313605
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp22
1 files changed, 2 insertions, 20 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 5b16abf25c6..09396466c40 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -362,29 +362,11 @@ static const Target *getTarget(const ObjectFile *Obj = nullptr) {
llvm::Triple TheTriple("unknown-unknown-unknown");
if (TripleName.empty()) {
if (Obj) {
- auto Arch = Obj->getArch();
- TheTriple.setArch(Triple::ArchType(Arch));
-
- // For ARM targets, try to use the build attributes to build determine
- // the build target. Target features are also added, but later during
- // disassembly.
- if (Arch == Triple::arm || Arch == Triple::armeb) {
- Obj->setARMSubArch(TheTriple);
- }
-
- // TheTriple defaults to ELF, and COFF doesn't have an environment:
- // the best we can do here is indicate that it is mach-o.
- if (Obj->isMachO())
- TheTriple.setObjectFormat(Triple::MachO);
-
- if (Obj->isCOFF()) {
- const auto COFFObj = dyn_cast<COFFObjectFile>(Obj);
- if (COFFObj->getArch() == Triple::thumb)
- TheTriple.setTriple("thumbv7-windows");
- }
+ TheTriple = Obj->makeTriple();
}
} else {
TheTriple.setTriple(Triple::normalize(TripleName));
+
// Use the triple, but also try to combine with ARM build attributes.
if (Obj) {
auto Arch = Obj->getArch();
OpenPOWER on IntegriCloud