Skip to content

Commit

Permalink
Object: ensure that structures are fully defined
Browse files Browse the repository at this point in the history
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270663 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
compnerd committed May 25, 2016
1 parent fbbe744 commit 9ccf7c7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/llvm/Object/COFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 9ccf7c7

Please sign in to comment.