kconfig: cmake: CMake linker script generator symbol added
A "Linker script" choice group has been added to the linker options menu. The existing HAVE_CUSTOM_LINKER_SCRIPT config has been relocated inside the linker script menu. Two new entries has been created: - LD template, for using the old ld template files together with the C pre-processor to create the final linker script. - CMake linker generator, used for ARMClang / armlink toolchain. The CMake linker generator is also supported for LD linker scripts for the ARM architecture. In CMake, the file cmake/linker/ld/target.cmake has been updated to support the CMake LD linker generator. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
e9e47a45dd
commit
761eada9d3
2 changed files with 95 additions and 44 deletions
|
@ -132,8 +132,36 @@ config ROM_START_OFFSET
|
||||||
alignment requirements on most ARM targets, although some targets
|
alignment requirements on most ARM targets, although some targets
|
||||||
may require smaller or larger values.
|
may require smaller or larger values.
|
||||||
|
|
||||||
|
config LD_LINKER_SCRIPT_SUPPORTED
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
|
choice LINKER_SCRIPT
|
||||||
|
prompt "Linker script"
|
||||||
|
default LD_LINKER_TEMPLATE if LD_LINKER_SCRIPT_SUPPORTED
|
||||||
|
|
||||||
|
config LD_LINKER_TEMPLATE
|
||||||
|
bool "LD template"
|
||||||
|
depends on LD_LINKER_SCRIPT_SUPPORTED
|
||||||
|
help
|
||||||
|
Select this option to use the LD linker script templates.
|
||||||
|
The templates are pre-processed by the C pre-processor to create the
|
||||||
|
final LD linker script.
|
||||||
|
|
||||||
|
config CMAKE_LINKER_GENERATOR
|
||||||
|
bool "CMake generator"
|
||||||
|
depends on ARM
|
||||||
|
help
|
||||||
|
Select this option to use the Zephyr CMake linker script generator.
|
||||||
|
The linker configuration is written in CMake and the final linker
|
||||||
|
script will be generated by the toolchain specific linker generator.
|
||||||
|
For LD based linkers, this will be the ld generator, for ARMClang /
|
||||||
|
armlink based linkers it will be the scatter generator.
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
config HAVE_CUSTOM_LINKER_SCRIPT
|
config HAVE_CUSTOM_LINKER_SCRIPT
|
||||||
bool "Custom linker scripts provided"
|
bool "Custom linker script provided"
|
||||||
help
|
help
|
||||||
Set this option if you have a custom linker script which needed to
|
Set this option if you have a custom linker script which needed to
|
||||||
be define in CUSTOM_LINKER_SCRIPT.
|
be define in CUSTOM_LINKER_SCRIPT.
|
||||||
|
|
|
@ -31,6 +31,28 @@ endif()
|
||||||
macro(configure_linker_script linker_script_gen linker_pass_define)
|
macro(configure_linker_script linker_script_gen linker_pass_define)
|
||||||
set(extra_dependencies ${ARGN})
|
set(extra_dependencies ${ARGN})
|
||||||
|
|
||||||
|
if(CONFIG_CMAKE_LINKER_GENERATOR)
|
||||||
|
if("${linker_pass_define}" STREQUAL "-DLINKER_ZEPHYR_PREBUILT")
|
||||||
|
set(PASS 1)
|
||||||
|
elseif("${linker_pass_define}" STREQUAL "-DLINKER_ZEPHYR_FINAL;-DLINKER_PASS2")
|
||||||
|
set(PASS 2)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${linker_script_gen}
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
-DPASS=${PASS}
|
||||||
|
-DFORMAT="$<TARGET_PROPERTY:linker,FORMAT>"
|
||||||
|
-DENTRY="$<TARGET_PROPERTY:linker,ENTRY>"
|
||||||
|
-DMEMORY_REGIONS="$<TARGET_PROPERTY:linker,MEMORY_REGIONS>"
|
||||||
|
-DGROUPS="$<TARGET_PROPERTY:linker,GROUPS>"
|
||||||
|
-DSECTIONS="$<TARGET_PROPERTY:linker,SECTIONS>"
|
||||||
|
-DSECTION_SETTINGS="$<TARGET_PROPERTY:linker,SECTION_SETTINGS>"
|
||||||
|
-DSYMBOLS="$<TARGET_PROPERTY:linker,SYMBOLS>"
|
||||||
|
-DOUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/${linker_script_gen}
|
||||||
|
-P ${ZEPHYR_BASE}/cmake/linker/ld/ld_script.cmake
|
||||||
|
)
|
||||||
|
else()
|
||||||
# Different generators deal with depfiles differently.
|
# Different generators deal with depfiles differently.
|
||||||
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
|
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
|
||||||
# Note that the IMPLICIT_DEPENDS option is currently supported only
|
# Note that the IMPLICIT_DEPENDS option is currently supported only
|
||||||
|
@ -76,6 +98,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define)
|
||||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
COMMAND_EXPAND_LISTS
|
COMMAND_EXPAND_LISTS
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Force symbols to be entered in the output file as undefined symbols
|
# Force symbols to be entered in the output file as undefined symbols
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue