From 2bf63134e8f03f19b25e2b0cb0ba01c9112e4313 Mon Sep 17 00:00:00 2001 From: Dino Li Date: Wed, 26 May 2021 14:45:07 +0800 Subject: [PATCH] arch: riscv: linker script: add support for rom_start section With this change, we can put contents into rom_start section by calling zephyr_linker_sources(ROM_START ...) Signed-off-by: Dino Li Co-authored-by: Torsten Tejlmand Rasmussen Change-Id: If1169423b013d3e4df52d91cdb2fbdddc3bace7b --- cmake/extensions.cmake | 3 ++- include/arch/riscv/common/linker.ld | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake index 0b279716122..d9423d2d12c 100644 --- a/cmake/extensions.cmake +++ b/cmake/extensions.cmake @@ -1088,7 +1088,8 @@ endfunction(zephyr_check_compiler_flag_hardcoded) # RODATA Inside the rodata output section. # 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. +# x86, ARC, openisa_rv32m1, and RISC-V. +# Note: On RISC-V the rom_start section will be after vector section. # 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. diff --git a/include/arch/riscv/common/linker.ld b/include/arch/riscv/common/linker.ld index 106658b056f..86b92f46e5a 100644 --- a/include/arch/riscv/common/linker.ld +++ b/include/arch/riscv/common/linker.ld @@ -108,6 +108,15 @@ SECTIONS KEEP(*(.vectors.*)) } GROUP_LINK_IN(ROMABLE_REGION) + SECTION_PROLOGUE(rom_start,,) + { + . = ALIGN(16); +/* Located in generated directory. This file is populated by calling + * zephyr_linker_sources(ROM_START ...). + */ +#include + } GROUP_LINK_IN(ROMABLE_REGION) + SECTION_PROLOGUE(_RESET_SECTION_NAME,,) { KEEP(*(.reset.*))