[Object, MachO] Fixup for r239075: use union to store mach_header and mach_header_64.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239110 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexey Samsonov 2015-06-04 22:49:55 +00:00
parent 62d21d2b1a
commit 27d60c99f7
2 changed files with 6 additions and 9 deletions

View File

@ -429,7 +429,10 @@ public:
}
private:
MachO::mach_header_64 Header64;
union {
MachO::mach_header_64 Header64;
MachO::mach_header Header;
};
typedef SmallVector<const char*, 1> SectionList;
SectionList Sections;
typedef SmallVector<const char*, 1> LibraryList;

View File

@ -234,10 +234,7 @@ MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian,
if (is64Bit())
parseHeader(this, Header64, EC);
else
// First fields of MachO::mach_header_64 are the same as
// in MachO::mach_header.
parseHeader(this, *reinterpret_cast<MachO::mach_header *>(&this->Header64),
EC);
parseHeader(this, Header, EC);
if (EC)
return;
@ -1251,7 +1248,6 @@ unsigned MachOObjectFile::getArch() const {
Triple MachOObjectFile::getArch(const char **McpuDefault,
Triple *ThumbTriple) const {
const auto &Header = getHeader();
*ThumbTriple = getThumbArch(Header.cputype, Header.cpusubtype, McpuDefault);
return getArch(Header.cputype, Header.cpusubtype, McpuDefault);
}
@ -2186,9 +2182,7 @@ MachOObjectFile::getDice(DataRefImpl Rel) const {
}
const MachO::mach_header &MachOObjectFile::getHeader() const {
// First fields of MachO::mach_header_64 are the same as
// in MachO::mach_header.
return *reinterpret_cast<const MachO::mach_header *>(&this->Header64);
return Header;
}
const MachO::mach_header_64 &MachOObjectFile::getHeader64() const {