summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Sukhomlinov <sukhomlinov@google.com>2021-10-07 12:14:42 -0700
committerCommit Bot <commit-bot@chromium.org>2021-10-07 22:01:53 +0000
commit713045974620ec3f3757fa37865edf9b25da8cc3 (patch)
tree3f022bcc2250c94680eb317222ea540eadb4bf24
parentee54c8a9c82746dbe3f1def393ddd1ba0f3a124a (diff)
downloadchrome-ec-713045974620ec3f3757fa37865edf9b25da8cc3.tar.gz
cr50: fix fuzzing
make runfuzztests started to fail once both: https://crrev.com/c/3162473 and https://crrev.com/c/3208916 landed. Clang seems to incorrectly discarding sections it generated for profiling, resulting in: __profc_DCRYPTO_hw_sha256_init' referenced in section .text.compute_hash[compute_hash]' of build/host/cr50_fuzz/libec.a(libec.a.2.o): defined in discarded section `__llvm_prf_cnts[__profd_DCRYPTO_hw_sha256_init]' of build/host/cr50_fuzz/libec.a(libec.a.2.o) __profc_DCRYPTO_hw_sha256_init' referenced in section .text.create_merkle_tree[create_merkle_tree]' of build/host/cr50_fuzz/libec.a(libec.a.2.o): defined in discarded section `__llvm_prf_cnts[__profd_DCRYPTO_hw_sha256_init]' of build/host/cr50_fuzz/libec.a(libec.a.2.o) clang-13: error: linker command failed with exit code 1 (use -v to see invocation) This definition of __always_inline should be useful in other cases, so moving it into common.h. Note, we have to #undef it first, as it is previously defined in system headers. BUG=none TEST=make buildall -j Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: I073b38a68fd43a14dbe92063011c95758030b225 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3213113 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org>
-rw-r--r--board/cr50/dcrypto/dcrypto.h8
-rw-r--r--include/common.h17
2 files changed, 17 insertions, 8 deletions
diff --git a/board/cr50/dcrypto/dcrypto.h b/board/cr50/dcrypto/dcrypto.h
index 561a1df7a9..3712f56fc4 100644
--- a/board/cr50/dcrypto/dcrypto.h
+++ b/board/cr50/dcrypto/dcrypto.h
@@ -46,14 +46,6 @@ enum hashing_mode {
HASH_NULL = 0x0010 /* = TPM_ALG_NULL, Only supported for PKCS#1 */
};
-#ifndef __warn_unused_result
-#define __warn_unused_result __attribute__((warn_unused_result))
-#endif
-
-#ifndef __always_inline
-#define __always_inline __inline __attribute__((always_inline))
-#endif
-
/**
* SHA1/SHA2, HMAC API
*/
diff --git a/include/common.h b/include/common.h
index 485cbcbe5c..2bbc24d684 100644
--- a/include/common.h
+++ b/include/common.h
@@ -130,6 +130,23 @@
#endif
#endif
+#ifndef __warn_unused_result
+#define __warn_unused_result __attribute__((warn_unused_result))
+#endif
+
+#ifdef TEST_CR50_FUZZ
+/**
+ * Workaround: Clang incorrectly handles profiling information
+ * used for fuzzing with __attribute__((always_inline)).
+ */
+#undef __always_inline
+#define __always_inline static inline
+#else
+#ifndef __always_inline
+#define __always_inline __inline __attribute__((always_inline))
+#endif
+#endif
+
/*
* Macros for combining bytes into larger integers. _LE and _BE signify little
* and big endian versions respectively.