cmake: linker generator replace % with @ for symbol referencing
Fixes: #41435 The use of %<symbol>% works well in Linux and MacOS but when passed to the linker script generator in Windows the %<symbol>% is processed by the windows shell causing the value to disappear and thus an empty value inside the generated ld linker script or scatter file. This is fixed by using the @ character instead of the % character. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
3d217b6bf6
commit
a03e7df9f5
|
@ -3859,13 +3859,13 @@ endfunction()
|
|||
# EXPR <expr> : Expression that defines the symbol. Due to linker limitations
|
||||
# all expressions should only contain simple math, such as
|
||||
# `+, -, *` and similar. The expression will go directly into the
|
||||
# linker, and all `%<symbol>%` will be replaced with the referred
|
||||
# linker, and all `@<symbol>@` will be replaced with the referred
|
||||
# symbol.
|
||||
#
|
||||
# Example:
|
||||
# To create a new symbol `bar` pointing to the start VMA address of section
|
||||
# `foo` + 1024, one can write:
|
||||
# zephyr_linker_symbol(SYMBOL bar EXPR "(%foo% + 1024)")
|
||||
# zephyr_linker_symbol(SYMBOL bar EXPR "(@foo@ + 1024)")
|
||||
#
|
||||
function(zephyr_linker_symbol)
|
||||
set(single_args "EXPR;SYMBOL")
|
||||
|
|
|
@ -394,12 +394,12 @@ function(symbol_to_string)
|
|||
get_property(subalign GLOBAL PROPERTY ${STRING_SYMBOL}_SUBALIGN)
|
||||
|
||||
string(REPLACE "\\" "" expr "${expr}")
|
||||
string(REGEX MATCHALL "%([^%]*)%" match_res ${expr})
|
||||
string(REGEX MATCHALL "@([^@]*)@" match_res ${expr})
|
||||
|
||||
foreach(match ${match_res})
|
||||
string(REPLACE "%" "" match ${match})
|
||||
string(REPLACE "@" "" match ${match})
|
||||
get_property(symbol_val GLOBAL PROPERTY SYMBOL_TABLE_${match})
|
||||
string(REPLACE "%${match}%" "ImageBase(${symbol_val})" expr ${expr})
|
||||
string(REPLACE "@${match}@" "ImageBase(${symbol_val})" expr ${expr})
|
||||
endforeach()
|
||||
|
||||
if(DEFINED subalign)
|
||||
|
|
|
@ -74,11 +74,11 @@ function(symbol_to_string)
|
|||
get_property(subalign GLOBAL PROPERTY ${STRING_SYMBOL}_SUBALIGN)
|
||||
|
||||
string(REPLACE "\\" "" expr "${expr}")
|
||||
string(REGEX MATCHALL "%([^%]*)%" match_res ${expr})
|
||||
string(REGEX MATCHALL "@([^@]*)@" match_res ${expr})
|
||||
|
||||
foreach(match ${match_res})
|
||||
string(REPLACE "%" "" match ${match})
|
||||
string(REPLACE "%${match}%" "${match}" expr ${expr})
|
||||
string(REPLACE "@" "" match ${match})
|
||||
string(REPLACE "@${match}@" "${match}" expr ${expr})
|
||||
endforeach()
|
||||
|
||||
set(${STRING_STRING} "${${STRING_STRING}}\n${symbol} = ${expr};\n" PARENT_SCOPE)
|
||||
|
|
|
@ -144,9 +144,9 @@ if(NOT CONFIG_USERSPACE)
|
|||
zephyr_linker_section_configure(SECTION .noinit INPUT ".kernel_noinit.*")
|
||||
endif()
|
||||
|
||||
zephyr_linker_symbol(SYMBOL __kernel_ram_start EXPR "(%__bss_start%)")
|
||||
zephyr_linker_symbol(SYMBOL __kernel_ram_start EXPR "(@__bss_start@)")
|
||||
zephyr_linker_symbol(SYMBOL __kernel_ram_end EXPR "(${RAM_ADDR} + ${RAM_SIZE})")
|
||||
zephyr_linker_symbol(SYMBOL __kernel_ram_size EXPR "(%__kernel_ram_end% - %__bss_start%)")
|
||||
zephyr_linker_symbol(SYMBOL __kernel_ram_size EXPR "(@__kernel_ram_end@ - @__bss_start@)")
|
||||
zephyr_linker_symbol(SYMBOL _image_ram_start EXPR "(${RAM_ADDR})" SUBALIGN 32) # ToDo calculate 32 correctly
|
||||
zephyr_linker_symbol(SYMBOL ARM_LIB_STACKHEAP EXPR "(${RAM_ADDR} + ${RAM_SIZE})" SIZE -0x1000)
|
||||
|
||||
|
|
Loading…
Reference in a new issue