From 9e8eb418e583974c7d24ca3d81f567accd5adbfa Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 22 Apr 2016 23:21:13 +0000 Subject: MachO: remove weird ARM/Thumb interface from MachOObjectFile Only one consumer (llvm-objdump) actually cared about the fact that there were two triples. Others were actively working around the fact that the Triple returned by getArch might have been invalid. As for llvm-objdump, it needs to be acutely aware of both Triples anyway, so being generic in the exposed API is no benefit. Also rename the version of getArch returning a Triple. Users were having to pass an unwanted nullptr to disambiguate the two, which was nasty. The only functional change here is that armv7m and armv7em object files no longer crash llvm-objdump. llvm-svn: 267249 --- llvm/tools/llvm-objdump/MachODump.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'llvm/tools/llvm-objdump') diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index ecf6b359146..7f256cb58fe 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -142,11 +142,18 @@ static const Target *GetTarget(const MachOObjectFile *MachOObj, const char **McpuDefault, const Target **ThumbTarget) { // Figure out the target triple. + llvm::Triple TT(TripleName); if (TripleName.empty()) { - llvm::Triple TT("unknown-unknown-unknown"); - llvm::Triple ThumbTriple = Triple(); - TT = MachOObj->getArch(McpuDefault, &ThumbTriple); + TT = MachOObj->getArchTriple(McpuDefault); TripleName = TT.str(); + } + + if (TT.getArch() == Triple::arm) { + // We've inferred a 32-bit ARM target from the object file. All MachO CPUs + // that support ARM are also capable of Thumb mode. + llvm::Triple ThumbTriple = TT; + std::string ThumbName = (Twine("thumb") + TT.getArchName().substr(3)).str(); + ThumbTriple.setArchName(ThumbName); ThumbTripleName = ThumbTriple.str(); } @@ -1157,10 +1164,10 @@ static bool checkMachOAndArchFlags(ObjectFile *O, StringRef Filename) { Triple T; if (MachO->is64Bit()) { H_64 = MachO->MachOObjectFile::getHeader64(); - T = MachOObjectFile::getArch(H_64.cputype, H_64.cpusubtype); + T = MachOObjectFile::getArchTriple(H_64.cputype, H_64.cpusubtype); } else { H = MachO->MachOObjectFile::getHeader(); - T = MachOObjectFile::getArch(H.cputype, H.cpusubtype); + T = MachOObjectFile::getArchTriple(H.cputype, H.cpusubtype); } unsigned i; for (i = 0; i < ArchFlags.size(); ++i) { -- cgit v1.2.3