[llvm] r270663 - Object: ensure that structures are fully defined

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 22:23:02 PDT 2016


Author: compnerd
Date: Wed May 25 00:23:02 2016
New Revision: 270663

URL: http://llvm.org/viewvc/llvm-project?rev=270663&view=rev
Log:
Object: ensure that structures are fully defined

Ensure that the unused fields are explicitly stated when defining the types.
Add some compile time assertions about the size requirements for the structure
types.

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

Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=270663&r1=270662&r2=270663&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Wed May 25 00:23:02 2016
@@ -439,20 +439,32 @@ struct coff_aux_function_definition {
   support::ulittle32_t TotalSize;
   support::ulittle32_t PointerToLinenumber;
   support::ulittle32_t PointerToNextFunction;
+  char Unused1[2];
 };
 
+static_assert(sizeof(coff_aux_function_definition) == 18,
+              "auxiliary entry must be 18 bytes");
+
 struct coff_aux_bf_and_ef_symbol {
   char Unused1[4];
   support::ulittle16_t Linenumber;
   char Unused2[6];
   support::ulittle32_t PointerToNextFunction;
+  char Unused3[2];
 };
 
+static_assert(sizeof(coff_aux_bf_and_ef_symbol) == 18,
+              "auxiliary entry must be 18 bytes");
+
 struct coff_aux_weak_external {
   support::ulittle32_t TagIndex;
   support::ulittle32_t Characteristics;
+  char Unused1[10];
 };
 
+static_assert(sizeof(coff_aux_weak_external) == 18,
+              "auxiliary entry must be 18 bytes");
+
 struct coff_aux_section_definition {
   support::ulittle32_t Length;
   support::ulittle16_t NumberOfRelocations;
@@ -470,12 +482,19 @@ struct coff_aux_section_definition {
   }
 };
 
+static_assert(sizeof(coff_aux_section_definition) == 18,
+              "auxiliary entry must be 18 bytes");
+
 struct coff_aux_clr_token {
   uint8_t              AuxType;
   uint8_t              Reserved;
   support::ulittle32_t SymbolTableIndex;
+  char                 MBZ[12];
 };
 
+static_assert(sizeof(coff_aux_clr_token) == 18,
+              "auxiliary entry must be 18 bytes");
+
 struct coff_import_header {
   support::ulittle16_t Sig1;
   support::ulittle16_t Sig2;




More information about the llvm-commits mailing list