xref: /optee_os/core/include/keep.h (revision b5ca97ccedd43fb82b7130f6ba473c0288b40c53)
19fa130bfSJens Wiklander /*
29fa130bfSJens Wiklander  * Copyright (c) 2015, Linaro Limited
39fa130bfSJens Wiklander  * All rights reserved.
49fa130bfSJens Wiklander  *
59fa130bfSJens Wiklander  * Redistribution and use in source and binary forms, with or without
69fa130bfSJens Wiklander  * modification, are permitted provided that the following conditions are met:
79fa130bfSJens Wiklander  *
89fa130bfSJens Wiklander  * 1. Redistributions of source code must retain the above copyright notice,
99fa130bfSJens Wiklander  * this list of conditions and the following disclaimer.
109fa130bfSJens Wiklander  *
119fa130bfSJens Wiklander  * 2. Redistributions in binary form must reproduce the above copyright notice,
129fa130bfSJens Wiklander  * this list of conditions and the following disclaimer in the documentation
139fa130bfSJens Wiklander  * and/or other materials provided with the distribution.
149fa130bfSJens Wiklander  *
159fa130bfSJens Wiklander  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
169fa130bfSJens Wiklander  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
179fa130bfSJens Wiklander  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
189fa130bfSJens Wiklander  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
199fa130bfSJens Wiklander  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
209fa130bfSJens Wiklander  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
219fa130bfSJens Wiklander  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
229fa130bfSJens Wiklander  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
239fa130bfSJens Wiklander  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
249fa130bfSJens Wiklander  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
259fa130bfSJens Wiklander  * POSSIBILITY OF SUCH DAMAGE.
269fa130bfSJens Wiklander  */
279fa130bfSJens Wiklander #ifndef KEEP_H
289fa130bfSJens Wiklander #define KEEP_H
299fa130bfSJens Wiklander 
30d6e86abcSJerome Forissier #ifdef ASM
31d6e86abcSJerome Forissier 
32d6e86abcSJerome Forissier 	.macro KEEP_PAGER sym
33d6e86abcSJerome Forissier 	.pushsection __keep_meta_vars_pager
34*b5ca97ccSJens Wiklander 	.global ____keep_pager_\sym
35*b5ca97ccSJens Wiklander 	____keep_pager_\sym:
36d6e86abcSJerome Forissier 	.long	\sym
37d6e86abcSJerome Forissier 	.popsection
38d6e86abcSJerome Forissier 	.endm
39d6e86abcSJerome Forissier 
40d6e86abcSJerome Forissier 	.macro KEEP_INIT sym
41d6e86abcSJerome Forissier 	.pushsection __keep_meta_vars_init
42*b5ca97ccSJens Wiklander 	.global ____keep_init_\sym
43*b5ca97ccSJens Wiklander 	____keep_init_\sym:
44d6e86abcSJerome Forissier 	.long	\sym
45d6e86abcSJerome Forissier 	.popsection
46d6e86abcSJerome Forissier 	.endm
47d6e86abcSJerome Forissier 
48d6e86abcSJerome Forissier #else
49d6e86abcSJerome Forissier 
509fa130bfSJens Wiklander #include <compiler.h>
519fa130bfSJens Wiklander 
529fa130bfSJens Wiklander #define KEEP_PAGER(sym) \
539fa130bfSJens Wiklander 	const unsigned long ____keep_pager_##sym  \
549fa130bfSJens Wiklander 		__section("__keep_meta_vars_pager") = (unsigned long)&sym
559fa130bfSJens Wiklander 
569fa130bfSJens Wiklander #define KEEP_INIT(sym) \
579fa130bfSJens Wiklander 	const unsigned long ____keep_init_##sym  \
589fa130bfSJens Wiklander 		__section("__keep_meta_vars_init") = (unsigned long)&sym
599fa130bfSJens Wiklander 
60d6e86abcSJerome Forissier #endif /* ASM */
61d6e86abcSJerome Forissier 
629fa130bfSJens Wiklander #endif /*KEEP_H*/
63