From 05f0d85b6a93ff1471e2fd9133a940a50cc11666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20R=C3=B8nningstad?= Date: Fri, 17 Jan 2020 14:36:19 +0100 Subject: [PATCH] extensions.cmake: Replace TEXT_START with ROM_START MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In zephyr_linker_sources(). This is done since the point of the location is to place things at given offsets. This can only be done consistenly if the linker code is placed into the _first_ section. All uses of TEXT_START are replaced with ROM_START. ROM_START is only supported in some arches, as some arches have several custom sections before text. These don't currently have ROM_START or TEXT_START available, but that could be added with a bit of refactoring in their linker script. No SORT_KEYs are changed. This also fixes an error introduced when TEXT_START was added, where TEXT_SECTION_OFFSET was applied to riscv's common linker.ld instead of to openisa_rv32m1's specific linker.ld. Signed-off-by: Øyvind Rønningstad --- arch/arc/core/CMakeLists.txt | 2 +- arch/arm/core/aarch32/CMakeLists.txt | 2 +- arch/arm/core/aarch32/cortex_m/CMakeLists.txt | 2 +- arch/common/CMakeLists.txt | 7 ++++--- cmake/extensions.cmake | 15 ++++++++------- include/arch/arc/v2/linker.ld | 7 ++++--- .../arch/arm/aarch32/cortex_m/scripts/linker.ld | 7 ++++--- .../arch/arm/aarch32/cortex_r/scripts/linker.ld | 7 ++++--- include/arch/nios2/linker.ld | 5 ----- include/arch/riscv/common/linker.ld | 5 ----- include/arch/x86/ia32/linker.ld | 7 ++++--- soc/arm/nxp_imx/rt/CMakeLists.txt | 2 +- soc/arm/nxp_kinetis/CMakeLists.txt | 2 +- soc/arm/ti_simplelink/cc32xx/CMakeLists.txt | 2 +- soc/riscv/openisa_rv32m1/CMakeLists.txt | 2 +- soc/riscv/openisa_rv32m1/linker.ld | 7 ++++--- 16 files changed, 39 insertions(+), 42 deletions(-) diff --git a/arch/arc/core/CMakeLists.txt b/arch/arc/core/CMakeLists.txt index 98d22f402a5..73d8c709d1a 100644 --- a/arch/arc/core/CMakeLists.txt +++ b/arch/arc/core/CMakeLists.txt @@ -31,4 +31,4 @@ zephyr_library_sources_ifdef(CONFIG_ARC_CONNECT arc_smp.c) add_subdirectory_ifdef(CONFIG_ARC_CORE_MPU mpu) add_subdirectory_ifdef(CONFIG_ARC_SECURE_FIRMWARE secureshield) -zephyr_linker_sources(TEXT_START SORT_KEY 0x0vectors vector_table.ld) +zephyr_linker_sources(ROM_START SORT_KEY 0x0vectors vector_table.ld) diff --git a/arch/arm/core/aarch32/CMakeLists.txt b/arch/arm/core/aarch32/CMakeLists.txt index 4adaf5528f5..0e17c1112ef 100644 --- a/arch/arm/core/aarch32/CMakeLists.txt +++ b/arch/arm/core/aarch32/CMakeLists.txt @@ -34,4 +34,4 @@ add_subdirectory_ifdef(CONFIG_ARM_NONSECURE_FIRMWARE cortex_m/tz) add_subdirectory_ifdef(CONFIG_CPU_CORTEX_R cortex_r) -zephyr_linker_sources(TEXT_START SORT_KEY 0x0vectors vector_table.ld) +zephyr_linker_sources(ROM_START SORT_KEY 0x0vectors vector_table.ld) diff --git a/arch/arm/core/aarch32/cortex_m/CMakeLists.txt b/arch/arm/core/aarch32/cortex_m/CMakeLists.txt index 886e15b696c..b2fe6b09cf9 100644 --- a/arch/arm/core/aarch32/cortex_m/CMakeLists.txt +++ b/arch/arm/core/aarch32/cortex_m/CMakeLists.txt @@ -12,7 +12,7 @@ zephyr_library_sources( ) zephyr_linker_sources_ifdef(CONFIG_SW_VECTOR_RELAY - TEXT_START + ROM_START SORT_KEY 0x0relay_vectors relay_vector_table.ld ) diff --git a/arch/common/CMakeLists.txt b/arch/common/CMakeLists.txt index 47c0ca0164a..d5cbe559557 100644 --- a/arch/common/CMakeLists.txt +++ b/arch/common/CMakeLists.txt @@ -34,7 +34,8 @@ zephyr_linker_sources_ifdef(CONFIG_NOCACHE_MEMORY 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) +# Only ARM, X86 and OPENISA_RV32M1_RISCV32 use TEXT_SECTION_OFFSET. +if (DEFINED CONFIG_ARM OR DEFINED CONFIG_X86 + OR DEFINED CONFIG_SOC_OPENISA_RV32M1_RISCV32) + zephyr_linker_sources(ROM_START SORT_KEY 0x0 text_section_offset.ld) endif() diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake index 45b09851788..b0b05fe1026 100644 --- a/cmake/extensions.cmake +++ b/cmake/extensions.cmake @@ -873,8 +873,9 @@ endfunction(zephyr_check_compiler_flag_hardcoded) # NOINIT Inside the noinit output section. # RWDATA Inside the data output section. # RODATA Inside the rodata output section. -# TEXT_START At the beginning of the text section, i.e. the beginning of -# the image. +# ROM_START Inside the first output section of the image. This option is +# currently only available on ARM Cortex-M, ARM Cortex-R, +# x86, ARC, and openisa_rv32m1. # RAM_SECTIONS Inside the RAMABLE_REGION GROUP. # SECTIONS Near the end of the file. Don't use this when linking into # RAMABLE_REGION, use RAM_SECTIONS instead. @@ -884,7 +885,7 @@ endfunction(zephyr_check_compiler_flag_hardcoded) # # Use NOINIT, RWDATA, and RODATA unless they don't work for your use case. # -# When placing into NOINIT, RWDATA, RODATA, or TEXT_START the contents of the files +# When placing into NOINIT, RWDATA, RODATA, ROM_START, the contents of the files # will be placed inside an output section, so assume the section definition is # already present, e.g.: # _mysection_start = .; @@ -914,7 +915,7 @@ function(zephyr_linker_sources location) set(snippet_base "${__build_dir}/include/generated") set(sections_path "${snippet_base}/snippets-sections.ld") set(ram_sections_path "${snippet_base}/snippets-ram-sections.ld") - set(text_start_path "${snippet_base}/snippets-text-start.ld") + set(rom_start_path "${snippet_base}/snippets-rom-start.ld") set(noinit_path "${snippet_base}/snippets-noinit.ld") set(rwdata_path "${snippet_base}/snippets-rwdata.ld") set(rodata_path "${snippet_base}/snippets-rodata.ld") @@ -924,7 +925,7 @@ function(zephyr_linker_sources location) if (NOT DEFINED cleared) file(WRITE ${sections_path} "") file(WRITE ${ram_sections_path} "") - file(WRITE ${text_start_path} "") + file(WRITE ${rom_start_path} "") file(WRITE ${noinit_path} "") file(WRITE ${rwdata_path} "") file(WRITE ${rodata_path} "") @@ -936,8 +937,8 @@ function(zephyr_linker_sources location) set(snippet_path "${sections_path}") elseif("${location}" STREQUAL "RAM_SECTIONS") set(snippet_path "${ram_sections_path}") - elseif("${location}" STREQUAL "TEXT_START") - set(snippet_path "${text_start_path}") + elseif("${location}" STREQUAL "ROM_START") + set(snippet_path "${rom_start_path}") elseif("${location}" STREQUAL "NOINIT") set(snippet_path "${noinit_path}") elseif("${location}" STREQUAL "RWDATA") diff --git a/include/arch/arc/v2/linker.ld b/include/arch/arc/v2/linker.ld index 55e9703bd79..4d6c4be3208 100644 --- a/include/arch/arc/v2/linker.ld +++ b/include/arch/arc/v2/linker.ld @@ -87,10 +87,11 @@ SECTIONS { _image_rom_start = .; _image_text_start = .; -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. +/* Located in generated directory. This file is populated by calling + * zephyr_linker_sources(ROM_START ...). This typically contains the vector + * table and debug information. */ -#include +#include *(.text) *(".text.*") diff --git a/include/arch/arm/aarch32/cortex_m/scripts/linker.ld b/include/arch/arm/aarch32/cortex_m/scripts/linker.ld index 62c6709463f..0e6e5bb97f6 100644 --- a/include/arch/arm/aarch32/cortex_m/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_m/scripts/linker.ld @@ -138,10 +138,11 @@ SECTIONS SECTION_PROLOGUE(rom_start,,) { -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. +/* Located in generated directory. This file is populated by calling + * zephyr_linker_sources(ROM_START ...). This typically contains the vector + * table and debug information. */ -#include +#include } GROUP_LINK_IN(ROMABLE_REGION) diff --git a/include/arch/arm/aarch32/cortex_r/scripts/linker.ld b/include/arch/arm/aarch32/cortex_r/scripts/linker.ld index 8b7bf477db0..408968167d2 100644 --- a/include/arch/arm/aarch32/cortex_r/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_r/scripts/linker.ld @@ -135,10 +135,11 @@ SECTIONS SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) { -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. +/* Located in generated directory. This file is populated by calling + * zephyr_linker_sources(ROM_START ...). This typically contains the vector + * table and debug information. */ -#include +#include } GROUP_LINK_IN(ROMABLE_REGION) diff --git a/include/arch/nios2/linker.ld b/include/arch/nios2/linker.ld index e3eeb7920b2..a949cc24fed 100644 --- a/include/arch/nios2/linker.ld +++ b/include/arch/nios2/linker.ld @@ -121,11 +121,6 @@ SECTIONS _image_text_start = .; -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ -#include - *(.text) *(".text.*") *(.gnu.linkonce.t.*) diff --git a/include/arch/riscv/common/linker.ld b/include/arch/riscv/common/linker.ld index 445357b7b58..d324bfc9bde 100644 --- a/include/arch/riscv/common/linker.ld +++ b/include/arch/riscv/common/linker.ld @@ -89,11 +89,6 @@ SECTIONS _image_text_start = .; -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. - */ -#include - *(.text) *(".text.*") *(.gnu.linkonce.t.*) diff --git a/include/arch/x86/ia32/linker.ld b/include/arch/x86/ia32/linker.ld index cd78f3b6e19..d4bdd2ffcd0 100644 --- a/include/arch/x86/ia32/linker.ld +++ b/include/arch/x86/ia32/linker.ld @@ -86,10 +86,11 @@ SECTIONS SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) { -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. +/* Located in generated directory. This file is populated by calling + * zephyr_linker_sources(ROM_START ...). This typically contains the vector + * table and debug information. */ -#include +#include *(.text_start) *(".text_start.*") diff --git a/soc/arm/nxp_imx/rt/CMakeLists.txt b/soc/arm/nxp_imx/rt/CMakeLists.txt index b709c3a72f8..11bc22d7341 100644 --- a/soc/arm/nxp_imx/rt/CMakeLists.txt +++ b/soc/arm/nxp_imx/rt/CMakeLists.txt @@ -9,4 +9,4 @@ zephyr_sources( ) zephyr_linker_sources_ifdef(CONFIG_NXP_IMX_RT_BOOT_HEADER - TEXT_START SORT_KEY 0 boot_header.ld) + ROM_START SORT_KEY 0 boot_header.ld) diff --git a/soc/arm/nxp_kinetis/CMakeLists.txt b/soc/arm/nxp_kinetis/CMakeLists.txt index 6f94099e80c..64b24a7cd1b 100644 --- a/soc/arm/nxp_kinetis/CMakeLists.txt +++ b/soc/arm/nxp_kinetis/CMakeLists.txt @@ -5,7 +5,7 @@ zephyr_sources_ifdef(CONFIG_KINETIS_FLASH_CONFIG flash_configuration.c) add_subdirectory(${SOC_SERIES}) zephyr_linker_sources_ifdef(CONFIG_KINETIS_FLASH_CONFIG - TEXT_START + ROM_START SORT_KEY ${CONFIG_KINETIS_FLASH_CONFIG_OFFSET} flash_config.ld ) diff --git a/soc/arm/ti_simplelink/cc32xx/CMakeLists.txt b/soc/arm/ti_simplelink/cc32xx/CMakeLists.txt index 341bb0c1e2f..245f7260113 100644 --- a/soc/arm/ti_simplelink/cc32xx/CMakeLists.txt +++ b/soc/arm/ti_simplelink/cc32xx/CMakeLists.txt @@ -3,5 +3,5 @@ zephyr_sources(soc.c) if (DEFINED CONFIG_CC3220SF_DEBUG OR DEFINED CONFIG_CC3235SF_DEBUG) - zephyr_linker_sources(TEXT_START SORT_KEY 0 cc32xx_debug.ld) + zephyr_linker_sources(ROM_START SORT_KEY 0 cc32xx_debug.ld) endif() diff --git a/soc/riscv/openisa_rv32m1/CMakeLists.txt b/soc/riscv/openisa_rv32m1/CMakeLists.txt index d9f1e6d82eb..8de37459c4c 100644 --- a/soc/riscv/openisa_rv32m1/CMakeLists.txt +++ b/soc/riscv/openisa_rv32m1/CMakeLists.txt @@ -19,4 +19,4 @@ zephyr_sources( soc.c ) -zephyr_linker_sources(TEXT_START SORT_KEY 0x0vectors vector_table.ld) +zephyr_linker_sources(ROM_START SORT_KEY 0x0vectors vector_table.ld) diff --git a/soc/riscv/openisa_rv32m1/linker.ld b/soc/riscv/openisa_rv32m1/linker.ld index b42522d0aa3..820aad2bb78 100644 --- a/soc/riscv/openisa_rv32m1/linker.ld +++ b/soc/riscv/openisa_rv32m1/linker.ld @@ -104,10 +104,11 @@ SECTIONS SECTION_PROLOGUE(_TEXT_SECTION_NAME,,) { -/* Located in generated directory. This file is populated by the - * zephyr_linker_sources() Cmake function. +/* Located in generated directory. This file is populated by calling + * zephyr_linker_sources(ROM_START ...). This typically contains the vector + * table and debug information. */ -#include +#include _image_text_start = .;