From 347f9a0a2d560bb7c23df6f699183426693090bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Fri, 22 Jun 2018 16:07:36 +0200 Subject: [PATCH] cmake: LD: Specify the entry point in the linker scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The entry point can and therefore should be set by linker scripts. Whenever possible one should express things in the source language, be it .c or .ld, and not in code generators or in the build system. This patch removes the flag -eCONFIG_KERNEL_ENTRY from the linker's command line and replaces it with the linker script command ENTRY(CONFIG_KERNEL_ENTRY) Signed-off-by: Sebastian Bøe --- CMakeLists.txt | 3 --- arch/arc/CMakeLists.txt | 2 -- arch/arm/CMakeLists.txt | 2 -- arch/nios2/CMakeLists.txt | 2 -- arch/riscv32/CMakeLists.txt | 2 -- arch/x86/CMakeLists.txt | 2 -- arch/xtensa/CMakeLists.txt | 2 -- arch/xtensa/soc/D_108mini/linker.ld | 2 +- arch/xtensa/soc/D_212GP/linker.ld | 2 +- arch/xtensa/soc/D_233L/linker.ld | 2 +- arch/xtensa/soc/XRC_D2PM_5swIrq/linker.ld | 2 +- arch/xtensa/soc/XRC_FUSION_AON_ALL_LM/linker.ld | 2 +- arch/xtensa/soc/esp32/linker.ld | 1 + arch/xtensa/soc/hifi2_std/linker.ld | 2 +- arch/xtensa/soc/hifi3_bd5/linker.ld | 2 +- arch/xtensa/soc/hifi3_bd5_call0/linker.ld | 2 +- arch/xtensa/soc/hifi4_bd7/linker.ld | 2 +- arch/xtensa/soc/hifi_mini/linker.ld | 2 +- arch/xtensa/soc/hifi_mini_4swIrq/linker.ld | 2 +- arch/xtensa/soc/intel_s1000/linker.ld | 2 ++ arch/xtensa/soc/sample_controller/linker.ld | 2 +- include/arch/arc/v2/linker.ld | 2 +- include/arch/arm/cortex_m/scripts/linker.ld | 2 ++ include/arch/nios2/linker.ld | 2 ++ include/arch/riscv32/common/linker.ld | 2 ++ include/arch/riscv32/pulpino/linker.ld | 2 ++ include/arch/x86/linker.ld | 2 ++ 27 files changed, 26 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6028d20d02..aa8081454f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -709,13 +709,10 @@ set_property(TARGET ${ZEPHYR_INCLUDE_DIRS} ) -get_property(E_KERNEL_ENTRY GLOBAL PROPERTY E_KERNEL_ENTRY) - set(zephyr_lnk ${LINKERFLAGPREFIX},-Map=${PROJECT_BINARY_DIR}/${KERNEL_MAP_NAME} -u_OffsetAbsSyms -u_ConfigAbsSyms - ${E_KERNEL_ENTRY} ${LINKERFLAGPREFIX},--start-group ${LINKERFLAGPREFIX},--whole-archive ${ZEPHYR_LIBS_PROPERTY} diff --git a/arch/arc/CMakeLists.txt b/arch/arc/CMakeLists.txt index e181c01801f..6edd56adfda 100644 --- a/arch/arc/CMakeLists.txt +++ b/arch/arc/CMakeLists.txt @@ -10,7 +10,5 @@ zephyr_cc_option(-fno-delete-null-pointer-checks) zephyr_cc_option_ifdef (CONFIG_LTO -flto) -set_property(GLOBAL PROPERTY E_KERNEL_ENTRY -e${CONFIG_KERNEL_ENTRY}) - add_subdirectory(soc/${SOC_PATH}) add_subdirectory(core) diff --git a/arch/arm/CMakeLists.txt b/arch/arm/CMakeLists.txt index 8fc468bfece..8306c03ca91 100644 --- a/arch/arm/CMakeLists.txt +++ b/arch/arm/CMakeLists.txt @@ -8,8 +8,6 @@ set(ARCH_FOR_cortex-m23 armv8-m.base ) set(ARCH_FOR_cortex-m33 armv8-m.main+dsp) set(ARCH_FOR_cortex-m33+nodsp armv8-m.main ) -set_property(GLOBAL PROPERTY E_KERNEL_ENTRY -e${CONFIG_KERNEL_ENTRY}) - if(ARCH_FOR_${GCC_M_CPU}) set(ARCH_FLAG -march=${ARCH_FOR_${GCC_M_CPU}}) endif() diff --git a/arch/nios2/CMakeLists.txt b/arch/nios2/CMakeLists.txt index 180a375c6ce..babd8a2b9d0 100644 --- a/arch/nios2/CMakeLists.txt +++ b/arch/nios2/CMakeLists.txt @@ -32,7 +32,5 @@ else() zephyr_cc_option(-mno-hw-div) endif() -set_property(GLOBAL PROPERTY E_KERNEL_ENTRY -e${CONFIG_KERNEL_ENTRY}) - add_subdirectory(soc/${SOC_PATH}) add_subdirectory(core) diff --git a/arch/riscv32/CMakeLists.txt b/arch/riscv32/CMakeLists.txt index a465a80be91..7e2566e191f 100644 --- a/arch/riscv32/CMakeLists.txt +++ b/arch/riscv32/CMakeLists.txt @@ -1,6 +1,4 @@ add_subdirectory(soc) add_subdirectory(core) -set_property(GLOBAL PROPERTY E_KERNEL_ENTRY -e${CONFIG_KERNEL_ENTRY}) - set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-littleriscv) diff --git a/arch/x86/CMakeLists.txt b/arch/x86/CMakeLists.txt index 6b63d9db2a7..f6263a55a61 100644 --- a/arch/x86/CMakeLists.txt +++ b/arch/x86/CMakeLists.txt @@ -24,8 +24,6 @@ endif() zephyr_cc_option_ifdef (CONFIG_LTO -flto) zephyr_cc_option_ifndef(CONFIG_SSE_FP_MATH -mno-sse) -set_property(GLOBAL PROPERTY E_KERNEL_ENTRY -e${CONFIG_KERNEL_ENTRY}) - if(CMAKE_VERBOSE_MAKEFILE) set(GENIDT_EXTRA_ARGS --verbose) else() diff --git a/arch/xtensa/CMakeLists.txt b/arch/xtensa/CMakeLists.txt index 5d2f1dfa2ef..f697a7f5fb9 100644 --- a/arch/xtensa/CMakeLists.txt +++ b/arch/xtensa/CMakeLists.txt @@ -7,6 +7,4 @@ else() add_subdirectory(soc/${SOC_PATH}) endif() -set_property(GLOBAL PROPERTY E_KERNEL_ENTRY -e${CONFIG_KERNEL_ENTRY}) - add_subdirectory(core) diff --git a/arch/xtensa/soc/D_108mini/linker.ld b/arch/xtensa/soc/D_108mini/linker.ld index 63fe2e9e6b7..8af2dab8ea7 100644 --- a/arch/xtensa/soc/D_108mini/linker.ld +++ b/arch/xtensa/soc/D_108mini/linker.ld @@ -88,7 +88,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_dram1_start = 0x3ffc0000; diff --git a/arch/xtensa/soc/D_212GP/linker.ld b/arch/xtensa/soc/D_212GP/linker.ld index 796ca529a7c..b52d9f0f6e9 100644 --- a/arch/xtensa/soc/D_212GP/linker.ld +++ b/arch/xtensa/soc/D_212GP/linker.ld @@ -88,7 +88,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_dport0_start = 0x3ffc0000; diff --git a/arch/xtensa/soc/D_233L/linker.ld b/arch/xtensa/soc/D_233L/linker.ld index 55ed68ca799..cd7b6ac27c8 100644 --- a/arch/xtensa/soc/D_233L/linker.ld +++ b/arch/xtensa/soc/D_233L/linker.ld @@ -81,7 +81,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_sram_start = 0x4; diff --git a/arch/xtensa/soc/XRC_D2PM_5swIrq/linker.ld b/arch/xtensa/soc/XRC_D2PM_5swIrq/linker.ld index ec429de248a..6fb62476f4a 100644 --- a/arch/xtensa/soc/XRC_D2PM_5swIrq/linker.ld +++ b/arch/xtensa/soc/XRC_D2PM_5swIrq/linker.ld @@ -88,7 +88,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_srom_start = 0x40000000; diff --git a/arch/xtensa/soc/XRC_FUSION_AON_ALL_LM/linker.ld b/arch/xtensa/soc/XRC_FUSION_AON_ALL_LM/linker.ld index 5385611378c..6eddc61e6ab 100644 --- a/arch/xtensa/soc/XRC_FUSION_AON_ALL_LM/linker.ld +++ b/arch/xtensa/soc/XRC_FUSION_AON_ALL_LM/linker.ld @@ -61,7 +61,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_dram0_start = 0x3ffe0000; diff --git a/arch/xtensa/soc/esp32/linker.ld b/arch/xtensa/soc/esp32/linker.ld index a3f35b27df4..9f91dde36c3 100644 --- a/arch/xtensa/soc/esp32/linker.ld +++ b/arch/xtensa/soc/esp32/linker.ld @@ -55,6 +55,7 @@ PHDRS /* Default entry point: */ PROVIDE ( _ResetVector = 0x40000400 ); +ENTRY(CONFIG_KERNEL_ENTRY) _rom_store_table = 0; diff --git a/arch/xtensa/soc/hifi2_std/linker.ld b/arch/xtensa/soc/hifi2_std/linker.ld index 56a8b1a8bb0..bf6b7ce18e1 100644 --- a/arch/xtensa/soc/hifi2_std/linker.ld +++ b/arch/xtensa/soc/hifi2_std/linker.ld @@ -88,7 +88,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_dram1_start = 0x3ffc0000; diff --git a/arch/xtensa/soc/hifi3_bd5/linker.ld b/arch/xtensa/soc/hifi3_bd5/linker.ld index 69c24225e28..c9c5ce7b2a8 100644 --- a/arch/xtensa/soc/hifi3_bd5/linker.ld +++ b/arch/xtensa/soc/hifi3_bd5/linker.ld @@ -60,7 +60,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_srom_start = 0x50000000; diff --git a/arch/xtensa/soc/hifi3_bd5_call0/linker.ld b/arch/xtensa/soc/hifi3_bd5_call0/linker.ld index 69c24225e28..c9c5ce7b2a8 100644 --- a/arch/xtensa/soc/hifi3_bd5_call0/linker.ld +++ b/arch/xtensa/soc/hifi3_bd5_call0/linker.ld @@ -60,7 +60,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_srom_start = 0x50000000; diff --git a/arch/xtensa/soc/hifi4_bd7/linker.ld b/arch/xtensa/soc/hifi4_bd7/linker.ld index 8117366ee34..08d103ac4fa 100644 --- a/arch/xtensa/soc/hifi4_bd7/linker.ld +++ b/arch/xtensa/soc/hifi4_bd7/linker.ld @@ -68,7 +68,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_srom_start = 0x50000000; diff --git a/arch/xtensa/soc/hifi_mini/linker.ld b/arch/xtensa/soc/hifi_mini/linker.ld index 6973c0a470a..73bdebc4a0a 100644 --- a/arch/xtensa/soc/hifi_mini/linker.ld +++ b/arch/xtensa/soc/hifi_mini/linker.ld @@ -54,7 +54,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_dram0_start = 0x60000000; diff --git a/arch/xtensa/soc/hifi_mini_4swIrq/linker.ld b/arch/xtensa/soc/hifi_mini_4swIrq/linker.ld index 8894b4d7b5e..9df77e97ad4 100644 --- a/arch/xtensa/soc/hifi_mini_4swIrq/linker.ld +++ b/arch/xtensa/soc/hifi_mini_4swIrq/linker.ld @@ -54,7 +54,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_dram0_start = 0x60000000; diff --git a/arch/xtensa/soc/intel_s1000/linker.ld b/arch/xtensa/soc/intel_s1000/linker.ld index 1b836653c74..41841b6e188 100644 --- a/arch/xtensa/soc/intel_s1000/linker.ld +++ b/arch/xtensa/soc/intel_s1000/linker.ld @@ -145,6 +145,8 @@ PHDRS _rom_store_table = 0; PROVIDE(_memmap_vecbase_reset = XCHAL_VECBASE_RESET_PADDR_SRAM); +ENTRY(CONFIG_KERNEL_ENTRY) + /* Various memory-map dependent cache attribute settings: */ _memmap_cacheattr_wb_base = 0x44024000; _memmap_cacheattr_wt_base = 0x11021000; diff --git a/arch/xtensa/soc/sample_controller/linker.ld b/arch/xtensa/soc/sample_controller/linker.ld index 63fe2e9e6b7..8af2dab8ea7 100644 --- a/arch/xtensa/soc/sample_controller/linker.ld +++ b/arch/xtensa/soc/sample_controller/linker.ld @@ -88,7 +88,7 @@ PHDRS /* Default entry point: */ -ENTRY(_ResetVector) +ENTRY(CONFIG_KERNEL_ENTRY) /* Memory boundary addresses: */ _memmap_mem_dram1_start = 0x3ffc0000; diff --git a/include/arch/arc/v2/linker.ld b/include/arch/arc/v2/linker.ld index ff00f865961..34b5f291f70 100644 --- a/include/arch/arc/v2/linker.ld +++ b/include/arch/arc/v2/linker.ld @@ -55,7 +55,7 @@ #endif OUTPUT_ARCH(arc) -ENTRY(__start) +ENTRY(CONFIG_KERNEL_ENTRY) MEMORY { #ifdef FLASH_START diff --git a/include/arch/arm/cortex_m/scripts/linker.ld b/include/arch/arm/cortex_m/scripts/linker.ld index 4b50b31467f..ee150e6143e 100644 --- a/include/arch/arm/cortex_m/scripts/linker.ld +++ b/include/arch/arm/cortex_m/scripts/linker.ld @@ -83,6 +83,8 @@ MEMORY IDT_LIST (wx) : ORIGIN = (RAM_ADDR + RAM_SIZE), LENGTH = 2K } +ENTRY(CONFIG_KERNEL_ENTRY) + SECTIONS { GROUP_START(ROMABLE_REGION) diff --git a/include/arch/nios2/linker.ld b/include/arch/nios2/linker.ld index b6ac81302c5..67c3f3239e6 100644 --- a/include/arch/nios2/linker.ld +++ b/include/arch/nios2/linker.ld @@ -78,6 +78,8 @@ MEMORY } #endif +ENTRY(CONFIG_KERNEL_ENTRY) + SECTIONS { GROUP_START(ROMABLE_REGION) diff --git a/include/arch/riscv32/common/linker.ld b/include/arch/riscv32/common/linker.ld index 3ab5bdda10b..36f93ae5ed4 100644 --- a/include/arch/riscv32/common/linker.ld +++ b/include/arch/riscv32/common/linker.ld @@ -41,6 +41,8 @@ MEMORY IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K } +ENTRY(CONFIG_KERNEL_ENTRY) + SECTIONS { diff --git a/include/arch/riscv32/pulpino/linker.ld b/include/arch/riscv32/pulpino/linker.ld index 05f3e026e2d..ffd473ca9d6 100644 --- a/include/arch/riscv32/pulpino/linker.ld +++ b/include/arch/riscv32/pulpino/linker.ld @@ -37,6 +37,8 @@ MEMORY IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K } +ENTRY(CONFIG_KERNEL_ENTRY) + SECTIONS { GROUP_START(INSTRRAM) diff --git a/include/arch/x86/linker.ld b/include/arch/x86/linker.ld index 04932cafd99..57b39441ea5 100644 --- a/include/arch/x86/linker.ld +++ b/include/arch/x86/linker.ld @@ -61,6 +61,8 @@ #define MMU_PAGE_ALIGN #endif +ENTRY(CONFIG_KERNEL_ENTRY) + /* SECTIONS definitions */ SECTIONS {