Add a build-time assert for sizeof(OBJECT)

Add a build assert that checks the sizeof the tpm2
OBJECT struct.  This check indicates that NV_FORMAT_VERSION
needs to be bumped, due to a change to tpm2 data structures.

BRANCH=none
BUG=none
TEST=build succeeds

Change-Id: Id6cddd7bec10ebf0aa78e2199826fb6e1ff4fd8c
Signed-off-by: nagendra modadugu <[email protected]>
Reviewed-on: https://chromium-review.googlesource.com/419120
Commit-Ready: Nagendra Modadugu <[email protected]>
Tested-by: Nagendra Modadugu <[email protected]>
Reviewed-by: Vadim Bendebury <[email protected]>
diff --git a/Global.h b/Global.h
index 057fa89..5b868ad 100644
--- a/Global.h
+++ b/Global.h
@@ -190,6 +190,12 @@
    TPM2B_NAME               name;                    // Name of the object name. Kept here
                                                      // to avoid repeatedly computing it.
 } OBJECT;
+#ifdef EMBEDDED_MODE
+// This build time assert serves as a rudimentary check for changes
+// to the OBJECT structure (which is serialized to NVmem).  Whenever
+// the OBJECT struct changes, NV_FORMAT_VERSION ought to be bumped.
+struct size_check { char a[sizeof(OBJECT) == 1536 ? 1 : -1]; };
+#endif
 //
 //
 //           HASH_OBJECT Structure