zephyr/cmake/linker_script/common/thread-local-storage.cmake
Torsten Rasmussen 38040292c3 cmake: linker: converter arm and common ld scripts into CMake code
Converted existing ld script templates into CMake files.

This commit takes the common-ram.ld, common-rom.ld, debug-sections.ld,
and thread-local-storage.ld and creates corresponding CMake files for
the linker script generator.

The CMake files uses the new Zephyr CMake functions:
- zephyr_linker_section()
- zephyr_linker_section_configure()
- zephyr_linker_section_obj_level()

to generate the same linker result as the existing C preprocessor based
scheme.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00

40 lines
1.3 KiB
CMake

# originates from thread-local-storage.ld
if(CONFIG_THREAD_LOCAL_STORAGE)
zephyr_linker_section(NAME .tdata LMA FLASH NOINPUT)
zephyr_linker_section_configure(SECTION .tdata INPUT ".gnu.linkonce.td.*")
# GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
zephyr_linker_section(NAME .tbss LMA FLASH NOINPUT)
zephyr_linker_section_configure(SECTION .tbss INPUT ".gnu.linkonce.tb.*")
zephyr_linker_section_configure(SECTION .tbss INPUT ".tcommon")
# GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#
# These needs to be outside of the tdata/tbss
# sections or else they would be considered
# thread-local variables, and the code would use
# the wrong values.
#
# This scheme is not yet handled
if(CONFIG_XIP)
# /* The "master copy" of tdata should be only in flash on XIP systems */
# PROVIDE(__tdata_start = LOADADDR(tdata));
else()
# PROVIDE(__tdata_start = ADDR(tdata));
endif()
# PROVIDE(__tdata_size = SIZEOF(tdata));
# PROVIDE(__tdata_end = __tdata_start + __tdata_size);
# PROVIDE(__tdata_align = ALIGNOF(tdata));
#
# PROVIDE(__tbss_start = ADDR(tbss));
# PROVIDE(__tbss_size = SIZEOF(tbss));
# PROVIDE(__tbss_end = __tbss_start + __tbss_size);
# PROVIDE(__tbss_align = ALIGNOF(tbss));
#
# PROVIDE(__tls_start = __tdata_start);
# PROVIDE(__tls_end = __tbss_end);
# PROVIDE(__tls_size = __tbss_end - __tdata_start);
endif()