Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_LINKER_UTILS_H_
8#define ZEPHYR_INCLUDE_LINKER_UTILS_H_
9
10#include <stdbool.h>
11
24static inline bool linker_is_in_rodata(const void *addr)
25{
26#if defined(CONFIG_LINKER_USE_PINNED_SECTION)
27 extern const char lnkr_pinned_rodata_start[];
28 extern const char lnkr_pinned_rodata_end[];
29
30 if (((const char *)addr >= (const char *)lnkr_pinned_rodata_start) &&
31 ((const char *)addr < (const char *)lnkr_pinned_rodata_end)) {
32 return true;
33 }
34#endif
35
36#if defined(CONFIG_ARM) || defined(CONFIG_ARC) || defined(CONFIG_X86) || \
37 defined(CONFIG_ARM64) || defined(CONFIG_NIOS2) || \
38 defined(CONFIG_RISCV) || defined(CONFIG_SPARC) || \
39 defined(CONFIG_MIPS) || defined(CONFIG_XTENSA)
40 extern char __rodata_region_start[];
41 extern char __rodata_region_end[];
42 #define RO_START __rodata_region_start
43 #define RO_END __rodata_region_end
44#else
45 #define RO_START 0
46 #define RO_END 0
47#endif
48
49 return (((const char *)addr >= (const char *)RO_START) &&
50 ((const char *)addr < (const char *)RO_END));
51
52 #undef RO_START
53 #undef RO_END
54}
55
56#endif /* ZEPHYR_INCLUDE_LINKER_UTILS_H_ */
#define RO_START
static bool linker_is_in_rodata(const void *addr)
Check if address is in read only section.
Definition: utils.h:24
#define RO_END