1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (C) 2019 Linaro Limited
4  */
5 
6 #include <string.h>
7 #include <string_ext.h>
8 
9 /*
10  * This method prevents dead store elimination, which could happen in case
11  * link-time optimization (LTO) is used.
12  * See "Dead Store Elimination (Still) Considered Harmful" [1] section 3.3.3.
13  *
14  * [1]
15  * http://www.usenix.org/system/files/conference/usenixsecurity17/sec17-yang.pdf
16  */
17 static volatile void * (*memset_func)(void *, int, size_t) =
18 	(volatile void * (*)(void *, int, size_t))&memset;
19 
memzero_explicit(void * s,size_t count)20 void memzero_explicit(void *s, size_t count)
21 {
22 	memset_func(s, 0, count);
23 }
24