Zephyr API
4.4.99
A Scalable Open Source RTOS
Toggle main menu visibility
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
#include <stddef.h>
12
#include <
zephyr/toolchain.h
>
13
30
static
inline
bool
linker_is_in_rodata
(
const
void
*addr)
31
{
32
#if defined(CONFIG_ARM) || defined(CONFIG_ARC) || defined(CONFIG_X86) || \
33
defined(CONFIG_ARM64) || defined(CONFIG_RISCV) || defined(CONFIG_SPARC) || \
34
defined(CONFIG_MIPS) || defined(CONFIG_XTENSA) || defined(CONFIG_RX) || \
35
defined(CONFIG_OPENRISC)
36
extern
char
__rodata_region_start[];
37
extern
char
__rodata_region_end[];
38
39
if
(((
const
char
*)addr >= (
const
char
*)__rodata_region_start) &&
40
((
const
char
*)addr < (
const
char
*)__rodata_region_end)) {
41
return
true
;
42
}
43
44
/* Relocated rodata sections (CCM, SMEM) live outside the default
45
* __rodata_region. zephyr_code_relocate(... CCM_RODATA/SMEM_RODATA)
46
* brackets the actual strings with __<mem>_rodata_reloc_start/end
47
* (gen_relocate_app.py). The bare __<mem>_rodata_start/end markers
48
* are zero-sized and never span the strings, so they must NOT be used
49
* here. Weak symbols let builds without these sections skip the check.
50
*
51
* This is kept under the same arch guard as __rodata_region: on the
52
* native/POSIX targets the symbols never exist, and the native
53
* simulator's "objcopy --localize-symbol" link step strips the weak
54
* binding off the undefined references, turning them into hard
55
* undefined references that break the final link.
56
*/
57
extern
char
__weak __ccm_rodata_reloc_start[];
58
extern
char
__weak __ccm_rodata_reloc_end[];
59
60
if
(((
const
char
*)__ccm_rodata_reloc_start != NULL) &&
61
((
const
char
*)addr >= (
const
char
*)__ccm_rodata_reloc_start) &&
62
((
const
char
*)addr < (
const
char
*)__ccm_rodata_reloc_end)) {
63
return
true
;
64
}
65
66
extern
char
__weak __smem_rodata_reloc_start[];
67
extern
char
__weak __smem_rodata_reloc_end[];
68
69
if
(((
const
char
*)__smem_rodata_reloc_start != NULL) &&
70
((
const
char
*)addr >= (
const
char
*)__smem_rodata_reloc_start) &&
71
((
const
char
*)addr < (
const
char
*)__smem_rodata_reloc_end)) {
72
return
true
;
73
}
74
#endif
75
76
return
false
;
77
}
78
79
#endif
/* ZEPHYR_INCLUDE_LINKER_UTILS_H_ */
linker_is_in_rodata
static bool linker_is_in_rodata(const void *addr)
Check if address is in a read only section.
Definition
utils.h:30
stdbool.h
toolchain.h
Macros to abstract toolchain specific capabilities.
zephyr
linker
utils.h
Generated on
for Zephyr API by
1.17.0