forked from OSchip/llvm-project
parent
bbcefa7d50
commit
ae95ad1935
|
@ -17,6 +17,7 @@
|
||||||
#include "llvm/Object/MachOObject.h"
|
#include "llvm/Object/MachOObject.h"
|
||||||
#include "llvm/Object/ObjectFile.h"
|
#include "llvm/Object/ObjectFile.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
|
#include "llvm/Support/MachO.h"
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -280,26 +281,26 @@ uint8_t MachOObjectFile::getBytesInAddress() const {
|
||||||
StringRef MachOObjectFile::getFileFormatName() const {
|
StringRef MachOObjectFile::getFileFormatName() const {
|
||||||
if (!MachOObj->is64Bit()) {
|
if (!MachOObj->is64Bit()) {
|
||||||
switch (MachOObj->getHeader().CPUType) {
|
switch (MachOObj->getHeader().CPUType) {
|
||||||
case 0x00000007:
|
case llvm::MachO::CPUTypeI386:
|
||||||
return "Mach-O 32-bit i386";
|
return "Mach-O 32-bit i386";
|
||||||
case 0x0000000c:
|
case llvm::MachO::CPUTypeARM:
|
||||||
return "Mach-O arm";
|
return "Mach-O arm";
|
||||||
case 0x00000012:
|
case llvm::MachO::CPUTypePowerPC:
|
||||||
return "Mach-O 32-bit ppc";
|
return "Mach-O 32-bit ppc";
|
||||||
default:
|
default:
|
||||||
assert((MachOObj->getHeader().CPUType & 0x01000000) == 0 &&
|
assert((MachOObj->getHeader().CPUType & llvm::MachO::CPUArchABI64) == 0 &&
|
||||||
"64-bit object file when we're not 64-bit?");
|
"64-bit object file when we're not 64-bit?");
|
||||||
return "Mach-O 32-bit unknown";
|
return "Mach-O 32-bit unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (MachOObj->getHeader().CPUType) {
|
switch (MachOObj->getHeader().CPUType) {
|
||||||
case 0x01000007:
|
case llvm::MachO::CPUTypeX86_64:
|
||||||
return "Mach-O 64-bit x86-64";
|
return "Mach-O 64-bit x86-64";
|
||||||
case 0x01000012:
|
case llvm::MachO::CPUTypePowerPC64:
|
||||||
return "Mach-O 64-bit ppc64";
|
return "Mach-O 64-bit ppc64";
|
||||||
default:
|
default:
|
||||||
assert((MachOObj->getHeader().CPUType & 0x01000000) == 1 &&
|
assert((MachOObj->getHeader().CPUType & llvm::MachO::CPUArchABI64) == 1 &&
|
||||||
"32-bit object file when we're 64-bit?");
|
"32-bit object file when we're 64-bit?");
|
||||||
return "Mach-O 64-bit unknown";
|
return "Mach-O 64-bit unknown";
|
||||||
}
|
}
|
||||||
|
@ -307,15 +308,15 @@ StringRef MachOObjectFile::getFileFormatName() const {
|
||||||
|
|
||||||
unsigned MachOObjectFile::getArch() const {
|
unsigned MachOObjectFile::getArch() const {
|
||||||
switch (MachOObj->getHeader().CPUType) {
|
switch (MachOObj->getHeader().CPUType) {
|
||||||
case 0x00000007:
|
case llvm::MachO::CPUTypeI386:
|
||||||
return Triple::x86;
|
return Triple::x86;
|
||||||
case 0x01000007:
|
case llvm::MachO::CPUTypeX86_64:
|
||||||
return Triple::x86_64;
|
return Triple::x86_64;
|
||||||
case 0x0000000c:
|
case llvm::MachO::CPUTypeARM:
|
||||||
return Triple::arm;
|
return Triple::arm;
|
||||||
case 0x00000012:
|
case llvm::MachO::CPUTypePowerPC:
|
||||||
return Triple::ppc;
|
return Triple::ppc;
|
||||||
case 0x01000012:
|
case llvm::MachO::CPUTypePowerPC64:
|
||||||
return Triple::ppc64;
|
return Triple::ppc64;
|
||||||
default:
|
default:
|
||||||
return Triple::UnknownArch;
|
return Triple::UnknownArch;
|
||||||
|
|
Loading…
Reference in New Issue