1/*
2 * Copyright (c) 2017,2021 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifdef CONFIG_USERSPACE
8
9	z_kobject_data_begin = .;
10	SECTION_DATA_PROLOGUE(kobject_data,,)
11	{
12
13#if !defined(LINKER_ZEPHYR_PREBUILT) && \
14    !defined(LINKER_ZEPHYR_FINAL)
15
16#ifdef CONFIG_DYNAMIC_OBJECTS
17	PROVIDE(_thread_idx_map = .);
18	. = . + CONFIG_MAX_THREAD_BYTES;
19#endif
20
21#endif /* !LINKER_ZEPHYR_PREBUILT && !LINKER_ZEPHYR_FINAL */
22
23	/* During LINKER_KOBJECT_PREBUILT and LINKER_ZEPHYR_PREBUILT,
24	 * space needs to be reserved for the rodata that will be
25	 * produced by gperf during the final stages of linking.
26	 * The alignment and size are produced by
27	 * scripts/build/gen_kobject_placeholders.py. These are here
28	 * so the addresses to kobjects would remain the same
29	 * during the final stages of linking (LINKER_ZEPHYR_FINAL).
30	 */
31
32#if defined(LINKER_ZEPHYR_PREBUILT)
33#include <zephyr/linker-kobject-prebuilt-data.h>
34
35#ifdef CONFIG_DYNAMIC_OBJECTS
36	/* This is produced by gperf. Put a place holder here
37	 * to avoid compilation error.
38	 */
39	PROVIDE(_thread_idx_map = .);
40#endif
41#ifdef KOBJECT_DATA_ALIGN
42	. = ALIGN(KOBJECT_DATA_ALIGN);
43	. = . + KOBJECT_DATA_SZ;
44#endif
45#endif /* LINKER_ZEPHYR_PREBUILT */
46
47#if defined(LINKER_ZEPHYR_FINAL)
48#include <zephyr/linker-kobject-prebuilt-data.h>
49#ifdef KOBJECT_DATA_ALIGN
50	. = ALIGN(KOBJECT_DATA_ALIGN);
51
52	_kobject_data_area_start = .;
53#endif
54
55	*(".kobject_data.data*")
56	*(".kobject_data.sdata*")
57
58#ifdef KOBJECT_DATA_ALIGN
59	_kobject_data_area_end = .;
60	_kobject_data_area_used = _kobject_data_area_end - _kobject_data_area_start;
61
62	ASSERT(_kobject_data_area_used <= KOBJECT_DATA_SZ,
63"scripts/build/gen_kobject_placeholders.py did not reserve enough space \
64for kobject data."
65	);
66
67	/* Padding is needed to preserve kobject addresses
68	 * if we have reserved more space than needed.
69	 */
70	. = MAX(., _kobject_data_area_start + KOBJECT_DATA_SZ);
71#endif /* KOBJECT_DATA_ALIGN */
72#endif /* LINKER_ZEPHYR_FINAL */
73
74        } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
75
76#endif /* CONFIG_USERSPACE */
77