[llvm-commits] [llvm] r162312 - /llvm/trunk/include/llvm/Object/MachOFormat.h

Richard Smith richard-llvm at metafoo.co.uk
Tue Aug 21 13:52:03 PDT 2012


Author: rsmith
Date: Tue Aug 21 15:52:03 2012
New Revision: 162312

URL: http://llvm.org/viewvc/llvm-project?rev=162312&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/Object/MachOFormat.h

Modified: llvm/trunk/include/llvm/Object/MachOFormat.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachOFormat.h?rev=162312&r1=162311&r2=162312&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachOFormat.h (original)
+++ llvm/trunk/include/llvm/Object/MachOFormat.h Tue Aug 21 15:52:03 2012
@@ -273,6 +273,10 @@
     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 @@
     uint16_t Flags;
     uint64_t Value;
   };
+#pragma pack(pop)
 
   /// @}
   /// @name Data-in-code Table Entry





More information about the llvm-commits mailing list