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 KEEP_PAGER sym 11 .pushsection __keep_meta_vars_pager 12 .global ____keep_pager_\sym 13 ____keep_pager_\sym: 14 .long \sym 15 .popsection 16 .endm 17 18 .macro KEEP_INIT sym 19 .pushsection __keep_meta_vars_init 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 __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 __KEEP_PAGER1(sym, file_id) __KEEP_PAGER2(sym, file_id) 36 #define KEEP_PAGER(sym) __KEEP_PAGER1(sym, __FILE_ID__) 37 38 #define __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 __KEEP_INIT1(sym, file_id) __KEEP_INIT2(sym, file_id) 44 #define KEEP_INIT(sym) __KEEP_INIT1(sym, __FILE_ID__) 45 46 #endif /* __ASSEMBLER__ */ 47 48 #endif /*KEEP_H*/ 49