diff --git a/arch/common/CMakeLists.txt b/arch/common/CMakeLists.txt index 38b71da460a..47c0ca0164a 100644 --- a/arch/common/CMakeLists.txt +++ b/arch/common/CMakeLists.txt @@ -33,3 +33,8 @@ zephyr_linker_sources_ifdef(CONFIG_NOCACHE_MEMORY RAM_SECTIONS nocache.ld ) + +# Only ARM, X86 and RISCV use TEXT_SECTION_OFFSET +if (DEFINED CONFIG_ARM OR DEFINED CONFIG_X86 OR DEFINED CONFIG_RISCV) + zephyr_linker_sources(TEXT_START SORT_KEY 0x0 text_section_offset.ld) +endif() diff --git a/arch/common/text_section_offset.ld b/arch/common/text_section_offset.ld new file mode 100644 index 00000000000..15e511eadad --- /dev/null +++ b/arch/common/text_section_offset.ld @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2019 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +. = CONFIG_TEXT_SECTION_OFFSET; +. = ALIGN(4); diff --git a/include/arch/arm/cortex_m/scripts/linker.ld b/include/arch/arm/cortex_m/scripts/linker.ld index 762870d0767..ae7baade4a9 100644 --- a/include/arch/arm/cortex_m/scripts/linker.ld +++ b/include/arch/arm/cortex_m/scripts/linker.ld @@ -138,8 +138,6 @@ SECTIONS SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) { - . = CONFIG_TEXT_SECTION_OFFSET; - /* Located in generated directory. This file is populated by the * zephyr_linker_sources() Cmake function. */ diff --git a/include/arch/arm/cortex_r/scripts/linker.ld b/include/arch/arm/cortex_r/scripts/linker.ld index d628e7ba27d..a4c683406fa 100644 --- a/include/arch/arm/cortex_r/scripts/linker.ld +++ b/include/arch/arm/cortex_r/scripts/linker.ld @@ -134,7 +134,6 @@ SECTIONS SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) { - . = CONFIG_TEXT_SECTION_OFFSET; /* Located in generated directory. This file is populated by the * zephyr_linker_sources() Cmake function. diff --git a/include/arch/x86/ia32/linker.ld b/include/arch/x86/ia32/linker.ld index 6306dd25111..cd78f3b6e19 100644 --- a/include/arch/x86/ia32/linker.ld +++ b/include/arch/x86/ia32/linker.ld @@ -85,7 +85,6 @@ SECTIONS _image_text_start = PHYS_LOAD_ADDR; SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) { - . = CONFIG_TEXT_SECTION_OFFSET; /* Located in generated directory. This file is populated by the * zephyr_linker_sources() Cmake function. diff --git a/soc/riscv/openisa_rv32m1/linker.ld b/soc/riscv/openisa_rv32m1/linker.ld index ff69f81f397..b6da378f81d 100644 --- a/soc/riscv/openisa_rv32m1/linker.ld +++ b/soc/riscv/openisa_rv32m1/linker.ld @@ -103,9 +103,6 @@ SECTIONS SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) { - . = CONFIG_TEXT_SECTION_OFFSET; - . = ALIGN(4); - /* * Respect for CONFIG_TEXT_SECTION_OFFSET is mandatory * for MCUboot support, so .reset.* and .exception.*