Fix misaligned access in MachO object file reader: despite containing an

int64_t, Symbol64TableEntry is actually only stored with 4-byte alignment
within the file.

The usage of #pragma pack here is copied from the corresponding code in
Support/Endian.h, so shouldn't introduce any new portability problems.

llvm-svn: 162312
This commit is contained in:
Richard Smith 2012-08-21 20:52:03 +00:00
parent 13473857a7
commit da32944cac
1 changed files with 5 additions and 0 deletions

View File

@ -273,6 +273,10 @@ namespace macho {
uint16_t Flags;
uint32_t Value;
};
// Despite containing a uint64_t, this structure is only 4-byte aligned within
// a MachO file.
#pragma pack(push)
#pragma pack(4)
struct Symbol64TableEntry {
uint32_t StringIndex;
uint8_t Type;
@ -280,6 +284,7 @@ namespace macho {
uint16_t Flags;
uint64_t Value;
};
#pragma pack(pop)
/// @}
/// @name Data-in-code Table Entry