1 /* 2 * Copyright (c) 2015, Linaro Limited 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * POSSIBILITY OF SUCH DAMAGE. 26 */ 27 #ifndef KEEP_H 28 #define KEEP_H 29 30 /* 31 * A bug in the Aarch64 linker sometimes triggers an assert when linking. 32 * These macros are only needed when the pager is active so stub them when 33 * not needed. 34 */ 35 36 #ifdef ASM 37 38 #ifdef CFG_WITH_PAGER 39 40 .macro KEEP_PAGER sym 41 .pushsection __keep_meta_vars_pager 42 ___keep_pager_\sym: 43 .long \sym 44 .popsection 45 .endm 46 47 .macro KEEP_INIT sym 48 .pushsection __keep_meta_vars_init 49 ___keep_init_\sym: 50 .long \sym 51 .popsection 52 .endm 53 54 #else /* CFG_WITH_PAGER */ 55 56 .macro KEEP_PAGER sym 57 .endm 58 59 .macro KEEP_INIT sym 60 .endm 61 62 #endif /* CFG_WITH_PAGER */ 63 64 #else 65 66 #include <compiler.h> 67 68 #ifdef CFG_WITH_PAGER 69 70 #define KEEP_PAGER(sym) \ 71 const unsigned long ____keep_pager_##sym \ 72 __section("__keep_meta_vars_pager") = (unsigned long)&sym 73 74 #define KEEP_INIT(sym) \ 75 const unsigned long ____keep_init_##sym \ 76 __section("__keep_meta_vars_init") = (unsigned long)&sym 77 78 #else /* CFG_WITH_PAGER */ 79 80 #define KEEP_PAGER(sym) \ 81 extern const unsigned long ____keep_pager_##sym 82 83 #define KEEP_INIT(sym) \ 84 extern const unsigned long ____keep_init_##sym 85 86 #endif /* CFG_WITH_PAGER */ 87 88 #endif /* ASM */ 89 90 #endif /*KEEP_H*/ 91