1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2015, Linaro Limited 4 */ 5 #ifndef KEEP_H 6 #define KEEP_H 7 8 #ifdef __ASSEMBLER__ 9 10 .macro DECLARE_KEEP_PAGER sym 11 .pushsection __keep_meta_vars_pager, "a" 12 .global ____keep_pager_\sym 13 ____keep_pager_\sym: 14 .long \sym 15 .popsection 16 .endm 17 18 .macro DECLARE_KEEP_INIT sym 19 .pushsection __keep_meta_vars_init, "a" 20 .global ____keep_init_\sym 21 ____keep_init_\sym: 22 .long \sym 23 .popsection 24 .endm 25 26 #else 27 28 #include <compiler.h> 29 30 #define __DECLARE_KEEP_PAGER2(sym, file_id) \ 31 extern const unsigned long ____keep_pager_##sym; \ 32 const unsigned long ____keep_pager_##sym##_##file_id \ 33 __section("__keep_meta_vars_pager") = (unsigned long)&(sym) 34 35 #define __DECLARE_KEEP_PAGER1(sym, file_id) __DECLARE_KEEP_PAGER2(sym, file_id) 36 #define DECLARE_KEEP_PAGER(sym) __DECLARE_KEEP_PAGER1(sym, __FILE_ID__) 37 38 #define __DECLARE_KEEP_INIT2(sym, file_id) \ 39 extern const unsigned long ____keep_init_##sym##file_id; \ 40 const unsigned long ____keep_init_##sym##_##file_id \ 41 __section("__keep_meta_vars_init") = (unsigned long)&(sym) 42 43 #define __DECLARE_KEEP_INIT1(sym, file_id) __DECLARE_KEEP_INIT2(sym, file_id) 44 #define DECLARE_KEEP_INIT(sym) __DECLARE_KEEP_INIT1(sym, __FILE_ID__) 45 46 #endif /* __ASSEMBLER__ */ 47 48 #endif /*KEEP_H*/ 49