diff options
author | Daniel Sanders <daniel_l_sanders@apple.com> | 2019-11-15 15:08:34 -0800 |
---|---|---|
committer | Daniel Sanders <daniel_l_sanders@apple.com> | 2019-11-18 12:57:39 -0800 |
commit | 17919017878e9abda5bb33a38199c593b151dcd7 (patch) | |
tree | 8de4260e234b3d5ce6981a8e09c5d98d16b772b9 /llvm/lib/Object/MachOObjectFile.cpp | |
parent | c941db5b1acdc45fc1c50762684f1014e981abc6 (diff) | |
download | bcm5719-llvm-17919017878e9abda5bb33a38199c593b151dcd7.tar.gz bcm5719-llvm-17919017878e9abda5bb33a38199c593b151dcd7.zip |
[macho] Allow CPUSubtype to contribute to architecture identification
Summary:
Sometimes the CPUSubtype determines the Triple::ArchType that must be used.
Add the subtype to the API's to allow targets that need this to correctly
identify the contents of the binary.
Reviewers: pete
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70345
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index c0c873f9735..8540b7ab03c 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -128,6 +128,10 @@ static unsigned getCPUType(const MachOObjectFile &O) { return O.getHeader().cputype; } +static unsigned getCPUSubType(const MachOObjectFile &O) { + return O.getHeader().cpusubtype; +} + static uint32_t getPlainRelocationAddress(const MachO::any_relocation_info &RE) { return RE.r_word0; @@ -2565,7 +2569,7 @@ StringRef MachOObjectFile::getFileFormatName() const { } } -Triple::ArchType MachOObjectFile::getArch(uint32_t CPUType) { +Triple::ArchType MachOObjectFile::getArch(uint32_t CPUType, uint32_t CPUSubType) { switch (CPUType) { case MachO::CPU_TYPE_I386: return Triple::x86; @@ -2737,7 +2741,7 @@ ArrayRef<StringRef> MachOObjectFile::getValidArchs() { } Triple::ArchType MachOObjectFile::getArch() const { - return getArch(getCPUType(*this)); + return getArch(getCPUType(*this), getCPUSubType(*this)); } Triple MachOObjectFile::getArchTriple(const char **McpuDefault) const { |