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