diff --git a/CMakeLists.txt b/CMakeLists.txt index 76d8466b8df0f..380701e106699 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1524,11 +1524,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 c384c8053f9fb..296ea4ebf4725 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -704,6 +704,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 8aac55b0400cd..54ed061e13931 100644 --- a/cmake/bintools/gnu/target_bintools.cmake +++ b/cmake/bintools/gnu/target_bintools.cmake @@ -41,7 +41,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.