1# SPDX-License-Identifier: Apache-2.0
2# The contents of this file is based on include/zephyr/linker/kobject-data.ld
3# Please keep in sync
4
5if(CONFIG_USERSPACE)
6
7  zephyr_linker_section(NAME kobject_data GROUP ${K_OBJECTS_GROUP} ALIGN_WITH_INPUT NOINPUT)
8
9  zephyr_linker_section_configure(
10    SECTION kobject_data
11    SYMBOLS z_kobject_data_begin
12    )
13
14  if(CONFIG_DYNAMIC_OBJECTS)
15    # generated by gperf, this avoids errors for the first build.
16    # Also, we dont have KOBJECT_DATA_SZ for the first build
17    zephyr_linker_section_configure(
18      SECTION kobject_data
19      SYMBOLS _thread_idx_map
20      MIN_SIZE ${CONFIG_MAX_THREAD_BYTES}
21      PASS NOT LINKER_ZEPHYR_PREBUILT LINKER_ZEPHYR_FINAL
22      )
23    zephyr_linker_section_configure(
24      SECTION kobject_data
25      SYMBOLS _kobject_data_area_start _kobject_data_area_end
26      PASS NOT LINKER_ZEPHYR_PREBUILT LINKER_ZEPHYR_FINAL
27      )
28  endif()
29
30  # During LINKER_KOBJECT_PREBUILT and LINKER_ZEPHYR_PREBUILT,
31  # space needs to be reserved for the rodata that will be
32  # produced by gperf during the final stages of linking.
33  # The alignment and size are produced by
34  # scripts/build/gen_kobject_placeholders.py. These are here
35  # so the addresses to kobjects would remain the same
36  # during the final stages of linking (LINKER_ZEPHYR_FINAL).
37  if(CONFIG_DYNAMIC_OBJECTS)
38    # in LINKER_ZEPHYR_PREBUILT there is no object file defining _thread_idx_map
39    # so we must have a synthetic one. Note that the size is not set here,
40    # since the space is provided in the section below:
41    zephyr_linker_section_configure(
42      SECTION kobject_data
43      SYMBOLS _thread_idx_map
44      PASS LINKER_ZEPHYR_PREBUILT
45      )
46  endif()
47
48  zephyr_linker_section_configure(
49    SECTION kobject_data
50    INPUT
51    ".kobject_data.data*"
52    ".kobject_data.sdata*"
53    PASS LINKER_ZEPHYR_PREBUILT LINKER_ZEPHYR_FINAL
54    ALIGN @KOBJECT_DATA_ALIGN,undef:4@
55    MIN_SIZE @KOBJECT_DATA_SZ@
56    MAX_SIZE @KOBJECT_DATA_SZ@
57    SYMBOLS _kobject_data_area_start _kobject_data_area_end
58    )
59endif()
60