diff --git a/CMakeLists.txt b/CMakeLists.txt index dfd1b4f75dae67..b4f19abb9c19fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1613,11 +1613,14 @@ endif() if(CONFIG_BUILD_OUTPUT_ADJUST_LMA) math(EXPR adjustment "${CONFIG_BUILD_OUTPUT_ADJUST_LMA}" OUTPUT_FORMAT DECIMAL) + set(args_adjustment ${CONFIG_BUILD_OUTPUT_ADJUST_LMA_SECTIONS}) + list(TRANSFORM args_adjustment PREPEND $) + list(TRANSFORM args_adjustment APPEND +${adjustment}) list(APPEND post_build_commands COMMAND $ $ - $${adjustment} + ${args_adjustment} $${KERNEL_ELF_NAME} $${KERNEL_ELF_NAME} ) diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 9897607fb3bf73..3b689ec97bdca4 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -822,6 +822,23 @@ config BUILD_OUTPUT_ADJUST_LMA default "$(dt_chosen_reg_addr_hex,$(DT_CHOSEN_IMAGE_M4))-\ $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH))" +config BUILD_OUTPUT_ADJUST_LMA_SECTIONS + def_string "*" + depends on BUILD_OUTPUT_ADJUST_LMA!="" + help + This determines the output sections to which the above LMA adjustment + will be applied. + The value can be the name of a section in the final ELF, like "text". + It can also be a pattern with wildcards, such as "*bss", which could + match more than one section name. Multiple such patterns can be given + as a ";"-separated list. It's possible to supply a 'negative' pattern + starting with "!", to exclude sections matched by a preceding pattern. + + By default, all sections will have their LMA adjusted. The following + example excludes one section produced by the code relocation feature: + config BUILD_OUTPUT_ADJUST_LMA_SECTIONS + default "*;!.extflash_text_reloc" + config BUILD_OUTPUT_INFO_HEADER bool "Create a image information header" help diff --git a/cmake/bintools/gnu/target_bintools.cmake b/cmake/bintools/gnu/target_bintools.cmake index f61860b31da555..0fa06ea7c32f00 100644 --- a/cmake/bintools/gnu/target_bintools.cmake +++ b/cmake/bintools/gnu/target_bintools.cmake @@ -44,7 +44,7 @@ set_property(TARGET bintools PROPERTY elfconvert_flag_section_remove "--remove-s set_property(TARGET bintools PROPERTY elfconvert_flag_section_only "--only-section=") set_property(TARGET bintools PROPERTY elfconvert_flag_section_rename "--rename-section;") -set_property(TARGET bintools PROPERTY elfconvert_flag_lma_adjust "--change-section-lma;*+") +set_property(TARGET bintools PROPERTY elfconvert_flag_lma_adjust "--change-section-lma;") # Note, placing a ';' at the end results in the following param to be a list, # and hence space separated.