diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-08 13:25:33 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-08 13:25:33 +0000 |
commit | 9d55c099d628d7835dd1b502cb29c96cae350099 (patch) | |
tree | 335fd71d28c964c9d5fc398252a8a27b4273e2fd /lib/Object | |
parent | bd7c634ab90ed63ee409fe781360cd42b05780f3 (diff) | |
download | external_llvm-9d55c099d628d7835dd1b502cb29c96cae350099.zip external_llvm-9d55c099d628d7835dd1b502cb29c96cae350099.tar.gz external_llvm-9d55c099d628d7835dd1b502cb29c96cae350099.tar.bz2 |
Add all 4 MachO object types. Use the stored type to implement is64Bits().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179021 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object')
-rw-r--r-- | lib/Object/MachOObjectFile.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index 4fe791c..24c916c 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -28,8 +28,9 @@ using namespace object; namespace llvm { namespace object { -MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, error_code &ec) - : ObjectFile(Binary::ID_MachO, Object) { +MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, bool Is64bits, + error_code &ec) + : ObjectFile(getMachOType(true, Is64bits), Object) { DataRefImpl DRI; moveToNextSection(DRI); uint32_t LoadCommandCount = getHeader()->NumLoadCommands; @@ -41,8 +42,8 @@ MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, error_code &ec) } bool MachOObjectFile::is64Bit() const { - StringRef Magic = getData(0, 4); - return (Magic == "\xFE\xED\xFA\xCF") || (Magic == "\xCF\xFA\xED\xFE"); + unsigned int Type = getType(); + return Type == ID_MachO64L || Type == ID_MachO64B; } const MachOFormat::LoadCommand * @@ -88,8 +89,10 @@ StringRef MachOObjectFile::getData(size_t Offset, size_t Size) const { } ObjectFile *ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer) { + StringRef Magic = Buffer->getBuffer().slice(0, 4); error_code ec; - ObjectFile *Ret = new MachOObjectFile(Buffer, ec); + bool Is64Bits = Magic == "\xFE\xED\xFA\xCF" || Magic == "\xCF\xFA\xED\xFE"; + ObjectFile *Ret = new MachOObjectFile(Buffer, Is64Bits, ec); if (ec) return NULL; return Ret; |